From: nds Date: Wed, 18 Nov 2015 12:01:38 +0000 (+0300) Subject: SALOME mode correction for dimension constraints editor. X-Git-Tag: V_2.0.0~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a6d1e8be5db1d94fdee39c412b8393d74bfcca2f;p=modules%2Fshaper.git SALOME mode correction for dimension constraints editor. 1. The enter is processed by enterClicked() only because operation manager do not receive this signal in SALOME mode 2. Sketcher Renetrant manager should not restart internal edit and create new feature if it is started. --- diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 3a2f19961..25ccc5aa1 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -200,6 +200,9 @@ signals: /// \param theEvent key release event void keyReleased(QKeyEvent* theEvent); + /// The signal is emitted if the enter is clicked in the control of the widget + void enterClicked(); + /// The signal about the widget is get focus /// \param theWidget the model base widget void focusInWidget(ModuleBase_ModelWidget* theWidget); diff --git a/src/ModuleBase/ModuleBase_WidgetEditor.cpp b/src/ModuleBase/ModuleBase_WidgetEditor.cpp index 87bb57ff1..20e836072 100644 --- a/src/ModuleBase/ModuleBase_WidgetEditor.cpp +++ b/src/ModuleBase/ModuleBase_WidgetEditor.cpp @@ -35,7 +35,8 @@ ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId) - : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId) +: ModuleBase_WidgetDoubleValue(theParent, theData, theParentId), + myIsKeyReleasedEmitted(false) { } @@ -52,7 +53,7 @@ void ModuleBase_WidgetEditor::editedValue(double& outValue, QString& outText) ModuleBase_ParamSpinBox* anEditor = new ModuleBase_ParamSpinBox(&aDlg); anEditor->enableKeyPressEvent(true); if (!myIsEditing) { - connect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*))); + connect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SLOT(onKeyReleased(QKeyEvent*))); } anEditor->setMinimum(0); @@ -72,7 +73,7 @@ void ModuleBase_WidgetEditor::editedValue(double& outValue, QString& outText) aDlg.exec(); if (!myIsEditing) { - disconnect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*))); + disconnect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SLOT(onKeyReleased(QKeyEvent*))); } outText = anEditor->text(); @@ -99,6 +100,8 @@ bool ModuleBase_WidgetEditor::focusTo() void ModuleBase_WidgetEditor::showPopupEditor() { + myIsKeyReleasedEmitted = false; + // we need to emit the focus in event manually in order to save the widget as an active // in the property panel before the mouse leave event happens in the viewer. The module // ask an active widget and change the feature visualization if the widget is not the current one. @@ -122,4 +125,12 @@ void ModuleBase_WidgetEditor::showPopupEditor() // the focus leaves the control automatically by the Enter/Esc event // it is processed in operation manager //emit focusOutWidget(this); + + if (myIsKeyReleasedEmitted) + emit enterClicked(); +} + +void ModuleBase_WidgetEditor::onKeyReleased(QKeyEvent* theEvent) +{ + myIsKeyReleasedEmitted = true; } diff --git a/src/ModuleBase/ModuleBase_WidgetEditor.h b/src/ModuleBase/ModuleBase_WidgetEditor.h index 5f26a60cc..8f494b366 100644 --- a/src/ModuleBase/ModuleBase_WidgetEditor.h +++ b/src/ModuleBase/ModuleBase_WidgetEditor.h @@ -46,6 +46,9 @@ Q_OBJECT /// Shous popup window under cursor for data editing void showPopupEditor(); +protected slots: + void onKeyReleased(QKeyEvent* theEvent); + private: void editedValue(double& outValue, QString& outText); @@ -55,6 +58,8 @@ private: ///< the kinds of possible features QStringList myFeatureKinds; + + bool myIsKeyReleasedEmitted; }; #endif diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index 63fa9c9b1..5e45abfee 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -274,6 +274,12 @@ bool PartSet_SketcherReetntrantMgr::isActiveMgr() const bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePreviousAttributeID) { bool isDone = false; + /// this is workaround for ModuleBase_WidgetEditor, used in SALOME mode. Sometimes key enter + /// event comes two times, so we should not start another internal edit operation + /// the Apply button becomes disabled becase the second additional internal feature is created + if (myIsInternalEditOperation) + return true; + ModuleBase_OperationFeature* aFOperation = dynamic_cast (myWorkshop->currentOperation()); diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index d441258e8..5d89fcab1 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -546,7 +546,8 @@ bool XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent) switch (theEvent->key()) { case Qt::Key_Return: case Qt::Key_Enter: { - ModuleBase_Operation* aOperation = currentOperation(); + isAccepted = onProcessEnter(); + /*ModuleBase_Operation* aOperation = currentOperation(); ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget(); if (!aActiveWgt || !aActiveWgt->processEnter()) { @@ -559,7 +560,7 @@ bool XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent) else isAccepted = false; } - } + }*/ } break; case Qt::Key_N: @@ -589,6 +590,26 @@ bool XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent) return isAccepted; } +bool XGUI_OperationMgr::onProcessEnter() +{ + bool isAccepted = true; + ModuleBase_Operation* aOperation = currentOperation(); + ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); + ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget(); + if (!aActiveWgt || !aActiveWgt->processEnter()) { + if (!myWorkshop->module()->processEnter(aActiveWgt ? aActiveWgt->attributeID() : "")) { + ModuleBase_OperationFeature* aFOperation = dynamic_cast(currentOperation()); + if (!aFOperation || myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty()) { + emit keyEnterReleased(); + commitOperation(); + } + else + isAccepted = false; + } + } + return isAccepted; +} + XGUI_Workshop* XGUI_OperationMgr::workshop() const { XGUI_ModuleConnector* aConnector = dynamic_cast(myWorkshop); diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index 0cda5543c..d6172b894 100755 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -176,6 +176,11 @@ protected: // TEMPORARY /// \param theEvent the mouse event bool onKeyReleased(QKeyEvent* theEvent); + /// The functionaly, that should be done by enter click + /// Fistly the active widget processes it, then module. If no one do not + /// process it, the current operation is committed + bool onProcessEnter(); + protected slots: /// Slot that is called by an operation stop. Removes the stopped operation form the stack. /// If there is a suspended operation, restart it. diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 57f55e9d9..c91596ec1 100755 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -121,6 +121,9 @@ void XGUI_PropertyPanel::setModelWidgets(const QList& t this, SLOT(activateNextWidget(ModuleBase_ModelWidget*))); connect(aWidget, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*))); + connect(aWidget, SIGNAL(enterClicked()), + this, SIGNAL(enterClicked())); + } } diff --git a/src/XGUI/XGUI_PropertyPanel.h b/src/XGUI/XGUI_PropertyPanel.h index 2d2b8e29c..a40ff085b 100644 --- a/src/XGUI/XGUI_PropertyPanel.h +++ b/src/XGUI/XGUI_PropertyPanel.h @@ -119,6 +119,9 @@ public slots: */ virtual void activateWidget(ModuleBase_ModelWidget* theWidget); +signals: + void enterClicked(); + protected: /// Makes the widget active, deactivate the previous, activate and hightlight the given one /// \param theWidget a widget diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index da722f6df..3e1eff31c 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1048,6 +1048,9 @@ void XGUI_Workshop::createDockWidgets() connect(aCancelAct, SIGNAL(triggered()), myOperationMgr, SLOT(onAbortOperation())); connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), myOperationMgr, SLOT(onKeyReleased(QKeyEvent*))); + + connect(myPropertyPanel, SIGNAL(enterClicked()), + myOperationMgr, SLOT(onProcessEnter())); //connect(myOperationMgr, SIGNAL(validationStateChanged(bool)), // this, SLOT(onValidationStateChanged(bool))); }