From 6b1866ccaf72e2c745a68614f7b2d3c5890141e0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 20 Oct 2016 09:46:28 +0200 Subject: [PATCH] issue #0002631: Ctrl-W Doesn't Close Window --- src/Gui/CommandWindow.cpp | 7 ++++--- src/Gui/MainWindow.cpp | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Gui/CommandWindow.cpp b/src/Gui/CommandWindow.cpp index 74e0758757..d6ca4bfde3 100644 --- a/src/Gui/CommandWindow.cpp +++ b/src/Gui/CommandWindow.cpp @@ -138,9 +138,10 @@ StdCmdCloseActiveWindow::StdCmdCloseActiveWindow() sToolTipText = QT_TR_NOOP("Close active window"); sWhatsThis = QT_TR_NOOP("Close active window"); sStatusTip = QT_TR_NOOP("Close active window"); - // CTRL+F4 is already set by an QMdiSubWindow and thus we must use the - // alternative CTRL+W here to avoid an ambiguous shortcut overload - sAccel = "Ctrl+W"; + // In QMdiSubWindow the 'QKeySequence::Close' shortcut is set which will + // collide with this shortcut. Thus the shortcut of QMdiSubWindow will be + // reset in MainWindow::addWindow() (#0002631) + sAccel = keySequenceToAccel(QKeySequence::Close); eType = 0; } diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index 50e9525f98..31d6c8e773 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -35,6 +35,7 @@ # include # include # include +# include # include # include # include @@ -723,6 +724,16 @@ void MainWindow::addWindow(MDIView* view) child->setWidget(view); child->setWindowIcon(view->windowIcon()); QMenu* menu = child->systemMenu(); + + // See StdCmdCloseActiveWindow (#0002631) + QList acts = menu->actions(); + for (QList::iterator it = acts.begin(); it != acts.end(); ++it) { + if ((*it)->shortcut() == QKeySequence(QKeySequence::Close)) { + (*it)->setShortcuts(QList()); + break; + } + } + QAction* action = menu->addAction(tr("Close All")); connect(action, SIGNAL(triggered()), d->mdiArea, SLOT(closeAllSubWindows())); d->mdiArea->addSubWindow(child);