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/widgets/dialogs/qdialog.cpp | |
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/widgets/dialogs/qdialog.cpp')
-rw-r--r-- | src/widgets/dialogs/qdialog.cpp | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 66f7870ce1..92cec3ef85 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -39,8 +39,9 @@ ** ****************************************************************************/ -#include "qdialog.h" - +#include "qcolordialog.h" +#include "qfontdialog.h" +#include "qfiledialog.h" #include "qevent.h" #include "qdesktopwidget.h" @@ -59,22 +60,36 @@ QT_BEGIN_NAMESPACE +static inline int themeDialogType(const QDialog *dialog) +{ + if (qobject_cast<const QFileDialog *>(dialog)) + return QPlatformTheme::FileDialog; + if (qobject_cast<const QColorDialog *>(dialog)) + return QPlatformTheme::ColorDialog; + if (qobject_cast<const QFontDialog *>(dialog)) + return QPlatformTheme::FontDialog; + return -1; +} + QPlatformDialogHelper *QDialogPrivate::platformHelper() const { // Delayed creation of the platform, ensuring that // that qobject_cast<> on the dialog works in the plugin. if (!m_platformHelperCreated) { - QDialogPrivate *ncThis = const_cast<QDialogPrivate *>(this); m_platformHelperCreated = true; + QDialogPrivate *ncThis = const_cast<QDialogPrivate *>(this); QDialog *dialog = ncThis->q_func(); - m_platformHelper = QGuiApplicationPrivate::platformTheme() - ->createPlatformDialogHelper(dialog); - if (m_platformHelper) { - QObject::connect(m_platformHelper, SIGNAL(accept()), dialog, SLOT(accept())); - QObject::connect(m_platformHelper, SIGNAL(reject()), dialog, SLOT(reject())); - QObject::connect(m_platformHelper, SIGNAL(launchNativeAppModalPanel()), - dialog, SLOT(_q_platformRunNativeAppModalPanel())); - ncThis->initHelper(m_platformHelper); + const int type = themeDialogType(dialog); + if (type >= 0) { + m_platformHelper = QGuiApplicationPrivate::platformTheme() + ->createPlatformDialogHelper(static_cast<QPlatformTheme::DialogType>(type)); + if (m_platformHelper) { + QObject::connect(m_platformHelper, SIGNAL(accept()), dialog, SLOT(accept())); + QObject::connect(m_platformHelper, SIGNAL(reject()), dialog, SLOT(reject())); + QObject::connect(m_platformHelper, SIGNAL(launchNativeAppModalPanel()), + dialog, SLOT(_q_platformRunNativeAppModalPanel())); + ncThis->initHelper(m_platformHelper); + } } } return m_platformHelper; |