From 991a865b6ff8ee9b095c4333e440933b4ea50a5c Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 1 Jun 2017 08:25:34 +0300 Subject: [PATCH] Issues #2173 Can't set length on several edges when property panel is undocked, #2169 Segmentation fault when drawing sketch line with undocked property panel --- src/ModuleBase/ModuleBase_Tools.cpp | 9 +++++++-- src/ModuleBase/ModuleBase_WidgetEditor.cpp | 2 ++ src/PartSet/PartSet_SketcherReentrantMgr.cpp | 2 +- src/SHAPERGUI/SHAPERGUI.cpp | 4 ++++ src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp | 7 +++++++ src/XGUI/XGUI_ErrorDialog.cpp | 1 - src/XGUI/XGUI_OperationMgr.cpp | 15 +++++++++------ src/XGUI/XGUI_PropertyPanel.cpp | 10 +++++++--- src/XGUI/XGUI_PropertyPanel.h | 10 ++++++---- src/XGUI/XGUI_Workshop.cpp | 2 -- 10 files changed, 43 insertions(+), 19 deletions(-) diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index c50573294..8e8f3a221 100755 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -118,7 +118,10 @@ void zeroMargins(QLayout* theLayout) void activateWindow(QWidget* theWidget, const QString& theInfo) { - theWidget->activateWindow(); + if (theWidget) { + theWidget->activateWindow(); + theWidget->raise(); + } #ifdef DEBUG_ACTIVATE_WINDOW qDebug(QString("activateWindow: %1").arg(theInfo).toStdString().c_str()); @@ -127,8 +130,10 @@ void activateWindow(QWidget* theWidget, const QString& theInfo) void setFocus(QWidget* theWidget, const QString& theInfo) { + activateWindow(theWidget); theWidget->setFocus(); - + // rectangle of focus is not visible on tool button widgets + theWidget->repaint(); #ifdef DEBUG_SET_FOCUS qDebug(QString("setFocus: %1").arg(theInfo).toStdString().c_str()); #endif diff --git a/src/ModuleBase/ModuleBase_WidgetEditor.cpp b/src/ModuleBase/ModuleBase_WidgetEditor.cpp index 2725012c3..af34674d8 100644 --- a/src/ModuleBase/ModuleBase_WidgetEditor.cpp +++ b/src/ModuleBase/ModuleBase_WidgetEditor.cpp @@ -129,6 +129,8 @@ bool ModuleBase_WidgetEditor::showPopupEditor(const bool theSendSignals) else storeValue(); } + ModuleBase_Tools::setFocus(mySpinBox, "ModuleBase_WidgetEditor::editedValue"); + mySpinBox->selectAll(); if (theSendSignals && !myIsEditing) emit enterClicked(this); diff --git a/src/PartSet/PartSet_SketcherReentrantMgr.cpp b/src/PartSet/PartSet_SketcherReentrantMgr.cpp index a98087127..a723c6564 100644 --- a/src/PartSet/PartSet_SketcherReentrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReentrantMgr.cpp @@ -517,7 +517,7 @@ bool PartSet_SketcherReentrantMgr::startInternalEdit(const std::string& thePrevi QToolButton* anOkBtn = dynamic_cast(aPanel)->findButton(PROP_PANEL_OK); if (anOkBtn) - anOkBtn->setFocus(Qt::TabFocusReason); + ModuleBase_Tools::setFocus(anOkBtn, "XGUI_PropertyPanel::activateNextWidget"); } } } diff --git a/src/SHAPERGUI/SHAPERGUI.cpp b/src/SHAPERGUI/SHAPERGUI.cpp index 5c71120f6..b07144617 100644 --- a/src/SHAPERGUI/SHAPERGUI.cpp +++ b/src/SHAPERGUI/SHAPERGUI.cpp @@ -47,6 +47,7 @@ #include #include +//#define SALOME_PATCH_FOR_CTRL_WHEEL extern "C" { SHAPERGUI_EXPORT CAM_Module* createModule() @@ -383,6 +384,9 @@ SHAPERGUI_OCCSelector* SHAPERGUI::createSelector(SUIT_ViewManager* theMgr) OCCViewer_Viewer* aViewer = static_cast(theMgr->getViewModel()); SHAPERGUI_OCCSelector* aSelector = new SHAPERGUI_OCCSelector(aViewer, getApp()->selectionMgr()); +#ifdef SALOME_PATCH_FOR_CTRL_WHEEL + aViewer->setUseLocalSelection(true); +#endif LightApp_SelectionMgr* aMgr = getApp()->selectionMgr(); QList aList; aMgr->selectors(aList); diff --git a/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp b/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp index 70b088848..46c7d445a 100644 --- a/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp +++ b/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp @@ -15,6 +15,8 @@ #include #include +//#define SALOME_PATCH_FOR_CTRL_WHEEL + SHAPERGUI_SalomeView::SHAPERGUI_SalomeView(OCCViewer_Viewer* theViewer) : ModuleBase_IViewWindow(), myCurrentView(0) { @@ -449,6 +451,11 @@ void SHAPERGUI_SalomeViewer::activateViewer(bool toActivate) if (!mySelector || !mySelector->viewer()) return; SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager(); +#ifdef SALOME_PATCH_FOR_CTRL_WHEEL + OCCViewer_Viewer* aViewer = dynamic_cast(aMgr->getViewModel()); + if (aViewer) + aViewer->setUseLocalSelection(toActivate); +#endif QVector aViews = aMgr->getViews(); if (toActivate) { foreach (SUIT_ViewWindow* aView, aViews) { diff --git a/src/XGUI/XGUI_ErrorDialog.cpp b/src/XGUI/XGUI_ErrorDialog.cpp index 6c278f9d7..b7b01fe69 100644 --- a/src/XGUI/XGUI_ErrorDialog.cpp +++ b/src/XGUI/XGUI_ErrorDialog.cpp @@ -67,7 +67,6 @@ void XGUI_ErrorDialog::addError(std::shared_ptr theMsg) refresh(); if (!isVisible()) { show(); - raise(); ModuleBase_Tools::activateWindow(this, "XGUI_ErrorDialog::addError"); } } diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 728bd1641..d2930c9c8 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -66,8 +66,7 @@ public: isAccepted = myOperationMgr->onProcessDelete(theObject); break; default: - myOperationMgr->onKeyReleased(theObject, aKeyEvent); - isAccepted = true; + isAccepted = myOperationMgr->onKeyReleased(theObject, aKeyEvent); break; } } @@ -605,10 +604,14 @@ bool XGUI_OperationMgr::onKeyReleased(QObject *theObject, QKeyEvent* theEvent) if (aOperation) { ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel(); if (aPanel) { - // check for case when the operation is started but property panel is not filled - XGUI_PropertyPanel* aPP = dynamic_cast(aPanel); - aPP->focusNextPrevChild_(theEvent->key() == Qt::Key_Tab); - isAccepted = true; + QWidget* aFocusedWidget = qApp->focusWidget(); + bool isPPChildObject = aFocusedWidget && isChildObject(aFocusedWidget, aPanel); + if (!isPPChildObject) { + // check for case when the operation is started but property panel is not filled + XGUI_PropertyPanel* aPP = dynamic_cast(aPanel); + aPP->setFocusNextPrevChild(theEvent->key() == Qt::Key_Tab); + isAccepted = true; + } } } } diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 065916040..5a52c4182 100755 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -281,7 +281,7 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget, aNewFocusWidget = aCancelBtn; } if (aNewFocusWidget) - aNewFocusWidget->setFocus(Qt::TabFocusReason); + ModuleBase_Tools::setFocus(aNewFocusWidget, "XGUI_PropertyPanel::activateNextWidget"); activateWidget(NULL); } @@ -342,7 +342,12 @@ void findDirectChildren(QWidget* theParent, QList& theWidgets, const b #endif } -bool XGUI_PropertyPanel::focusNextPrevChild_(bool theIsNext) +bool XGUI_PropertyPanel::setFocusNextPrevChild(bool theIsNext) +{ + return focusNextPrevChild(theIsNext); +} + +bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext) { // it wraps the Tabs clicking to follow in the chain: // controls, last control, Apply, Cancel, first control, controls @@ -411,7 +416,6 @@ bool XGUI_PropertyPanel::focusNextPrevChild_(bool theIsNext) } // we want to have property panel as an active window to enter values in double control - ModuleBase_Tools::activateWindow(this, "XGUI_PropertyPanel::activateNextWidget()"); ModuleBase_Tools::setFocus(aNewFocusWidget, "XGUI_PropertyPanel::focusNextPrevChild()"); ModuleBase_ModelWidget* aNewFocusMWidget = ModuleBase_ModelWidget::findModelWidget(this, diff --git a/src/XGUI/XGUI_PropertyPanel.h b/src/XGUI/XGUI_PropertyPanel.h index 0b508df96..2a5d2e129 100644 --- a/src/XGUI/XGUI_PropertyPanel.h +++ b/src/XGUI/XGUI_PropertyPanel.h @@ -114,6 +114,11 @@ Q_OBJECT /// \return button instance or NULL QToolButton* findButton(const char* theInternalName) const; + /// Possibility to process focus by method, for example when Tab or SHIF+Tab is pressed + /// but property panel is not active widget + /// \param theIsNext true, if Tab(to the next widget) or false(moving to the previous) + bool setFocusNextPrevChild(bool theIsNext); + public slots: /// \brief Update all widgets in property panel with values from the given feature /// \param theFeature a Feature to update values in widgets @@ -151,13 +156,10 @@ protected: /// Makes the widget active, deactivate the previous, activate and hightlight the given one /// \param theWidget a widget bool setActiveWidget(ModuleBase_ModelWidget* theWidget); -public: /// The parent method that processes the "Tab"/"SHIF + Tab" keyboard events /// Emits a signal about focus change /// If theIsNext is true, this function searches forward, if next is false, it searches backward. - virtual bool focusNextPrevChild_(bool theIsNext); -protected: - virtual bool focusNextPrevChild(bool theIsNext) { return true; } + virtual bool focusNextPrevChild(bool theIsNext); /// Activate the next widget in the property panel /// \param theWidget a widget. The next widget should be activated /// \param isCheckVisibility flag whether the next widget visibility is checked diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 855abacc1..526110571 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1275,7 +1275,6 @@ void XGUI_Workshop::showPropertyPanel() // in order to operation manager could process key events of the panel. // otherwise they are ignored. It happens only if the same(activateWindow) is // not happened by property panel activation(e.g. resume operation of Sketch) - ModuleBase_Tools::activateWindow(myPropertyPanel, "XGUI_Workshop::showPropertyPanel()"); ModuleBase_Tools::setFocus(myPropertyPanel, "XGUI_Workshop::showPropertyPanel()"); } @@ -1295,7 +1294,6 @@ void XGUI_Workshop::hidePropertyPanel() // are processed by this console. For example Undo actions. // It is possible that this code is to be moved to SHAPER package QMainWindow* aDesktop = desktop(); - ModuleBase_Tools::activateWindow(aDesktop, "XGUI_Workshop::hidePropertyPanel()"); ModuleBase_Tools::setFocus(aDesktop, "XGUI_Workshop::showPropertyPanel()"); } -- 2.39.2