From 777841813efb26f5baba702bc936035b0daa138c Mon Sep 17 00:00:00 2001 From: tarapn79 Date: Thu, 19 Sep 2024 21:03:05 +0200 Subject: [PATCH] changed "finish" button to "save changes", as well as the functionality to disabled if no changes were made --- .../gatelibrary_pages/generalinfo_wizardpage.h | 3 ++- .../gatelibrary_wizard.h | 3 +++ .../gatelibrary_pages/bool_wizardpage.cpp | 1 + .../gatelibrary_wizard.cpp | 18 ++++++++++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) 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 c7019a063cf..caecd607a55 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 @@ -70,6 +70,7 @@ namespace hal { bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent = QModelIndex()) const override; }; + class GateLibraryWizard; class GeneralInfoWizardPage:public QWizardPage{ Q_OBJECT @@ -100,7 +101,7 @@ namespace hal { void handleNameChanged(const QString& txt); private: - QWizard* mWizard; + GateLibraryWizard* mWizard; QGridLayout* mLayout; QLabel* mLabelName; diff --git a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_wizard.h b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_wizard.h index 9ae42ca588a..537916c7fd6 100644 --- a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_wizard.h +++ b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_wizard.h @@ -76,6 +76,8 @@ namespace hal int nextId() const override; Q_SIGNALS: void triggerUnsavedChanges(); + private Q_SLOTS: + void handleWasEdited(); private: GateLibrary* mGateLibrary; GateType* mGateType; @@ -92,5 +94,6 @@ namespace hal PinModel* mPinModel; GateType* mNewGateType; + bool mWasEdited; }; } 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 16ad722ebc5..4f222c5b552 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/bool_wizardpage.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/bool_wizardpage.cpp @@ -177,6 +177,7 @@ namespace hal return false; } } + if(!mWizard->mWasEdited) return false; return true; } diff --git a/plugins/gui/src/gatelibrary_management/gatelibrary_wizard.cpp b/plugins/gui/src/gatelibrary_management/gatelibrary_wizard.cpp index 1201cb778be..45e2038faa0 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_wizard.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_wizard.cpp @@ -45,6 +45,7 @@ namespace hal mGateLibrary = gateLibrary; mGateType = gateType; mPinModel = new PinModel(this, true); + mWasEdited = false; if(mGateType == nullptr) { @@ -65,6 +66,18 @@ namespace hal boolPage->setData(mGateType); } + setButtonText(WizardButton::FinishButton, "Save changes"); + + 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(latchPage, &LatchWizardPage::completeChanged, this, &GateLibraryWizard::handleWasEdited); + connect(lutPage, &LUTWizardPage::completeChanged, this, &GateLibraryWizard::handleWasEdited); + connect(initPage, &InitWizardPage::completeChanged, this, &GateLibraryWizard::handleWasEdited); + connect(ramPage, &RAMWizardPage::completeChanged, this, &GateLibraryWizard::handleWasEdited); + connect(ramportPage, &RAMPortWizardPage::completeChanged, this, &GateLibraryWizard::handleWasEdited); + connect(statePage, &StateWizardPage::completeChanged, this, &GateLibraryWizard::handleWasEdited); } void GateLibraryWizard::accept() @@ -126,6 +139,11 @@ namespace hal gFileStatusManager->gatelibChanged(); } + void GateLibraryWizard::handleWasEdited() + { + mWasEdited = true; + } + GateType* GateLibraryWizard::getRecentCreatedGate(){ return mNewGateType; }