summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-11-11 14:50:20 +0100
committerQt by Nokia <qt-info@nokia.com>2011-11-11 15:22:02 +0100
commit4e732b87d2b898b9720bd128247beb202fb4aaff (patch)
treefa338154584c8c6e2feaa7e88b2316793799db51 /src/plugins/platforms/windows
parentc92d6130fe9df1dc6b42b9d66627cc905e13519b (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/windows')
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.cpp20
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.h4
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp15
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.h6
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp61
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.h60
-rw-r--r--src/plugins/platforms/windows/windows.pro18
7 files changed, 150 insertions, 34 deletions
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
index 82fbd8c712..bd10efede1 100644
--- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
@@ -1317,16 +1317,18 @@ namespace QWindowsDialogs {
// QWindowsDialogHelperBase creation functions
bool useHelper(const QDialog *dialog)
{
- switch (QWindowsDialogs::dialogType(dialog)) {
- case QWindowsDialogs::FileDialog:
- return true;
- case QWindowsDialogs::ColorDialog:
+ if (dialog) {
+ switch (QWindowsDialogs::dialogType(dialog)) {
+ case QWindowsDialogs::FileDialog:
+ return true;
+ case QWindowsDialogs::ColorDialog:
#ifdef USE_NATIVE_COLOR_DIALOG
- return true;
+ return true;
#endif
- case QWindowsDialogs::FontDialog:
- case QWindowsDialogs::UnknownType:
- break;
+ case QWindowsDialogs::FontDialog:
+ case QWindowsDialogs::UnknownType:
+ break;
+ }
}
return false;
}
@@ -1335,6 +1337,8 @@ QPlatformDialogHelper *createHelper(QDialog *dialog)
{
if (QWindowsContext::verboseDialogs)
qDebug("%s %p %s" , __FUNCTION__, dialog, dialog->metaObject()->className());
+ if (!dialog)
+ return 0;
switch (QWindowsDialogs::dialogType(dialog)) {
case QWindowsDialogs::FileDialog:
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.h b/src/plugins/platforms/windows/qwindowsdialoghelpers.h
index 99f3c0b2d2..96c03bbaec 100644
--- a/src/plugins/platforms/windows/qwindowsdialoghelpers.h
+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.h
@@ -61,8 +61,8 @@ namespace QWindowsDialogs
Type dialogType(const QDialog *dialog);
void eatMouseMove();
- bool useHelper(const QDialog *dialog);
- QPlatformDialogHelper *createHelper(QDialog *dialog);
+ bool useHelper(const QDialog *dialog = 0);
+ QPlatformDialogHelper *createHelper(QDialog *dialog = 0);
} // namespace QWindowsDialogs
template <class BaseClass>
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index 4ffbdb7491..cebb17c9c7 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -45,6 +45,7 @@
#include "qwindowscontext.h"
#include "qwindowsglcontext.h"
#include "qwindowsscreen.h"
+#include "qwindowstheme.h"
#ifndef QT_NO_FREETYPE
#include "qwindowsfontdatabase_ft.h"
#endif
@@ -54,7 +55,6 @@
#include "qwindowsdrag.h"
#include "qwindowsinputcontext.h"
#include "qwindowsaccessibility.h"
-#include "qwindowsdialoghelpers.h"
#include <QtGui/QPlatformNativeInterface>
#include <QtGui/QWindowSystemInterface>
@@ -159,6 +159,7 @@ struct QWindowsIntegrationPrivate
QOpenGLStaticContextPtr m_staticOpenGLContext;
QWindowsInputContext m_inputContext;
QWindowsAccessibility m_accessibility;
+ QWindowsTheme m_theme;
};
QWindowsIntegrationPrivate::QWindowsIntegrationPrivate()
@@ -322,17 +323,9 @@ QAbstractEventDispatcher * QWindowsIntegration::guiThreadEventDispatcher() const
return d->m_eventDispatcher;
}
-#ifdef QT_WIDGETS_LIB
-bool QWindowsIntegration::usePlatformNativeDialog(QDialog *dialog) const
+QPlatformTheme *QWindowsIntegration::platformTheme() const
{
- return QWindowsDialogs::useHelper(dialog);
+ return &d->m_theme;
}
-QPlatformDialogHelper *QWindowsIntegration::createPlatformDialogHelper(QDialog *dialog) const
-{
- return QWindowsDialogs::createHelper(dialog);
-}
-
-#endif // QT_WIDGETS_LIB
-
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h
index ad5493015a..1c2a714fcb 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.h
+++ b/src/plugins/platforms/windows/qwindowsintegration.h
@@ -69,13 +69,9 @@ public:
virtual QPlatformAccessibility *accessibility() const;
virtual QPlatformNativeInterface *nativeInterface() const;
virtual QPlatformFontDatabase *fontDatabase() const;
+ virtual QPlatformTheme *platformTheme() const;
virtual QVariant styleHint(StyleHint hint) const;
-#ifdef QT_WIDGETS_LIB
- virtual bool usePlatformNativeDialog(QDialog *dialog = 0) const;
- virtual QPlatformDialogHelper *createPlatformDialogHelper(QDialog *dialog = 0) const;
-#endif // QT_WIDGETS_LIB
-
static QWindowsIntegration *instance();
private:
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
new file mode 100644
index 0000000000..a7001719fe
--- /dev/null
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** 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 "qwindowstheme.h"
+#include "qwindowsdialoghelpers.h"
+
+QT_BEGIN_NAMESPACE
+
+QWindowsTheme::QWindowsTheme()
+{
+}
+
+bool QWindowsTheme::usePlatformNativeDialog(const QDialog *dialog) const
+{
+ return QWindowsDialogs::useHelper(dialog);
+}
+
+QPlatformDialogHelper *QWindowsTheme::createPlatformDialogHelper(QDialog *dialog) const
+{
+ return QWindowsDialogs::createHelper(dialog);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h
new file mode 100644
index 0000000000..057e30d262
--- /dev/null
+++ b/src/plugins/platforms/windows/qwindowstheme.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** 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 QWINDOWSTHEME_H
+#define QWINDOWSTHEME_H
+
+#include <QtGui/QPlatformTheme>
+
+QT_BEGIN_NAMESPACE
+
+class QWindowsTheme : public QPlatformTheme
+{
+public:
+ QWindowsTheme();
+
+ virtual bool usePlatformNativeDialog(const QDialog *dialog = 0) const;
+ virtual QPlatformDialogHelper *createPlatformDialogHelper(QDialog *dialog = 0) const;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWINDOWSTHEME_H
diff --git a/src/plugins/platforms/windows/windows.pro b/src/plugins/platforms/windows/windows.pro
index 627df4ab8e..33ca07d134 100644
--- a/src/plugins/platforms/windows/windows.pro
+++ b/src/plugins/platforms/windows/windows.pro
@@ -4,6 +4,8 @@ load(qt_plugin)
QT *= core-private
QT *= gui-private
QT *= platformsupport-private
+# ### fixme: Remove widgets dependencies of dialog helpers
+QT *= widgets
INCLUDEPATH += ../../../3rdparty/harfbuzz/src
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
@@ -11,6 +13,8 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
# Note: OpenGL32 must precede Gdi32 as it overwrites some functions.
LIBS *= -lOpenGL32 -lGdi32 -lUser32 -lOle32 -lWinspool -lImm32 -lWinmm -lOleaut32
win32-g++: LIBS *= -luuid
+# For the dialog helpers:
+LIBS *= -lshlwapi -lShell32
contains(QT_CONFIG, directwrite) {
LIBS *= -ldwrite
@@ -41,7 +45,9 @@ SOURCES += \
qwindowscursor.cpp \
pixmaputils.cpp \
qwindowsinputcontext.cpp \
- qwindowsaccessibility.cpp
+ qwindowsaccessibility.cpp \
+ qwindowstheme.cpp \
+ qwindowsdialoghelpers.cpp
HEADERS += \
qwindowsnativeimage.h \
@@ -67,13 +73,9 @@ HEADERS += \
pixmaputils.h \
array.h \
qwindowsinputcontext.h \
- qwindowsaccessibility.h
-
-# Dialog helper: Should be used only if QtWidgets is built
-QT *= widgets
-HEADERS += qwindowsdialoghelpers.h
-SOURCES += qwindowsdialoghelpers.cpp
-LIBS += -lshlwapi -lShell32
+ qwindowsaccessibility.h \
+ qwindowstheme.h \
+ qwindowsdialoghelpers.h
contains(QT_CONFIG, freetype) {
DEFINES *= QT_NO_FONTCONFIG