Commit 7dfb7df4 authored by Eike Ziller's avatar Eike Ziller
Browse files

OS X: Add action for closing external windows



E.g. editor windows and help windows. There is no automatic system
shortcut for this on OS X.

Change-Id: I27f1208cde0a6f4b1a6952a7988d00a8481a08a4
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent febdfeb9
......@@ -103,6 +103,7 @@ const char TOGGLE_FULLSCREEN[] = "QtCreator.ToggleFullScreen";
const char MINIMIZE_WINDOW[] = "QtCreator.MinimizeWindow";
const char ZOOM_WINDOW[] = "QtCreator.ZoomWindow";
const char CLOSE_WINDOW[] = "QtCreator.CloseWindow";
const char SPLIT[] = "QtCreator.Split";
const char SPLIT_SIDE_BY_SIDE[] = "QtCreator.SplitSideBySide";
......
......@@ -330,6 +330,7 @@ bool MainWindow::init(QString *errorMessage)
void MainWindow::extensionsInitialized()
{
m_windowSupport = new WindowSupport(this, Context("Core.MainWindow"));
m_windowSupport->setCloseActionEnabled(false);
m_editorManager->init();
m_statusBarManager->extensionsInitalized();
OutputPaneManager::instance()->init();
......@@ -654,8 +655,17 @@ void MainWindow::registerDefaultActions()
cmd->setAttribute(Command::CA_UpdateText);
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
if (UseMacShortcuts)
if (UseMacShortcuts) {
mwindow->addSeparator(globalContext, Constants::G_WINDOW_SIZE);
QAction *closeAction = new QAction(tr("Close Window"), this);
closeAction->setEnabled(false);
cmd = ActionManager::registerAction(closeAction, Constants::CLOSE_WINDOW, globalContext);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Meta+W")));
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
mwindow->addSeparator(globalContext, Constants::G_WINDOW_SIZE);
}
// Show Sidebar Action
m_toggleSideBarAction = new QAction(QIcon(QLatin1String(Constants::ICON_TOGGLE_SIDEBAR)),
......
......@@ -61,6 +61,10 @@ WindowSupport::WindowSupport(QWidget *window, const Context &context)
m_zoomAction = new QAction(this);
ActionManager::registerAction(m_zoomAction, Constants::ZOOM_WINDOW, context);
connect(m_zoomAction, SIGNAL(triggered()), m_window, SLOT(showMaximized()));
m_closeAction = new QAction(this);
ActionManager::registerAction(m_closeAction, Constants::CLOSE_WINDOW, context);
connect(m_closeAction, SIGNAL(triggered()), m_window, SLOT(close()), Qt::QueuedConnection);
}
m_toggleFullScreenAction = new QAction(this);
......@@ -74,6 +78,12 @@ WindowSupport::~WindowSupport()
ICore::removeContextObject(m_contextObject);
}
void WindowSupport::setCloseActionEnabled(bool enabled)
{
if (UseMacShortcuts)
m_closeAction->setEnabled(enabled);
}
bool WindowSupport::eventFilter(QObject *obj, QEvent *event)
{
if (obj != m_window)
......
......@@ -49,6 +49,8 @@ public:
WindowSupport(QWidget *window, const Context &context);
~WindowSupport();
void setCloseActionEnabled(bool enabled);
protected:
bool eventFilter(QObject *obj, QEvent *event);
......@@ -61,6 +63,7 @@ private:
IContext *m_contextObject;
QAction *m_minimizeAction;
QAction *m_zoomAction;
QAction *m_closeAction;
QAction *m_toggleFullScreenAction;
};
......
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