TilesOrderDialog::TilesOrderDialog(QWidget* pParent, const std::vector<unsigned int>& state) : QDialog(pParent, Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint) { setupUi(this); QString boardStateStr; for (auto index : state) { boardStateStr += QString::number(index) + " "; } QRegExpValidator * validator = new QRegExpValidator(); validator->setRegExp(QRegExp(validatorRegExpPattern(state.size()))); lineEditPosition->setValidator(validator); lineEditPosition->setText(boardStateStr); connect(buttonCancel, &QPushButton::clicked, this, &TilesOrderDialog::reject); connect(buttonOk , &QPushButton::clicked, this, &TilesOrderDialog::onOkClick); if (pParent) { move(pParent->frameGeometry().center() - frameGeometry().center()); } }
QValidator::State cwClinoValidator::validate ( QString & input, int & pos ) const { if(input.isEmpty()) { return QValidator::Acceptable; } QDoubleValidator doubleValidator; doubleValidator.setTop(90); doubleValidator.setBottom(-90); doubleValidator.setNotation(QDoubleValidator::StandardNotation); QValidator::State state = doubleValidator.validate(input, pos); switch(state) { case QValidator::Invalid: { QRegExpValidator upDownValidator; QRegExp regexp("up|down", Qt::CaseInsensitive); upDownValidator.setRegExp(regexp); return upDownValidator.validate(input, pos); } case QValidator::Acceptable: { //Just make sure we can convert the input bool okay; double value = input.toDouble(&okay); if(!okay || !check(value)) { //The validator is dump ... this handle use case input="5,5" return QValidator::Invalid; } break; } default: break; } return state; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimWellPathCompletions::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) { caf::PdmUiLineEditorAttribute* lineEditorAttr = dynamic_cast<caf::PdmUiLineEditorAttribute*>(attribute); if (field == &m_wellNameForExport && lineEditorAttr) { QRegExpValidator* validator = new QRegExpValidator(nullptr); validator->setRegExp(wellNameForExportRegExp()); lineEditorAttr->validator = validator; } else if (field == &m_drainageRadiusForPI && lineEditorAttr) { caf::PdmDoubleStringValidator* validator = new caf::PdmDoubleStringValidator("1*"); lineEditorAttr->validator = validator; } else if (field == &m_wellBoreFluidPVTTable && lineEditorAttr) { // Positive integer QIntValidator* validator = new QIntValidator(0, std::numeric_limits<int>::max(), nullptr); lineEditorAttr->validator = validator; } else if (field == &m_fluidInPlaceRegion && lineEditorAttr) { // Any integer QIntValidator* validator = new QIntValidator(-std::numeric_limits<int>::max(), std::numeric_limits<int>::max(), nullptr); lineEditorAttr->validator = validator; } }
//================================================================================ void customLineEdit::setRange(std::string regexp) { QRegExp theRegexp(QString(regexp.c_str())); QRegExpValidator * validator = new QRegExpValidator(this) ; validator->setRegExp(theRegexp); this->setValidator(validator) ; }
QtColorLineEdit::QtColorLineEdit(QWidget * parent) : QLineEdit(parent) { QRegExpValidator *validator = new QRegExpValidator(); validator->setRegExp(QRegExp("#[A-F0-9]{8}", Qt::CaseInsensitive)); setValidator(validator); QObject::connect(this, SIGNAL(editingFinished()), this, SLOT(EditFinished())); }
ConfigurationDialog::ConfigurationDialog(QWidget *parent) : QDialog(parent), ui(new Ui::ConfigurationDialog), m_settings(0) { ui->setupUi(this); // Filter out characters which are not allowed in a file name QRegExpValidator *fileNameValidator = new QRegExpValidator(ui->name); fileNameValidator->setRegExp(QRegExp(QLatin1String("^[^\\/\\\\\\?\\>\\<\\*\\%\\:\\\"\\']*$"))); ui->name->setValidator(fileNameValidator); updateDocumentation(); connect(ui->name, SIGNAL(textChanged(QString)), this, SLOT(updateOkButton())); updateOkButton(); // force initial test. connect(ui->editor, SIGNAL(documentationChanged(QString,QString)), this, SLOT(updateDocumentation(QString,QString))); // Set palette and font according to settings const TextEditor::FontSettings fs = TextEditor::TextEditorSettings::instance()->fontSettings(); const QTextCharFormat tf = fs.toTextCharFormat(TextEditor::C_TEXT); const QTextCharFormat selectionFormat = fs.toTextCharFormat(TextEditor::C_SELECTION); QPalette pal; pal.setColor(QPalette::Base, tf.background().color()); pal.setColor(QPalette::Text, tf.foreground().color()); pal.setColor(QPalette::Foreground, tf.foreground().color()); if (selectionFormat.background().style() != Qt::NoBrush) pal.setColor(QPalette::Highlight, selectionFormat.background().color()); pal.setBrush(QPalette::HighlightedText, selectionFormat.foreground()); ui->documentation->setPalette(pal); ui->editor->setPalette(pal); ui->documentation->setFont(tf.font()); ui->editor->setFont(tf.font()); // Set style sheet for documentation browser const QTextCharFormat tfOption = fs.toTextCharFormat(TextEditor::C_FIELD); const QTextCharFormat tfParam = fs.toTextCharFormat(TextEditor::C_STRING); const QString css = QString::fromLatin1("span.param {color: %1; background-color: %2;} " "span.option {color: %3; background-color: %4;} " "p { text-align: justify; } ") .arg(tfParam.foreground().color().name()) .arg(tfParam.background().style() == Qt::NoBrush ? QString() : tfParam.background().color().name()) .arg(tfOption.foreground().color().name()) .arg(tfOption.background().style() == Qt::NoBrush ? QString() : tfOption.background().color().name()) ; ui->documentation->document()->setDefaultStyleSheet(css); }
// set line regexp void MainWindow::bgLineChangeRegExp(int index) { QRegExpValidator *validator = new QRegExpValidator(bgColorLine); switch (index) { case 0 : // hex rgb16 { bgRedLabel->hide(); bgRedBox->hide(); bgGreenLabel->hide(); bgGreenBox->hide(); bgBlueLabel->hide(); bgBlueBox->hide(); bgColorLine->show(); validator->setRegExp(QRegExp("0x[0-9A-Fa-f]{1,4}")); bgColorLine->setValidator(validator); bgColorLine->setText(convertShortToQString( convertQColorToShort(bgColor))); break; } case 1 : // hex rgb24 { bgRedLabel->hide(); bgRedBox->hide(); bgGreenLabel->hide(); bgGreenBox->hide(); bgBlueLabel->hide(); bgBlueBox->hide(); bgColorLine->show(); validator->setRegExp(QRegExp("0x[0-9A-Fa-f]{1,6}")); bgColorLine->setValidator(validator); bgColorLine->setText(convertQColorToQString(bgColor)); break; } case 2 : // dec pallete { bgColorLine->hide(); bgRedLabel->show(); bgRedBox->show(); bgGreenLabel->show(); bgGreenBox->show(); bgBlueLabel->show(); bgBlueBox->show(); bgRedBox->setValue(bgColor.red()); bgGreenBox->setValue(bgColor.green()); bgBlueBox->setValue(bgColor.blue()); break; } } }
static PyObject *meth_QRegExpValidator_validate(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds) { PyObject *sipParseErr = NULL; bool sipSelfWasArg = (!sipSelf || sipIsDerived((sipSimpleWrapper *)sipSelf)); if (sipIsAPIEnabled(sipName_QString, 2, 0)) { QString * a0; int a0State = 0; int a1; QRegExpValidator *sipCpp; static const char *sipKwdList[] = { sipName_input, sipName_pos, }; if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, NULL, "BJ1i", &sipSelf, sipType_QRegExpValidator, &sipCpp, sipType_QString,&a0, &a0State, &a1)) { QValidator::State sipRes; PyObject *sipResult; Py_BEGIN_ALLOW_THREADS sipRes = (sipSelfWasArg ? sipCpp->QRegExpValidator::validate(*a0,a1) : sipCpp->validate(*a0,a1)); Py_END_ALLOW_THREADS sipResult = sipBuildResult(0,"(FDi)",sipRes,sipType_QValidator_State,a0,sipType_QString,NULL,a1); sipReleaseType(a0,sipType_QString,a0State); return sipResult; } } if (sipIsAPIEnabled(sipName_QString, 0, 2)) { QString * a0; int a1; QRegExpValidator *sipCpp; if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, NULL, NULL, "BJ9i", &sipSelf, sipType_QRegExpValidator, &sipCpp, sipType_QString,&a0, &a1)) { QValidator::State sipRes; Py_BEGIN_ALLOW_THREADS sipRes = (sipSelfWasArg ? sipCpp->QRegExpValidator::validate(*a0,a1) : sipCpp->validate(*a0,a1)); Py_END_ALLOW_THREADS return sipBuildResult(0,"(Fi)",sipRes,sipType_QValidator_State,a1); }
frmConnect::frmConnect(QWidget *parent) : QWidget(parent), ui(new Ui::frmConnect) { ui->setupUi(this); moveWindowToCenter(); //маска для IP QRegExpValidator *v = new QRegExpValidator(this); QRegExp rx("((1{0,1}[0-9]{0,2}|2[0-4]{1,1}[0-9]{1,1}|25[0-5]{1,1})\\.){3,3}(1{0,1}[0-9]{0,2}|2[0-4]{1,1}[0-9]{1,1}|25[0-5]{1,1})"); v->setRegExp(rx); ui->txtServer->setValidator(v); ui->txtPort->setValidator(new QIntValidator(0,65536,ui->txtPort)); }
QWidget* TileTexturePreviewWidgetItemDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const { QWidget* widget = QItemDelegate::createEditor(parent, option, index); QLineEdit* edit = qobject_cast<QLineEdit*>(widget); if (edit != 0) { QRegExpValidator* validator = new QRegExpValidator(); validator->setRegExp(QRegExp(TILE_COLOR_VALIDATE_REGEXP, Qt::CaseInsensitive)); edit->setValidator(validator); } return widget; }
LoginWidget::LoginWidget(QWidget *parent) : QWidget(parent) { QGridLayout* mainLayout = new QGridLayout(this); this->setLayout(mainLayout); ipEdit = new QLineEdit(); ipEdit->setInputMask("000.000.000.000;_"); loginEdit = new QLineEdit(); loginEdit->setMaxLength(25); passwordEdit = new QLineEdit(); passwordEdit->setEchoMode(QLineEdit::Password); passwordEdit->setMaxLength(25); mainLayout->addWidget(new QLabel("IP адрес: "), 0, 0); mainLayout->addWidget(new QLabel("Логин: "), 1, 0); mainLayout->addWidget(new QLabel("Пароль: "), 2, 0); mainLayout->addWidget(ipEdit, 0, 1); mainLayout->addWidget(loginEdit, 1, 1); mainLayout->addWidget(passwordEdit, 2, 1); QHBoxLayout* buttonLayout = new QHBoxLayout(); mainLayout->addLayout(buttonLayout, 3, 1); goLogin = new QPushButton("Вход"); goExit = new QPushButton("Выход"); buttonLayout->addWidget(goLogin); buttonLayout->addWidget(goExit); this->setWindowFlags(Qt::CustomizeWindowHint); this->setWindowFlags(Qt::WindowMinMaxButtonsHint | Qt::WindowTitleHint); QRegExpValidator* userNameValid = new QRegExpValidator(); QRegExp userNameReg("[A-Za-z0-9_]+$"); userNameValid->setRegExp(userNameReg); loginEdit->setValidator(userNameValid); connect(goLogin,SIGNAL(clicked(bool)),this,SLOT(onGoLogin())); connect(goExit,SIGNAL(clicked(bool)),this,SLOT(onGoExit())); }
DlgImportExportIges::DlgImportExportIges(QWidget* parent) : PreferencePage(parent) { ui = new Ui_DlgImportExportIges(); ui->setupUi(this); ui->lineEditProduct->setReadOnly(true); bg = new QButtonGroup(this); bg->addButton(ui->radioButtonBRepOff, 0); bg->addButton(ui->radioButtonBRepOn, 1); QRegExp rx; rx.setPattern(QString::fromLatin1("[\\x00-\\x7F]+")); QRegExpValidator* companyValidator = new QRegExpValidator(ui->lineEditCompany); companyValidator->setRegExp(rx); ui->lineEditCompany->setValidator(companyValidator); QRegExpValidator* authorValidator = new QRegExpValidator(ui->lineEditAuthor); authorValidator->setRegExp(rx); ui->lineEditAuthor->setValidator(authorValidator); }
void QmitkIGTLDeviceSetupConnectionWidget::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { // create GUI widgets m_Controls = new Ui::QmitkIGTLDeviceSetupConnectionWidgetControls; // setup GUI widgets m_Controls->setupUi(parent); } // set the validator for the ip edit box (values must be between 0 and 255 and // there are four of them, seperated with a point QRegExpValidator *v = new QRegExpValidator(this); QRegExp rx("((1{0,1}[0-9]{0,2}|2[0-4]{1,1}[0-9]{1,1}|25[0-5]{1,1})\\.){3,3}(1{0,1}[0-9]{0,2}|2[0-4]{1,1}[0-9]{1,1}|25[0-5]{1,1})"); v->setRegExp(rx); m_Controls->editIP->setValidator(v); // set the validator for the port edit box (values must be between 1 and 65535) m_Controls->editPort->setValidator(new QIntValidator(1, 65535, this)); //connect slots with signals CreateConnections(); }
DlgImportExportStep::DlgImportExportStep(QWidget* parent) : PreferencePage(parent) { ui = new Ui_DlgImportExportStep(); ui->setupUi(this); ui->lineEditProduct->setReadOnly(true); ui->radioButtonAP203->setToolTip(tr("Configuration controlled 3D designs of mechanical parts and assemblies")); ui->radioButtonAP214->setToolTip(tr("Core data for automotive mechanical design processes")); // https://tracker.dev.opencascade.org/view.php?id=25654 ui->checkBoxPcurves->setToolTip(tr("This parameter indicates whether parametric curves (curves in parametric space of surface)\n" "should be written into the STEP file. This parameter can be set to off in order to minimize\n" "the size of the resulting STEP file.")); QRegExp rx; rx.setPattern(QString::fromLatin1("[\\x00-\\x7F]+")); QRegExpValidator* companyValidator = new QRegExpValidator(ui->lineEditCompany); companyValidator->setRegExp(rx); ui->lineEditCompany->setValidator(companyValidator); QRegExpValidator* authorValidator = new QRegExpValidator(ui->lineEditAuthor); authorValidator->setRegExp(rx); ui->lineEditAuthor->setValidator(authorValidator); }
Config::Config(QWidget *parent,int index) : QDialog(parent) { programPath = qApp->applicationDirPath() + "/"; ui.setupUi(this); ui.tabConfiguration->setCurrentIndex(index); ui.radioManualProxy->setChecked(true); QRegExpValidator *proxyValidator = new QRegExpValidator(this); QRegExp validate("[0-9]*"); proxyValidator->setRegExp(validate); ui.proxyPort->setValidator(proxyValidator); // build language list and sort alphabetically QStringList langs = findLanguageFiles(); for(int i = 0; i < langs.size(); ++i) lang.insert(languageName(langs.at(i)) + QString(" (%1)").arg(langs.at(i)), langs.at(i)); lang.insert(DEFAULT_LANG, DEFAULT_LANG_CODE); QMap<QString, QString>::const_iterator i = lang.constBegin(); while (i != lang.constEnd()) { ui.listLanguages->addItem(i.key()); i++; } ComboBoxViewDelegate *delegate = new ComboBoxViewDelegate(this); ui.mountPoint->setItemDelegate(delegate); #if !defined(DBG) ui.mountPoint->setEditable(false); #endif ui.listLanguages->setSelectionMode(QAbstractItemView::SingleSelection); ui.proxyPass->setEchoMode(QLineEdit::Password); ui.treeDevices->setAlternatingRowColors(true); ui.listLanguages->setAlternatingRowColors(true); /* Explicitly set some widgets to have left-to-right layout */ ui.treeDevices->setLayoutDirection(Qt::LeftToRight); ui.mountPoint->setLayoutDirection(Qt::LeftToRight); ui.proxyHost->setLayoutDirection(Qt::LeftToRight); ui.proxyPort->setLayoutDirection(Qt::LeftToRight); ui.proxyUser->setLayoutDirection(Qt::LeftToRight); ui.proxyPass->setLayoutDirection(Qt::LeftToRight); ui.listLanguages->setLayoutDirection(Qt::LeftToRight); ui.cachePath->setLayoutDirection(Qt::LeftToRight); ui.comboTts->setLayoutDirection(Qt::LeftToRight); this->setModal(true); connect(ui.buttonOk, SIGNAL(clicked()), this, SLOT(accept())); connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(abort())); connect(ui.radioNoProxy, SIGNAL(toggled(bool)), this, SLOT(setNoProxy(bool))); connect(ui.radioSystemProxy, SIGNAL(toggled(bool)), this, SLOT(setSystemProxy(bool))); connect(ui.refreshMountPoint, SIGNAL(clicked()), this, SLOT(refreshMountpoint())); connect(ui.buttonAutodetect,SIGNAL(clicked()),this,SLOT(autodetect())); connect(ui.buttonCacheBrowse, SIGNAL(clicked()), this, SLOT(browseCache())); connect(ui.buttonCacheClear, SIGNAL(clicked()), this, SLOT(cacheClear())); connect(ui.configTts, SIGNAL(clicked()), this, SLOT(configTts())); connect(ui.configEncoder, SIGNAL(clicked()), this, SLOT(configEnc())); connect(ui.comboTts, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTtsState(int))); connect(ui.treeDevices, SIGNAL(itemSelectionChanged()), this, SLOT(updateEncState())); connect(ui.testTTS,SIGNAL(clicked()),this,SLOT(testTts())); connect(ui.showDisabled, SIGNAL(toggled(bool)), this, SLOT(showDisabled(bool))); connect(ui.mountPoint, SIGNAL(editTextChanged(QString)), this, SLOT(updateMountpoint(QString))); connect(ui.mountPoint, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMountpoint(int))); // delete this dialog after it finished automatically. connect(this, SIGNAL(finished(int)), this, SLOT(deleteLater())); setUserSettings(); setDevices(); }
// ----------------------------------------------------------- // Is called if user clicked on component text of if return is // pressed in the component text QLineEdit. // In "view->MAx3" is the number of the current property. void QucsApp::slotApplyCompText() { QString s; QFont f = QucsSettings.font; Schematic *Doc = (Schematic*)DocumentTab->currentPage(); f.setPointSizeFloat( Doc->Scale * float(f.pointSize()) ); editText->setFont(f); Property *pp = 0; Component *pc = (Component*)view->focusElement; if(!pc) return; // should never happen view->MAx1 = pc->cx + pc->tx; view->MAy1 = pc->cy + pc->ty; int z, n=0; // "n" is number of property on screen pp = pc->Props.first(); for(z=view->MAx3; z>0; z--) { // calculate "n" if(!pp) { // should never happen editText->setHidden(true); return; } if(pp->display) n++; // is visible ? pp = pc->Props.next(); } pp = 0; if(view->MAx3 > 0) pp = pc->Props.at(view->MAx3-1); // current property else s = pc->Name; if(!editText->isHidden()) { // is called the first time ? // no -> apply value to current property if(view->MAx3 == 0) { // component name ? Component *pc2; if(!editText->text().isEmpty()) if(pc->Name != editText->text()) { for(pc2 = Doc->Components->first(); pc2!=0; pc2 = Doc->Components->next()) if(pc2->Name == editText->text()) break; // found component with the same name ? if(!pc2) { pc->Name = editText->text(); Doc->setChanged(true, true); // only one undo state } } } else if(pp) { // property was applied if(pp->Value != editText->text()) { pp->Value = editText->text(); Doc->recreateComponent(pc); // because of "Num" and schematic symbol Doc->setChanged(true, true); // only one undo state } } n++; // next row on screen (view->MAx3)++; // next property pp = pc->Props.at(view->MAx3-1); // search for next property Doc->viewport()->update(); view->drawn = false; if(!pp) { // was already last property ? editText->setHidden(true); return; } while(!pp->display) { // search for next visible property (view->MAx3)++; // next property pp = pc->Props.next(); if(!pp) { // was already last property ? editText->setHidden(true); return; } } } // avoid seeing the property text behind the line edit if(pp) // Is it first property or component name ? s = pp->Value; editText->setMinimumWidth(editText->fontMetrics().width(s)+4); Doc->contentsToViewport(int(Doc->Scale * float(view->MAx1 - Doc->ViewX1)), int(Doc->Scale * float(view->MAy1 - Doc->ViewY1)), view->MAx2, view->MAy2); editText->setReadOnly(false); if(pp) { // is it a property ? s = pp->Value; view->MAx2 += editText->fontMetrics().width(pp->Name+"="); if(pp->Description.find('[') >= 0) // is selection list ? editText->setReadOnly(true); Expr_CompProp.setPattern("[^\"]*"); if(!pc->showName) n--; } else // it is the component name Expr_CompProp.setPattern("[\\w_]+"); Val_CompProp.setRegExp(Expr_CompProp); editText->setValidator(&Val_CompProp); z = editText->fontMetrics().lineSpacing(); view->MAy2 += n*z; editText->setText(s); editText->setPaletteBackgroundColor(QucsSettings.BGColor); editText->setFocus(); editText->selectAll(); editText->reparent(Doc->viewport(), 0, QPoint(view->MAx2, view->MAy2), true); }
EEPROMWindow::EEPROMWindow(QStringList eepromLines, QWidget *parent) : QDialog(parent), ui(new Ui::EEPROMWindow) { ui->setupUi(this); QSettings settings; firmware = settings.value("printer/firmware").toInt(); QLayout *layout = new QVBoxLayout(); if(firmware == Repetier) { int j = 0; foreach (QString str, eepromLines) { str.remove("EPR:"); // Clear the unneeded part repetierEEPROMline currentLine; //Storage for EEPROM values QStringList tmp = str.split(' '); currentLine.T = tmp.at(0).toInt(); currentLine.P = tmp.at(1).toInt(); currentLine.S = tmp.at(2); lines.append(currentLine); QString msg; for(int i = 3; i < tmp.size(); i++) msg+=(tmp.at(i) + " "); //Rejoin the rest QLayout *line = new QGridLayout(); QLabel *label = new QLabel(msg, this); QLineEdit *edit = new QLineEdit(currentLine.S,this); QFrame* hline = new QFrame(); hline->setFrameShape(QFrame::HLine); hline->setFrameShadow(QFrame::Sunken); line->addWidget(hline); edit->setObjectName("e"+QString::number(j)); //Name the LineEdit, so when it emits signal we know where it came from QRegExpValidator *doublevalidator = new QRegExpValidator( QRegExp("^\\-?\\d+\\.?\\d+(e\\-?\\d+)?$", Qt::CaseInsensitive), this); doublevalidator->setLocale(QLocale::English); switch(currentLine.T) // set right validator for the line { case 0: edit->setValidator(new QIntValidator(-128, 255, this)); case 1: case 2: edit->setValidator(new QIntValidator(this)); break; case 3: edit->setValidator(doublevalidator); break; default: break; } connect(edit, &QLineEdit::textChanged, this, &EEPROMWindow::lineChanged); line->addWidget(label); line->addWidget(edit); line->setMargin(2); layout->addItem(line); j++; // increase counter }