diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2013-08-29 09:30:32 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-13 11:47:06 +0200 |
commit | 209a5f1e8dc3e2275f225823ad9edfee09ba756c (patch) | |
tree | 22614b82f0ffce796964f526507e681153bff76e /src/gui/kernel/qplatformdialoghelper.h | |
parent | 060b862b614285aae88540895736a57eb8563102 (diff) |
Adding QPlatformMessageDialogHelper and QMessageDialogOptions
We plan to add support for native message/alert dialogs on Android
and iOS because it's otherwise impossible to have a true popup window.
Then we might as well have native message/alert dialogs on other
platforms too. It will become an alternative implementation behind
QMessageBox and perhaps QErrorMessage.
Task-number: QTBUG-30883
Task-number: QTBUG-29462
Change-Id: I73dcfc6438e696189b6d37091874c7ad69b4ec68
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src/gui/kernel/qplatformdialoghelper.h')
-rw-r--r-- | src/gui/kernel/qplatformdialoghelper.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h index 5269416ffd..ad818c8644 100644 --- a/src/gui/kernel/qplatformdialoghelper.h +++ b/src/gui/kernel/qplatformdialoghelper.h @@ -72,6 +72,7 @@ class QUrl; class QColorDialogOptionsPrivate; class QFontDialogOptionsPrivate; class QFileDialogOptionsPrivate; +class QMessageDialogOptionsPrivate; class Q_GUI_EXPORT QPlatformDialogHelper : public QObject { @@ -325,6 +326,86 @@ private: QSharedPointer<QFileDialogOptions> m_options; }; +class Q_GUI_EXPORT QMessageDialogOptions +{ +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) + + QMessageDialogOptions(); + QMessageDialogOptions(const QMessageDialogOptions &rhs); + QMessageDialogOptions &operator=(const QMessageDialogOptions &rhs); + ~QMessageDialogOptions(); + + void swap(QMessageDialogOptions &other) { qSwap(d, other.d); } + + QString windowTitle() const; + void setWindowTitle(const QString &); + + void setIcon(Icon icon); + Icon icon() const; + + void setText(const QString &text); + QString text() const; + + void setInformativeText(const QString &text); + QString informativeText() const; + + void setDetailedText(const QString &text); + QString detailedText() const; + + void setStandardButtons(StandardButtons buttons); + StandardButtons standardButtons() const; + +private: + QSharedDataPointer<QMessageDialogOptionsPrivate> d; +}; + +Q_DECLARE_SHARED(QMessageDialogOptions) + +class Q_GUI_EXPORT QPlatformMessageDialogHelper : public QPlatformDialogHelper +{ + Q_OBJECT +public: + const QSharedPointer<QMessageDialogOptions> &options() const; + void setOptions(const QSharedPointer<QMessageDialogOptions> &options); + +Q_SIGNALS: + void clicked(QMessageDialogOptions::StandardButton button); + +private: + QSharedPointer<QMessageDialogOptions> m_options; +}; + QT_END_NAMESPACE #endif // QPLATFORMDIALOGHELPER_H |