From: nds Date: Mon, 26 May 2014 09:04:45 +0000 (+0400) Subject: Process property panel values change. This modification should be corrected: keyRelea... X-Git-Tag: V_0.2~4^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7f6341eabf8fe82dbb4a852bbf3f2854ddd8e52b;p=modules%2Fshaper.git Process property panel values change. This modification should be corrected: keyRelease processing and eventFilter removing. --- diff --git a/src/ModuleBase/ModuleBase_MetaWidget.cpp b/src/ModuleBase/ModuleBase_MetaWidget.cpp index 308cc3065..a8a65232b 100644 --- a/src/ModuleBase/ModuleBase_MetaWidget.cpp +++ b/src/ModuleBase/ModuleBase_MetaWidget.cpp @@ -38,3 +38,17 @@ bool ModuleBase_MetaWidget::restoreValue(boost::shared_ptr the #endif return true; } + +bool ModuleBase_MetaWidget::focusTo(const std::string& theAttributeName) +{ + #ifdef _DEBUG + std::cout << "ModuleBase_MetaWidget::focusTo" + << myWrappedWidget->metaObject()->className() << std::endl; + #endif + return true; +} + +QList ModuleBase_MetaWidget::getControls() const +{ + return QList(); +} diff --git a/src/ModuleBase/ModuleBase_MetaWidget.h b/src/ModuleBase/ModuleBase_MetaWidget.h index 2899374c5..0bbc6fbcd 100644 --- a/src/ModuleBase/ModuleBase_MetaWidget.h +++ b/src/ModuleBase/ModuleBase_MetaWidget.h @@ -27,6 +27,14 @@ public: //! Interface for loading widget's data from the data model MODULEBASE_EXPORT virtual bool restoreValue(boost::shared_ptr theFeature); + /// Set focus to the current widget if it corresponds to the given attribute + /// \param theAttribute name + MODULEBASE_EXPORT virtual bool focusTo(const std::string& theAttributeName); + + /// Returns list of widget controls + /// \return a control list + virtual QList getControls() const; + private: QWidget* myWrappedWidget; }; diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index a684515a3..57b75346a 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -12,6 +12,7 @@ #include class ModelAPI_Feature; +class QKeyEvent; /**\class ModuleBase_ModelWidget * \brief An abstract custom widget class. This class realization is assumed to create some controls. @@ -37,10 +38,21 @@ public: virtual bool restoreValue(boost::shared_ptr theFeature) = 0; + /// Set focus to the current widget if it corresponds to the given attribute + /// \param theAttribute name + virtual bool focusTo(const std::string& theAttributeName) = 0; + + /// Returns list of widget controls + /// \return a control list + virtual QList getControls() const = 0; signals: /// The signal about widget values changed void valuesChanged(); + /// The signal about key release on the control, that corresponds to the attribute + /// \param theAttributeName a name of the attribute + /// \param theEvent key release event + void keyReleased(const std::string& theAttributeName, QKeyEvent* theEvent); }; #endif diff --git a/src/ModuleBase/ModuleBase_Operation.h b/src/ModuleBase/ModuleBase_Operation.h index 89b369995..e66d58ab9 100644 --- a/src/ModuleBase/ModuleBase_Operation.h +++ b/src/ModuleBase/ModuleBase_Operation.h @@ -20,6 +20,8 @@ class ModelAPI_Feature; class ModelAPI_Document; +class QKeyEvent; + /*! \class ModuleBase_Operation * \brief Base class for all operations @@ -66,6 +68,8 @@ public: /// Stores a custom value in model. void storeCustomValue(); + virtual void keyReleased(std::string theName, QKeyEvent* theEvent) {}; + protected: /// Virtual method called when operation started (see start() method for more description) /// Default impl calls corresponding slot and commits immediately. diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp index 4d99d01be..01f9902eb 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp +++ b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include @@ -57,6 +59,8 @@ ModuleBase_WidgetPoint2D::ModuleBase_WidgetPoint2D(QWidget* theParent, QString t connect(myYSpin, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged())); } + myXSpin->installEventFilter(this); + myYSpin->installEventFilter(this); } ModuleBase_WidgetPoint2D::~ModuleBase_WidgetPoint2D() @@ -90,7 +94,39 @@ bool ModuleBase_WidgetPoint2D::restoreValue(boost::shared_ptr return true; } +bool ModuleBase_WidgetPoint2D::focusTo(const std::string& theAttributeName) +{ + if (theAttributeName != myFeatureAttributeID) + return false; + + if (!myXSpin->hasFocus() && !myYSpin->hasFocus()) { + myXSpin->setFocus(); + } + + return true; +} + QWidget* ModuleBase_WidgetPoint2D::getControl() const { return myGroupBox; } + +QList ModuleBase_WidgetPoint2D::getControls() const +{ + QList aControls; + aControls.push_back(myXSpin); + aControls.push_back(myYSpin); + + return aControls; +} + +bool ModuleBase_WidgetPoint2D::eventFilter(QObject *theObject, QEvent *theEvent) +{ + if (theObject == myXSpin || theObject == myYSpin) { + if (theEvent->type() == QEvent::KeyRelease) { + emit keyReleased(myFeatureAttributeID, (QKeyEvent*) theEvent); + return true; + } + } + return ModuleBase_ModelWidget::eventFilter(theObject, theEvent); +} diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.h b/src/ModuleBase/ModuleBase_WidgetPoint2D.h index cd52779dc..016b17217 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2D.h +++ b/src/ModuleBase/ModuleBase_WidgetPoint2D.h @@ -38,10 +38,20 @@ public: virtual bool restoreValue(boost::shared_ptr theFeature); + /// Set focus to the current widget if it corresponds to the given attribute + /// \param theAttribute name + virtual bool focusTo(const std::string& theAttributeName); + /// Returns the internal parent wiget control, that can be shown anywhere /// \returns the widget QWidget* getControl() const; + /// Returns list of widget controls + /// \return a control list + virtual QList getControls() const; + + virtual bool eventFilter(QObject *theObject, QEvent *theEvent); + private: std::string myFeatureAttributeID; ///< the identifier of the feature attribute QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 57fbe728f..94ef5f926 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -52,6 +53,9 @@ PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop) XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr(); + connect(anOperationMgr, SIGNAL(operationStarted()), + this, SLOT(onOperationStarted())); + connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), this, SLOT(onOperationStopped(ModuleBase_Operation*))); @@ -118,12 +122,26 @@ void PartSet_Module::launchOperation(const QString& theCmdId) sendOperation(anOperation); } +void PartSet_Module::onOperationStarted() +{ + PartSet_OperationSketchBase* aPreviewOp = dynamic_cast( + myWorkshop->operationMgr()->currentOperation()); + if (aPreviewOp) { + XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel(); + connect(aPreviewOp, SIGNAL(focusActivated(const std::string&)), + aPropPanel, SLOT(onFocusActivated(const std::string&))); + } +} + void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation) { if (!theOperation) return; PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(theOperation); if (aPreviewOp) { + XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel(); + disconnect(aPreviewOp, SIGNAL(focusActivated(const std::string&)), + aPropPanel, SLOT(onFocusActivated(const std::string&))); } } diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 1766a6e02..bf571a323 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -59,6 +59,8 @@ public: public slots: void onFeatureTriggered(); + /// SLOT, that is called after the operation is started. Connect on the focus activated signal + void onOperationStarted(); /// SLOT, that is called after the operation is stopped. Switched off the modfications performed /// by the operation start void onOperationStopped(ModuleBase_Operation* theOperation); @@ -79,7 +81,7 @@ public slots: /// SLOT, that is called by the key in the viewer is clicked. /// \param theEvent the mouse event - void onKeyRelease(QKeyEvent*); + void onKeyRelease(QKeyEvent* theEvent); /// SLOT, to apply to the current viewer the operation /// \param theX the X projection value diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp index acf76c60a..0a581c178 100644 --- a/src/PartSet/PartSet_OperationSketchBase.cpp +++ b/src/PartSet/PartSet_OperationSketchBase.cpp @@ -9,6 +9,8 @@ #include +#include + #ifdef _DEBUG #include #endif @@ -88,3 +90,8 @@ void PartSet_OperationSketchBase::keyReleased(const int theKey) break; } } + +void PartSet_OperationSketchBase::keyReleased(std::string theName, QKeyEvent* theEvent) +{ + keyReleased(theEvent->key()); +} diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h index 5aa07c3f0..f4d01b3a0 100644 --- a/src/PartSet/PartSet_OperationSketchBase.h +++ b/src/PartSet/PartSet_OperationSketchBase.h @@ -92,7 +92,17 @@ public: /// \param theKey a key value virtual void keyReleased(const int theKey); + virtual void keyReleased(std::string theName, QKeyEvent* theEvent); + signals: + /// signal about the request to launch operation + /// theName the operation name + /// theFeature the operation argument + void launchOperation(std::string theName, boost::shared_ptr theFeature); + /// signal about the focus activated + /// theName the attribute name + void focusActivated(const std::string& theAttibuteName); + /// Signal about the feature construing is finished /// \param theFeature the result feature /// \param theMode the mode of the feature modification @@ -101,10 +111,6 @@ signals: /// Signal about the features should be selected /// \param theSelected the list of selected presentations void featureSelected(const std::list& theSelected); - /// signal about the request to launch operation - /// theName the operation name - /// theFeature the operation argument - void launchOperation(std::string theName, boost::shared_ptr theFeature); /// signal to enable/disable multi selection in the viewer /// \param theEnabled the boolean state void multiSelectionEnabled(bool theEnabled); diff --git a/src/PartSet/PartSet_OperationSketchLine.cpp b/src/PartSet/PartSet_OperationSketchLine.cpp index 33e03c5e2..ddd9bd728 100644 --- a/src/PartSet/PartSet_OperationSketchLine.cpp +++ b/src/PartSet/PartSet_OperationSketchLine.cpp @@ -25,6 +25,7 @@ #include #include +#include #include @@ -146,15 +147,15 @@ void PartSet_OperationSketchLine::mouseReleased(QMouseEvent* theEvent, Handle(V3 setLinePoint(feature(), aX, anY, LINE_ATTR_END); flushUpdated(); - myPointSelectionMode = SM_SecondPoint; + setPointSelectionMode(SM_SecondPoint); } break; case SM_SecondPoint: { setLinePoint(feature(), aX, anY, LINE_ATTR_END); flushUpdated(); - myPointSelectionMode = SM_DonePoint; - } + setPointSelectionMode(SM_DonePoint); + } break; default: break; @@ -172,6 +173,7 @@ void PartSet_OperationSketchLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_V setLinePoint(feature(), aX, anY, LINE_ATTR_START); setLinePoint(feature(), aX, anY, LINE_ATTR_END); flushUpdated(); + emit focusActivated(LINE_ATTR_START); } break; case SM_SecondPoint: @@ -179,6 +181,7 @@ void PartSet_OperationSketchLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_V gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView); setLinePoint(aPoint, theView, LINE_ATTR_END); flushUpdated(); + emit focusActivated(LINE_ATTR_END); } break; case SM_DonePoint: @@ -192,6 +195,20 @@ void PartSet_OperationSketchLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_V } } +void PartSet_OperationSketchLine::keyReleased(std::string theName, QKeyEvent* theEvent) +{ + int aKeyType = theEvent->key(); + if (!theName.empty() && aKeyType == Qt::Key_Return) { + if (theName == LINE_ATTR_START) { + setPointSelectionMode(SM_SecondPoint, false); + } + else if (theName == LINE_ATTR_END) { + setPointSelectionMode(SM_DonePoint, false); + } + } + keyReleased(theEvent->key()); +} + void PartSet_OperationSketchLine::keyReleased(const int theKey) { switch (theKey) { @@ -200,10 +217,11 @@ void PartSet_OperationSketchLine::keyReleased(const int theKey) { commit(); emit featureConstructed(feature(), FM_Deactivation); + emit launchOperation(PartSet_OperationSketchLine::Type(), boost::shared_ptr()); } - else - abort(); - emit launchOperation(PartSet_OperationSketchLine::Type(), boost::shared_ptr()); + //else + // abort(); + //emit launchOperation(PartSet_OperationSketchLine::Type(), boost::shared_ptr()); } break; case Qt::Key_Escape: { @@ -223,7 +241,8 @@ void PartSet_OperationSketchLine::keyReleased(const int theKey) void PartSet_OperationSketchLine::startOperation() { PartSet_OperationSketchBase::startOperation(); - myPointSelectionMode = !myInitPoint ? SM_FirstPoint : SM_SecondPoint; + setPointSelectionMode(!myInitPoint ? SM_FirstPoint : SM_SecondPoint); + emit multiSelectionEnabled(false); } @@ -378,3 +397,26 @@ void PartSet_OperationSketchLine::setLinePoint(const gp_Pnt& thePoint, boost::dynamic_pointer_cast(aData->attribute(theAttribute)); aPoint->setValue(aX, anY); } + +void PartSet_OperationSketchLine::setPointSelectionMode(const PointSelectionMode& theMode, + const bool isToEmitSignal) +{ + myPointSelectionMode = theMode; + if (isToEmitSignal) { + std::string aName; + switch (theMode) { + case SM_FirstPoint: + aName = LINE_ATTR_START; + break; + case SM_SecondPoint: + aName = LINE_ATTR_END; + break; + case SM_DonePoint: + aName = XGUI::PROP_PANEL_OK; + break; + default: + break; + } + emit focusActivated(aName); + } +} diff --git a/src/PartSet/PartSet_OperationSketchLine.h b/src/PartSet/PartSet_OperationSketchLine.h index db20415c7..6b78f0369 100644 --- a/src/PartSet/PartSet_OperationSketchLine.h +++ b/src/PartSet/PartSet_OperationSketchLine.h @@ -12,6 +12,7 @@ class GeomDataAPI_Point2D; class QMouseEvent; +class QKeyEvent; /*! \class PartSet_OperationSketchLine @@ -72,6 +73,8 @@ public: /// \param theKey a key value virtual void keyReleased(const int theKey); + virtual void keyReleased(std::string theName, QKeyEvent* theEvent); + protected: /// \brief Virtual method called when operation is started /// Virtual method called when operation started (see start() method for more description) @@ -134,6 +137,11 @@ protected: ///< Structure to lists the possible types of point selection modes enum PointSelectionMode {SM_FirstPoint, SM_SecondPoint, SM_DonePoint}; + ///< Set the point selection mode. Emit signal about focus change if necessary. + /// \param theMode a new selection mode + /// \param isToEmitSignal the neccessity to emit signal + void setPointSelectionMode(const PointSelectionMode& theMode, const bool isToEmitSignal = true); + private: boost::shared_ptr mySketch; ///< the sketch feature boost::shared_ptr myInitPoint; ///< the first line point diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 2a27188c9..3fb2cad89 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -7,10 +7,14 @@ #include "ModuleBase_Operation.h" #include +#include +#include XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent) : QObject(theParent) { + // listen to Escape signal to stop the current operation + qApp->installEventFilter(this); } XGUI_OperationMgr::~XGUI_OperationMgr() @@ -66,6 +70,20 @@ QStringList XGUI_OperationMgr::operationList() return result; } +bool XGUI_OperationMgr::eventFilter(QObject *theObject, QEvent *theEvent) +{ + if (theEvent->type() == QEvent::KeyRelease) { + QKeyEvent* aKeyEvent = (QKeyEvent*)theEvent; + if (aKeyEvent && aKeyEvent->key() == Qt::Key_Escape) { + // TODO: this is Escape button processing when the property panel has empty content, + // but the operation should be stopped by the Enter has been clicked + onKeyReleased("", aKeyEvent); + return true; + } + } + return QObject::eventFilter(theObject, theEvent); +} + void XGUI_OperationMgr::resumeOperation(ModuleBase_Operation* theOperation) { theOperation->resume(); @@ -135,3 +153,10 @@ void XGUI_OperationMgr::onOperationStopped() if (aResultOp) resumeOperation(aResultOp); } + +void XGUI_OperationMgr::onKeyReleased(const std::string& theName, QKeyEvent* theEvent) +{ + ModuleBase_Operation* anOperation = currentOperation(); + if (anOperation) + anOperation->keyReleased(theName, theEvent); +} diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index 56db2c4c5..82680fb56 100644 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -13,6 +13,8 @@ #include #include +class QKeyEvent; + /**\class XGUI_OperationMgr * \ingroup GUI * \brief Operation manager. Servers to manupulate to the workshop operations. Contains a stack @@ -50,6 +52,8 @@ public: ///Returns list of all operations IDs QStringList operationList(); + virtual bool eventFilter(QObject *theObject, QEvent *theEvent); + signals: /// Signal about an operation is started. It is emitted after the start() of operation is done. void operationStarted(); @@ -84,6 +88,11 @@ protected slots: /// If there is a suspended operation, restart it. void onOperationStopped(); + /// SLOT, that is called by the key in the property panel is clicked. + /// \param theName the attribute name + /// \param theEvent the mouse event + void onKeyReleased(const std::string& theName, QKeyEvent* theEvent); + private: typedef QList Operations; ///< definition for a list of operations Operations myOperations; ///< a stack of started operations. The active operation is on top, diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index ccf0469cf..f9328b5e1 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -14,6 +14,8 @@ #include #include #include +#include +#include #ifdef _DEBUG #include @@ -44,9 +46,13 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) aBtnLay->addStretch(1); aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm); aBtn->setObjectName(XGUI::PROP_PANEL_OK); + aBtn->setToolTip(tr("Ok")); aBtn->setFlat(true); aBtnLay->addWidget(aBtn); + aBtn->installEventFilter(this); + aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm); + aBtn->setToolTip(tr("Cancel")); aBtn->setObjectName(XGUI::PROP_PANEL_CANCEL); aBtn->setFlat(true); aBtnLay->addWidget(aBtn); @@ -54,6 +60,8 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) myCustomWidget = new QWidget(aContent); aMainLay->addWidget(myCustomWidget); aMainLay->addStretch(1); + + aBtn->installEventFilter(this); } XGUI_PropertyPanel::~XGUI_PropertyPanel() @@ -63,6 +71,45 @@ XGUI_PropertyPanel::~XGUI_PropertyPanel() void XGUI_PropertyPanel::setModelWidgets(const QList& theWidgets) { myWidgets = theWidgets; + + if (!theWidgets.empty()) { + + QList::const_iterator anIt = theWidgets.begin(), aLast = theWidgets.end(); + for (; anIt != aLast; anIt++) { + connect(*anIt, SIGNAL(keyReleased(const std::string&, QKeyEvent*)), + this, SIGNAL(keyReleased(const std::string&, QKeyEvent*))); + } + ModuleBase_ModelWidget* aLastWidget = theWidgets.last(); + if (aLastWidget) { + QList aControls = aLastWidget->getControls(); + if (!aControls.empty()) { + QWidget* aLastControl = aControls.last(); + + QPushButton* anOkBtn = findChild(XGUI::PROP_PANEL_OK); + QPushButton* aCancelBtn = findChild(XGUI::PROP_PANEL_CANCEL); + + setTabOrder(aLastControl, anOkBtn); + setTabOrder(anOkBtn, aCancelBtn); + } + } + } +} + +bool XGUI_PropertyPanel::eventFilter(QObject *theObject, QEvent *theEvent) +{ + QPushButton* anOkBtn = findChild(XGUI::PROP_PANEL_OK); + QPushButton* aCancelBtn = findChild(XGUI::PROP_PANEL_CANCEL); + if (theObject == anOkBtn || theObject == aCancelBtn) { + if (theEvent->type() == QEvent::KeyRelease) { + QKeyEvent* aKeyEvent = (QKeyEvent*)theEvent; + if (aKeyEvent && aKeyEvent->key() == Qt::Key_Return) { + // TODO: this is enter button processing when the focus is on "Apply" or "Cancel" buttons + emit keyReleased("", (QKeyEvent*) theEvent); + return true; + } + } + } + return QDockWidget::eventFilter(theObject, theEvent); } QWidget* XGUI_PropertyPanel::contentWidget() @@ -78,3 +125,21 @@ void XGUI_PropertyPanel::updateContentWidget(boost::shared_ptr // the repaint is used here to immediatelly react in GUI to the values change. repaint(); } + +void XGUI_PropertyPanel::onFocusActivated(const std::string& theAttributeName) +{ + if (theAttributeName == XGUI::PROP_PANEL_OK) { + QPushButton* aBtn = findChild(XGUI::PROP_PANEL_OK); + aBtn->setFocus(); + } + if (theAttributeName == XGUI::PROP_PANEL_CANCEL) { + QPushButton* aBtn = findChild(XGUI::PROP_PANEL_CANCEL); + aBtn->setFocus(); + } + else { + foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) { + if (eachWidget->focusTo(theAttributeName)) + break; + } + } +} diff --git a/src/XGUI/XGUI_PropertyPanel.h b/src/XGUI/XGUI_PropertyPanel.h index 546ae19b7..d034d7289 100644 --- a/src/XGUI/XGUI_PropertyPanel.h +++ b/src/XGUI/XGUI_PropertyPanel.h @@ -15,6 +15,8 @@ #include #include +class QKeyEvent; + class XGUI_EXPORT XGUI_PropertyPanel: public QDockWidget { Q_OBJECT @@ -25,8 +27,19 @@ public: QWidget* contentWidget(); void setModelWidgets(const QList& theWidgets); + virtual bool eventFilter(QObject *theObject, QEvent *theEvent); + public slots: void updateContentWidget(boost::shared_ptr theFeature); + /// slot to set the focus to the widget visualized an attribute with the given name + /// \param theAttributteName + void onFocusActivated(const std::string& theAttributeName); + +signals: + /// The signal about key release on the control, that corresponds to the attribute + /// \param theAttributeName a name of the attribute + /// \param theEvent key release event + void keyReleased(const std::string& theAttributeName, QKeyEvent* theEvent); private: QWidget* myCustomWidget; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 2c9efd296..e075762ae 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -687,6 +687,9 @@ void XGUI_Workshop::createDockWidgets() connect(aOkBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onCommitOperation())); QPushButton* aCancelBtn = myPropertyPanel->findChild(XGUI::PROP_PANEL_CANCEL); connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation())); + + connect(myPropertyPanel, SIGNAL(keyReleased(const std::string&, QKeyEvent*)), + myOperationMgr, SLOT(onKeyReleased(const std::string&, QKeyEvent*))); } //******************************************************