forked from qt-creator/qt-creator
		
	Merge remote-tracking branch 'origin/3.2'
Conflicts: src/plugins/git/changeselectiondialog.cpp src/plugins/git/changeselectiondialog.h src/plugins/git/gerrit/gerritplugin.cpp src/plugins/git/gitclient.cpp src/plugins/git/gitclient.h src/plugins/git/gitsettings.cpp src/plugins/git/gitsettings.h src/plugins/git/mergetool.cpp Change-Id: Icd1b2741da96395ed1b41903f453049a303e4791
This commit is contained in:
		@@ -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";
 | 
			
		||||
 
 | 
			
		||||
@@ -100,7 +100,8 @@ SOURCES += mainwindow.cpp \
 | 
			
		||||
    dialogs/addtovcsdialog.cpp \
 | 
			
		||||
    icorelistener.cpp \
 | 
			
		||||
    ioutputpane.cpp \
 | 
			
		||||
    patchtool.cpp
 | 
			
		||||
    patchtool.cpp \
 | 
			
		||||
    windowsupport.cpp
 | 
			
		||||
 | 
			
		||||
HEADERS += mainwindow.h \
 | 
			
		||||
    editmode.h \
 | 
			
		||||
@@ -199,7 +200,8 @@ HEADERS += mainwindow.h \
 | 
			
		||||
    documentmanager.h \
 | 
			
		||||
    removefiledialog.h \
 | 
			
		||||
    dialogs/addtovcsdialog.h \
 | 
			
		||||
    patchtool.h
 | 
			
		||||
    patchtool.h \
 | 
			
		||||
    windowsupport.h
 | 
			
		||||
 | 
			
		||||
FORMS += dialogs/newdialog.ui \
 | 
			
		||||
    dialogs/saveitemsdialog.ui \
 | 
			
		||||
 
 | 
			
		||||
