X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2FXGUI%2FXGUI_PropertyPanel.cpp;h=94712d811a10ed6f52df4a2fb43c0a8586d70d40;hb=94ba553e7b92f11a936e027b49bbd1d501eeee44;hp=d6b88d19c9171e29cb6d9f754b1c3532f6e52a84;hpb=489132d99e1d417d5c7ce93fed8fb8ee138befbc;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index d6b88d19c..94712d811 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -23,7 +23,8 @@ #endif XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) - : QDockWidget(theParent) + : ModuleBase_IPropertyPanel(theParent), + myActiveWidget(NULL) { this->setWindowTitle(tr("Property Panel")); QAction* aViewAct = this->toggleViewAction(); @@ -51,19 +52,17 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) 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); + aBtn->setShortcut(QKeySequence(Qt::Key_Escape)); aBtnLay->addWidget(aBtn); myCustomWidget = new QWidget(aContent); myMainLayout->addWidget(myCustomWidget); myMainLayout->addStretch(1); - - aBtn->installEventFilter(this); } XGUI_PropertyPanel::~XGUI_PropertyPanel() @@ -74,25 +73,24 @@ void XGUI_PropertyPanel::cleanContent() { myWidgets.clear(); qDeleteAll(myCustomWidget->children()); + myActiveWidget = NULL; } void XGUI_PropertyPanel::setModelWidgets(const QList& theWidgets) { myWidgets = theWidgets; + int aS = myWidgets.size(); if (theWidgets.empty()) return; QList::const_iterator anIt = theWidgets.begin(), aLast = theWidgets.end(); for (; anIt != aLast; anIt++) { - //TODO(sbh): Think how to connect prop panle hotkeys and operations mgr - connect(*anIt, SIGNAL(keyReleased(QKeyEvent*)), this, - SIGNAL(keyReleased(QKeyEvent*))); + connect(*anIt, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*))); connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), this, - SLOT(onActivateNextWidget(ModuleBase_ModelWidget*))); - - //connect(*anIt, SIGNAL(activated(ModuleBase_ModelWidget*)), - // this, SIGNAL(widgetActivated(ModuleBase_ModelWidget*))); + SLOT(activateNextWidget(ModuleBase_ModelWidget*))); + connect(*anIt, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)), + this, SLOT(activateWidget(ModuleBase_ModelWidget*))); ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast(*anIt); if (aPointWidget) @@ -112,7 +110,6 @@ void XGUI_PropertyPanel::setModelWidgets(const QList& t setTabOrder(anOkBtn, aCancelBtn); } } - onActivateNextWidget(NULL); } const QList& XGUI_PropertyPanel::modelWidgets() const @@ -120,24 +117,6 @@ const QList& XGUI_PropertyPanel::modelWidgets() const return myWidgets; } -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 || - aKeyEvent->key() == Qt::Key_Enter)) { - // 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() { return myCustomWidget; @@ -150,11 +129,11 @@ void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature) eachWidget->setFeature(theFeature); eachWidget->restoreValue(); } - // the repaint is used here to immediatelly react in GUI to the values change. + // the repaint is used here to immediately react in GUI to the values change. repaint(); } -void XGUI_PropertyPanel::onActivateNextWidget(ModuleBase_ModelWidget* theWidget) +void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget) { ModuleBase_ModelWidget* aNextWidget = 0; QList::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end(); @@ -167,7 +146,16 @@ void XGUI_PropertyPanel::onActivateNextWidget(ModuleBase_ModelWidget* theWidget) } isFoundWidget = (*anIt) == theWidget; } - emit widgetActivated(aNextWidget); + // Normaly focusTo is enough to activate widget + // here is a special case on mouse click in the viewer + if(aNextWidget == NULL) { + activateWidget(NULL); + } +} + +void XGUI_PropertyPanel::activateNextWidget() +{ + activateNextWidget(myActiveWidget); } void XGUI_PropertyPanel::setAcceptEnabled(bool isEnabled) @@ -175,3 +163,15 @@ void XGUI_PropertyPanel::setAcceptEnabled(bool isEnabled) QPushButton* anOkBtn = findChild(XGUI::PROP_PANEL_OK); anOkBtn->setEnabled(isEnabled); } + +void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget) +{ + if(myActiveWidget) { + myActiveWidget->setHighlighted(false); + } + if(theWidget) { + theWidget->setHighlighted(true); + } + myActiveWidget = theWidget; + emit widgetActivated(theWidget); +}