From 82c6b6d564a3220fb6bdc04807c885a03327bedf Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 24 Jan 2018 14:22:25 +0300 Subject: [PATCH] Issue #2412: Use remembering last choice only for widget toolbox --- src/ModuleBase/ModuleBase_PagedContainer.cpp | 12 ++++++++---- src/ModuleBase/ModuleBase_PagedContainer.h | 3 +++ src/ModuleBase/ModuleBase_WidgetSwitch.cpp | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ModuleBase/ModuleBase_PagedContainer.cpp b/src/ModuleBase/ModuleBase_PagedContainer.cpp index 8ba5a314e..2cb2fddde 100644 --- a/src/ModuleBase/ModuleBase_PagedContainer.cpp +++ b/src/ModuleBase/ModuleBase_PagedContainer.cpp @@ -35,7 +35,7 @@ static QMap defaultValues; ModuleBase_PagedContainer::ModuleBase_PagedContainer(QWidget* theParent, const Config_WidgetAPI* theData) : ModuleBase_ModelWidget(theParent, theData), - myIsFocusOnCurrentPage(false), myIsFirst(true) + myIsFocusOnCurrentPage(false), myIsFirst(true), myRemeberChoice(true) { // it is not obligatory to be ignored when property panel tries to activate next active widget // but if focus is moved to this control, it can accept it. @@ -95,10 +95,13 @@ bool ModuleBase_PagedContainer::restoreValueCustom() // A rare case when plugin was not loaded. if(!myFeature) return false; + + std::string aDefVal = myRemeberChoice? myDefValue : ""; + DataPtr aData = myFeature->data(); AttributeStringPtr aStringAttr = aData->string(attributeID()); - QString aCaseId = QString::fromStdString(myDefValue.empty()? - aStringAttr->value() : myDefValue); + QString aCaseId = QString::fromStdString(aDefVal.empty()? + aStringAttr->value() : aDefVal); myIsFirst = false; int idx = myCaseIds.indexOf(aCaseId); if (idx == -1) @@ -150,6 +153,7 @@ void ModuleBase_PagedContainer::onPageChanged() void ModuleBase_PagedContainer::onFeatureAccepted() { - defaultValues[myFeatureId + attributeID()] = myDefValue; + if (myRemeberChoice) + defaultValues[myFeatureId + attributeID()] = myDefValue; } diff --git a/src/ModuleBase/ModuleBase_PagedContainer.h b/src/ModuleBase/ModuleBase_PagedContainer.h index cd525cdba..265b3474f 100644 --- a/src/ModuleBase/ModuleBase_PagedContainer.h +++ b/src/ModuleBase/ModuleBase_PagedContainer.h @@ -81,6 +81,9 @@ class MODULEBASE_EXPORT ModuleBase_PagedContainer : public ModuleBase_ModelWidge /// Redefinition of virtual function virtual bool restoreValueCustom(); + // A flag which let to remeber last user choice and restore it on next launch + bool myRemeberChoice; + protected slots: /// A slot called on page change void onPageChanged(); diff --git a/src/ModuleBase/ModuleBase_WidgetSwitch.cpp b/src/ModuleBase/ModuleBase_WidgetSwitch.cpp index a762432f0..bf1b29749 100644 --- a/src/ModuleBase/ModuleBase_WidgetSwitch.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSwitch.cpp @@ -33,6 +33,7 @@ ModuleBase_WidgetSwitch::ModuleBase_WidgetSwitch(QWidget* theParent, const Config_WidgetAPI* theData) : ModuleBase_PagedContainer(theParent, theData) { + myRemeberChoice = false; QVBoxLayout* aMainLay = new QVBoxLayout(this); //aMainLay->setContentsMargins(2, 4, 2, 2); ModuleBase_Tools::adjustMargins(aMainLay); -- 2.39.2