diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-11-11 14:50:20 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-11 15:22:02 +0100 |
commit | 4e732b87d2b898b9720bd128247beb202fb4aaff (patch) | |
tree | fa338154584c8c6e2feaa7e88b2316793799db51 /src/plugins/platforms/cocoa | |
parent | c92d6130fe9df1dc6b42b9d66627cc905e13519b (diff) |
Factor out QPlatformTheme from QPlatformPlugin.
Implement QCocoaPlatformTheme. The menus and dialog
API is moved from the platform to the theme plugin.
(Both APIs contain references to QtWidget classes,
which we are working towards removing.)
The theme plugin is created after the platform
plugin, first by asking the platform plugin, then
by looking for a separate plugin if the platform
does not specify a theme.
Initial-patch-by: Morten Sorvig <msorvig@trolltech.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Change-Id: I2778cdd3a205c4ce35ead93e39fe6b4cd58a39f9
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r-- | src/plugins/platforms/cocoa/cocoa.pro | 2 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/main.mm | 4 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaintegration.h | 8 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaintegration.mm | 33 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoatheme.h | 66 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoatheme.mm | 93 |
6 files changed, 171 insertions, 35 deletions
diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 5531c49e23..3d42b02df6 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -4,6 +4,7 @@ DESTDIR = $$QT.gui.plugins/platforms OBJECTIVE_SOURCES += main.mm \ qcocoaintegration.mm \ + qcocoatheme.mm \ qcocoabackingstore.mm \ qcocoawindow.mm \ qnsview.mm \ @@ -26,6 +27,7 @@ OBJECTIVE_SOURCES += main.mm \ qcocoacursor.mm \ HEADERS += qcocoaintegration.h \ + qcocoatheme.h \ qcocoabackingstore.h \ qcocoawindow.h \ qnsview.h \ diff --git a/src/plugins/platforms/cocoa/main.mm b/src/plugins/platforms/cocoa/main.mm index 1ef7d622e8..0be6ebd682 100644 --- a/src/plugins/platforms/cocoa/main.mm +++ b/src/plugins/platforms/cocoa/main.mm @@ -42,7 +42,9 @@ #include <Cocoa/Cocoa.h> #include <QtGui/QPlatformIntegrationPlugin> +#include <QtGui/QPlatformThemePlugin> #include "qcocoaintegration.h" +#include "qcocoatheme.h" QT_BEGIN_NAMESPACE @@ -69,6 +71,6 @@ QPlatformIntegration * QCocoaIntegrationPlugin::create(const QString& system, co return 0; } -Q_EXPORT_PLUGIN2(Cocoa, QCocoaIntegrationPlugin) +Q_EXPORT_PLUGIN2(CocoaIntegration, QCocoaIntegrationPlugin) QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h index 9cba69da3a..5311eaff83 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.h +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -84,20 +84,18 @@ public: QAbstractEventDispatcher *guiThreadEventDispatcher() const; QPlatformFontDatabase *fontDatabase() const; - QPlatformMenu *createPlatformMenu(QMenu *menu = 0) const; - QPlatformMenuBar *createPlatformMenuBar(QMenuBar *menuBar = 0) const; - - bool usePlatformNativeDialog(QDialog *dialog = 0) const; - QPlatformDialogHelper *createPlatformDialogHelper(QDialog *dialog = 0) const; QPlatformNativeInterface *nativeInterface() const; QPlatformAccessibility *accessibility() const; + + QPlatformTheme *platformTheme() const; private: QPlatformFontDatabase *mFontDb; QAbstractEventDispatcher *mEventDispatcher; QCocoaAutoReleasePool *mPool; QPlatformAccessibility *mAccessibility; + QPlatformTheme *mPlatformTheme; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index b1926eb6e8..f7f8452e5a 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -51,6 +51,7 @@ #include "qcocoaapplicationdelegate.h" #include "qmenu_mac.h" #include "qcocoafiledialoghelper.h" +#include "qcocoatheme.h" #include <QtGui/qplatformaccessibility_qpa.h> #include <QtCore/qcoreapplication.h> @@ -134,6 +135,7 @@ QCocoaIntegration::QCocoaIntegration() } mAccessibility = new QPlatformAccessibility; + mPlatformTheme = new QCocoaTheme; } QCocoaIntegration::~QCocoaIntegration() @@ -179,16 +181,6 @@ QPlatformFontDatabase *QCocoaIntegration::fontDatabase() const return mFontDb; } -QPlatformMenu *QCocoaIntegration::createPlatformMenu(QMenu *menu) const -{ - return new QCocoaMenu(menu); -} - -QPlatformMenuBar *QCocoaIntegration::createPlatformMenuBar(QMenuBar *menuBar) const -{ - return new QCocoaMenuBar(menuBar); -} - QPlatformNativeInterface *QCocoaIntegration::nativeInterface() const { return new QCocoaNativeInterface(); @@ -199,26 +191,9 @@ QPlatformAccessibility *QCocoaIntegration::accessibility() const return mAccessibility; } -bool QCocoaIntegration::usePlatformNativeDialog(QDialog *dialog) const +QPlatformTheme *QCocoaIntegration::platformTheme() const { - Q_UNUSED(dialog); - return true; -#if 0 - QFileDialog *fileDialog = qobject_cast<QFileDialog*>(dialog); - if (fileDialog) { - return true; - } - return false; -#endif -} - -QPlatformDialogHelper * QCocoaIntegration::createPlatformDialogHelper(QDialog *dialog) const -{ - QFileDialog *fileDialog = qobject_cast<QFileDialog*>(dialog); - if (fileDialog) { - return new QCocoaFileDialogHelper(fileDialog); - } - return 0; + return mPlatformTheme; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoatheme.h b/src/plugins/platforms/cocoa/qcocoatheme.h new file mode 100644 index 0000000000..8a7add73a8 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoatheme.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPLATFORMTHEME_COCOA_H +#define QPLATFORMTHEME_COCOA_H + +#include <Cocoa/Cocoa.h> + +#include <QtGui/QPlatformTheme> + +QT_BEGIN_NAMESPACE + +class QCocoaTheme : public QPlatformTheme +{ +public: + QCocoaTheme(); + ~QCocoaTheme(); + + QPlatformMenu *createPlatformMenu(QMenu *menu = 0) const; + QPlatformMenuBar *createPlatformMenuBar(QMenuBar *menuBar = 0) const; + + bool usePlatformNativeDialog(const QDialog *dialog = 0) const; + QPlatformDialogHelper *createPlatformDialogHelper(QDialog *dialog = 0) const; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm new file mode 100644 index 0000000000..ef73cc2abe --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcocoatheme.h" + +#include "qmenu_mac.h" +#include "qcocoafiledialoghelper.h" +#include <QtWidgets/QFileDialog> + +QT_BEGIN_NAMESPACE + +QCocoaTheme::QCocoaTheme() +{ + +} + +QCocoaTheme::~QCocoaTheme() +{ + +} + +QPlatformMenu *QCocoaTheme::createPlatformMenu(QMenu *menu) const +{ + return new QCocoaMenu(menu); +} + +QPlatformMenuBar *QCocoaTheme::createPlatformMenuBar(QMenuBar *menuBar) const +{ + return new QCocoaMenuBar(menuBar); +} + + +bool QCocoaTheme::usePlatformNativeDialog(const QDialog *dialog) const +{ + Q_UNUSED(dialog); + return true; +#if 0 + QFileDialog *fileDialog = qobject_cast<QFileDialog*>(dialog); + if (fileDialog) { + return true; + } + return false; +#endif +} + +QPlatformDialogHelper * QCocoaTheme::createPlatformDialogHelper(QDialog *dialog) const +{ + QFileDialog *fileDialog = qobject_cast<QFileDialog*>(dialog); + if (fileDialog) { + return new QCocoaFileDialogHelper(fileDialog); + } + return 0; +} + +QT_END_NAMESPACE |