From: nds Date: Wed, 7 Oct 2015 11:51:20 +0000 (+0300) Subject: Apply modifications in the editors by Enter/Tab event only. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7608cab6b63c3e3d16eaf30d85573c46a19b2de1;p=modules%2Fshaper.git Apply modifications in the editors by Enter/Tab event only. --- diff --git a/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp b/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp index 080138f54..e436875bf 100644 --- a/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp @@ -57,7 +57,8 @@ const double PSEUDO_ZERO = 1.e-20; */ ModuleBase_DoubleSpinBox::ModuleBase_DoubleSpinBox(QWidget* theParent, int thePrecision) : QDoubleSpinBox(theParent), - myCleared(false) + myCleared(false), + myIsModified(false) { // VSR 01/07/2010: Disable thousands separator for spin box // (to avoid inconsistency of double-2-string and string-2-double conversion) @@ -75,6 +76,9 @@ ModuleBase_DoubleSpinBox::ModuleBase_DoubleSpinBox(QWidget* theParent, int thePr connect(lineEdit(), SIGNAL(textChanged( const QString& )), this, SLOT(onTextChanged( const QString& ))); + + connect(this, SIGNAL(valueChanged(const QString&)), this, SLOT(onValueChanged(const QString&))); + connect(this, SIGNAL(editingFinished()), this, SLOT(onEditingFinished())); } /*! @@ -196,6 +200,31 @@ QString ModuleBase_DoubleSpinBox::removeTrailingZeroes(const QString& src) const return res; } +#include +void ModuleBase_DoubleSpinBox::keyPressEvent(QKeyEvent *theEvent) +{ + myProcessedEvent = 0; + + bool anIsModified = myIsModified; + QDoubleSpinBox::keyPressEvent(theEvent); + + switch (theEvent->key()) { + case Qt::Key_Enter: + case Qt::Key_Return: { + if (anIsModified) + myProcessedEvent = theEvent; + /*qDebug("ModuleBase_DoubleSpinBox::keyPressEvent"); + if (anIsModified) // we should not perform this event outside + theEvent->setAccepted(true); + else + theEvent->setAccepted(false);*/ + } + break; + default: + break; + } +} + /*! \brief Perform \a steps increment/decrement steps. @@ -306,4 +335,20 @@ QValidator::State ModuleBase_DoubleSpinBox::validate(QString& str, int& pos) con void ModuleBase_DoubleSpinBox::onTextChanged(const QString& ) { myCleared = false; + myIsModified = true; +} + +void ModuleBase_DoubleSpinBox::onValueChanged(const QString& theValue) +{ + myIsModified = true; +} + +void ModuleBase_DoubleSpinBox::onEditingFinished() +{ + myIsModified = false; +} + +bool ModuleBase_DoubleSpinBox::isEventProcessed(QKeyEvent* theEvent) +{ + return myProcessedEvent && myProcessedEvent == theEvent; } diff --git a/src/ModuleBase/ModuleBase_DoubleSpinBox.h b/src/ModuleBase/ModuleBase_DoubleSpinBox.h index 87cbe6e84..52eb6e3f9 100644 --- a/src/ModuleBase/ModuleBase_DoubleSpinBox.h +++ b/src/ModuleBase/ModuleBase_DoubleSpinBox.h @@ -11,6 +11,7 @@ #include #include +class QKeyEvent; /** * \ingroup GUI @@ -48,13 +49,18 @@ Q_OBJECT /// Validate current value virtual QValidator::State validate(QString&, int&) const; + virtual bool isEventProcessed(QKeyEvent* theEvent); + protected slots: /// Called on text changed virtual void onTextChanged(const QString&); + void onValueChanged(const QString& theValue); + void onEditingFinished(); protected: /// Removes extra trailing zero symbols QString removeTrailingZeroes(const QString&) const; + virtual void keyPressEvent(QKeyEvent* theEvent); private: /// Is clear flag @@ -62,6 +68,10 @@ Q_OBJECT /// Precision value int myPrecision; + /// Boolean value whether the spin box content is modified + bool myIsModified; + + QKeyEvent* myProcessedEvent; }; #endif diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index e2bd9b17e..49fb1c61c 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -179,10 +179,10 @@ bool ModuleBase_IModule::canRedo() const return aMgr->hasModuleDocument() && aMgr->canRedo() && !aMgr->isOperation(); } -bool ModuleBase_IModule::canCommitOperation() const +/*/bool ModuleBase_IModule::canCommitOperation() const { return true; -} +}*/ void ModuleBase_IModule::onFeatureTriggered() { diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 301bcbe5b..782d42c5c 100644 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -122,7 +122,7 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// Returns True if the current operation can be committed. By default it is true. /// \return a boolean value - virtual bool canCommitOperation() const; + //virtual bool canCommitOperation() const; /// Returns whether the object can be erased. The default realization returns true. /// \param theObject a model object diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index 75d99535b..87d490d88 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -148,6 +148,14 @@ bool ModuleBase_ModelWidget::restoreValue() return isDone; } +void ModuleBase_ModelWidget::storeValueByApply() +{ + // do not emit signal about update the currenty feature object + // in order to do not perform additional redisplay in the viewer. + // It should happens by finish operation of the apply action + storeValueCustom(); +} + void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj) { blockUpdateViewer(true); @@ -168,6 +176,11 @@ void ModuleBase_ModelWidget::moveObject(ObjectPtr theObj) //blockUpdateViewer(false); } +bool ModuleBase_ModelWidget::isEventProcessed(QKeyEvent* theEvent) +{ + return false; +} + bool ModuleBase_ModelWidget::eventFilter(QObject* theObject, QEvent *theEvent) { QWidget* aWidget = qobject_cast(theObject); diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 175305244..dd60b1664 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -91,6 +91,10 @@ Q_OBJECT /// \return True in success bool restoreValue(); + /// Saves the internal parameters to the given feature. Emits signals before and after store + /// \return True in success + void storeValueByApply(); + /// Set focus to the first control of the current widget. The focus policy of the control is checked. /// If the widget has the NonFocus focus policy, it is skipped. /// \return the state whether the widget can accept the focus @@ -147,6 +151,9 @@ Q_OBJECT /// \return Current Editing mode bool isEditingMode() const { return myIsEditing; } + /// Returns true if the event is processed. + virtual bool isEventProcessed(QKeyEvent* theEvent); + /// Sends Update and Redisplay for the given object /// \param theObj is updating object static void updateObject(ObjectPtr theObj); @@ -160,6 +167,8 @@ signals: void beforeValuesChanged(); /// The signal about widget values changed void valuesChanged(); + /// The signal about widget values modified + void valuesModified(); /// The signal about widget values are to be changed void afterValuesChanged(); diff --git a/src/ModuleBase/ModuleBase_OperationFeature.cpp b/src/ModuleBase/ModuleBase_OperationFeature.cpp index b3540002f..a3f581d6b 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.cpp +++ b/src/ModuleBase/ModuleBase_OperationFeature.cpp @@ -37,6 +37,8 @@ #include #endif +#define APPLY_BY_ENTER_OR_TAB + ModuleBase_OperationFeature::ModuleBase_OperationFeature(const QString& theId, QObject* theParent) : ModuleBase_Operation(theId, theParent), myIsEditing(false) @@ -266,9 +268,14 @@ bool ModuleBase_OperationFeature::commit() // selection and if the active widget listens it, the attribute value is errnoneous // changed. ModuleBase_IPropertyPanel* aPropertyPanel = propertyPanel(); - if (aPropertyPanel) + if (aPropertyPanel) { +#ifdef APPLY_BY_ENTER_OR_TAB + ModuleBase_ModelWidget* aWidget = aPropertyPanel->activeWidget(); + if (aWidget) + aWidget->storeValueByApply(); +#endif aPropertyPanel->cleanContent(); - + } SessionPtr aMgr = ModelAPI_Session::get(); /// Set current feature and remeber old current feature if (myIsEditing) { diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index 2687b72a2..80737131f 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -31,7 +31,7 @@ #include #endif -//#define APPLY_BY_ENTER_OR_TAB +#define APPLY_BY_ENTER_OR_TAB ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, const Config_WidgetAPI* theData, @@ -90,6 +90,8 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, #ifdef APPLY_BY_ENTER_OR_TAB // Apply widget value change by enter/tab event. connect(mySpinBox, SIGNAL(editingFinished()), this, SIGNAL(valuesChanged())); + connect(mySpinBox, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified())); + #else connect(mySpinBox, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesChanged())); #endif @@ -156,3 +158,8 @@ QList ModuleBase_WidgetDoubleValue::getControls() const aList.append(mySpinBox); return aList; } + +bool ModuleBase_WidgetDoubleValue::isEventProcessed(QKeyEvent* theEvent) +{ + return mySpinBox->isEventProcessed(theEvent); +} diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.h b/src/ModuleBase/ModuleBase_WidgetDoubleValue.h index 81052981c..04e871795 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.h +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.h @@ -44,6 +44,9 @@ Q_OBJECT /// \return a control list virtual QList getControls() const; + /// Returns true if the event is processed. + virtual bool isEventProcessed(QKeyEvent* theEvent); + public slots: // Delayed value chnged: when user starts typing something, // it gives him a 0,5 second to finish typing, when sends valueChnaged() signal diff --git a/src/ModuleBase/ModuleBase_WidgetIntValue.cpp b/src/ModuleBase/ModuleBase_WidgetIntValue.cpp index 54e737c11..68b928a8c 100644 --- a/src/ModuleBase/ModuleBase_WidgetIntValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetIntValue.cpp @@ -34,7 +34,7 @@ #include #endif -//#define APPLY_BY_ENTER_OR_TAB +#define APPLY_BY_ENTER_OR_TAB ModuleBase_WidgetIntValue::ModuleBase_WidgetIntValue(QWidget* theParent, const Config_WidgetAPI* theData, @@ -89,6 +89,7 @@ ModuleBase_WidgetIntValue::ModuleBase_WidgetIntValue(QWidget* theParent, #ifdef APPLY_BY_ENTER_OR_TAB // Apply widget value change by enter/tab event. connect(mySpinBox, SIGNAL(editingFinished()), this, SIGNAL(valuesChanged())); + connect(mySpinBox, SIGNAL(valueChanged(int)), this, SIGNAL(valuesModified())); #else connect(mySpinBox, SIGNAL(valueChanged(int)), this, SIGNAL(valuesChanged())); #endif diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 0cbbf1759..d8fcc0030 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -374,10 +374,10 @@ bool PartSet_Module::canApplyAction(const ObjectPtr& theObject, const QString& t return aValid; } -bool PartSet_Module::canCommitOperation() const +/*bool PartSet_Module::canCommitOperation() const { return mySketchMgr->canCommitOperation(); -} +}*/ bool PartSet_Module::canEraseObject(const ObjectPtr& theObject) const { diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index a475b5f65..8408a7679 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -118,7 +118,7 @@ public: /// Returns True if the current operation can be committed. Asks the sketch manager. /// \return a boolean value - virtual bool canCommitOperation() const; + //virtual bool canCommitOperation() const; /// Returns whether the object can be erased at the bounds of the active operation. /// The sub-objects of the current operation can not be erased diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index c1a80e4bd..1a9c7da38 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -152,7 +152,7 @@ void getAttributesOrResults(const Handle(SelectMgr_EntityOwner)& theOwner, PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule) : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false), - myIsResetCurrentValue(false), myIsMouseOverWindow(false), + myIsResetCurrentValue(false), myIsCurrentValueUnderModification(false), myIsMouseOverWindow(false), myIsMouseOverViewProcessed(true), myPreviousUpdateViewerEnabled(true), myIsPopupMenuActive(false), myIsConstraintsShown(true) { @@ -192,6 +192,7 @@ void PartSet_SketcherMgr::onEnterViewPort() // redisplayed before this update, the feature presentation jumps from reset value to current. myIsMouseOverWindow = true; myIsResetCurrentValue = false; + myIsCurrentValueUnderModification = false; // it is important to validate operation here only if sketch entity create operation is active // because at this operation we reacts to the mouse leave/enter view port //operationMgr()->onValidateOperation(); @@ -273,9 +274,20 @@ void PartSet_SketcherMgr::onLeaveViewPort() } } +void PartSet_SketcherMgr::onValuesModied() +{ + myIsCurrentValueUnderModification = true; + // update Apply enable state + //myIsResetCurrentValue = false; + //if (!isNestedCreateOperation(getCurrentOperation())) + // return; + operationMgr()->onValidateOperation(); +} + void PartSet_SketcherMgr::onBeforeValuesChangedInPropertyPanel() { myIsResetCurrentValue = false; + myIsCurrentValueUnderModification = false; if (isNestedCreateOperation(getCurrentOperation())) return; @@ -693,7 +705,8 @@ QString PartSet_SketcherMgr::getFeatureError(const FeaturePtr& theFeature) AttributeStringPtr aAttributeString = aSketch->string(SketchPlugin_Sketch::SOLVER_ERROR()); anError = aAttributeString->value().c_str(); } - else if (myIsResetCurrentValue) { // this flag do not allow commit of the current operation + else if (myIsResetCurrentValue || myIsCurrentValueUnderModification) { + // this flags do not allow commit of the current operation ModuleBase_OperationFeature* aFOperation = dynamic_cast (getCurrentOperation()); if (aFOperation) { @@ -707,7 +720,11 @@ QString PartSet_SketcherMgr::getFeatureError(const FeaturePtr& theFeature) if (anAttr.get()) anAttributeName = anAttr->id().c_str(); } - anError = "Attribute \"" + anAttributeName + "\" is not initialized."; + if (myIsResetCurrentValue) + anError = "Attribute \"" + anAttributeName + "\" is not initialized."; + else if (myIsCurrentValueUnderModification) { + anError = "Attribute \"" + anAttributeName + "\" modification is not applyed. Please click \"Enter\" or \"Tab\"."; + } } } } @@ -927,6 +944,7 @@ void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOp) { connectToPropertyPanel(false); myIsResetCurrentValue = false; + myIsCurrentValueUnderModification = false; myIsMouseOverViewProcessed = true; operationMgr()->onValidateOperation(); if (isNestedCreateOperation(theOp)) @@ -959,15 +977,16 @@ bool PartSet_SketcherMgr::canRedo() const return isNestedCreateOperation(getCurrentOperation()); } -bool PartSet_SketcherMgr::canCommitOperation() const +/*bool PartSet_SketcherMgr::canCommitOperation() const { bool aCanCommit = true; - if (isNestedCreateOperation(getCurrentOperation()) && myIsResetCurrentValue) + if (isNestedCreateOperation(getCurrentOperation()) && + (myIsResetCurrentValue || myIsCurrentValueUnderModification)) aCanCommit = false; return aCanCommit; -} +}*/ bool PartSet_SketcherMgr::canEraseObject(const ObjectPtr& theObject) const { @@ -1065,7 +1084,7 @@ bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const bool PartSet_SketcherMgr::canDisplayCurrentCreatedFeature() const { - return myIsMouseOverWindow || !myIsResetCurrentValue; + return myIsMouseOverWindow || (!myIsResetCurrentValue && !myIsCurrentValueUnderModification); #ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS qDebug(QString("canDisplayCurrentCreatedFeature: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str()); #endif @@ -1222,6 +1241,8 @@ void PartSet_SketcherMgr::connectToPropertyPanel(const bool isToConnect) if (isToConnect) { connect(aWidget, SIGNAL(beforeValuesChanged()), this, SLOT(onBeforeValuesChangedInPropertyPanel())); + connect(aWidget, SIGNAL(valuesModified()), + this, SLOT(onValuesModied())); connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel())); connect(aWidget, SIGNAL(afterValuesChanged()), this, SLOT(onAfterValuesChangedInPropertyPanel())); diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index 94540d988..c0a91463a 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -137,7 +137,7 @@ public: /// Returns False only if the sketch creating feature can not be visualized. /// \return a boolean value - bool canCommitOperation() const; + //bool canCommitOperation() const; /// Returns whether the object can be erased at the bounds of the active operation. /// Sketch sub-entities can not be erased during the sketch operation @@ -205,6 +205,9 @@ 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(); + + /// Updates the flag of reset state + void onValuesModied(); /// 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 @@ -298,6 +301,7 @@ private: bool myIsDragging; bool myDragDone; bool myIsResetCurrentValue; /// the state that value in the property panel is reset + bool myIsCurrentValueUnderModification; /// the value is modified in PP but it is not applyed in the model bool myIsMouseOverWindow; /// the state that the mouse over the view bool myIsMouseOverViewProcessed; /// the state whether the over view state is processed by mouseMove method bool myIsPopupMenuActive; /// the state of the popup menu is shown diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index bb75fd068..09dff2d14 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -52,7 +52,7 @@ const double MaxCoordinate = 1e12; static QStringList MyFeaturesForCoincedence; -//#define APPLY_BY_ENTER_OR_TAB +#define APPLY_BY_ENTER_OR_TAB PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, @@ -93,6 +93,7 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent, #ifdef APPLY_BY_ENTER_OR_TAB // Apply widget value change by enter/tab event. connect(myXSpin, SIGNAL(editingFinished()), this, SLOT(onValuesChanged())); + connect(myXSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified())); #else connect(myXSpin, SIGNAL(valueChanged(const QString&)), this, SLOT(onValuesChanged())); #endif @@ -111,6 +112,7 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent, #ifdef APPLY_BY_ENTER_OR_TAB // Apply widget value change by enter/tab event. connect(myYSpin, SIGNAL(editingFinished()), this, SLOT(onValuesChanged())); + connect(myYSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified())); #else connect(myYSpin, SIGNAL(valueChanged(const QString&)), this, SLOT(onValuesChanged())); #endif @@ -473,3 +475,8 @@ void PartSet_WidgetPoint2D::onValuesChanged() myLockApplyMgr->valuesChanged(); emit valuesChanged(); } + +bool PartSet_WidgetPoint2D::isEventProcessed(QKeyEvent* theEvent) +{ + return myXSpin->isEventProcessed(theEvent) || myXSpin->isEventProcessed(theEvent); +} diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index c85ad2082..181378e04 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -87,6 +87,9 @@ Q_OBJECT /// Returns coordinate Y currently defined in the control double y() const; + /// Returns true if the event is processed. + virtual bool isEventProcessed(QKeyEvent* theEvent); + signals: /// Signal about selection of an existing vertex from an object void vertexSelected(); diff --git a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp b/src/PartSet/PartSet_WidgetPoint2dDistance.cpp index a644d55cc..15061b90c 100644 --- a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp +++ b/src/PartSet/PartSet_WidgetPoint2dDistance.cpp @@ -23,7 +23,7 @@ #include -//#define APPLY_BY_ENTER_OR_TAB +#define APPLY_BY_ENTER_OR_TAB PartSet_WidgetPoint2dDistance::PartSet_WidgetPoint2dDistance(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, @@ -40,6 +40,7 @@ PartSet_WidgetPoint2dDistance::PartSet_WidgetPoint2dDistance(QWidget* theParent, // Apply widget value change by enter/tab event. disconnect(mySpinBox, SIGNAL(editingFinished()), this, SIGNAL(valuesChanged())); connect(mySpinBox, SIGNAL(editingFinished()), this, SLOT(onValuesChanged())); + connect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesModified())); #else disconnect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged())); connect(mySpinBox, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged())); @@ -139,3 +140,7 @@ void PartSet_WidgetPoint2dDistance::onValuesChanged() emit valuesChanged(); } +bool PartSet_WidgetPoint2dDistance::isEventProcessed(QKeyEvent* theEvent) +{ + return mySpinBox->isEventProcessed(theEvent); +} diff --git a/src/PartSet/PartSet_WidgetPoint2dDistance.h b/src/PartSet/PartSet_WidgetPoint2dDistance.h index f300f2fb8..7dc45bcca 100644 --- a/src/PartSet/PartSet_WidgetPoint2dDistance.h +++ b/src/PartSet/PartSet_WidgetPoint2dDistance.h @@ -59,6 +59,9 @@ Q_OBJECT /// Set sketch instance void setSketch(CompositeFeaturePtr theSketch) { mySketch = theSketch; } + /// Returns true if the event is processed. + virtual bool isEventProcessed(QKeyEvent* theEvent); + public slots: /// Process of mouse move /// \param theWnd a pointer to a window diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 2d36b4575..5b12abc10 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -421,16 +421,34 @@ void XGUI_OperationMgr::onOperationStopped() } } +#include +#include bool XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent) { + qDebug("XGUI_OperationMgr::onKeyReleased"); + QObject* aSender = sender(); + // Let the manager decide what to do with the given key combination. ModuleBase_Operation* anOperation = currentOperation(); bool isAccepted = true; switch (theEvent->key()) { case Qt::Key_Return: case Qt::Key_Enter: { - emit keyEnterReleased(); - commitOperation(); + ModuleBase_Operation* aOperation = currentOperation(); + ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); + ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget(); + if (aActiveWgt && !aActiveWgt->isEventProcessed(theEvent)) { + qDebug("XGUI_OperationMgr::onKeyReleased accept Enter"); + ModuleBase_OperationFeature* aFOperation = dynamic_cast(currentOperation()); + if (!aFOperation || myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty()) { + emit keyEnterReleased(); + commitOperation(); + } + else + isAccepted = false; + } + //else + // isAccepted = false; } case Qt::Key_N: case Qt::Key_P: {