diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2012-01-26 11:29:24 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-27 21:17:14 +0100 |
commit | 692a1babe53c342e9f5435517a1265765f77f676 (patch) | |
tree | 5383327f93a82fa8b183c1c27ec7efef2df2db99 /src/plugins/platforms/windows | |
parent | b3dda7c5bfcc22ebbd443c667dad58112ecddb4b (diff) |
Decouple QPlatformTheme from QDialog.
- Use an enumeration for the dialog type.
- Implemented on Windows and Mac
Reviewed-by: Morten Johan Sorvig <morten.sorvig@nokia.com>
Change-Id: I213748a08168efbabc2ac0106308e97ff19d19c0
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/plugins/platforms/windows')
4 files changed, 27 insertions, 44 deletions
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index ceb983d22b..cdb1505dad 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -341,17 +341,6 @@ void eatMouseMove() qDebug("%s triggered=%d" , __FUNCTION__, msg.message == WM_MOUSEMOVE); } -Type dialogType(const QDialog *dialog) -{ - if (qobject_cast<const QFileDialog *>(dialog)) - return FileDialog; - if (qobject_cast<const QFontDialog *>(dialog)) - return FontDialog; - if (qobject_cast<const QColorDialog *>(dialog)) - return ColorDialog; - return UnknownType; -} - } // namespace QWindowsDialogs /*! @@ -1359,40 +1348,36 @@ QWindowsNativeDialogBase *QWindowsColorDialogHelper::createNativeDialog() namespace QWindowsDialogs { // QWindowsDialogHelperBase creation functions -bool useHelper(const QDialog *dialog) +bool useHelper(QPlatformTheme::DialogType type) { - if (dialog) { - switch (QWindowsDialogs::dialogType(dialog)) { - case QWindowsDialogs::FileDialog: - return true; - case QWindowsDialogs::ColorDialog: + switch (type) { + case QPlatformTheme::FileDialog: + return true; + break; + case QPlatformTheme::ColorDialog: #ifdef USE_NATIVE_COLOR_DIALOG - return true; + return true; +#else + break; #endif - case QWindowsDialogs::FontDialog: - case QWindowsDialogs::UnknownType: - break; - } + case QPlatformTheme::FontDialog: + break; } return false; } -QPlatformDialogHelper *createHelper(QDialog *dialog) +QPlatformDialogHelper *createHelper(QPlatformTheme::DialogType type) { - if (QWindowsContext::verboseDialogs) - qDebug("%s %p %s" , __FUNCTION__, dialog, dialog->metaObject()->className()); - if (!dialog) - return 0; - - switch (QWindowsDialogs::dialogType(dialog)) { - case QWindowsDialogs::FileDialog: + switch (type) { + case QPlatformTheme::FileDialog: return new QWindowsFileDialogHelper(); - case QWindowsDialogs::ColorDialog: + case QPlatformTheme::ColorDialog: #ifdef USE_NATIVE_COLOR_DIALOG return new QWindowsColorDialogHelper(); +#else + break; #endif - case QWindowsDialogs::FontDialog: - case QWindowsDialogs::UnknownType: + case QPlatformTheme::FontDialog: break; } return 0; diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.h b/src/plugins/platforms/windows/qwindowsdialoghelpers.h index ea5aafe2ca..58cd912510 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.h +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.h @@ -46,6 +46,7 @@ #include "qtwindows_additional.h" #include <QtWidgets/qplatformdialoghelper_qpa.h> +#include <QtGui/QPlatformTheme> #include <QtCore/QStringList> QT_BEGIN_NAMESPACE @@ -56,13 +57,10 @@ class QWindowsNativeDialogBase; namespace QWindowsDialogs { - enum Type { UnknownType, ColorDialog, FontDialog, FileDialog }; - - Type dialogType(const QDialog *dialog); void eatMouseMove(); - bool useHelper(const QDialog *dialog = 0); - QPlatformDialogHelper *createHelper(QDialog *dialog = 0); + bool useHelper(QPlatformTheme::DialogType type); + QPlatformDialogHelper *createHelper(QPlatformTheme::DialogType type); } // namespace QWindowsDialogs template <class BaseClass> diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 42a7e5af53..2a622b5fc8 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -81,14 +81,14 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const return QVariant(); } -bool QWindowsTheme::usePlatformNativeDialog(const QDialog *dialog) const +bool QWindowsTheme::usePlatformNativeDialog(DialogType type) const { - return QWindowsDialogs::useHelper(dialog); + return QWindowsDialogs::useHelper(type); } -QPlatformDialogHelper *QWindowsTheme::createPlatformDialogHelper(QDialog *dialog) const +QPlatformDialogHelper *QWindowsTheme::createPlatformDialogHelper(DialogType type) const { - return QWindowsDialogs::createHelper(dialog); + return QWindowsDialogs::createHelper(type); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h index 50f4e0d8ed..0d72d0ef87 100644 --- a/src/plugins/platforms/windows/qwindowstheme.h +++ b/src/plugins/platforms/windows/qwindowstheme.h @@ -51,8 +51,8 @@ class QWindowsTheme : public QPlatformTheme public: QWindowsTheme(); - virtual bool usePlatformNativeDialog(const QDialog *dialog = 0) const; - virtual QPlatformDialogHelper *createPlatformDialogHelper(QDialog *dialog = 0) const; + virtual bool usePlatformNativeDialog(DialogType type) const; + virtual QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const; virtual QVariant themeHint(ThemeHint) const; }; |