@@ -100,6 +100,7 @@ QtcPlugin {
 | 
			
		||||
            "variablemanager.cpp", "variablemanager.h",
 | 
			
		||||
            "vcsmanager.cpp", "vcsmanager.h",
 | 
			
		||||
            "versiondialog.cpp", "versiondialog.h",
 | 
			
		||||
            "windowsupport.cpp", "windowsupport.h"
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -687,9 +687,18 @@ void EditorManager::splitNewWindow(Internal::EditorView *view)
 | 
			
		||||
    else
 | 
			
		||||
        newEditor = editor; // move to the new view
 | 
			
		||||
    splitter = new SplitterOrView;
 | 
			
		||||
    splitter->setAttribute(Qt::WA_DeleteOnClose);
 | 
			
		||||
    splitter->setAttribute(Qt::WA_QuitOnClose, false); // don't prevent Qt Creator from closing
 | 
			
		||||
    splitter->resize(QSize(800, 600));
 | 
			
		||||
    QWidget *win = new QWidget;
 | 
			
		||||
    QVBoxLayout *layout = new QVBoxLayout;
 | 
			
		||||
    layout->setMargin(0);
 | 
			
		||||
    layout->setSpacing(0);
 | 
			
		||||
    win->setLayout(layout);
 | 
			
		||||
    layout->addWidget(splitter);
 | 
			
		||||
    win->setFocusProxy(splitter);
 | 
			
		||||
    win->setAttribute(Qt::WA_DeleteOnClose);
 | 
			
		||||
    win->setAttribute(Qt::WA_QuitOnClose, false); // don't prevent Qt Creator from closing
 | 
			
		||||
    win->resize(QSize(800, 600));
 | 
			
		||||
    static int windowId = 0;
 | 
			
		||||
    ICore::registerWindow(win, Context(Id("EditorManager.ExternalWindow.").withSuffix(++windowId)));
 | 
			
		||||
    IContext *context = new IContext;
 | 
			
		||||
    context->setContext(Context(Constants::C_EDITORMANAGER));
 | 
			
		||||
    context->setWidget(splitter);
 | 
			
		||||
@@ -697,8 +706,8 @@ void EditorManager::splitNewWindow(Internal::EditorView *view)
 | 
			
		||||
    d->m_root.append(splitter);
 | 
			
		||||
    d->m_rootContext.append(context);
 | 
			
		||||
    connect(splitter, SIGNAL(destroyed(QObject*)), m_instance, SLOT(rootDestroyed(QObject*)));
 | 
			
		||||
    splitter->show();
 | 
			
		||||
    ICore::raiseWindow(splitter);
 | 
			
		||||
    win->show();
 | 
			
		||||
    ICore::raiseWindow(win);
 | 
			
		||||
    if (newEditor)
 | 
			
		||||
        m_instance->activateEditor(splitter->view(), newEditor, IgnoreNavigationHistory);
 | 
			
		||||
    else
 | 
			
		||||
 
 | 
			
		||||
@@ -148,7 +148,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
 | 
			
		||||
 | 
			
		||||
    m_ui.advancedButton->setDefaultAction(Core::ActionManager::command(Constants::ADVANCED_FIND)->action());
 | 
			
		||||
 | 
			
		||||
    m_goToCurrentFindAction = new QAction(tr("Go to Current Document Find"), this);
 | 
			
		||||
    m_goToCurrentFindAction = new QAction(this);
 | 
			
		||||
    Core::ActionManager::registerAction(m_goToCurrentFindAction, Constants::S_RETURNTOEDITOR,
 | 
			
		||||
                                        Context(Constants::C_FINDTOOLBAR));
 | 
			
		||||
    connect(m_goToCurrentFindAction, SIGNAL(triggered()), this, SLOT(setFocusToCurrentFindSupport()));
 | 
			
		||||
 
 | 
			
		||||
@@ -28,6 +28,7 @@
 | 
			
		||||
****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#include "icore.h"
 | 
			
		||||
#include "windowsupport.h"
 | 
			
		||||
 | 
			
		||||
#include <app/app_version.h>
 | 
			
		||||
#include <extensionsystem/pluginmanager.h>
 | 
			
		||||
@@ -523,6 +524,11 @@ void ICore::removeContextObject(IContext *context)
 | 
			
		||||
    m_mainwindow->removeContextObject(context);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ICore::registerWindow(QWidget *window, const Context &context)
 | 
			
		||||
{
 | 
			
		||||
    new WindowSupport(window, context); // deletes itself when widget is destroyed
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ICore::openFiles(const QStringList &arguments, ICore::OpenFilesFlags flags)
 | 
			
		||||
{
 | 
			
		||||
    m_mainwindow->openFiles(arguments, flags);
 | 
			
		||||
 
 | 
			
		||||
@@ -109,6 +109,9 @@ public:
 | 
			
		||||
    static void addContextObject(IContext *context);
 | 
			
		||||
    static void removeContextObject(IContext *context);
 | 
			
		||||
 | 
			
		||||
    // manages the minimize, zoom and fullscreen actions for the window
 | 
			
		||||
    static void registerWindow(QWidget *window, const Context &context);
 | 
			
		||||
 | 
			
		||||
    enum OpenFilesFlags {
 | 
			
		||||
        None = 0,
 | 
			
		||||
        SwitchMode = 1,
 | 
			
		||||
 
 | 
			
		||||
@@ -54,6 +54,7 @@
 | 
			
		||||
#include "statusbarwidget.h"
 | 
			
		||||
#include "externaltoolmanager.h"
 | 
			
		||||
#include "editormanager/systemeditor.h"
 | 
			
		||||
#include "windowsupport.h"
 | 
			
		||||
 | 
			
		||||
#include <app/app_version.h>
 | 
			
		||||
#include <coreplugin/actionmanager/actioncontainer.h>
 | 
			
		||||
@@ -111,6 +112,7 @@ MainWindow::MainWindow() :
 | 
			
		||||
                                            QLatin1String("QtCreator"),
 | 
			
		||||
                                            this)),
 | 
			
		||||
    m_printer(0),
 | 
			
		||||
    m_windowSupport(0),
 | 
			
		||||
    m_actionManager(new ActionManager(this)),
 | 
			
		||||
    m_editorManager(0),
 | 
			
		||||
    m_externalToolManager(0),
 | 
			
		||||
@@ -138,9 +140,6 @@ MainWindow::MainWindow() :
 | 
			
		||||
    m_exitAction(0),
 | 
			
		||||
    m_optionsAction(0),
 | 
			
		||||
    m_toggleSideBarAction(0),
 | 
			
		||||
    m_toggleFullScreenAction(0),
 | 
			
		||||
    m_minimizeAction(0),
 | 
			
		||||
    m_zoomAction(0),
 | 
			
		||||
    m_toggleSideBarButton(new QToolButton)
 | 
			
		||||
{
 | 
			
		||||
    ActionManager::initialize(); // must be done before registering any actions
 | 
			
		||||
@@ -236,21 +235,6 @@ void MainWindow::setOverrideColor(const QColor &color)
 | 
			
		||||
    m_overrideColor = color;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWindow::updateFullScreenAction()
 | 
			
		||||
{
 | 
			
		||||
    if (isFullScreen()) {
 | 
			
		||||
        if (Utils::HostOsInfo::isMacHost())
 | 
			
		||||
            m_toggleFullScreenAction->setText(tr("Exit Full Screen"));
 | 
			
		||||
        else
 | 
			
		||||
            m_toggleFullScreenAction->setChecked(true);
 | 
			
		||||
    } else {
 | 
			
		||||
        if (Utils::HostOsInfo::isMacHost())
 | 
			
		||||
            m_toggleFullScreenAction->setText(tr("Enter Full Screen"));
 | 
			
		||||
        else
 | 
			
		||||
            m_toggleFullScreenAction->setChecked(false);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool MainWindow::isNewItemDialogRunning() const
 | 
			
		||||
{
 | 
			
		||||
    return !m_newDialog.isNull();
 | 
			
		||||
@@ -345,6 +329,8 @@ 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();
 | 
			
		||||
@@ -386,6 +372,11 @@ void MainWindow::closeEvent(QCloseEvent *event)
 | 
			
		||||
    m_navigationWidget->closeSubWidgets();
 | 
			
		||||
 | 
			
		||||
    event->accept();
 | 
			
		||||
 | 
			
		||||
    // explicitly delete window support, because that calls methods from ICore that call methods
 | 
			
		||||
    // from mainwindow, so mainwindow still needs to be alive
 | 
			
		||||
    delete m_windowSupport;
 | 
			
		||||
    m_windowSupport = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWindow::openDroppedFiles(const QStringList &files)
 | 
			
		||||
@@ -640,34 +631,42 @@ void MainWindow::registerDefaultActions()
 | 
			
		||||
 | 
			
		||||
    if (UseMacShortcuts) {
 | 
			
		||||
        // Minimize Action
 | 
			
		||||
        m_minimizeAction = new QAction(tr("Minimize"), this);
 | 
			
		||||
        cmd = ActionManager::registerAction(m_minimizeAction, Constants::MINIMIZE_WINDOW, globalContext);
 | 
			
		||||
        QAction *minimizeAction = new QAction(tr("Minimize"), this);
 | 
			
		||||
        minimizeAction->setEnabled(false); // actual implementation in WindowSupport
 | 
			
		||||
        cmd = ActionManager::registerAction(minimizeAction, Constants::MINIMIZE_WINDOW, globalContext);
 | 
			
		||||
        cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+M")));
 | 
			
		||||
        mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
 | 
			
		||||
        connect(m_minimizeAction, SIGNAL(triggered()), this, SLOT(showMinimized()));
 | 
			
		||||
 | 
			
		||||
        // Zoom Action
 | 
			
		||||
        m_zoomAction = new QAction(tr("Zoom"), this);
 | 
			
		||||
        cmd = ActionManager::registerAction(m_zoomAction, Constants::ZOOM_WINDOW, globalContext);
 | 
			
		||||
        QAction *zoomAction = new QAction(tr("Zoom"), this);
 | 
			
		||||
        zoomAction->setEnabled(false); // actual implementation in WindowSupport
 | 
			
		||||
        cmd = ActionManager::registerAction(zoomAction, Constants::ZOOM_WINDOW, globalContext);
 | 
			
		||||
        mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
 | 
			
		||||
        connect(m_zoomAction, SIGNAL(triggered()), this, SLOT(showMaximized()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Full Screen Action
 | 
			
		||||
    m_toggleFullScreenAction = new QAction(this);
 | 
			
		||||
    m_toggleFullScreenAction->setMenuRole(QAction::NoRole);
 | 
			
		||||
    m_toggleFullScreenAction->setCheckable(!Utils::HostOsInfo::isMacHost());
 | 
			
		||||
    updateFullScreenAction();
 | 
			
		||||
    cmd = ActionManager::registerAction(m_toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN, globalContext);
 | 
			
		||||
    QAction *toggleFullScreenAction = new QAction(tr("Full Screen"), this);
 | 
			
		||||
    toggleFullScreenAction->setMenuRole(QAction::NoRole);
 | 
			
		||||
    toggleFullScreenAction->setCheckable(!Utils::HostOsInfo::isMacHost());
 | 
			
		||||
    toggleFullScreenAction->setEnabled(false); // actual implementation in WindowSupport
 | 
			
		||||
    cmd = ActionManager::registerAction(toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN, globalContext);
 | 
			
		||||
    cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Meta+F") : tr("Ctrl+Shift+F11")));
 | 
			
		||||
    if (Utils::HostOsInfo::isMacHost())
 | 
			
		||||
        cmd->setAttribute(Command::CA_UpdateText);
 | 
			
		||||
    mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
 | 
			
		||||
    connect(m_toggleFullScreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));
 | 
			
		||||
 | 
			
		||||
    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)),
 | 
			
		||||
                                        tr("Show Sidebar"), this);
 | 
			
		||||
@@ -898,15 +897,6 @@ void MainWindow::changeEvent(QEvent *e)
 | 
			
		||||
                qDebug() << "main window activated";
 | 
			
		||||
            emit windowActivated();
 | 
			
		||||
        }
 | 
			
		||||
    } else if (e->type() == QEvent::WindowStateChange) {
 | 
			
		||||
        if (Utils::HostOsInfo::isMacHost()) {
 | 
			
		||||
            bool minimized = isMinimized();
 | 
			
		||||
            if (debugMainWindow)
 | 
			
		||||
                qDebug() << "main window state changed to minimized=" << minimized;
 | 
			
		||||
            m_minimizeAction->setEnabled(!minimized);
 | 
			
		||||
            m_zoomAction->setEnabled(!minimized);
 | 
			
		||||
        }
 | 
			
		||||
        updateFullScreenAction();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1113,15 +1103,6 @@ QPrinter *MainWindow::printer() const
 | 
			
		||||
    return m_printer;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWindow::toggleFullScreen()
 | 
			
		||||
{
 | 
			
		||||
    if (isFullScreen()) {
 | 
			
		||||
        setWindowState(windowState() & ~Qt::WindowFullScreen);
 | 
			
		||||
    } else {
 | 
			
		||||
        setWindowState(windowState() | Qt::WindowFullScreen);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Display a warning with an additional button to open
 | 
			
		||||
// the debugger settings dialog if settingsId is nonempty.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -76,6 +76,7 @@ class ToolSettings;
 | 
			
		||||
class MimeTypeSettings;
 | 
			
		||||
class StatusBarManager;
 | 
			
		||||
class VersionDialog;
 | 
			
		||||
class WindowSupport;
 | 
			
		||||
class SystemEditor;
 | 
			
		||||
 | 
			
		||||
class MainWindow : public Utils::AppMainWindow
 | 
			
		||||
@@ -107,8 +108,6 @@ public:
 | 
			
		||||
 | 
			
		||||
    void setOverrideColor(const QColor &color);
 | 
			
		||||
 | 
			
		||||
    void updateFullScreenAction();
 | 
			
		||||
 | 
			
		||||
    bool isNewItemDialogRunning() const;
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
@@ -119,7 +118,6 @@ public slots:
 | 
			
		||||
    void newFile();
 | 
			
		||||
    void openFileWith();
 | 
			
		||||
    void exit();
 | 
			
		||||
    void toggleFullScreen();
 | 
			
		||||
 | 
			
		||||
    void showNewItemDialog(const QString &title,
 | 
			
		||||
                           const QList<IWizardFactory *> &factories,
 | 
			
		||||
@@ -167,6 +165,7 @@ private:
 | 
			
		||||
    Context m_additionalContexts;
 | 
			
		||||
    SettingsDatabase *m_settingsDatabase;
 | 
			
		||||
    mutable QPrinter *m_printer;
 | 
			
		||||
    WindowSupport *m_windowSupport;
 | 
			
		||||
    ActionManager *m_actionManager;
 | 
			
		||||
    EditorManager *m_editorManager;
 | 
			
		||||
    ExternalToolManager *m_externalToolManager;
 | 
			
		||||
@@ -205,9 +204,6 @@ private:
 | 
			
		||||
    QAction *m_optionsAction;
 | 
			
		||||
    QAction *m_toggleSideBarAction;
 | 
			
		||||
    QAction *m_toggleModeSelectorAction;
 | 
			
		||||
    QAction *m_toggleFullScreenAction;
 | 
			
		||||
    QAction *m_minimizeAction;
 | 
			
		||||
    QAction *m_zoomAction;
 | 
			
		||||
 | 
			
		||||
    QToolButton *m_toggleSideBarButton;
 | 
			
		||||
    QColor m_overrideColor;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										128
									
								
								src/plugins/coreplugin/windowsupport.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										128
									
								
								src/plugins/coreplugin/windowsupport.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,128 @@
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
**
 | 
			
		||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
 | 
			
		||||
** Contact: http://www.qt-project.org/legal
 | 
			
		||||
**
 | 
			
		||||
** This file is part of Qt Creator.
 | 
			
		||||
**
 | 
			
		||||
** Commercial License Usage
 | 
			
		||||
** Licensees holding valid commercial Qt licenses may use this file in
 | 
			
		||||
** accordance with the commercial license agreement provided with the
 | 
			
		||||
** Software or, alternatively, in accordance with the terms contained in
 | 
			
		||||
** a written agreement between you and Digia.  For licensing terms and
 | 
			
		||||
** conditions see http://qt.digia.com/licensing.  For further information
 | 
			
		||||
** use the contact form at http://qt.digia.com/contact-us.
 | 
			
		||||
**
 | 
			
		||||
** GNU Lesser General Public License Usage
 | 
			
		||||
** Alternatively, this file may be used under the terms of the GNU Lesser
 | 
			
		||||
** General Public License version 2.1 as published by the Free Software
 | 
			
		||||
** Foundation and appearing in the file LICENSE.LGPL included in the
 | 
			
		||||
** packaging of this file.  Please review the following information to
 | 
			
		||||
** ensure the GNU Lesser General Public License version 2.1 requirements
 | 
			
		||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 | 
			
		||||
**
 | 
			
		||||
** In addition, as a special exception, Digia gives you certain additional
 | 
			
		||||
** rights.  These rights are described in the Digia Qt LGPL Exception
 | 
			
		||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 | 
			
		||||
**
 | 
			
		||||
****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#include "windowsupport.h"
 | 
			
		||||
 | 
			
		||||
#include "actionmanager/actionmanager.h"
 | 
			
		||||
#include "coreconstants.h"
 | 
			
		||||
#include "icore.h"
 | 
			
		||||
 | 
			
		||||
#include <utils/hostosinfo.h>
 | 
			
		||||
 | 
			
		||||
#include <QAction>
 | 
			
		||||
#include <QWidget>
 | 
			
		||||
#include <QEvent>
 | 
			
		||||
 | 
			
		||||
namespace Core {
 | 
			
		||||
namespace Internal {
 | 
			
		||||
 | 
			
		||||
WindowSupport::WindowSupport(QWidget *window, const Context &context)
 | 
			
		||||
    : QObject(window),
 | 
			
		||||
      m_window(window)
 | 
			
		||||
{
 | 
			
		||||
    m_window->installEventFilter(this);
 | 
			
		||||
 | 
			
		||||
    m_contextObject = new IContext(this);
 | 
			
		||||
    m_contextObject->setWidget(window);
 | 
			
		||||
    m_contextObject->setContext(context);
 | 
			
		||||
    ICore::addContextObject(m_contextObject);
 | 
			
		||||
 | 
			
		||||
    if (UseMacShortcuts) {
 | 
			
		||||
        m_minimizeAction = new QAction(this);
 | 
			
		||||
        ActionManager::registerAction(m_minimizeAction, Constants::MINIMIZE_WINDOW, context);
 | 
			
		||||
        connect(m_minimizeAction, SIGNAL(triggered()), m_window, SLOT(showMinimized()));
 | 
			
		||||
 | 
			
		||||
        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);
 | 
			
		||||
    updateFullScreenAction();
 | 
			
		||||
    ActionManager::registerAction(m_toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN, context);
 | 
			
		||||
    connect(m_toggleFullScreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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)
 | 
			
		||||
        return false;
 | 
			
		||||
    if (event->type() == QEvent::WindowStateChange) {
 | 
			
		||||
        if (Utils::HostOsInfo::isMacHost()) {
 | 
			
		||||
            bool minimized = m_window->isMinimized();
 | 
			
		||||
            m_minimizeAction->setEnabled(!minimized);
 | 
			
		||||
            m_zoomAction->setEnabled(!minimized);
 | 
			
		||||
        }
 | 
			
		||||
        updateFullScreenAction();
 | 
			
		||||
    }
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void WindowSupport::toggleFullScreen()
 | 
			
		||||
{
 | 
			
		||||
    if (m_window->isFullScreen()) {
 | 
			
		||||
        m_window->setWindowState(m_window->windowState() & ~Qt::WindowFullScreen);
 | 
			
		||||
    } else {
 | 
			
		||||
        m_window->setWindowState(m_window->windowState() | Qt::WindowFullScreen);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void WindowSupport::updateFullScreenAction()
 | 
			
		||||
{
 | 
			
		||||
    if (m_window->isFullScreen()) {
 | 
			
		||||
        if (Utils::HostOsInfo::isMacHost())
 | 
			
		||||
            m_toggleFullScreenAction->setText(tr("Exit Full Screen"));
 | 
			
		||||
        else
 | 
			
		||||
            m_toggleFullScreenAction->setChecked(true);
 | 
			
		||||
    } else {
 | 
			
		||||
        if (Utils::HostOsInfo::isMacHost())
 | 
			
		||||
            m_toggleFullScreenAction->setText(tr("Enter Full Screen"));
 | 
			
		||||
        else
 | 
			
		||||
            m_toggleFullScreenAction->setChecked(false);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
} // Internal
 | 
			
		||||
} // Core
 | 
			
		||||
							
								
								
									
										73
									
								
								src/plugins/coreplugin/windowsupport.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								src/plugins/coreplugin/windowsupport.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,73 @@
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
**
 | 
			
		||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
 | 
			
		||||
** Contact: http://www.qt-project.org/legal
 | 
			
		||||
**
 | 
			
		||||
** This file is part of Qt Creator.
 | 
			
		||||
**
 | 
			
		||||
** Commercial License Usage
 | 
			
		||||
** Licensees holding valid commercial Qt licenses may use this file in
 | 
			
		||||
** accordance with the commercial license agreement provided with the
 | 
			
		||||
** Software or, alternatively, in accordance with the terms contained in
 | 
			
		||||
** a written agreement between you and Digia.  For licensing terms and
 | 
			
		||||
** conditions see http://qt.digia.com/licensing.  For further information
 | 
			
		||||
** use the contact form at http://qt.digia.com/contact-us.
 | 
			
		||||
**
 | 
			
		||||
** GNU Lesser General Public License Usage
 | 
			
		||||
** Alternatively, this file may be used under the terms of the GNU Lesser
 | 
			
		||||
** General Public License version 2.1 as published by the Free Software
 | 
			
		||||
** Foundation and appearing in the file LICENSE.LGPL included in the
 | 
			
		||||
** packaging of this file.  Please review the following information to
 | 
			
		||||
** ensure the GNU Lesser General Public License version 2.1 requirements
 | 
			
		||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 | 
			
		||||
**
 | 
			
		||||
** In addition, as a special exception, Digia gives you certain additional
 | 
			
		||||
** rights.  These rights are described in the Digia Qt LGPL Exception
 | 
			
		||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 | 
			
		||||
**
 | 
			
		||||
****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifndef WINDOWSUPPORT_H
 | 
			
		||||
#define WINDOWSUPPORT_H
 | 
			
		||||
 | 
			
		||||
#include "icontext.h"
 | 
			
		||||
 | 
			
		||||
#include <QObject>
 | 
			
		||||
 | 
			
		||||
QT_BEGIN_NAMESPACE
 | 
			
		||||
class QAction;
 | 
			
		||||
class QWidget;
 | 
			
		||||
QT_END_NAMESPACE
 | 
			
		||||
 | 
			
		||||
namespace Core {
 | 
			
		||||
namespace Internal {
 | 
			
		||||
 | 
			
		||||
class WindowSupport : public QObject
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
public:
 | 
			
		||||
    WindowSupport(QWidget *window, const Context &context);
 | 
			
		||||
    ~WindowSupport();
 | 
			
		||||
 | 
			
		||||
    void setCloseActionEnabled(bool enabled);
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
    bool eventFilter(QObject *obj, QEvent *event);
 | 
			
		||||
 | 
			
		||||
private slots:
 | 
			
		||||
    void toggleFullScreen();
 | 
			
		||||
    void updateFullScreenAction();
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    QWidget *m_window;
 | 
			
		||||
    IContext *m_contextObject;
 | 
			
		||||
    QAction *m_minimizeAction;
 | 
			
		||||
    QAction *m_zoomAction;
 | 
			
		||||
    QAction *m_closeAction;
 | 
			
		||||
    QAction *m_toggleFullScreenAction;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
} // Internal
 | 
			
		||||
} // Core
 | 
			
		||||
 | 
			
		||||
#endif // WINDOWSUPPORT_H
 | 
			
		||||
		Reference in New Issue
	
	Block a user