MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); /** *add icon */ ui->record_button->setIcon(QIcon(":/images/images/media_record.png")); ui->start_button->setIcon(QIcon(":/images/images/play-normal-red.png")); /** * keystring! */ key = new keyw; /** * wiggly widget */ WigglyWidget *wigglyWidget = new WigglyWidget(this); ui->gridForWiggly->addWidget(wigglyWidget); QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect(this); // QGEffect-> wigglyWidget->setGraphicsEffect(effect); wigglyWidget->setFocus(); /** * Menu */ QMenu *file = menuBar()->addMenu("File"); QMenu *load_str = menuBar()->addMenu("Load"); QAction *load_str_file = new QAction(tr("Load file"), this); QAction *load_str_err = new QAction(tr("Load err"), this); /** * Connect */ connect(key, &keyw::textChanged, wigglyWidget, &WigglyWidget::setText); connect(this,&MainWindow::changeMode, wigglyWidget,&WigglyWidget::changeMode); connect(key,SIGNAL(paintCurrentSymbol(int)), wigglyWidget, SLOT(paintCurrentSymbol(int))); connect(this,SIGNAL(keyEvent(QKeyEvent*)),key,SLOT(keyEvent(QKeyEvent*))); connect(this,SIGNAL(keyRecord(QKeyEvent*)),key,SLOT(keyRecord(QKeyEvent*))); // connect(newFile,SIGNAL(triggered()),this, SLOT(action())); // connect(Open,SIGNAL(triggered()),this, SLOT(action())); connect(this,SIGNAL(keyClear()),key,SLOT(keyClear())); connect(key,SIGNAL(set_count_error(int)),this,SLOT(set_count_error(int))); connect(this, SIGNAL(numClear()), key, SLOT(numClear())); connect(this, SIGNAL(keyStartStat()), key, SLOT(keyStartStat())); // connect(key,SIGNAL(),ui->number_error, SLOT(display(int)); connect(key, SIGNAL(setMode(qint8)), this, SLOT(setMode(qint8))); connect(load_str_file, SIGNAL(triggered()), key, SLOT(loadFromFile())); connect(load_str_err, SIGNAL(triggered()), key, SLOT(loadFromError())); // newFile->setShortcut(tr("Ctrl+F")); // Open->setShortcut(tr("Ctrl+N")); load_str->addAction(load_str_file); load_str->addAction(load_str_err); key->setText("mamku ebal"); key->str = "mamku ebal"; }
static void test_keyClear (const size_t storagePlugin, const char * tmpFile) { Key * parentKey = keyNew (TEST_ROOT_KEY, KEY_VALUE, tmpFile, KEY_END); open_storage_plugin (storagePlugin); Plugin * plugin = plugins[storagePlugin]; KeySet * ks = metaTestKeySet (); succeed_if (plugin->kdbSet (plugin, ks, parentKey) == 1, "kdbSet was not successful"); succeed_if (plugin->kdbGet (plugin, ks, parentKey) == 1, "kdbGet was not successful"); Key * found = ksLookupByName (ks, "user/tests/storage/a", 0); succeed_if (found, "did not find key"); succeed_if (keyClear (found) == 0, "Key was NULL, keyClear failed"); keySetName (found, "user/tests/storage/foo"); keySetString (found, "new key value"); succeed_if (plugin->kdbSet (plugin, ks, parentKey) == 1, "kdbSet was not successful"); succeed_if (plugin->kdbGet (plugin, ks, parentKey) == 1, "kdbGet was not successful"); keyDel (parentKey); ksDel (ks); closeStoragePlugin (storagePlugin); }
/** * A destructor for Key objects. * * Every key created by keyNew() must be * deleted with keyDel(). * * It is save to delete keys which are * in a keyset, the number of references * will be returned then. * * It is save to delete a nullpointer, * -1 will be returned then. * * It is also save to delete a multiple * referenced key, nothing will happen * then and the reference counter will * be returned. * * @param key the key object to delete * @see keyNew(), keyIncRef(), keyGetRef() * @return the value of the reference counter * if the key is within keyset(s) * @retval 0 when the key was freed * @retval -1 on null pointers * @ingroup key * */ int keyDel (Key * key) { int rc; if (!key) return -1; if (key->ksReference > 0) { return key->ksReference; } rc = keyClear (key); elektraFree (key); return rc; }
ShortcutsConfig::ShortcutsConfig(QWidget *parent, ShortcutsPlugin *plugin) : ShortcutsConfigBase(parent) { m_plugin = plugin; lstKeys->setSorting(0); loadMenu(MenuMain, true); loadMenu(MenuGroup, false); loadMenu(MenuContact, false); loadMenu(MenuStatus, true); adjustColumns(); selectionChanged(); connect(lstKeys, SIGNAL(selectionChanged()), this, SLOT(selectionChanged())); connect(edtKey, SIGNAL(changed()), this, SLOT(keyChanged())); connect(btnClear, SIGNAL(clicked()), this, SLOT(keyClear())); connect(chkGlobal, SIGNAL(toggled(bool)), this, SLOT(globalChanged(bool))); for (QObject *p = parent; p != NULL; p = p->parent()){ if (!p->inherits("QTabWidget")) continue; QTabWidget *tab = static_cast<QTabWidget*>(p); mouse_cfg = new MouseConfig(tab, plugin); tab->addTab(mouse_cfg, i18n("Mouse")); break; } }
void MainWindow::setMode(qint8 mode) { switch (mode) { case 0 : switch(this->mode) { case 1 : ui->start_button->setChecked(false); ui->start_button->setIcon(QIcon(":/images/images/play-normal-red.png")); break; case 2 : ui->record_button->setChecked(false); ui->record_button->setIcon(QIcon(":/images/images/media_record.png")); break; case 3 : break; default: break; } this->mode = 0; emit changeMode(this->mode); emit keyStartStat(); break; case 1 : if(!this->key->str.size()) { ui->start_button->setChecked(false); ui->start_button->setIcon(QIcon(":/images/images/play-normal-red.png")); break; } if(this->mode == 2) { this->ui->record_button->setChecked(false); ui->record_button->setIcon(QIcon(":/images/images/media_record.png")); } this->mode = 1; emit changeMode(this->mode); emit numClear(); ui->number_error->display(0); ui->start_button->setIcon(QIcon(":/images/images/red_stop.png")); break; case 2 : if(this->mode == 1) { this->ui->start_button->setChecked(false); ui->start_button->setIcon(QIcon(":/images/images/play-normal-red.png")); } this->mode = 2; emit changeMode(this->mode); emit keyClear(); ui->record_button->setIcon(QIcon(":/images/images/red_stop_rec.png")); break; case 3 : break; default : break; } }
/** * Copy or Clear a key. * * Most often you may prefer keyDup() which allocates * a new key and returns a duplication of another key. * * But when you need to copy into an existing key, e.g. * because it was passed by a pointer in a function * you can do so: * * @snippet keyCopy.c Basic Usage * * The reference counter will not be changed for * both keys. Affiliation to keysets * are also not affected. * * The meta data will be duplicated for the destination * key. So it will not take much additional space, even * with lots of metadata. * * When you pass a NULL-pointer as source the * data of dest will be cleaned completely * (except reference counter, see keyClear()) and * you get a fresh dest key: * * @snippet keyCopy.c Clear * * If you want to copy everything, except e.g. the value * you can use keyCopy() too: * * @snippet keyCopy.c Copy Without Value * * Restrain from coping everything yourself, because it will lead to * wrong metadata and is not able to copy empty or cascading names: * * @snippet keyCopy.c Individual Copy * * * @param dest the key which will be written to * @param source the key which should be copied * or NULL to clean the destination key * @ingroup key * @retval -1 on failure when a NULL pointer * was passed for dest or a dynamic property could not * be written. The content will be unmodified then. * @retval 0 when dest was cleaned * @retval 1 when source was successfully copied * @see keyDup() to get a duplication of a key */ int keyCopy (Key * dest, const Key * source) { if (!dest) return -1; if (test_bit (dest->flags, KEY_FLAG_RO_NAME) || test_bit (dest->flags, KEY_FLAG_RO_VALUE) || test_bit (dest->flags, KEY_FLAG_RO_META)) { return -1; } if (!source) { keyClear (dest); return 0; } // remember dynamic memory to be removed char * destKey = dest->key; void * destData = dest->data.c; KeySet * destMeta = dest->meta; // duplicate dynamic properties if (source->key) { dest->key = elektraStrNDup (source->key, source->keySize + source->keyUSize); if (!dest->key) goto memerror; } else { dest->key = 0; } if (source->data.v) { dest->data.v = elektraStrNDup (source->data.v, source->dataSize); if (!dest->data.v) goto memerror; } else { dest->data.v = 0; } if (source->meta) { dest->meta = ksDup (source->meta); if (!dest->meta) goto memerror; } else { dest->meta = 0; } // successful, now do the irreversible stuff: we obviously modified dest set_bit (dest->flags, KEY_FLAG_SYNC); // copy sizes accordingly dest->keySize = source->keySize; dest->keyUSize = source->keyUSize; dest->dataSize = source->dataSize; // free old resources of destination elektraFree (destKey); elektraFree (destData); ksDel (destMeta); return 1; memerror: elektraFree (dest->key); elektraFree (dest->data.v); ksDel (dest->meta); dest->key = destKey; dest->data.v = destData; dest->meta = destMeta; return -1; }
void CalculatorTestApp::handleKey(widgetid_t keyPressed) { // keyMap origKeyMap = (keyMap)buttons->getMap(); switch (keyPressed) { case zero: case one: case two: case three: case four: case five: case six: case seven: case eight: case nine: case hex_a: case hex_b: case hex_c: case hex_d: case hex_e: case hex_f: keyDigit(keyPressed); break; case decimal: keyDecimal(); break; case enter: keyEnter(); break; case clear: keyClear(); break; case backspace: keyBackspace(); break; case shift: keyShift(); break; case ee: keyEE(); break; default: // the following are functions that accept the current input string acceptText(); switch (keyPressed) { case divide: keyDivide(); break; case multiply: keyMultiply(); break; case add: keyAdd(); break; case subtract: keySubtract(); break; case inverse: keyInverse(); break; case percent: keyPercent(); break; case swap: keySwap(); break; case changeBase: keyBase(); break; case send: keySend(); break; case square_f: keySquare(); break; case cube_f: keyCube(); break; case pow_f: keyPow(); break; case exp_f: keyExp(); break; case pow10_f: keyPow10(); break; case sqrt_f: keySqrt(); break; case cubert_f: keyCubert(); break; case xroot_f: keyXroot(); break; case ln_f: keyLn(); break; case log10_f: keyLog10(); break; case sin_f: keySin(); break; case cos_f: keyCos(); break; case tan_f: keyTan(); break; case pi_f: keyPi(); break; case e_f: keyE(); break; case asin_f: keyAsin(); break; case acos_f: keyAcos(); break; case atan_f: keyAtan(); break; case logy_f: keyLogy(); break; case log2_f: keyLog2(); break; case in2mm_f: keyIn2mm(); break; case mm2in_f: keyMm2In(); break; case g2lb_f: keyG2lb(); break; case lb2g_f: keyLb2g(); break; case c2f_f: keyC2f(); break; case f2c_f: keyF2c(); break; case ppi_f: keyPpi(); break; default: break; } } // if (origKeyMap == sci_map && buttons->getMap() == sci_map) { // buttons->setMap(basic_map); // } drawDisplay(); }