diff options
author | Eike Ziller <eike.ziller@digia.com> | 2014-07-10 16:57:28 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@digia.com> | 2014-07-11 11:06:01 +0200 |
commit | c3093cfff7f958087681f34afa147cbce39d5941 (patch) | |
tree | e08d7349944daec49db260d8bc4eb646302b8a61 | |
parent | 6da19d072d3375e41b016b2736feb189aeb0a8ed (diff) | |
download | qt-creator-c3093cfff7f958087681f34afa147cbce39d5941.tar.gz |
Remove special code path for fullscreen support on Mac
This was necessary for supporting full screen on 10.7 even while
keeping compatibility with 10.6. Since we no longer support 10.6,
we can remove the workaround.
Change-Id: I03e23e9203836ab6fb5a836fc06a525e44516d34
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
-rw-r--r-- | src/plugins/coreplugin/coreplugin.pro | 4 | ||||
-rw-r--r-- | src/plugins/coreplugin/macfullscreen.h | 48 | ||||
-rw-r--r-- | src/plugins/coreplugin/macfullscreen.mm | 114 | ||||
-rw-r--r-- | src/plugins/coreplugin/mainwindow.cpp | 84 | ||||
-rw-r--r-- | src/plugins/coreplugin/mainwindow.h | 4 |
5 files changed, 34 insertions, 220 deletions
diff --git a/src/plugins/coreplugin/coreplugin.pro b/src/plugins/coreplugin/coreplugin.pro index 840787e563..aa5cda3904 100644 --- a/src/plugins/coreplugin/coreplugin.pro +++ b/src/plugins/coreplugin/coreplugin.pro @@ -224,10 +224,8 @@ win32 { LIBS += -lole32 -luser32 } else:macx { - HEADERS += macfullscreen.h OBJECTIVE_SOURCES += \ - progressmanager/progressmanager_mac.mm \ - macfullscreen.mm + progressmanager/progressmanager_mac.mm LIBS += -framework AppKit } else:unix { diff --git a/src/plugins/coreplugin/macfullscreen.h b/src/plugins/coreplugin/macfullscreen.h deleted file mode 100644 index 2482750cbd..0000000000 --- a/src/plugins/coreplugin/macfullscreen.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** 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 MACFULLSCREEN_H -#define MACFULLSCREEN_H - -#include "mainwindow.h" - -namespace Core { -namespace Internal { -namespace MacFullScreen { - -bool supportsFullScreen(); -// adds fullscreen button to window for lion -void addFullScreen(Core::Internal::MainWindow *window); -void toggleFullScreen(Core::Internal::MainWindow *window); - -} // MacFullScreen -} // Internal -} // Core - -#endif // MACFULLSCREEN_H diff --git a/src/plugins/coreplugin/macfullscreen.mm b/src/plugins/coreplugin/macfullscreen.mm deleted file mode 100644 index bd693cba95..0000000000 --- a/src/plugins/coreplugin/macfullscreen.mm +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** 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 "macfullscreen.h" - -#include <AppKit/NSView.h> -#include <AppKit/NSWindow.h> -#include <Foundation/NSNotification.h> - -#include <QSysInfo> -#include <qglobal.h> - -enum { - Qtc_NSWindowCollectionBehaviorFullScreenPrimary = (1 << 7) -}; - -static NSString *Qtc_NSWindowDidEnterFullScreenNotification = @"NSWindowDidEnterFullScreenNotification"; -static NSString *Qtc_NSWindowDidExitFullScreenNotification = @"NSWindowDidExitFullScreenNotification"; - -@interface WindowObserver : NSObject { - Core::Internal::MainWindow *window; -} - -- (id)initWithMainWindow:(Core::Internal::MainWindow *)w; - -- (void)notifyDidEnterFullScreen:(NSNotification *)notification; -- (void)notifyDidExitFullScreen:(NSNotification *)notification; - -@end - -@implementation WindowObserver - -- (id)initWithMainWindow:(Core::Internal::MainWindow *)w -{ - if ((self = [self init])) { - window = w; - } - return self; -} - -- (void)notifyDidEnterFullScreen:(NSNotification *)notification -{ - Q_UNUSED(notification) - window->setIsFullScreen(true); -} - -- (void)notifyDidExitFullScreen:(NSNotification* )notification -{ - Q_UNUSED(notification) - window->setIsFullScreen(false); -} - -@end - -static WindowObserver *observer = nil; - -using namespace Core::Internal; - -bool MacFullScreen::supportsFullScreen() -{ - return QSysInfo::MacintoshVersion >= QSysInfo::MV_LION; -} - -void MacFullScreen::addFullScreen(MainWindow *window) -{ - if (supportsFullScreen()) { - NSView *nsview = (NSView *) window->winId(); - NSWindow *nswindow = [nsview window]; - [nswindow setCollectionBehavior:Qtc_NSWindowCollectionBehaviorFullScreenPrimary]; - - if (observer == nil) - observer = [[WindowObserver alloc] initWithMainWindow:window]; - NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:observer selector:@selector(notifyDidEnterFullScreen:) - name:Qtc_NSWindowDidEnterFullScreenNotification object:nswindow]; - [nc addObserver:observer selector:@selector(notifyDidExitFullScreen:) - name:Qtc_NSWindowDidExitFullScreenNotification object:nswindow]; - } -} - -void MacFullScreen::toggleFullScreen(MainWindow *window) -{ - if (supportsFullScreen()) { - NSView *nsview = (NSView *) window->winId(); - NSWindow *nswindow = [nsview window]; - [nswindow performSelector:@selector(toggleFullScreen:) withObject: nil]; - } -} diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index ceaa983340..d2a469b5a7 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -55,10 +55,6 @@ #include "externaltoolmanager.h" #include "editormanager/systemeditor.h" -#if defined(Q_OS_MAC) -#include "macfullscreen.h" -#endif - #include <app/app_version.h> #include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/actionmanager.h> @@ -215,10 +211,6 @@ MainWindow::MainWindow() : auto dropSupport = new Utils::FileDropSupport(this); connect(dropSupport, SIGNAL(filesDropped(QStringList)), this, SLOT(openDroppedFiles(QStringList))); - -#if defined(Q_OS_MAC) - MacFullScreen::addFullScreen(this); -#endif } void MainWindow::setSidebarVisible(bool visible) @@ -244,12 +236,19 @@ void MainWindow::setOverrideColor(const QColor &color) m_overrideColor = color; } -void MainWindow::setIsFullScreen(bool fullScreen) +void MainWindow::updateFullScreenAction() { - if (fullScreen) - m_toggleFullScreenAction->setText(tr("Exit Full Screen")); - else - m_toggleFullScreenAction->setText(tr("Enter Full Screen")); + 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 @@ -652,10 +651,22 @@ void MainWindow::registerDefaultActions() cmd = ActionManager::registerAction(m_zoomAction, Constants::ZOOM_WINDOW, globalContext); mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); connect(m_zoomAction, SIGNAL(triggered()), this, SLOT(showMaximized())); + } - // Window separator + // 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); + 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) mwindow->addSeparator(globalContext, Constants::G_WINDOW_SIZE); - } // Show Sidebar Action m_toggleSideBarAction = new QAction(QIcon(QLatin1String(Constants::ICON_TOGGLE_SIDEBAR)), @@ -676,25 +687,6 @@ void MainWindow::registerDefaultActions() connect(m_toggleModeSelectorAction, SIGNAL(triggered(bool)), ModeManager::instance(), SLOT(setModeSelectorVisible(bool))); mwindow->addAction(cmd, Constants::G_WINDOW_VIEWS); -#if defined(Q_OS_MAC) - const QString fullScreenActionText(tr("Enter Full Screen")); - bool supportsFullScreen = MacFullScreen::supportsFullScreen(); -#else - const QString fullScreenActionText(tr("Full Screen")); - bool supportsFullScreen = true; -#endif - if (supportsFullScreen) { - // Full Screen Action - m_toggleFullScreenAction = new QAction(fullScreenActionText, this); - m_toggleFullScreenAction->setMenuRole(QAction::NoRole); - m_toggleFullScreenAction->setCheckable(!Utils::HostOsInfo::isMacHost()); - cmd = ActionManager::registerAction(m_toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN, globalContext); - cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Meta+F") : tr("Ctrl+Shift+F11"))); - cmd->setAttribute(Command::CA_UpdateText); /* for Mac */ - mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); - connect(m_toggleFullScreenAction, SIGNAL(triggered(bool)), this, SLOT(setFullScreen(bool))); - } - // Window->Views ActionContainer *mviews = ActionManager::createMenu(Constants::M_WINDOW_VIEWS); mwindow->addMenu(mviews, Constants::G_WINDOW_VIEWS); @@ -921,10 +913,8 @@ void MainWindow::changeEvent(QEvent *e) qDebug() << "main window state changed to minimized=" << minimized; m_minimizeAction->setEnabled(!minimized); m_zoomAction->setEnabled(!minimized); - } else { - bool isFullScreen = (windowState() & Qt::WindowFullScreen) != 0; - m_toggleFullScreenAction->setChecked(isFullScreen); } + updateFullScreenAction(); } } @@ -1131,25 +1121,13 @@ QPrinter *MainWindow::printer() const return m_printer; } -void MainWindow::setFullScreen(bool on) +void MainWindow::toggleFullScreen() { -#if defined(Q_OS_MAC) - Q_UNUSED(on) - MacFullScreen::toggleFullScreen(this); -#else - if (bool(windowState() & Qt::WindowFullScreen) == on) - return; - - if (on) { - setWindowState(windowState() | Qt::WindowFullScreen); - //statusBar()->hide(); - //menuBar()->hide(); - } else { + if (isFullScreen()) { setWindowState(windowState() & ~Qt::WindowFullScreen); - //menuBar()->show(); - //statusBar()->show(); + } else { + setWindowState(windowState() | Qt::WindowFullScreen); } -#endif } // Display a warning with an additional button to open diff --git a/src/plugins/coreplugin/mainwindow.h b/src/plugins/coreplugin/mainwindow.h index 6743ad5540..5d89286969 100644 --- a/src/plugins/coreplugin/mainwindow.h +++ b/src/plugins/coreplugin/mainwindow.h @@ -107,7 +107,7 @@ public: void setOverrideColor(const QColor &color); - void setIsFullScreen(bool fullScreen); + void updateFullScreenAction(); bool isNewItemDialogRunning() const; @@ -119,7 +119,7 @@ public slots: void newFile(); void openFileWith(); void exit(); - void setFullScreen(bool on); + void toggleFullScreen(); void showNewItemDialog(const QString &title, const QList<IWizardFactory *> &factories, |