diff --git a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/bool_wizardpage.h b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/bool_wizardpage.h index 2578e294629..4474ed50ead 100644 --- a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/bool_wizardpage.h +++ b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/bool_wizardpage.h @@ -55,6 +55,9 @@ namespace hal { QString mState; std::set mLegalVariables; + const char* EMPTY = "Empty"; + const char* VALID = "Valid"; + const char* INVALID = "Invalid"; Q_SIGNALS: void stateChanged(QString s); private Q_SLOTS: @@ -63,6 +66,8 @@ namespace hal { BooleanFunctionEdit(std::set& legalVar, QWidget* parent = nullptr); QString state() const { return mState; } void setState(const QString& s); + bool isValid() const { return mState == VALID; } + void setFunctionText(const QString& txt); }; class BoolWizardPage:public QWizardPage diff --git a/plugins/gui/resources/stylesheet/dark.qss b/plugins/gui/resources/stylesheet/dark.qss index 7a2193d5cb9..0e6fbf84d44 100755 --- a/plugins/gui/resources/stylesheet/dark.qss +++ b/plugins/gui/resources/stylesheet/dark.qss @@ -1495,7 +1495,8 @@ hal--BooleanFunctionEdit[state="Empty"] hal--BooleanFunctionEdit[state="Invalid"] { - background: red; + background: #802010; + color : #F0E0C0; } hal--GuiPluginManager diff --git a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/bool_wizardpage.cpp b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/bool_wizardpage.cpp index 60832a17fe7..208b75448dd 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/bool_wizardpage.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/bool_wizardpage.cpp @@ -5,10 +5,10 @@ namespace hal { BooleanFunctionEdit::BooleanFunctionEdit(std::set &legalVar, QWidget *parent) - : QLineEdit(parent), mState("Valid"), mLegalVariables(legalVar) + : QLineEdit(parent), mState(VALID), mLegalVariables(legalVar) { connect(this, &QLineEdit::editingFinished, this, &BooleanFunctionEdit::handleEditingFinished); - setState("Empty"); + setState(EMPTY); // do an active transition to enforce style } void BooleanFunctionEdit::setState(const QString &s) @@ -26,15 +26,15 @@ namespace hal { if (text().isEmpty()) { - setState("Empty"); + setState(EMPTY); return; } - QString nextState = "Valid"; // think positive + QString nextState = VALID; // think positive auto bfres = BooleanFunction::from_string(text().toStdString()); if(bfres.is_error()) - nextState = "Invalid"; + nextState = INVALID; else { BooleanFunction bf = bfres.get(); @@ -44,7 +44,7 @@ namespace hal { if (mLegalVariables.find(vname) == mLegalVariables.end()) { - nextState = "Invalid"; + nextState = INVALID; break; } } @@ -53,6 +53,11 @@ namespace hal setState(nextState); } + void BooleanFunctionEdit::setFunctionText(const QString &txt) + { + setText(txt); + handleEditingFinished(); + } //-------------------------------------------- BoolWizardPage::BoolWizardPage(QWidget* parent) : QWizardPage(parent) { @@ -80,7 +85,7 @@ namespace hal BooleanFunctionEdit* lineEdit = new BooleanFunctionEdit(input_pins, this); mLayout->addWidget(label, boolFuncCnt, 0); mLayout->addWidget(lineEdit, boolFuncCnt, 1); - lineEdit->setText(QString::fromStdString(bf.second.to_string())); + lineEdit->setFunctionText(QString::fromStdString(bf.second.to_string())); boolFuncCnt++; } }