summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qplatformtheme_qpa.cpp8
-rw-r--r--src/gui/kernel/qplatformtheme_qpa.h11
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.h3
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm18
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.h4
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.mm17
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.cpp51
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.h8
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp8
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.h4
-rw-r--r--src/widgets/dialogs/qdialog.cpp37
11 files changed, 78 insertions, 91 deletions
diff --git a/src/gui/kernel/qplatformtheme_qpa.cpp b/src/gui/kernel/qplatformtheme_qpa.cpp
index 2f681e5cd4..e3cf637694 100644
--- a/src/gui/kernel/qplatformtheme_qpa.cpp
+++ b/src/gui/kernel/qplatformtheme_qpa.cpp
@@ -83,15 +83,15 @@ QPlatformMenuBar *QPlatformTheme::createPlatformMenuBar(QMenuBar *menuBar) const
return 0;
}
-bool QPlatformTheme::usePlatformNativeDialog(const QDialog *dialog) const
+bool QPlatformTheme::usePlatformNativeDialog(DialogType type) const
{
- Q_UNUSED(dialog);
+ Q_UNUSED(type);
return false;
}
-QPlatformDialogHelper *QPlatformTheme::createPlatformDialogHelper(QDialog *dialog) const
+QPlatformDialogHelper *QPlatformTheme::createPlatformDialogHelper(DialogType type) const
{
- Q_UNUSED(dialog);
+ Q_UNUSED(type);
return 0;
}
diff --git a/src/gui/kernel/qplatformtheme_qpa.h b/src/gui/kernel/qplatformtheme_qpa.h
index 42151a1270..215aa319fe 100644
--- a/src/gui/kernel/qplatformtheme_qpa.h
+++ b/src/gui/kernel/qplatformtheme_qpa.h
@@ -54,7 +54,6 @@ class QMenuBar;
class QPlatformMenu;
class QPlatformMenuBar;
class QPlatformDialogHelper;
-class QDialog;
class QVariant;
class Q_GUI_EXPORT QPlatformTheme
@@ -66,11 +65,17 @@ public:
MaximumScrollBarDragDistance
};
+ enum DialogType {
+ FileDialog,
+ ColorDialog,
+ FontDialog
+ };
+
virtual QPlatformMenu *createPlatformMenu(QMenu *menu = 0) const;
virtual QPlatformMenuBar *createPlatformMenuBar(QMenuBar *menuBar = 0) const;
- 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 hint) const;
};
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h
index 2589e13d84..dc0c8b8f66 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h
@@ -53,7 +53,7 @@ class QFileDialogPrivate;
class QCocoaFileDialogHelper : public QPlatformFileDialogHelper
{
public:
- QCocoaFileDialogHelper(QFileDialog *dialog);
+ QCocoaFileDialogHelper();
virtual ~QCocoaFileDialogHelper();
void platformNativeDialogModalHelp();
@@ -84,7 +84,6 @@ public:
void QNSOpenSavePanelDelegate_filterSelected(int menuIndex);
private:
- QFileDialog *qtFileDialog;
void *mDelegate;
};
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
index a8944d3bbd..f7018ecae3 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
@@ -92,7 +92,6 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
NSView *mAccessoryView;
NSPopUpButton *mPopUpButton;
NSTextField *mTextField;
- QFileDialog *mFileDialog;
QCocoaFileDialogHelper *mHelper;
NSString *mCurrentDir;
@@ -126,12 +125,10 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
- (id)initWithAcceptMode:
(const QString &)selectFile
- fileDialog:(QFileDialog *)fileDialog
options:(SharedPointerFileDialogOptions)options
helper:(QCocoaFileDialogHelper *)helper
{
self = [super init];
- mFileDialog = fileDialog;
mOptions = options;
if (mOptions->acceptMode() == QT_PREPEND_NAMESPACE(QFileDialogOptions::AcceptOpen)){
mOpenPanel = [NSOpenPanel openPanel];
@@ -149,7 +146,7 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
mLastFilterCheckPath = new QString;
mQDirFilterEntryList = new QStringList;
mNameFilterDropDownList = new QStringList(mOptions->nameFilters());
- QString selectedVisualNameFilter = mFileDialog->selectedNameFilter();
+ QString selectedVisualNameFilter = mOptions->initiallySelectedNameFilter();
mSelectedNameFilter = new QStringList([self findStrippedFilterWithVisualFilterName:selectedVisualNameFilter]);
QFileInfo sel(selectFile);
@@ -518,8 +515,8 @@ static bool qt_mac_is_macsheet(const QWidget *w)
return w->parentWidget() && (modality == Qt::WindowModal || w->windowType() == Qt::Sheet);
}
-QCocoaFileDialogHelper::QCocoaFileDialogHelper(QFileDialog *dialog) :
- qtFileDialog(dialog), mDelegate(0)
+QCocoaFileDialogHelper::QCocoaFileDialogHelper()
+ :mDelegate(0)
{
}
@@ -624,16 +621,12 @@ void QCocoaFileDialogHelper::deleteNativeDialog_sys()
void QCocoaFileDialogHelper::hide_sys()
{
- if (!qtFileDialog->isHidden())
- hideCocoaFilePanel();
+ hideCocoaFilePanel();
}
bool QCocoaFileDialogHelper::show_sys(ShowFlags /* flags */, Qt::WindowFlags windowFlags, QWindow *parent)
{
// Q_Q(QFileDialog);
- if (!qtFileDialog->isHidden())
- return false;
-
if (windowFlags & Qt::WindowStaysOnTopHint) {
// The native file dialog tries all it can to stay
// on the NSModalPanel level. And it might also show
@@ -657,7 +650,6 @@ void QCocoaFileDialogHelper::createNSOpenSavePanelDelegate()
QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = [[QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) alloc]
initWithAcceptMode:
selection
- fileDialog:qtFileDialog
options:opts
helper:this];
@@ -669,7 +661,7 @@ bool QCocoaFileDialogHelper::showCocoaFilePanel(QWindow *parent)
// Q_Q(QFileDialog);
createNSOpenSavePanelDelegate();
QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
- if (qt_mac_is_macsheet(qtFileDialog))
+ if (0 /*qt_mac_is_macsheet(qtFileDialog)*/) // ### sheet support.
[delegate showWindowModalSheet:parent];
else
[delegate showModelessPanel];
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.h b/src/plugins/platforms/cocoa/qcocoatheme.h
index 7de6790617..e89bb44a11 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.h
+++ b/src/plugins/platforms/cocoa/qcocoatheme.h
@@ -57,8 +57,8 @@ public:
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;
+ bool usePlatformNativeDialog(DialogType dialogType) const;
+ QPlatformDialogHelper *createPlatformDialogHelper(DialogType dialogType) const;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm
index 326d9988c3..2e5d976ec2 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.mm
+++ b/src/plugins/platforms/cocoa/qcocoatheme.mm
@@ -68,24 +68,17 @@ QPlatformMenuBar *QCocoaTheme::createPlatformMenuBar(QMenuBar *menuBar) const
}
-bool QCocoaTheme::usePlatformNativeDialog(const QDialog *dialog) const
+bool QCocoaTheme::usePlatformNativeDialog(DialogType dialogType) const
{
- Q_UNUSED(dialog);
- return true;
-#if 0
- QFileDialog *fileDialog = qobject_cast<QFileDialog*>(dialog);
- if (fileDialog) {
+ if (dialogType == QPlatformTheme::FileDialog)
return true;
- }
return false;
-#endif
}
-QPlatformDialogHelper * QCocoaTheme::createPlatformDialogHelper(QDialog *dialog) const
+QPlatformDialogHelper * QCocoaTheme::createPlatformDialogHelper(DialogType dialogType) const
{
- QFileDialog *fileDialog = qobject_cast<QFileDialog*>(dialog);
- if (fileDialog) {
- return new QCocoaFileDialogHelper(fileDialog);
+ if (dialogType == QPlatformTheme::FileDialog) {
+ return new QCocoaFileDialogHelper();
}
return 0;
}
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;
};
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;