From 19cdee247caf31d412c5eb583678b71b6b206960 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 16 Oct 2015 09:12:05 +0300 Subject: [PATCH] Apply button to be disabled during value modification for any operation, not only Sketch. Checked on Extrusion and on Edit operation. --- src/ModuleBase/ModuleBase_IModule.h | 5 ++++ src/PartSet/PartSet_Module.cpp | 5 ++++ src/PartSet/PartSet_Module.h | 5 ++++ src/PartSet/PartSet_SketcherMgr.cpp | 44 ++++++++--------------------- src/PartSet/PartSet_SketcherMgr.h | 12 ++++---- src/XGUI/XGUI_Workshop.cpp | 33 ++++++++++++++++++++++ src/XGUI/XGUI_Workshop.h | 7 +++++ 7 files changed, 72 insertions(+), 39 deletions(-) diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 27e71bfc8..859b43fa6 100644 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -188,6 +188,11 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject //! \return string value virtual QString getFeatureError(const FeaturePtr& theFeature); + /// Connects or disconnects to the value changed signal of the property panel widgets + /// \param theWidget a property contol widget + /// \param isToConnect a boolean value whether connect or disconnect + virtual void connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect) {}; + signals: /// Signal which is emitted when operation is launched void operationLaunched(); diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index b60fe129b..dd096b6a4 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -244,6 +244,11 @@ void PartSet_Module::registerProperties() Config_Prop::Integer, SKETCH_WIDTH); } +void PartSet_Module::connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect) +{ + mySketchMgr->connectToPropertyPanel(theWidget, isToConnect); +} + void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation) { if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) { diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index d28cae00f..79445f445 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -254,6 +254,11 @@ protected slots: /// Register properties of this module virtual void registerProperties(); + /// Connects or disconnects to the value changed signal of the property panel widgets + /// \param theWidget a property contol widget + /// \param isToConnect a boolean value whether connect or disconnect + virtual void connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect); + private slots: /// Processing of vertex selected void onVertexSelected(); diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index d26b9dde7..6c94099d9 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -265,13 +265,6 @@ void PartSet_SketcherMgr::onLeaveViewPort() } } -void PartSet_SketcherMgr::onValueStateChanged() -{ - ModuleBase_ModelWidget* anActiveWidget = getActiveWidget(); - if (anActiveWidget && anActiveWidget->getValueState() != ModuleBase_ModelWidget::Stored) - operationMgr()->onValidateOperation(); -} - void PartSet_SketcherMgr::onBeforeValuesChangedInPropertyPanel() { if (isNestedCreateOperation(getCurrentOperation())) @@ -911,14 +904,12 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation) void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation) { - connectToPropertyPanel(true); if (isNestedCreateOperation(theOperation) && myIsMouseOverWindow) QApplication::setOverrideCursor(QCursor(Qt::CrossCursor));//QIcon(":pictures/button_plus.png").pixmap(20,20))); } void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOp) { - connectToPropertyPanel(false); myIsMouseOverViewProcessed = true; operationMgr()->onValidateOperation(); if (isNestedCreateOperation(theOp)) @@ -1193,32 +1184,21 @@ void PartSet_SketcherMgr::getSelectionOwners(const FeaturePtr& theFeature, } } -void PartSet_SketcherMgr::connectToPropertyPanel(const bool isToConnect) +void PartSet_SketcherMgr::connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect) { - ModuleBase_IWorkshop* anIWorkshop = myModule->workshop(); - XGUI_ModuleConnector* aConnector = dynamic_cast(anIWorkshop); - XGUI_Workshop* aWorkshop = aConnector->workshop(); - XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel(); - if (aPropertyPanel) { - const QList& aWidgets = aPropertyPanel->modelWidgets(); - foreach (ModuleBase_ModelWidget* aWidget, aWidgets) { - if (isToConnect) { - connect(aWidget, SIGNAL(beforeValuesChanged()), + if (isToConnect) { + connect(theWidget, SIGNAL(beforeValuesChanged()), + this, SLOT(onBeforeValuesChangedInPropertyPanel())); + connect(theWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel())); + connect(theWidget, SIGNAL(afterValuesChanged()), + this, SLOT(onAfterValuesChangedInPropertyPanel())); + } + else { + disconnect(theWidget, SIGNAL(beforeValuesChanged()), this, SLOT(onBeforeValuesChangedInPropertyPanel())); - connect(aWidget, SIGNAL(valueStateChanged()), - this, SLOT(onValueStateChanged())); - connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel())); - connect(aWidget, SIGNAL(afterValuesChanged()), + disconnect(theWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel())); + disconnect(theWidget, SIGNAL(afterValuesChanged()), this, SLOT(onAfterValuesChangedInPropertyPanel())); - } - else { - disconnect(aWidget, SIGNAL(beforeValuesChanged()), - this, SLOT(onBeforeValuesChangedInPropertyPanel())); - disconnect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel())); - disconnect(aWidget, SIGNAL(afterValuesChanged()), - this, SLOT(onAfterValuesChangedInPropertyPanel())); - } - } } } diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index f5f38555d..66666c190 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -191,6 +191,11 @@ public: /// \param theModes a list of modes static void sketchSelectionModes(QIntList& theModes); + /// Connects or disconnects to the value changed signal of the property panel widgets + /// \param theWidget a property contol widget + /// \param isToConnect a boolean value whether connect or disconnect + void connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect); + public slots: /// Process sketch plane selected event void onPlaneSelected(const std::shared_ptr& thePln); @@ -205,9 +210,6 @@ private slots: /// Process the leave mouse of the view port. If the current operation is a create of /// a nested sketch feature, it hides the feature in the viewer void onLeaveViewPort(); - - /// Validates the operation. Apply button is disabled if the widget value is in Modified state - void onValueStateChanged(); /// Listens to the value changed signal and display the current operation feature void onBeforeValuesChangedInPropertyPanel(); /// Listens to the signal about values are to be changed in the property panel @@ -269,10 +271,6 @@ private: const FeatureToSelectionMap& theSelection, SelectMgr_IndexedMapOfOwner& anOwnersToSelect); - /// Connects or disconnects to the value changed signal of the property panel widgets - /// \param isToConnect a boolean value whether connect or disconnect - void connectToPropertyPanel(const bool isToConnect); - /// Returns true if the created feature is visible /// \param bool isVisibleCreatedFeature() const; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 343e3a6fb..56228ab22 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -459,6 +459,7 @@ void XGUI_Workshop::onOperationStarted(ModuleBase_Operation* theOperation) } updateCommandStatus(); + connectToPropertyPanel(true); myModule->operationStarted(aFOperation); // the objects of the current operation should be deactivated @@ -507,6 +508,7 @@ void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation) hidePropertyPanel(); myPropertyPanel->cleanContent(); + connectToPropertyPanel(false); myModule->operationStopped(aFOperation); // the deactivated objects of the current operation should be activated back. @@ -602,6 +604,23 @@ void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation) myErrorMgr->setPropertyPanel(myPropertyPanel); } +void XGUI_Workshop::connectToPropertyPanel(const bool isToConnect) +{ + XGUI_PropertyPanel* aPropertyPanel = propertyPanel(); + if (aPropertyPanel) { + const QList& aWidgets = aPropertyPanel->modelWidgets(); + foreach (ModuleBase_ModelWidget* aWidget, aWidgets) { + myModule->connectToPropertyPanel(aWidget, isToConnect); + if (isToConnect) { + connect(aWidget, SIGNAL(valueStateChanged()), this, SLOT(onValueStateChanged())); + } + else { + disconnect(aWidget, SIGNAL(valueStateChanged()), this, SLOT(onValueStateChanged())); + } + } + } +} + /* * Saves document with given name. */ @@ -836,6 +855,20 @@ void XGUI_Workshop::onPreferences() } } +//****************************************************** +void XGUI_Workshop::onValueStateChanged() +{ + ModuleBase_ModelWidget* anActiveWidget = 0; + ModuleBase_Operation* anOperation = myOperationMgr->currentOperation(); + if (anOperation) { + ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel(); + if (aPanel) + anActiveWidget = aPanel->activeWidget(); + } + if (anActiveWidget && anActiveWidget->getValueState() != ModuleBase_ModelWidget::Stored) + operationMgr()->onValidateOperation(); +} + //****************************************************** ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule) { diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 628e721ce..6a72b02d5 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -304,6 +304,9 @@ signals: /// Rebuild data tree void onRebuild(); + /// Validates the operation. Apply button is disabled if the widget value is in Modified state + void onValueStateChanged(); + /// Open preferences dialog box void onPreferences(); @@ -333,6 +336,10 @@ signals: /// \param theOperation an operation void setPropertyPanel(ModuleBase_Operation* theOperation); + /// Connects or disconnects to the value changed signal of the property panel widgets + /// \param isToConnect a boolean value whether connect or disconnect + void connectToPropertyPanel(const bool isToConnect); + private: /// Display all results //void displayAllResults(); -- 2.39.2