static void InitializeDataNodeFromQButtonGroup(QButtonGroup *co, DataNode *node) { std::string objectName(co->objectName().toStdString()); DataNode *currentNode = node->GetNode(objectName); QAbstractButton *sb = co->checkedButton(); if(currentNode != 0) { // Use int or string, depending on what the node was initially. NodeTypeEnum t = currentNode->GetNodeType(); node->RemoveNode(objectName); if(t == STRING_NODE) { if(sb != 0) node->AddNode(new DataNode(objectName, sb->text().toStdString())); else node->AddNode(new DataNode(objectName, int(0))); } else { int index = sb ? co->id(sb) : 0; node->AddNode(new DataNode(objectName, index)); } } else { // There's no preference on which type to use so use int int index = sb ? co->id(sb) : 0; node->AddNode(new DataNode(objectName, index)); } }
wxString wxRadioBox::GetString(unsigned int n) const { QAbstractButton *qtButton = GetButtonAt( m_qtButtonGroup, n ); CHECK_BUTTON( qtButton, wxEmptyString ); return wxQtConvertString( qtButton->text() ); }
void MultiDataInputInstance::saveSelectedRadioButtonOrCheckBox() { QAbstractButton *checkedButton = mButtonGroup->checkedButton(); if(checkedButton) setVariable(mVariable, checkedButton->text()); else setVariable(mVariable, scriptEngine()->nullValue()); }
int Preferences::getTime() { if (!grTime->isChecked()) return -1; QAbstractButton* button = groupTime->checkedButton(); return button->text().toInt(); }
void Preferences::changedTime() { if ( grTime->isChecked()) { QAbstractButton* button = groupTime->checkedButton(); magic_->setTime( button->text().toInt() ); } else magic_->setTime(-1); }
QString ColorFormatDlg::colorStr() const { QAbstractButton* checkedBtn = _ui.buttonGroup->checkedButton(); if ( checkedBtn != 0 ) { int id = _ui.buttonGroup->checkedId(); PluginSettings::set( _plugin, "format", id ); return checkedBtn->text(); } else { return ""; } }
void NumberWidget::onNumberButtonClicked(bool checked) { // Downcast. Any other good idea? QAbstractButton * btn = static_cast<QAbstractButton *>(sender()); bool ok = false; int number = btn->text().toInt(&ok); // Handle overflow. if (ok) { emit numberClicked( number ); } }
QAbstractButton * Tab::get_profile_button(QString profile_name){ QAbstractButton * get_profile = NULL; QList<QAbstractButton *> buttons_list = group->buttons(); QListIterator<QAbstractButton *> it(buttons_list); while(it.hasNext() && get_profile == NULL){ QAbstractButton * button = it.next(); if(button->text() == profile_name){ get_profile = button; } } return get_profile; }
int drv_basebutton(int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9) { handle_head* head = (handle_head*)a0; QAbstractButton *self = (QAbstractButton*)head->native; switch (drvid) { case BASEBUTTON_SETTEXT: { self->setText(drvGetString(a1)); break; } case BASEBUTTON_TEXT: { drvSetString(a1,self->text()); break; } default: return 0; } return 1; }
int GwtCallback::showMessageBox(int type, QString caption, QString message, QString buttons, int defaultButton, int cancelButton) { // cancel other message box if it's visible QMessageBox* pMsgBox = qobject_cast<QMessageBox*>( QApplication::activeModalWidget()); if (pMsgBox != NULL) pMsgBox->close(); QMessageBox msgBox(safeMessageBoxIcon(static_cast<QMessageBox::Icon>(type)), caption, message, QMessageBox::NoButton, pOwner_->asWidget(), Qt::Dialog | Qt::Sheet); msgBox.setWindowModality(Qt::WindowModal); msgBox.setTextFormat(Qt::PlainText); QStringList buttonList = buttons.split(QChar::fromLatin1('|')); for (int i = 0; i != buttonList.size(); i++) { QPushButton* pBtn = msgBox.addButton(buttonList.at(i), captionToRole(buttonList.at(i))); if (defaultButton == i) msgBox.setDefaultButton(pBtn); } msgBox.exec(); QAbstractButton* button = msgBox.clickedButton(); if (!button) return cancelButton; for (int i = 0; i < buttonList.size(); i++) if (buttonList.at(i) == button->text()) return i; return cancelButton; }
bool Tab::remove_profile_from_button_group(QString * profile_name){ bool remove_profile_from_button_group = false; QList<QAbstractButton *> buttons_list = group->buttons(); QListIterator<QAbstractButton *> it(buttons_list); while(it.hasNext() && remove_profile_from_button_group != true){ QAbstractButton * button = it.next(); if(button->text() == profile_name){ v_layout->removeWidget(button); group->removeButton(button); button->~QAbstractButton(); remove_profile_from_button_group =true; } } return remove_profile_from_button_group; }
int GwtCallback::showMessageBox(int type, QString caption, QString message, QString buttons, int defaultButton, int cancelButton) { QMessageBox msgBox(safeMessageBoxIcon(static_cast<QMessageBox::Icon>(type)), caption, message, QMessageBox::NoButton, pOwnerWindow_, Qt::Dialog | Qt::Sheet); msgBox.setWindowModality(Qt::WindowModal); msgBox.setTextFormat(Qt::PlainText); QStringList buttonList = buttons.split(QChar::fromAscii('|')); for (int i = 0; i != buttonList.size(); i++) { QPushButton* pBtn = msgBox.addButton(buttonList.at(i), captionToRole(buttonList.at(i))); if (defaultButton == i) msgBox.setDefaultButton(pBtn); } msgBox.exec(); QAbstractButton* button = msgBox.clickedButton(); if (!button) return cancelButton; for (int i = 0; i < buttonList.size(); i++) if (buttonList.at(i) == button->text()) return i; return cancelButton; }
// ---------------------------------------------------------------------------- void ctkMessageBoxDontShowAgainTester::testDontShowAgainCustomText() { ctkMessageBox messageBox; messageBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); QAbstractButton *okButton = messageBox.button(QMessageBox::Ok); okButton->setText("SaveData"); QAbstractButton *cancelButton = messageBox.button(QMessageBox::Cancel); cancelButton->setText("Discard Data"); QFETCH(bool, visible); messageBox.setDontShowAgainVisible(visible); QFETCH(bool, dontShowAgain); messageBox.setDontShowAgain(dontShowAgain); this->testExecMessageBox(messageBox); // check that the don't show again text has been updated QCheckBox *checkBox = messageBox.findChild<QCheckBox*>("ctk_msgbox_dontshowcheckbox"); QString dontShowAgainText = checkBox->text(); if (visible) { // the custom text was set from the Ok box as it has the accept role QString expectedString = QString("Don't show this message again and always ") + okButton->text(); QCOMPARE(dontShowAgainText, expectedString); } else { // the custom text was not added to the end of the standard message QString expectedString = QString("Don't show this message again"); QCOMPARE(dontShowAgainText, expectedString); } }
void ClsQNeuronStateVariableDisplay::setSelectedStates(list<string> lstStates) { #ifdef DEBUG_CLSQSTATEVARIABLEDISPLAY cout << "ClsQNeuronStateVariableDisplay::setSelectedStates(list<string> lst)" << endl; #endif QList<QAbstractButton *> lst = qbtngrpStateVariables->buttons (); QList<QAbstractButton*>::iterator it; for (it = lst.begin(); it != lst.end(); ++it) { string str= (string)((*it)->text().latin1()); if(std::find(lstStates.begin(), lstStates.end(), str) != lstStates.end()){ QAbstractButton *qrb = (*it); qrb->toggle(); string strSinkID = qrb->text().latin1() + strID; QColor qc; qc.setHsv(clsFEDataClient->getDataSinkColor(strSinkID), 255, 210); QPalette palette = qrb->palette(); palette.setColor ( QColorGroup::Foreground, qc ); // palette.setColor ( QColorGroup::ButtonText, qc ); qrb->setPalette(palette); } } };
void ClsQNeuronStateVariableDisplay::slotStateVariables(int ii){ #ifdef DEBUG_CLSQSTATEVARIABLEDISPLAY cout << "void ClsQNeuronStateVariableDisplay::slotStateVariables(int ii)" << endl; #endif /* cout << "qbtngrpStateVariables->exclusive ( ): " << qbtngrpStateVariables->exclusive ( ) << endl; cout << "iCurrentStateButton: " << iCurrentStateButton << endl; cout << "ii: " << ii << endl; */ QAbstractButton *btn = qbtngrpStateVariables->button ( ii ); if(btn==NULL){ return; } if(qchkbxLiveData->isOn() && ii != iCurrentStateButton){ if(btn->isChecked()){ //cout << "send request: " << btn->text().latin1() << endl; /* send request */ string strSinkID = btn->text().latin1() + strID; clsFEDataClient->addDataSink(strSinkID, clsFEGroup, btn->text().latin1(), strSelectedIndices); QColor qc; qc.setHsv(clsFEDataClient->getDataSinkColor(strSinkID), 255, 210); QPalette palette = (btn)->palette(); palette.setColor ( QColorGroup::Foreground, qc ); (btn)->setPalette(palette); if(bAverage){ clsFEDataClient->setSinkMath(strSinkID, ClsFEDataSink::MATH_AVERAGE); } if(qbtngrpStateVariables->exclusive( ) && iCurrentStateButton >= 0){ /* cancel rewquest of the last active checkbox (iCurrentStateButton) */ QAbstractButton *btnCurrent = qbtngrpStateVariables->button (iCurrentStateButton); if(btnCurrent!=NULL){ // cout << "cancel request: " << btnCurrent->text().latin1() << endl; string strSinkID = btnCurrent->text().latin1() + strID; clsFEDataClient->removeDataSink(strSinkID); QColor qc; qc.setRgb(0,0,0); QPalette palette = btnCurrent->palette(); palette.setColor ( QColorGroup::Foreground, qc ); btnCurrent->setPalette(palette); } } } else { /* cancel request */ // cout << "cancel request: " << btn->text().latin1() << endl; string strSinkID = btn->text().latin1() + strID; clsFEDataClient->removeDataSink(strSinkID); QColor qc; qc.setRgb(0,0,0); QPalette palette = (btn)->palette(); palette.setColor ( QColorGroup::Foreground, qc ); (btn)->setPalette(palette); } } if(qbtngrpStateVariables->exclusive ( )){ iCurrentStateButton = ii; } };
int Preferences::getLength() { QAbstractButton* button = groupLength->checkedButton(); return button->text().toInt(); }
static QAbstractButton * getRunButton(QWizard *w) { QAbstractButton *runButton = w->button(QWizard::CustomButton1); CHECK(NULL != runButton, NULL); CHECK(!runButton->text().isEmpty(), NULL); return runButton; }
void Preferences::changedLength() { QAbstractButton* button = groupLength->checkedButton(); magic_->setLength( button->text().toInt() ); }
void LaunchPad::buttonContextMenu(const QPoint& /*pos*/) { QAbstractButton* btn = static_cast<QAbstractButton*>(sender()); int id = mButtons.id(btn); QDialog dialog; QGridLayout layout(&dialog); QLabel* label; int row = 0; // Count layout rows label = new QLabel(tr("Name")); label->setAlignment(Qt::AlignRight); layout.addWidget(label, row, 0); QLineEdit name(btn->text()); name.setToolTip(tr("Button caption")); layout.addWidget(&name, row++, 1); layout.setColumnStretch(1, 1); label = new QLabel(tr("Tip")); label->setAlignment(Qt::AlignRight); layout.addWidget(label, row, 0); QLineEdit tip(btn->toolTip()); tip.setToolTip(tr("Button tool tip")); tip.setCursorPosition(0); layout.addWidget(&tip, row++, 1, 1, 2); layout.setColumnStretch(2, 3); label = new QLabel(tr("Command")); label->setAlignment(Qt::AlignRight); layout.addWidget(label, row, 0); QLineEdit command(mCommands.at(id)); //QTextEdit command(mCommands.at(id)); command.setCursorPosition(0); command.setToolTip(tr("Available Tags are: %1").arg("[Provider] [Symbol] [Market] " "[FiId] [MarketId]")); layout.addWidget(&command, row++, 1, 1, 2); // Spawn over two colums... // layout.setColumnStretch(2, 2); // ...and take more space label = new QLabel(tr("Symbol Type")); label->setAlignment(Qt::AlignRight); layout.addWidget(label, row, 0); // QLineEdit symbolType(mSymbolTypes.at(id)); QComboBox symbolType; symbolType.setToolTip(tr("Witch type has to be [Symbol]. When empty is called once with any symbol\n" "(You should not use [Symbol] in this case at the command)")); SymbolTypeTuple* st = mFilu->getSymbolTypes(Filu::eAllTypes); if(st) { while(st->next()) symbolType.addItem(st->caption()); } symbolType.addItem(""); symbolType.setCurrentIndex(symbolType.findText(mSymbolTypes.at(id))); layout.addWidget(&symbolType, row, 1); QCheckBox allMarkets(tr("All Markets")); allMarkets.setToolTip(tr("Call multiple times with all markets by 'Symbol Type'")); allMarkets.setChecked(mMultis.at(id)); layout.addWidget(&allMarkets, row++, 2); // Add an empty row to take unused space layout.addWidget(new QWidget, row, 1); layout.setRowStretch(row++, 2); // Build the button line QDialogButtonBox dlgBtns(QDialogButtonBox::Save | QDialogButtonBox::Discard); QPushButton* db = dlgBtns.button(QDialogButtonBox::Discard); dlgBtns.addButton(db, QDialogButtonBox::RejectRole); connect(&dlgBtns, SIGNAL(accepted()), &dialog, SLOT(accept())); connect(&dlgBtns, SIGNAL(rejected()), &dialog, SLOT(reject())); DialogButton* remove = new DialogButton(tr("&Remove"), -1); remove->setToolTip(tr("Remove button")); dlgBtns.addButton(remove, QDialogButtonBox::ActionRole); connect(remove, SIGNAL(clicked(int)), &dialog, SLOT(done(int))); DialogButton* add = new DialogButton(tr("&Add"), 2); add->setToolTip(tr("Copy to new button")); dlgBtns.addButton(add, QDialogButtonBox::ActionRole); connect(add, SIGNAL(clicked(int)), &dialog, SLOT(done(int))); layout.addWidget(&dlgBtns, row, 1, 1, 2); dialog.setWindowTitle(tr("LaunchPad - Edit button '%1'").arg(btn->text())); dialog.setMinimumWidth(350); switch (dialog.exec()) { case 0: // Discard return; break; case -1: // Remove { int ret = QMessageBox::warning(&dialog , tr("LaunchPad - Last chance to keep your data") , tr("Are you sure to delete button <b>'%1'</b> with all your work<b>?</b>") .arg(btn->text()) , QMessageBox::Yes | QMessageBox::No , QMessageBox::No); if(ret == QMessageBox::No) return; deleteButton(btn); mCommands.removeAt(id); mSymbolTypes.removeAt(id); mMultis.removeAt(id); break; } case 1: // Save setButtonName(btn, name.text()); btn->setToolTip(tip.text()); mCommands[id] = command.text(); //mCommands[id] = command.toPlainText(); // mSymbolTypes[id] = symbolType.text(); mSymbolTypes[id] = symbolType.currentText(); mMultis[id] = allMarkets.isChecked(); break; case 2: // Add btn = newButton(name.text()); btn->setToolTip(tip.text()); mCommands.append(command.text()); //mCommands.append(command.toPlainText()); // mSymbolTypes.append(symbolType.text()); mSymbolTypes.append(symbolType.currentText()); mMultis.append(allMarkets.isChecked()); mButtons.setId(btn, mCommands.size() - 1); break; } saveSettings(); }
void shortcuts::setStandardKeys(QWidget* widget) { if (!widget) return; // Add standard shortcuts to applicable buttons bool hasShortcut = false; QPushButton* button; // For Save button = widget->findChild<QPushButton*>("_save"); if (button) { button->setShortcut(QKeySequence::Save); button->setToolTip(button->text().remove("&") + " " + button->shortcut().toString(QKeySequence::NativeText)); hasShortcut = true; } if (!hasShortcut) // Because some screens have both { // For Post button = widget->findChild<QPushButton*>("_post"); if (button) { button->setShortcut(QKeySequence::Save); button->setToolTip(button->text().remove("&") + " " + button->shortcut().toString(QKeySequence::NativeText)); } } if (!hasShortcut) { QDialogButtonBox* bb = widget->findChild<QDialogButtonBox*>(); if (bb) { QList<QAbstractButton*> buttons = bb->buttons(); for (int i = 0; i < buttons.size(); ++i) { QAbstractButton *bbutton = buttons.at(i); QDialogButtonBox::ButtonRole btnrole = bb->buttonRole(buttons.at(i)); if (btnrole == QDialogButtonBox::AcceptRole) { bbutton->setShortcut(QKeySequence::Save); bbutton->setToolTip(bbutton->text().remove("&") + " " + bbutton->shortcut().toString(QKeySequence::NativeText)); } else if (btnrole == QDialogButtonBox::RejectRole) { bbutton->setShortcut(QKeySequence::Close); bbutton->setToolTip(bbutton->text().remove("&") + " " + bbutton->shortcut().toString(QKeySequence::NativeText)); } } } } // For Close hasShortcut = false; button = widget->findChild<QPushButton*>("_close"); if (button) { button->setShortcut(QKeySequence::Close); button->setToolTip(button->text().remove("&") + " " + button->shortcut().toString(QKeySequence::NativeText)); hasShortcut = true; } if (!hasShortcut) // Because some screens have both { // For Post button = widget->findChild<QPushButton*>("_cancel"); if (button) { button->setShortcut(QKeySequence::Close); button->setToolTip(button->text().remove("&") + " " + button->shortcut().toString(QKeySequence::NativeText)); } } // For New button = widget->findChild<QPushButton*>("_new"); if (button) { button->setShortcut(QKeySequence::New); button->setToolTip(button->text().remove("&") + " " + button->shortcut().toString(QKeySequence::NativeText)); hasShortcut = true; } // For Print button = widget->findChild<QPushButton*>("_print"); if (button) { button->setShortcut(QKeySequence::Print); button->setToolTip(button->text().remove("&") + " " + button->shortcut().toString(QKeySequence::NativeText)); hasShortcut = true; } // For Query button = widget->findChild<QPushButton*>("_query"); if (button) { button->setShortcut(QKeySequence::Refresh); button->setToolTip(button->text().remove("&") + " " + button->shortcut().toString(QKeySequence::NativeText)); hasShortcut = true; } // Page up/down for tab widgets QTabWidget* tab = widget->findChild<QTabWidget*>(); if (tab) { TabWidgetNavigtor* tabNav = new TabWidgetNavigtor(tab, widget); QAction* pagedownAct = new QAction(tab); pagedownAct->setShortcut(QKeySequence::MoveToNextPage); pagedownAct->connect(pagedownAct, SIGNAL(triggered()), tabNav, SLOT(pageDown())); tab->addAction(pagedownAct); QAction* pageupAct = new QAction(tab); pageupAct->setShortcut(QKeySequence::MoveToPreviousPage); pageupAct->connect(pageupAct, SIGNAL(triggered()), tabNav, SLOT(pageUp())); tab->addAction(pageupAct); } }