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 9e0876b4f33..0f1348b5c8e 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 @@ -80,9 +80,11 @@ namespace hal { bool isComplete() const override; void setData(GateType* gate); std::unordered_map getBoolFunctions(); + Q_SIGNALS: + void hasChanged(); private Q_SLOTS: void handleStateChanged(const QString& stat); - + void handleTextChanged(const QString& txt); private: QGridLayout* mLayout; GateLibraryWizard* mWizard; diff --git a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/flipflop_wizardpage.h b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/flipflop_wizardpage.h index 0c4043b8ca5..5445c6b4399 100644 --- a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/flipflop_wizardpage.h +++ b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/flipflop_wizardpage.h @@ -44,7 +44,8 @@ namespace hal { void initializePage() override; void setData(GateType* gate); bool isComplete() const override; - + Q_SIGNALS: + void hasChanged(); public Q_SLOTS: void handleTextChanged(const QString& txt); private: diff --git a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/generalinfo_wizardpage.h b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/generalinfo_wizardpage.h index caecd607a55..4068293c50a 100644 --- a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/generalinfo_wizardpage.h +++ b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/generalinfo_wizardpage.h @@ -84,6 +84,7 @@ namespace hal { QString getName(); QList getProperties() const; bool isComplete() const override; + void initializePage() override; QString disabledIconStyle() const { return mDisabledIconStyle; } QString enabledIconStyle() const { return mEnabledIconStyle; } diff --git a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/init_wizardpage.h b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/init_wizardpage.h index 9903277ea9d..d8caeab3c47 100644 --- a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/init_wizardpage.h +++ b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/init_wizardpage.h @@ -37,13 +37,19 @@ namespace hal { class InitWizardPage:public QWizardPage{ friend class GateLibraryWizard; + Q_OBJECT public: InitWizardPage(QWidget* parent = nullptr); - //void initializePage() override; - //int nextId() const override; + void initializePage() override; + bool isComplete() const override; void setData(GateType* gate); + private Q_SLOTS: + void handleTextChanged(const QString& txt); + void handleTextEditChanged(); + private: + GateLibraryWizard* mWizard; QGridLayout* mLayout; QLineEdit* mCategory; diff --git a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/latch_wizardpage.h b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/latch_wizardpage.h index 6a9a67dbc66..5214b337e2b 100644 --- a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/latch_wizardpage.h +++ b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/latch_wizardpage.h @@ -34,6 +34,7 @@ #include namespace hal { + class GateLibraryWizard; class LatchWizardPage:public QWizardPage{ friend class GateLibraryWizard; public: diff --git a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/ram_port_wizardpage.h b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/ram_port_wizardpage.h index c7c0adb2b91..4e522578deb 100644 --- a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/ram_port_wizardpage.h +++ b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/ram_port_wizardpage.h @@ -51,6 +51,7 @@ namespace hal { QList getRamPorts(); void setData(GateType* gate); void initializePage() override; + bool isComplete() const override; private: GateLibraryWizard* mWizard; diff --git a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_wizard.h b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_wizard.h index 537916c7fd6..2523ad9322f 100644 --- a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_wizard.h +++ b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_wizard.h @@ -47,11 +47,15 @@ namespace hal { Q_OBJECT - friend class RAMPortWizardPage; + friend class GeneralInfoWizardPage; friend class PinsWizardPage; friend class FlipFlopWizardPage; - friend class StateWizardPage; friend class BoolWizardPage; + friend class LatchWizardPage; + + friend class RAMPortWizardPage; + friend class StateWizardPage; + friend class InitWizardPage; public: enum PAGE { @@ -95,5 +99,7 @@ namespace hal PinModel* mPinModel; GateType* mNewGateType; bool mWasEdited; + bool mEditMode; + QString mTitle; }; } diff --git a/plugins/gui/src/gatelibrary_management/gatelibrary_manager.cpp b/plugins/gui/src/gatelibrary_management/gatelibrary_manager.cpp index 1d0b4a3b0cb..00561353648 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_manager.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_manager.cpp @@ -162,13 +162,17 @@ namespace hal { if(mReadOnly) return; - mWizard = new GateLibraryWizard(mGateLibrary, mTableModel->getGateTypeAtIndex(index.row())); + GateType* gtEditable = mTableModel->getGateTypeAtIndex(index.row()); + mWizard = new GateLibraryWizard(mGateLibrary, gtEditable); connect(mWizard, &GateLibraryWizard::triggerUnsavedChanges, mContentWidget, &GatelibraryContentWidget::handleUnsavedChanges); mWizard->exec(); initialize(mGateLibrary); - mContentWidget->mTableView->selectRow(index.row()); + for (int r=0; rrowCount(); r++) { + if(mTableModel->getGateTypeAtIndex(r) == gtEditable) + mContentWidget->mTableView->selectRow(r); + } mContentWidget->setGateLibrary(mGateLibrary); mContentWidget->setGateLibraryPath(mPath); } @@ -235,7 +239,10 @@ namespace hal void GateLibraryManager::handleCancelClicked() { if(!gFileStatusManager->isGatelibModified()) + { + window()->setWindowTitle("HAL"); Q_EMIT close(); + } else { callUnsavedChangesWindow(); 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 4f222c5b552..d8da8bbb685 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/bool_wizardpage.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/bool_wizardpage.cpp @@ -63,6 +63,7 @@ namespace hal } if (mState != nextState) setState(nextState); + } //-------------------------------------------- BoolWizardPage::BoolWizardPage(QWidget* parent) @@ -113,7 +114,8 @@ namespace hal { lineEdit->setText(QString::fromStdString(bf->second.to_string())); } - connect(lineEdit,&BooleanFunctionEdit::stateChanged,this,&BoolWizardPage::handleStateChanged); + connect(lineEdit, &BooleanFunctionEdit::stateChanged,this,&BoolWizardPage::handleStateChanged); + connect(lineEdit, &BooleanFunctionEdit::textChanged, this, &BoolWizardPage::handleTextChanged); mEditFunctions.append(lineEdit); mOutputPins.append(label->text()); boolFuncCnt++; @@ -144,6 +146,7 @@ namespace hal mLayout->addWidget(label, rowCount, 0); mLayout->addWidget(lineEdit, rowCount, 1); connect(lineEdit,&BooleanFunctionEdit::stateChanged,this,&BoolWizardPage::handleStateChanged); + connect(lineEdit, &BooleanFunctionEdit::textChanged, this, &BoolWizardPage::handleTextChanged); mEditFunctions.append(lineEdit); mOutputPins.append(label->text()); rowCount++; @@ -155,6 +158,8 @@ namespace hal } setLayout(mLayout); + Q_EMIT completeChanged(); + mWizard->mEditMode = true; } void BoolWizardPage::setData(GateType *gate) @@ -166,6 +171,23 @@ namespace hal { Q_UNUSED(stat); Q_EMIT completeChanged(); + if(mWizard->mEditMode) Q_EMIT hasChanged(); + } + + void BoolWizardPage::handleTextChanged(const QString& txt) + { + Q_UNUSED(txt); + + //explicitly needed here because isComplete() is called + //before mWasEdited is changed in the wizard + // + + Q_EMIT completeChanged(); + if(mWizard->mEditMode) + { + mWizard->mWasEdited = true; + Q_EMIT hasChanged(); + } } bool BoolWizardPage::isComplete() const @@ -177,7 +199,8 @@ namespace hal return false; } } - if(!mWizard->mWasEdited) return false; + if(isFinalPage() && !mWizard->mWasEdited) return false; + mWizard->mEditMode = false; return true; } diff --git a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/flipflop_wizardpage.cpp b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/flipflop_wizardpage.cpp index 54660334489..71d4a92fc30 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/flipflop_wizardpage.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/flipflop_wizardpage.cpp @@ -116,10 +116,14 @@ namespace hal } Q_EMIT completeChanged(); + + mWizard->mEditMode = true; } void FlipFlopWizardPage::handleTextChanged(const QString& text){ Q_UNUSED(text); + mWizard = static_cast(wizard()); + if(mASet->text().isEmpty() || mAReset->text().isEmpty()) { mIntState->clear(); @@ -132,8 +136,9 @@ namespace hal mIntState->setDisabled(false); mNegIntState->setDisabled(false); } - Q_EMIT completeChanged(); + + if(mWizard->mEditMode) Q_EMIT hasChanged(); } void FlipFlopWizardPage::setData(GateType *gate){ @@ -187,6 +192,7 @@ namespace hal mNegIntState->text().toStdString() != enum_to_string(AsyncSetResetBehavior::X)) return false; } + mWizard->mEditMode = false; return true; } } diff --git a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/generalinfo_wizardpage.cpp b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/generalinfo_wizardpage.cpp index 6f1afa5bf96..f1135b80452 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/generalinfo_wizardpage.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/generalinfo_wizardpage.cpp @@ -117,6 +117,12 @@ namespace hal mName->setValidator(mValidator); } + void GeneralInfoWizardPage::initializePage() + { + mWizard = static_cast(wizard()); + mWizard->mEditMode = true; + } + void GeneralInfoWizardPage::setData(QString name, const std::vector& properties) { mName->setText(name); @@ -185,6 +191,7 @@ namespace hal if (QString::fromStdString(it.first) == mName->text()) return false; } + mWizard->mEditMode = false; return true; } } diff --git a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/init_wizardpage.cpp b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/init_wizardpage.cpp index 96b2d9282c3..d8b8afefe7e 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/init_wizardpage.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/init_wizardpage.cpp @@ -22,6 +22,15 @@ namespace hal mLayout->addWidget(mIdentifiers, 1, 1); setLayout(mLayout); + + connect(mCategory, &QLineEdit::textChanged, this, &InitWizardPage::handleTextChanged); + connect(mIdentifiers, &QTextEdit::textChanged, this, &InitWizardPage::handleTextEditChanged); + } + + void InitWizardPage::initializePage() + { + mWizard = static_cast(wizard()); + mWizard->mEditMode = true; } void InitWizardPage::setData(GateType *gate){ @@ -47,4 +56,34 @@ namespace hal } } } + + void InitWizardPage::handleTextChanged(const QString& txt) + { + Q_UNUSED(txt); + mWizard = static_cast(wizard()); + + //explicitly needed here because isComplete() is called + //before mWasEdited is changed in the wizard + if(mWizard->mEditMode) mWizard->mWasEdited = true; + + Q_EMIT completeChanged(); + } + + void InitWizardPage::handleTextEditChanged() + { + mWizard = static_cast(wizard()); + + //explicitly needed here because isComplete() is called + //before mWasEdited is changed in the wizard + if(mWizard->mEditMode) mWizard->mWasEdited = true; + + Q_EMIT completeChanged(); + } + + bool InitWizardPage::isComplete() const + { + if(isFinalPage() && !mWizard->mWasEdited) return false; + mWizard->mEditMode = false; + return true; + } } diff --git a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/latch_wizardpage.cpp b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/latch_wizardpage.cpp index 672e67eecb7..ac3ced3b63b 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/latch_wizardpage.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/latch_wizardpage.cpp @@ -42,6 +42,12 @@ namespace hal setLayout(mLayout); + connect(mDataIn, &QLineEdit::textChanged, this, &LatchWizardPage::completeChanged); + connect(mEnableOn, &QLineEdit::textChanged, this, &LatchWizardPage::completeChanged); + connect(mAReset, &QLineEdit::textChanged, this, &LatchWizardPage::completeChanged); + connect(mASet, &QLineEdit::textChanged, this, &LatchWizardPage::completeChanged); + connect(mIntState, &QLineEdit::textChanged, this, &LatchWizardPage::completeChanged); + connect(mNegIntState, &QLineEdit::textChanged, this, &LatchWizardPage::completeChanged); } void LatchWizardPage::setData(GateType *gate){ diff --git a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/lut_wizardpage.cpp b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/lut_wizardpage.cpp index 0a4a5c68c1b..f3174cedc2d 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/lut_wizardpage.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/lut_wizardpage.cpp @@ -19,6 +19,7 @@ namespace hal setLayout(mLayout); + connect(mAscending, &QCheckBox::stateChanged, this, &LUTWizardPage::completeChanged); } void LUTWizardPage::setData(GateType *gate){ diff --git a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/pins_wizardpage.cpp b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/pins_wizardpage.cpp index 58f414fb234..064a199e7a7 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/pins_wizardpage.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/pins_wizardpage.cpp @@ -28,6 +28,7 @@ namespace hal { mWizard = static_cast(wizard()); mWizard->mPinModel = mPinModel; + mWizard->mEditMode = true; if(!mGateset) { @@ -70,6 +71,7 @@ namespace hal } } } + mWizard->mEditMode = false; return hasPingroup; } } diff --git a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/ram_port_wizardpage.cpp b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/ram_port_wizardpage.cpp index 4880f5508dd..22e4cfc4ded 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/ram_port_wizardpage.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/ram_port_wizardpage.cpp @@ -66,9 +66,16 @@ void RAMPortWizardPage::initializePage(){ rp.isWritePort->setChecked(ram_port->is_write_port()); } mRamPortEdits.append(rp); + + connect(rp.dataGroup, &QLineEdit::textChanged, this, &RAMPortWizardPage::completeChanged); + connect(rp.addressGroup, &QLineEdit::textChanged, this, &RAMPortWizardPage::completeChanged); + connect(rp.clockFunction, &QLineEdit::textChanged, this, &RAMPortWizardPage::completeChanged); + connect(rp.enableFunciton, &QLineEdit::textChanged, this, &RAMPortWizardPage::completeChanged); + connect(rp.isWritePort, &QCheckBox::stateChanged, this, &RAMPortWizardPage::completeChanged); } } + mWizard->mEditMode = true; setLayout(mLayout); } @@ -79,4 +86,10 @@ void RAMPortWizardPage::initializePage(){ QList RAMPortWizardPage::getRamPorts(){ return mRamPortEdits; } + + bool RAMPortWizardPage::isComplete() const + { + mWizard->mEditMode = false; + return true; + } } diff --git a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/ram_wizardpage.cpp b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/ram_wizardpage.cpp index c9437069dec..abbb46729bf 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/ram_wizardpage.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/ram_wizardpage.cpp @@ -19,6 +19,7 @@ namespace hal setLayout(mLayout); + connect(mBitSize, &QLineEdit::textChanged, this, &RAMWizardPage::completeChanged); } void RAMWizardPage::setData(GateType *gate){ diff --git a/plugins/gui/src/gatelibrary_management/gatelibrary_wizard.cpp b/plugins/gui/src/gatelibrary_management/gatelibrary_wizard.cpp index 45e2038faa0..d581f18bd3b 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_wizard.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_wizard.cpp @@ -19,11 +19,12 @@ namespace hal { GateLibraryWizard::GateLibraryWizard(GateLibrary *gateLibrary, GateType *gateType, QWidget* parent): QWizard(parent) { + mEditMode = false; + generalInfoPage = new GeneralInfoWizardPage(gateLibrary, this); pinsPage = new PinsWizardPage(this); ffPage = new FlipFlopWizardPage(this); boolPage = new BoolWizardPage(this); - latchPage = new LatchWizardPage(this); lutPage = new LUTWizardPage(this); initPage = new InitWizardPage(this); @@ -50,10 +51,12 @@ namespace hal if(mGateType == nullptr) { setWindowTitle("Create new gate type"); + setButtonText(WizardButton::FinishButton, "Finish"); } else { setWindowTitle("Modify gate type " + QString::fromStdString(mGateType->get_name())); + setButtonText(WizardButton::FinishButton, "Save changes"); generalInfoPage->setData(QString::fromStdString(mGateType->get_name()), mGateType->get_property_list()); ffPage->setData(mGateType); @@ -65,13 +68,12 @@ namespace hal statePage->setData(mGateType); boolPage->setData(mGateType); } - - setButtonText(WizardButton::FinishButton, "Save changes"); + mTitle = windowTitle(); connect(generalInfoPage, &GeneralInfoWizardPage::completeChanged, this, &GateLibraryWizard::handleWasEdited); connect(pinsPage, &PinsWizardPage::completeChanged, this, &GateLibraryWizard::handleWasEdited); - connect(ffPage, &FlipFlopWizardPage::completeChanged, this, &GateLibraryWizard::handleWasEdited); - connect(boolPage, &BoolWizardPage::completeChanged, this, &GateLibraryWizard::handleWasEdited); + connect(ffPage, &FlipFlopWizardPage::hasChanged, this, &GateLibraryWizard::handleWasEdited); + connect(boolPage, &BoolWizardPage::hasChanged, this, &GateLibraryWizard::handleWasEdited); connect(latchPage, &LatchWizardPage::completeChanged, this, &GateLibraryWizard::handleWasEdited); connect(lutPage, &LUTWizardPage::completeChanged, this, &GateLibraryWizard::handleWasEdited); connect(initPage, &InitWizardPage::completeChanged, this, &GateLibraryWizard::handleWasEdited); @@ -142,6 +144,7 @@ namespace hal void GateLibraryWizard::handleWasEdited() { mWasEdited = true; + setWindowTitle(mTitle+" *"); } GateType* GateLibraryWizard::getRecentCreatedGate(){