From: vsv Date: Tue, 31 Mar 2020 18:27:44 +0000 (+0300) Subject: Issue #18929(Tuleap): Make exclusion for processing key events in modal dialog boxes X-Git-Tag: V9_5_0a2~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=66b4eb75d38ea84c7a236d314184c29df5aa692b;p=modules%2Fshaper.git Issue #18929(Tuleap): Make exclusion for processing key events in modal dialog boxes --- diff --git a/src/ModuleBase/ModuleBase_WidgetEditor.cpp b/src/ModuleBase/ModuleBase_WidgetEditor.cpp index 017298b96..9ab66d197 100644 --- a/src/ModuleBase/ModuleBase_WidgetEditor.cpp +++ b/src/ModuleBase/ModuleBase_WidgetEditor.cpp @@ -53,6 +53,7 @@ public: ModuleBase_EditorDialog(QWidget* theParent, Qt::WindowFlags theFlags) : QDialog(theParent, theFlags) { + setObjectName("ModuleBase_EditorDialog"); setMinimumWidth(100); } ~ModuleBase_EditorDialog() {} diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index c199a2f68..a8813844b 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -52,6 +52,7 @@ #include #include #include +#include //#define DEBUG_CURRENT_FEATURE @@ -78,26 +79,37 @@ public: virtual bool eventFilter(QObject *theObject, QEvent *theEvent) { bool isAccepted = false; - if (myIsActive && (!qApp->modalWindow())) { - if (theEvent->type() == QEvent::KeyRelease) { - QKeyEvent* aKeyEvent = dynamic_cast(theEvent); - if (aKeyEvent) { - myOperationMgr->setSHIFTPressed(aKeyEvent->modifiers() & Qt::ShiftModifier); - switch (aKeyEvent->key()) { + + if (myIsActive) { + // Do not process keys for modal dialogues: all keys has to be processed within the dialog + // There is only one exception: ModuleBase_EditorDialog + QWindow* aWnd = qApp->modalWindow(); + QString aName = "NoModal"; + if (aWnd) { + if (!aWnd->objectName().startsWith("ModuleBase_EditorDialog")) + aName = aWnd->objectName(); + } + if (aName == "NoModal") { + if (theEvent->type() == QEvent::KeyRelease) { + QKeyEvent* aKeyEvent = dynamic_cast(theEvent); + if (aKeyEvent) { + myOperationMgr->setSHIFTPressed(aKeyEvent->modifiers() & Qt::ShiftModifier); + switch (aKeyEvent->key()) { case Qt::Key_Delete: isAccepted = myOperationMgr->onProcessDelete(theObject); - break; + break; default: isAccepted = myOperationMgr->onKeyReleased(theObject, aKeyEvent); break; + } } } - } - else if (theEvent->type() == QEvent::KeyPress) { - if (myOperationMgr->hasOperation()) { - QKeyEvent* aKeyEvent = dynamic_cast(theEvent); - myOperationMgr->setSHIFTPressed(aKeyEvent->modifiers() & Qt::ShiftModifier); - isAccepted = myOperationMgr->onKeyPressed(theObject, aKeyEvent); + else if (theEvent->type() == QEvent::KeyPress) { + if (myOperationMgr->hasOperation()) { + QKeyEvent* aKeyEvent = dynamic_cast(theEvent); + myOperationMgr->setSHIFTPressed(aKeyEvent->modifiers() & Qt::ShiftModifier); + isAccepted = myOperationMgr->onKeyPressed(theObject, aKeyEvent); + } } } }