summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2014-02-07 14:04:37 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-15 10:43:20 +0100
commit760a771fce3758fe34b1f3ce8a22f283bb24b326 (patch)
treefacfdedcfe17c21c8ae2de061ea79f6ff60f3fe1 /src
parentf8dbed12266c42785c1e4758eed05833ec035f33 (diff)
Consolidate StandardButton, ButtonRole and related static functions
Moving them into QPlatformDialogHelper for the convenience of both widgets and QtQuick.Dialogs. The main reason is to ensure that QtQuick.Dialogs does not need to depend on the widgets module, in order to re-implement the button box concept in a generic dialog. Change-Id: If400d215338d7cb6dade39d9de60e50b5e7515ef Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qplatformdialoghelper.cpp88
-rw-r--r--src/gui/kernel/qplatformdialoghelper.h120
-rw-r--r--src/gui/kernel/qplatformtheme.cpp38
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp14
-rw-r--r--src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp6
-rw-r--r--src/plugins/platforms/android/qandroidplatformtheme.cpp8
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.mm4
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp2
-rw-r--r--src/plugins/platforms/winrt/qwinrtplatformmessagedialoghelper.cpp10
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp12
-rw-r--r--src/widgets/dialogs/qmessagebox.h7
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.cpp122
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.h5
13 files changed, 235 insertions, 201 deletions
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp
index 5ddd718e69..c119b90001 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -62,6 +62,70 @@ QT_BEGIN_NAMESPACE
*/
+static const quint32 buttonRoleLayouts[2][5][14] =
+{
+ // Qt::Horizontal
+ {
+ // WinLayout
+ { QPlatformDialogHelper::ResetRole, QPlatformDialogHelper::Stretch, QPlatformDialogHelper::YesRole, QPlatformDialogHelper::AcceptRole,
+ QPlatformDialogHelper::AlternateRole, QPlatformDialogHelper::DestructiveRole, QPlatformDialogHelper::NoRole,
+ QPlatformDialogHelper::ActionRole, QPlatformDialogHelper::RejectRole, QPlatformDialogHelper::ApplyRole,
+ QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL },
+
+ // MacLayout
+ { QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::ResetRole, QPlatformDialogHelper::ApplyRole, QPlatformDialogHelper::ActionRole,
+ QPlatformDialogHelper::Stretch, QPlatformDialogHelper::DestructiveRole | QPlatformDialogHelper::Reverse,
+ QPlatformDialogHelper::AlternateRole | QPlatformDialogHelper::Reverse, QPlatformDialogHelper::RejectRole | QPlatformDialogHelper::Reverse,
+ QPlatformDialogHelper::AcceptRole | QPlatformDialogHelper::Reverse, QPlatformDialogHelper::NoRole | QPlatformDialogHelper::Reverse,
+ QPlatformDialogHelper::YesRole | QPlatformDialogHelper::Reverse, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL },
+
+ // KdeLayout
+ { QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::ResetRole, QPlatformDialogHelper::Stretch, QPlatformDialogHelper::YesRole,
+ QPlatformDialogHelper::NoRole, QPlatformDialogHelper::ActionRole, QPlatformDialogHelper::AcceptRole, QPlatformDialogHelper::AlternateRole,
+ QPlatformDialogHelper::ApplyRole, QPlatformDialogHelper::DestructiveRole, QPlatformDialogHelper::RejectRole, QPlatformDialogHelper::EOL },
+
+ // GnomeLayout
+ { QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::ResetRole, QPlatformDialogHelper::Stretch, QPlatformDialogHelper::ActionRole,
+ QPlatformDialogHelper::ApplyRole | QPlatformDialogHelper::Reverse, QPlatformDialogHelper::DestructiveRole | QPlatformDialogHelper::Reverse,
+ QPlatformDialogHelper::AlternateRole | QPlatformDialogHelper::Reverse, QPlatformDialogHelper::RejectRole | QPlatformDialogHelper::Reverse,
+ QPlatformDialogHelper::AcceptRole | QPlatformDialogHelper::Reverse, QPlatformDialogHelper::NoRole | QPlatformDialogHelper::Reverse,
+ QPlatformDialogHelper::YesRole | QPlatformDialogHelper::Reverse, QPlatformDialogHelper::EOL },
+
+ // MacModelessLayout
+ { QPlatformDialogHelper::ResetRole, QPlatformDialogHelper::ApplyRole, QPlatformDialogHelper::ActionRole, QPlatformDialogHelper::Stretch,
+ QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL,
+ QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL }
+ },
+
+ // Qt::Vertical
+ {
+ // WinLayout
+ { QPlatformDialogHelper::ActionRole, QPlatformDialogHelper::YesRole, QPlatformDialogHelper::AcceptRole, QPlatformDialogHelper::AlternateRole,
+ QPlatformDialogHelper::DestructiveRole, QPlatformDialogHelper::NoRole, QPlatformDialogHelper::RejectRole, QPlatformDialogHelper::ApplyRole, QPlatformDialogHelper::ResetRole,
+ QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::Stretch, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL },
+
+ // MacLayout
+ { QPlatformDialogHelper::YesRole, QPlatformDialogHelper::NoRole, QPlatformDialogHelper::AcceptRole, QPlatformDialogHelper::RejectRole,
+ QPlatformDialogHelper::AlternateRole, QPlatformDialogHelper::DestructiveRole, QPlatformDialogHelper::Stretch, QPlatformDialogHelper::ActionRole, QPlatformDialogHelper::ApplyRole,
+ QPlatformDialogHelper::ResetRole, QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL },
+
+ // KdeLayout
+ { QPlatformDialogHelper::AcceptRole, QPlatformDialogHelper::AlternateRole, QPlatformDialogHelper::ApplyRole, QPlatformDialogHelper::ActionRole,
+ QPlatformDialogHelper::YesRole, QPlatformDialogHelper::NoRole, QPlatformDialogHelper::Stretch, QPlatformDialogHelper::ResetRole,
+ QPlatformDialogHelper::DestructiveRole, QPlatformDialogHelper::RejectRole, QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::EOL },
+
+ // GnomeLayout
+ { QPlatformDialogHelper::YesRole, QPlatformDialogHelper::NoRole, QPlatformDialogHelper::AcceptRole, QPlatformDialogHelper::RejectRole,
+ QPlatformDialogHelper::AlternateRole, QPlatformDialogHelper::DestructiveRole, QPlatformDialogHelper::ApplyRole, QPlatformDialogHelper::ActionRole, QPlatformDialogHelper::Stretch,
+ QPlatformDialogHelper::ResetRole, QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL },
+
+ // MacModelessLayout
+ { QPlatformDialogHelper::ActionRole, QPlatformDialogHelper::ApplyRole, QPlatformDialogHelper::ResetRole, QPlatformDialogHelper::Stretch,
+ QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL,
+ QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL }
+ }
+};
+
QPlatformDialogHelper::QPlatformDialogHelper()
{
}
@@ -603,7 +667,7 @@ class QMessageDialogOptionsPrivate : public QSharedData
public:
QMessageDialogOptionsPrivate() :
icon(QMessageDialogOptions::NoIcon),
- buttons(QMessageDialogOptions::Ok)
+ buttons(QPlatformDialogHelper::Ok)
{}
QString windowTitle;
@@ -611,7 +675,7 @@ public:
QString text;
QString informativeText;
QString detailedText;
- QMessageDialogOptions::StandardButtons buttons;
+ QPlatformDialogHelper::StandardButtons buttons;
};
QMessageDialogOptions::QMessageDialogOptions() : d(new QMessageDialogOptionsPrivate)
@@ -683,17 +747,17 @@ void QMessageDialogOptions::setDetailedText(const QString &detailedText)
d->detailedText = detailedText;
}
-void QMessageDialogOptions::setStandardButtons(StandardButtons buttons)
+void QMessageDialogOptions::setStandardButtons(QPlatformDialogHelper::StandardButtons buttons)
{
d->buttons = buttons;
}
-QMessageDialogOptions::StandardButtons QMessageDialogOptions::standardButtons() const
+QPlatformDialogHelper::StandardButtons QMessageDialogOptions::standardButtons() const
{
return d->buttons;
}
-QMessageDialogOptions::ButtonRole QMessageDialogOptions::buttonRole(QMessageDialogOptions::StandardButton button)
+QPlatformDialogHelper::ButtonRole QPlatformDialogHelper::buttonRole(QPlatformDialogHelper::StandardButton button)
{
switch (button) {
case Ok:
@@ -736,6 +800,20 @@ QMessageDialogOptions::ButtonRole QMessageDialogOptions::buttonRole(QMessageDial
return InvalidRole;
}
+const quint32 *QPlatformDialogHelper::buttonLayout(Qt::Orientation orientation, ButtonLayout policy)
+{
+ if (policy == UnknownLayout) {
+#if defined (Q_OS_OSX)
+ policy = MacLayout;
+#elif defined (Q_OS_LINUX) || defined (Q_OS_UNIX)
+ policy = KdeLayout;
+#else
+ policy = WinLayout;
+#endif
+ }
+ return buttonRoleLayouts[orientation == Qt::Vertical][policy];
+}
+
/*!
\class QPlatformMessageDialogHelper
\since 5.0
diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h
index 9eeb0a6da4..87fac83d50 100644
--- a/src/gui/kernel/qplatformdialoghelper.h
+++ b/src/gui/kernel/qplatformdialoghelper.h
@@ -82,6 +82,71 @@ public:
};
enum DialogCode { Rejected, Accepted };
+ enum StandardButton {
+ // keep this in sync with QDialogButtonBox::StandardButton and QMessageBox::StandardButton
+ NoButton = 0x00000000,
+ Ok = 0x00000400,
+ Save = 0x00000800,
+ SaveAll = 0x00001000,
+ Open = 0x00002000,
+ Yes = 0x00004000,
+ YesToAll = 0x00008000,
+ No = 0x00010000,
+ NoToAll = 0x00020000,
+ Abort = 0x00040000,
+ Retry = 0x00080000,
+ Ignore = 0x00100000,
+ Close = 0x00200000,
+ Cancel = 0x00400000,
+ Discard = 0x00800000,
+ Help = 0x01000000,
+ Apply = 0x02000000,
+ Reset = 0x04000000,
+ RestoreDefaults = 0x08000000,
+
+
+ FirstButton = Ok, // internal
+ LastButton = RestoreDefaults, // internal
+ LowestBit = 10, // internal: log2(FirstButton)
+ HighestBit = 27 // internal: log2(LastButton)
+ };
+
+ Q_DECLARE_FLAGS(StandardButtons, StandardButton)
+
+ enum ButtonRole {
+ // keep this in sync with QDialogButtonBox::ButtonRole and QMessageBox::ButtonRole
+ // TODO Qt 6: make the enum copies explicit, and make InvalidRole == 0 so that
+ // AcceptRole can be or'ed with flags, and EOL can be the same as InvalidRole (null-termination)
+ InvalidRole = -1,
+ AcceptRole,
+ RejectRole,
+ DestructiveRole,
+ ActionRole,
+ HelpRole,
+ YesRole,
+ NoRole,
+ ResetRole,
+ ApplyRole,
+
+ NRoles,
+
+ RoleMask = 0x0FFFFFFF,
+ AlternateRole = 0x10000000,
+ Stretch = 0x20000000,
+ EOL = 0x40000000,
+ Reverse = 0x80000000
+ };
+
+ enum ButtonLayout {
+ // keep this in sync with QDialogButtonBox::ButtonLayout and QMessageBox::ButtonLayout
+ UnknownLayout = -1,
+ WinLayout,
+ MacLayout,
+ KdeLayout,
+ GnomeLayout,
+ MacModelessLayout
+ };
+
QPlatformDialogHelper();
virtual ~QPlatformDialogHelper();
@@ -95,6 +160,9 @@ public:
static QVariant defaultStyleHint(QPlatformDialogHelper::StyleHint hint);
+ static const quint32 *buttonLayout(Qt::Orientation orientation = Qt::Horizontal, ButtonLayout policy = UnknownLayout);
+ static ButtonRole buttonRole(StandardButton button);
+
Q_SIGNALS:
void accept();
void reject();
@@ -332,50 +400,6 @@ public:
// Keep in sync with QMessageBox::Icon
enum Icon { NoIcon, Information, Warning, Critical, Question };
- enum StandardButton {
- // keep this in sync with QDialogButtonBox::StandardButton and QMessageBox::StandardButton
- NoButton = 0x00000000,
- Ok = 0x00000400,
- Save = 0x00000800,
- SaveAll = 0x00001000,
- Open = 0x00002000,
- Yes = 0x00004000,
- YesToAll = 0x00008000,
- No = 0x00010000,
- NoToAll = 0x00020000,
- Abort = 0x00040000,
- Retry = 0x00080000,
- Ignore = 0x00100000,
- Close = 0x00200000,
- Cancel = 0x00400000,
- Discard = 0x00800000,
- Help = 0x01000000,
- Apply = 0x02000000,
- Reset = 0x04000000,
- RestoreDefaults = 0x08000000,
-
-
- FirstButton = Ok, // internal
- LastButton = RestoreDefaults // internal
- };
-
- Q_DECLARE_FLAGS(StandardButtons, StandardButton)
-
- enum ButtonRole {
- InvalidRole = -1,
- AcceptRole,
- RejectRole,
- DestructiveRole,
- ActionRole,
- HelpRole,
- YesRole,
- NoRole,
- ResetRole,
- ApplyRole,
-
- NRoles
- };
-
QMessageDialogOptions();
QMessageDialogOptions(const QMessageDialogOptions &rhs);
QMessageDialogOptions &operator=(const QMessageDialogOptions &rhs);
@@ -398,10 +422,8 @@ public:
void setDetailedText(const QString &text);
QString detailedText() const;
- void setStandardButtons(StandardButtons buttons);
- StandardButtons standardButtons() const;
-
- static ButtonRole buttonRole(StandardButton button);
+ void setStandardButtons(QPlatformDialogHelper::StandardButtons buttons);
+ QPlatformDialogHelper::StandardButtons standardButtons() const;
private:
QSharedDataPointer<QMessageDialogOptionsPrivate> d;
@@ -417,7 +439,7 @@ public:
void setOptions(const QSharedPointer<QMessageDialogOptions> &options);
Q_SIGNALS:
- void clicked(QMessageDialogOptions::StandardButton button, QMessageDialogOptions::ButtonRole role);
+ void clicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role);
private:
QSharedPointer<QMessageDialogOptions> m_options;
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
index 90edf4c49f..e12eb318dc 100644
--- a/src/gui/kernel/qplatformtheme.cpp
+++ b/src/gui/kernel/qplatformtheme.cpp
@@ -632,7 +632,7 @@ QList<QKeySequence> QPlatformTheme::keyBindings(QKeySequence::StandardKey key) c
Returns the text of a standard \a button.
\since 5.3
- \sa QMessageDialogOptions::StandardButton
+ \sa QPlatformDialogHelper::StandardButton
*/
QString QPlatformTheme::standardButtonText(int button) const
@@ -643,41 +643,41 @@ QString QPlatformTheme::standardButtonText(int button) const
QString QPlatformTheme::defaultStandardButtonText(int button)
{
switch (button) {
- case QMessageDialogOptions::Ok:
+ case QPlatformDialogHelper::Ok:
return QCoreApplication::translate("QPlatformTheme", "OK");
- case QMessageDialogOptions::Save:
+ case QPlatformDialogHelper::Save:
return QCoreApplication::translate("QPlatformTheme", "Save");
- case QMessageDialogOptions::SaveAll:
+ case QPlatformDialogHelper::SaveAll:
return QCoreApplication::translate("QPlatformTheme", "Save All");
- case QMessageDialogOptions::Open:
+ case QPlatformDialogHelper::Open:
return QCoreApplication::translate("QPlatformTheme", "Open");
- case QMessageDialogOptions::Yes:
+ case QPlatformDialogHelper::Yes:
return QCoreApplication::translate("QPlatformTheme", "&Yes");
- case QMessageDialogOptions::YesToAll:
+ case QPlatformDialogHelper::YesToAll:
return QCoreApplication::translate("QPlatformTheme", "Yes to &All");
- case QMessageDialogOptions::No:
+ case QPlatformDialogHelper::No:
return QCoreApplication::translate("QPlatformTheme", "&No");
- case QMessageDialogOptions::NoToAll:
+ case QPlatformDialogHelper::NoToAll:
return QCoreApplication::translate("QPlatformTheme", "N&o to All");
- case QMessageDialogOptions::Abort:
+ case QPlatformDialogHelper::Abort:
return QCoreApplication::translate("QPlatformTheme", "Abort");
- case QMessageDialogOptions::Retry:
+ case QPlatformDialogHelper::Retry:
return QCoreApplication::translate("QPlatformTheme", "Retry");
- case QMessageDialogOptions::Ignore:
+ case QPlatformDialogHelper::Ignore:
return QCoreApplication::translate("QPlatformTheme", "Ignore");
- case QMessageDialogOptions::Close:
+ case QPlatformDialogHelper::Close:
return QCoreApplication::translate("QPlatformTheme", "Close");
- case QMessageDialogOptions::Cancel:
+ case QPlatformDialogHelper::Cancel:
return QCoreApplication::translate("QPlatformTheme", "Cancel");
- case QMessageDialogOptions::Discard:
+ case QPlatformDialogHelper::Discard:
return QCoreApplication::translate("QPlatformTheme", "Discard");
- case QMessageDialogOptions::Help:
+ case QPlatformDialogHelper::Help:
return QCoreApplication::translate("QPlatformTheme", "Help");
- case QMessageDialogOptions::Apply:
+ case QPlatformDialogHelper::Apply:
return QCoreApplication::translate("QPlatformTheme", "Apply");
- case QMessageDialogOptions::Reset:
+ case QPlatformDialogHelper::Reset:
return QCoreApplication::translate("QPlatformTheme", "Reset");
- case QMessageDialogOptions::RestoreDefaults:
+ case QPlatformDialogHelper::RestoreDefaults:
return QCoreApplication::translate("QPlatformTheme", "Restore Defaults");
default:
break;
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index c72815ca1b..4a1d67f4b5 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -408,7 +408,7 @@ QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
case QPlatformTheme::DialogButtonBoxButtonsHaveIcons:
return QVariant(true);
case QPlatformTheme::DialogButtonBoxLayout:
- return QVariant(2); // QDialogButtonBox::KdeLayout
+ return QVariant(QPlatformDialogHelper::KdeLayout);
case QPlatformTheme::ToolButtonStyle:
return QVariant(d->toolButtonStyle);
case QPlatformTheme::ToolBarIconSize:
@@ -504,7 +504,7 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
case QPlatformTheme::DialogButtonBoxButtonsHaveIcons:
return QVariant(true);
case QPlatformTheme::DialogButtonBoxLayout:
- return QVariant(3); // QDialogButtonBox::GnomeLayout
+ return QVariant(QPlatformDialogHelper::GnomeLayout);
case QPlatformTheme::SystemIconThemeName:
case QPlatformTheme::SystemIconFallbackThemeName:
return QVariant(QString(QStringLiteral("gnome")));
@@ -541,15 +541,15 @@ const QFont *QGnomeTheme::font(Font type) const
QString QGnomeTheme::standardButtonText(int button) const
{
switch (button) {
- case QMessageDialogOptions::Ok:
+ case QPlatformDialogHelper::Ok:
return QCoreApplication::translate("QGnomeTheme", "&OK");
- case QMessageDialogOptions::Save:
+ case QPlatformDialogHelper::Save:
return QCoreApplication::translate("QGnomeTheme", "&Save");
- case QMessageDialogOptions::Cancel:
+ case QPlatformDialogHelper::Cancel:
return QCoreApplication::translate("QGnomeTheme", "&Cancel");
- case QMessageDialogOptions::QMessageDialogOptions::Close:
+ case QPlatformDialogHelper::Close:
return QCoreApplication::translate("QGnomeTheme", "&Close");
- case QMessageDialogOptions::Discard:
+ case QPlatformDialogHelper::Discard:
return QCoreApplication::translate("QGnomeTheme", "Close without Saving");
default:
break;
diff --git a/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp b/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp
index 4b99f2ce73..fa123827e7 100644
--- a/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp
+++ b/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp
@@ -92,7 +92,7 @@ bool QAndroidPlatformMessageDialogHelper::show(Qt::WindowFlags windowFlags
if (!str.isEmpty())
m_javaMessageDialog.callMethod<void>("setDetailedText", "(Ljava/lang/String;)V", QJNIObjectPrivate::fromString(str).object());
- for (int i = QMessageDialogOptions::FirstButton; i < QMessageDialogOptions::LastButton; i<<=1) {
+ for (int i = QPlatformDialogHelper::FirstButton; i < QPlatformDialogHelper::LastButton; i<<=1) {
if ( opt->standardButtons() & i ) {
const QString text = QGuiApplicationPrivate::platformTheme()->standardButtonText(i);
m_javaMessageDialog.callMethod<void>("addButton", "(ILjava/lang/String;)V", i, QJNIObjectPrivate::fromString(text).object());
@@ -120,8 +120,8 @@ void QAndroidPlatformMessageDialogHelper::dialogResult(int buttonID)
return;
}
- QMessageDialogOptions::StandardButton standardButton = static_cast<QMessageDialogOptions::StandardButton>(buttonID);
- QMessageDialogOptions::ButtonRole role = QMessageDialogOptions::buttonRole(standardButton);
+ QPlatformDialogHelper::StandardButton standardButton = static_cast<QPlatformDialogHelper::StandardButton>(buttonID);
+ QPlatformDialogHelper::ButtonRole role = QPlatformDialogHelper::buttonRole(standardButton);
emit clicked(standardButton, role);
}
diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp
index 5468c00a57..039b19f861 100644
--- a/src/plugins/platforms/android/qandroidplatformtheme.cpp
+++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp
@@ -188,13 +188,13 @@ QVariant QAndroidPlatformTheme::themeHint(ThemeHint hint) const
QString QAndroidPlatformTheme::standardButtonText(int button) const
{
switch (button) {
- case QMessageDialogOptions::Yes:
+ case QPlatformDialogHelper::Yes:
return QCoreApplication::translate("QAndroidPlatformTheme", "Yes");
- case QMessageDialogOptions::YesToAll:
+ case QPlatformDialogHelper::YesToAll:
return QCoreApplication::translate("QAndroidPlatformTheme", "Yes to All");
- case QMessageDialogOptions::No:
+ case QPlatformDialogHelper::No:
return QCoreApplication::translate("QAndroidPlatformTheme", "No");
- case QMessageDialogOptions::NoToAll:
+ case QPlatformDialogHelper::NoToAll:
return QCoreApplication::translate("QAndroidPlatformTheme", "No to All");
}
return QPlatformTheme::standardButtonText(button);
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm
index 109649f24e..dce1671800 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.mm
+++ b/src/plugins/platforms/cocoa/qcocoatheme.mm
@@ -279,7 +279,7 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const
case QPlatformTheme::StyleNames:
return QStringList(QStringLiteral("macintosh"));
case QPlatformTheme::DialogButtonBoxLayout:
- return QVariant(1); // QDialogButtonBox::MacLayout
+ return QVariant(QPlatformDialogHelper::MacLayout);
case KeyboardScheme:
return QVariant(int(MacKeyboardScheme));
case TabAllWidgets:
@@ -303,7 +303,7 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const
QString QCocoaTheme::standardButtonText(int button) const
{
- return button == QMessageDialogOptions::Discard ? msgDialogButtonDiscard() : QPlatformTheme::standardButtonText(button);
+ return button == QPlatformDialogHelper::Discard ? msgDialogButtonDiscard() : QPlatformTheme::standardButtonText(button);
}
QPlatformMenuItem *QCocoaTheme::createPlatformMenuItem() const
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index 988e34ea6d..6349c1e355 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -354,7 +354,7 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const
case UseFullScreenForPopupMenu:
return QVariant(true);
case DialogButtonBoxLayout:
- return QVariant(int(0)); // QDialogButtonBox::WinLayout
+ return QVariant(QPlatformDialogHelper::WinLayout);
case IconThemeSearchPaths:
return QVariant(iconThemeSearchPaths());
case StyleNames:
diff --git a/src/plugins/platforms/winrt/qwinrtplatformmessagedialoghelper.cpp b/src/plugins/platforms/winrt/qwinrtplatformmessagedialoghelper.cpp
index 1bc3e95f18..e70d06860c 100644
--- a/src/plugins/platforms/winrt/qwinrtplatformmessagedialoghelper.cpp
+++ b/src/plugins/platforms/winrt/qwinrtplatformmessagedialoghelper.cpp
@@ -128,9 +128,9 @@ bool QWinRTPlatformMessageDialogHelper::show(Qt::WindowFlags windowFlags, Qt::Wi
// If no button is specified we need to create one to get close notification
int buttons = options->standardButtons();
if (buttons == 0)
- buttons = QMessageDialogOptions::Ok;
+ buttons = QPlatformDialogHelper::Ok;
- for (int i = QMessageDialogOptions::FirstButton; i < QMessageDialogOptions::LastButton; i<<=1) {
+ for (int i = QPlatformDialogHelper::FirstButton; i < QPlatformDialogHelper::LastButton; i<<=1) {
if (buttons & i) {
// Add native command
const QString label = QGuiApplicationPrivate::platformTheme()->standardButtonText(i);
@@ -176,7 +176,7 @@ HRESULT QWinRTPlatformMessageDialogHelper::onInvoked(ABI::Windows::UI::Popups::I
command->get_Label(&hLabel);
QString label = QString::fromWCharArray(::WindowsGetStringRawBuffer(hLabel, &labelLength));
int buttonId = -1;
- for (int i = QMessageDialogOptions::FirstButton; i < QMessageDialogOptions::LastButton; i<<=1) {
+ for (int i = QPlatformDialogHelper::FirstButton; i < QPlatformDialogHelper::LastButton; i<<=1) {
if ( options()->standardButtons() & i ) {
if (QGuiApplicationPrivate::platformTheme()->standardButtonText(i) == label) {
buttonId = i;
@@ -194,8 +194,8 @@ HRESULT QWinRTPlatformMessageDialogHelper::onInvoked(ABI::Windows::UI::Popups::I
return S_OK;
}
- QMessageDialogOptions::StandardButton standardButton = static_cast<QMessageDialogOptions::StandardButton>(buttonId);
- QMessageDialogOptions::ButtonRole role = QMessageDialogOptions::buttonRole(standardButton);
+ QPlatformDialogHelper::StandardButton standardButton = static_cast<QPlatformDialogHelper::StandardButton>(buttonId);
+ QPlatformDialogHelper::ButtonRole role = QPlatformDialogHelper::buttonRole(standardButton);
emit clicked(standardButton, role);
return S_OK;
}
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index 1b64b0ba67..3080d5f1e8 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -209,7 +209,7 @@ public:
void init(const QString &title = QString(), const QString &text = QString());
void setupLayout();
void _q_buttonClicked(QAbstractButton *);
- void _q_clicked(QMessageDialogOptions::StandardButton button, QMessageDialogOptions::ButtonRole role);
+ void _q_clicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role);
QAbstractButton *findButton(int button0, int button1, int button2, int flags);
void addOldButtons(int button0, int button1, int button2);
@@ -524,7 +524,7 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
}
}
-void QMessageBoxPrivate::_q_clicked(QMessageDialogOptions::StandardButton button, QMessageDialogOptions::ButtonRole role)
+void QMessageBoxPrivate::_q_clicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role)
{
Q_UNUSED(role);
Q_Q(QMessageBox);
@@ -2697,8 +2697,8 @@ QPixmap QMessageBoxPrivate::standardIcon(QMessageBox::Icon icon, QMessageBox *mb
void QMessageBoxPrivate::initHelper(QPlatformDialogHelper *h)
{
Q_Q(QMessageBox);
- QObject::connect(h, SIGNAL(clicked(QMessageDialogOptions::StandardButton, QMessageDialogOptions::ButtonRole)),
- q, SLOT(_q_clicked(QMessageDialogOptions::StandardButton, QMessageDialogOptions::ButtonRole)));
+ QObject::connect(h, SIGNAL(clicked(QPlatformDialogHelper::StandardButton, QPlatformDialogHelper::ButtonRole)),
+ q, SLOT(_q_clicked(QPlatformDialogHelper::StandardButton, QPlatformDialogHelper::ButtonRole)));
static_cast<QPlatformMessageDialogHelper *>(h)->setOptions(options);
}
@@ -2719,9 +2719,9 @@ static QMessageDialogOptions::Icon helperIcon(QMessageBox::Icon i)
return QMessageDialogOptions::NoIcon;
}
-static QMessageDialogOptions::StandardButtons helperStandardButtons(QMessageBox * q)
+static QPlatformDialogHelper::StandardButtons helperStandardButtons(QMessageBox * q)
{
- QMessageDialogOptions::StandardButtons buttons(int(q->standardButtons()));
+ QPlatformDialogHelper::StandardButtons buttons(int(q->standardButtons()));
return buttons;
}
diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h
index c5598a8f1d..5fae174fe1 100644
--- a/src/widgets/dialogs/qmessagebox.h
+++ b/src/widgets/dialogs/qmessagebox.h
@@ -72,6 +72,7 @@ class Q_WIDGETS_EXPORT QMessageBox : public QDialog
public:
enum Icon {
+ // keep this in sync with QMessageDialogOptions::Icon
NoIcon = 0,
Information = 1,
Warning = 2,
@@ -80,7 +81,7 @@ public:
};
enum ButtonRole {
- // keep this in sync with QDialogButtonBox::ButtonRole
+ // keep this in sync with QDialogButtonBox::ButtonRole and QPlatformDialogHelper::ButtonRole
InvalidRole = -1,
AcceptRole,
RejectRole,
@@ -96,7 +97,7 @@ public:
};
enum StandardButton {
- // keep this in sync with QDialogButtonBox::StandardButton and QMessageDialogOptions::StandardButton
+ // keep this in sync with QDialogButtonBox::StandardButton and QPlatformDialogHelper::StandardButton
NoButton = 0x00000000,
Ok = 0x00000400,
Save = 0x00000800,
@@ -309,7 +310,7 @@ protected:
private:
Q_PRIVATE_SLOT(d_func(), void _q_buttonClicked(QAbstractButton *))
- Q_PRIVATE_SLOT(d_func(), void _q_clicked(QMessageDialogOptions::StandardButton, QMessageDialogOptions::ButtonRole))
+ Q_PRIVATE_SLOT(d_func(), void _q_clicked(QPlatformDialogHelper::StandardButton, QPlatformDialogHelper::ButtonRole))
Q_DISABLE_COPY(QMessageBox)
Q_DECLARE_PRIVATE(QMessageBox)
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp
index d28fb66551..e24247b02f 100644
--- a/src/widgets/widgets/qdialogbuttonbox.cpp
+++ b/src/widgets/widgets/qdialogbuttonbox.cpp
@@ -150,77 +150,6 @@ QT_BEGIN_NAMESPACE
\sa QMessageBox, QPushButton, QDialog
*/
-enum {
- AcceptRole = QDialogButtonBox::AcceptRole,
- RejectRole = QDialogButtonBox::RejectRole,
- DestructiveRole = QDialogButtonBox::DestructiveRole,
- ActionRole = QDialogButtonBox::ActionRole,
- HelpRole = QDialogButtonBox::HelpRole,
- YesRole = QDialogButtonBox::YesRole,
- NoRole = QDialogButtonBox::NoRole,
- ApplyRole = QDialogButtonBox::ApplyRole,
- ResetRole = QDialogButtonBox::ResetRole,
-
- AlternateRole = 0x10000000,
- Stretch = 0x20000000,
- EOL = 0x40000000,
- Reverse = 0x80000000
-};
-
-static QDialogButtonBox::ButtonRole roleFor(QDialogButtonBox::StandardButton button)
-{
- return static_cast<QDialogButtonBox::ButtonRole>(QMessageDialogOptions::buttonRole(
- static_cast<QMessageDialogOptions::StandardButton>(button)));
-}
-
-static const uint layouts[2][5][14] =
-{
- // Qt::Horizontal
- {
- // WinLayout
- { ResetRole, Stretch, YesRole, AcceptRole, AlternateRole, DestructiveRole, NoRole, ActionRole, RejectRole, ApplyRole,
- HelpRole, EOL, EOL, EOL },
-
- // MacLayout
- { HelpRole, ResetRole, ApplyRole, ActionRole, Stretch, DestructiveRole | Reverse,
- AlternateRole | Reverse, RejectRole | Reverse, AcceptRole | Reverse, NoRole | Reverse, YesRole | Reverse, EOL, EOL },
-
- // KdeLayout
- { HelpRole, ResetRole, Stretch, YesRole, NoRole, ActionRole, AcceptRole, AlternateRole,
- ApplyRole, DestructiveRole, RejectRole, EOL },
-
- // GnomeLayout
- { HelpRole, ResetRole, Stretch, ActionRole, ApplyRole | Reverse, DestructiveRole | Reverse,
- AlternateRole | Reverse, RejectRole | Reverse, AcceptRole | Reverse, NoRole | Reverse, YesRole | Reverse, EOL },
-
- // Mac modeless
- { ResetRole, ApplyRole, ActionRole, Stretch, HelpRole, EOL, EOL, EOL, EOL, EOL, EOL, EOL, EOL, EOL }
- },
-
- // Qt::Vertical
- {
- // WinLayout
- { ActionRole, YesRole, AcceptRole, AlternateRole, DestructiveRole, NoRole, RejectRole, ApplyRole, ResetRole,
- HelpRole, Stretch, EOL, EOL, EOL },
-
- // MacLayout
- { YesRole, NoRole, AcceptRole, RejectRole, AlternateRole, DestructiveRole, Stretch, ActionRole, ApplyRole,
- ResetRole, HelpRole, EOL, EOL },
-
- // KdeLayout
- { AcceptRole, AlternateRole, ApplyRole, ActionRole, YesRole, NoRole, Stretch, ResetRole,
- DestructiveRole, RejectRole, HelpRole, EOL },
-
- // GnomeLayout
- { YesRole, NoRole, AcceptRole, RejectRole, AlternateRole, DestructiveRole, ApplyRole, ActionRole, Stretch,
- ResetRole, HelpRole, EOL, EOL, EOL },
-
- // Mac modeless
- { ActionRole, ApplyRole, ResetRole, Stretch, HelpRole, EOL, EOL, EOL, EOL, EOL, EOL, EOL, EOL, EOL }
- }
-};
-
-
class QDialogButtonBoxPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QDialogButtonBox)
@@ -323,7 +252,8 @@ void QDialogButtonBoxPrivate::layoutButtons()
int tmpPolicy = layoutPolicy;
static const int M = 5;
- static const int ModalRoles[M] = { AcceptRole, RejectRole, DestructiveRole, YesRole, NoRole };
+ static const int ModalRoles[M] = { QPlatformDialogHelper::AcceptRole, QPlatformDialogHelper::RejectRole,
+ QPlatformDialogHelper::DestructiveRole, QPlatformDialogHelper::YesRole, QPlatformDialogHelper::NoRole };
if (tmpPolicy == QDialogButtonBox::MacLayout) {
bool hasModalButton = false;
for (int i = 0; i < M; ++i) {
@@ -336,23 +266,24 @@ void QDialogButtonBoxPrivate::layoutButtons()
tmpPolicy = 4; // Mac modeless
}
- const uint *currentLayout = layouts[orientation == Qt::Vertical][tmpPolicy];
+ const quint32 *currentLayout = QPlatformDialogHelper::buttonLayout(
+ orientation, static_cast<QPlatformDialogHelper::ButtonLayout>(tmpPolicy));
if (center)
buttonLayout->addStretch();
- QList<QAbstractButton *> acceptRoleList = buttonLists[AcceptRole];
+ QList<QAbstractButton *> acceptRoleList = buttonLists[QPlatformDialogHelper::AcceptRole];
- while (*currentLayout != EOL) {
- int role = (*currentLayout & ~Reverse);
- bool reverse = (*currentLayout & Reverse);
+ while (*currentLayout != QPlatformDialogHelper::EOL) {
+ int role = (*currentLayout & ~QPlatformDialogHelper::Reverse);
+ bool reverse = (*currentLayout & QPlatformDialogHelper::Reverse);
switch (role) {
- case Stretch:
+ case QPlatformDialogHelper::Stretch:
if (!center)
buttonLayout->addStretch();
break;
- case AcceptRole: {
+ case QPlatformDialogHelper::AcceptRole: {
if (acceptRoleList.isEmpty())
break;
// Only the first one
@@ -361,7 +292,7 @@ void QDialogButtonBoxPrivate::layoutButtons()
button->show();
}
break;
- case AlternateRole:
+ case QPlatformDialogHelper::AlternateRole:
{
if (acceptRoleList.size() < 2)
break;
@@ -370,7 +301,7 @@ void QDialogButtonBoxPrivate::layoutButtons()
addButtonsToLayout(list, reverse);
}
break;
- case DestructiveRole:
+ case QPlatformDialogHelper::DestructiveRole:
{
const QList<QAbstractButton *> &list = buttonLists[role];
@@ -396,13 +327,13 @@ void QDialogButtonBoxPrivate::layoutButtons()
buttonLayout->addSpacing(MacGap);
}
break;
- case RejectRole:
- case ActionRole:
- case HelpRole:
- case YesRole:
- case NoRole:
- case ApplyRole:
- case ResetRole:
+ case QPlatformDialogHelper::RejectRole:
+ case QPlatformDialogHelper::ActionRole:
+ case QPlatformDialogHelper::HelpRole:
+ case QPlatformDialogHelper::YesRole:
+ case QPlatformDialogHelper::NoRole:
+ case QPlatformDialogHelper::ApplyRole:
+ case QPlatformDialogHelper::ResetRole:
addButtonsToLayout(buttonLists[role], reverse);
}
++currentLayout;
@@ -484,8 +415,9 @@ QPushButton *QDialogButtonBoxPrivate::createButton(QDialogButtonBox::StandardBut
if (style != QApplication::style()) // Propagate style
button->setStyle(style);
standardButtonHash.insert(button, sbutton);
- if (roleFor(sbutton) != QDialogButtonBox::InvalidRole) {
- addButton(button, roleFor(sbutton), doLayout);
+ QPlatformDialogHelper::ButtonRole role = QPlatformDialogHelper::buttonRole(static_cast<QPlatformDialogHelper::StandardButton>(sbutton));
+ if (role != QPlatformDialogHelper::InvalidRole) {
+ addButton(button, static_cast<QDialogButtonBox::ButtonRole>(role), doLayout);
} else {
qWarning("QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
}
@@ -934,15 +866,15 @@ void QDialogButtonBoxPrivate::_q_handleButtonClicked()
emit q->clicked(button);
switch (q->buttonRole(button)) {
- case AcceptRole:
- case YesRole:
+ case QPlatformDialogHelper::AcceptRole:
+ case QPlatformDialogHelper::YesRole:
emit q->accepted();
break;
- case RejectRole:
- case NoRole:
+ case QPlatformDialogHelper::RejectRole:
+ case QPlatformDialogHelper::NoRole:
emit q->rejected();
break;
- case HelpRole:
+ case QPlatformDialogHelper::HelpRole:
emit q->helpRequested();
break;
default:
diff --git a/src/widgets/widgets/qdialogbuttonbox.h b/src/widgets/widgets/qdialogbuttonbox.h
index d8e1a997d4..5cd94f88b0 100644
--- a/src/widgets/widgets/qdialogbuttonbox.h
+++ b/src/widgets/widgets/qdialogbuttonbox.h
@@ -61,7 +61,7 @@ class Q_WIDGETS_EXPORT QDialogButtonBox : public QWidget
public:
enum ButtonRole {
- // keep this in sync with QMessageBox::ButtonRole
+ // keep this in sync with QMessageBox::ButtonRole and QPlatformDialogHelper::ButtonRole
InvalidRole = -1,
AcceptRole,
RejectRole,
@@ -77,7 +77,7 @@ public:
};
enum StandardButton {
- // keep this in sync with QMessageBox::StandardButton
+ // keep this in sync with QMessageBox::StandardButton and QPlatformDialogHelper::StandardButton
NoButton = 0x00000000,
Ok = 0x00000400,
Save = 0x00000800,
@@ -107,6 +107,7 @@ public:
Q_DECLARE_FLAGS(StandardButtons, StandardButton)
enum ButtonLayout {
+ // keep this in sync with QMessageBox::ButtonLayout and QPlatformDialogHelper::ButtonLayout
WinLayout,
MacLayout,
KdeLayout,