summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qplatformdialoghelper.h
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/gui/kernel/qplatformdialoghelper.h
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/gui/kernel/qplatformdialoghelper.h')
-rw-r--r--src/gui/kernel/qplatformdialoghelper.h120
1 files changed, 71 insertions, 49 deletions
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;