Commit c3093cff authored by Eike Ziller's avatar Eike Ziller

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: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 6da19d07
......@@ -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 {
......
/****************************************************************************
**
** 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
/****************************************************************************
**
** 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];
}
}
......@@ -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
......
......@@ -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,
......
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