issue #0002631: Ctrl-W Doesn't Close Window

This commit is contained in:
wmayer 2016-10-20 09:46:28 +02:00
parent 3e82b3b10d
commit 6b1866ccaf
2 changed files with 15 additions and 3 deletions

View File

@ -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;
}

View File

@ -35,6 +35,7 @@
# include <QDesktopWidget>
# include <QDockWidget>
# include <QFontMetrics>
# include <QKeySequence>
# include <QLabel>
# include <QMdiSubWindow>
# include <QMessageBox>
@ -723,6 +724,16 @@ void MainWindow::addWindow(MDIView* view)
child->setWidget(view);
child->setWindowIcon(view->windowIcon());
QMenu* menu = child->systemMenu();
// See StdCmdCloseActiveWindow (#0002631)
QList<QAction*> acts = menu->actions();
for (QList<QAction*>::iterator it = acts.begin(); it != acts.end(); ++it) {
if ((*it)->shortcut() == QKeySequence(QKeySequence::Close)) {
(*it)->setShortcuts(QList<QKeySequence>());
break;
}
}
QAction* action = menu->addAction(tr("Close All"));
connect(action, SIGNAL(triggered()), d->mdiArea, SLOT(closeAllSubWindows()));
d->mdiArea->addSubWindow(child);