Commit 1a77c287 authored by mae's avatar mae

Workaround for QTCREATORBUG-72 (multiple shortcuts)

This fixes the Ctrl+W vs. Ctrl+F4 for close on MS-Windows
by introducing Ctrl+F4 as an alternative shortcut.

Reviewed-by: con
parent 78f130a1
......@@ -141,6 +141,7 @@ const char * const GOTO_OTHER_SPLIT = "QtCreator.GotoOtherSplit";
const char * const SAVEASDEFAULT = "QtCreator.SaveAsDefaultLayout";
const char * const RESTOREDEFAULT = "QtCreator.RestoreDefaultLayout";
const char * const CLOSE = "QtCreator.Close";
const char * const CLOSE_ALTERNATIVE = "QtCreator.Close_Alternative"; // temporary, see QTCREATORBUG-72
const char * const CLOSEALL = "QtCreator.CloseAll";
const char * const CLOSEOTHERS = "QtCreator.CloseOthers";
const char * const GOTONEXT = "QtCreator.GotoNext";
......
......@@ -67,6 +67,7 @@
#include <QtCore/QSettings>
#include <QtGui/QAction>
#include <QtGui/QShortcut>
#include <QtGui/QApplication>
#include <QtGui/QFileDialog>
#include <QtGui/QLayout>
......@@ -311,16 +312,21 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
// Close Action
cmd = am->registerAction(m_d->m_closeCurrentEditorAction, Constants::CLOSE, editManagerContext);
#ifdef Q_WS_WIN
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+F4")));
#else
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+W")));
#endif
cmd->setAttribute(Core::Command::CA_UpdateText);
cmd->setDefaultText(m_d->m_closeCurrentEditorAction->text());
mfile->addAction(cmd, Constants::G_FILE_CLOSE);
connect(m_d->m_closeCurrentEditorAction, SIGNAL(triggered()), this, SLOT(closeEditor()));
#ifdef Q_WS_WIN
// workaround for QTCREATORBUG-72
QShortcut *sc = new QShortcut(parent);
cmd = am->registerShortcut(sc, Constants::CLOSE_ALTERNATIVE, editManagerContext);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+F4")));
cmd->setDefaultText(EditorManager::tr("Close"));
connect(sc, SIGNAL(activated()), this, SLOT(closeEditor()));
#endif
// Close All Action
cmd = am->registerAction(m_d->m_closeAllEditorsAction, Constants::CLOSEALL, editManagerContext);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+W")));
......@@ -733,6 +739,8 @@ void EditorManager::closeOtherEditors()
// SLOT connected to action
void EditorManager::closeEditor()
{
if (!m_d->m_currentEditor)
return;
addCurrentPositionToNavigationHistory();
closeEditor(m_d->m_currentEditor);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment