summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qplatformdialoghelper.cpp117
-rw-r--r--src/gui/kernel/qplatformdialoghelper.h81
-rw-r--r--src/gui/kernel/qplatformtheme.h3
-rw-r--r--src/widgets/dialogs/qmessagebox.h2
4 files changed, 201 insertions, 2 deletions
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp
index f297236655..fe5db27117 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -596,4 +596,121 @@ QStringList QPlatformFileDialogHelper::cleanFilterList(const QString &filter)
return f.split(QLatin1Char(' '), QString::SkipEmptyParts);
}
+// Message dialog
+
+class QMessageDialogOptionsPrivate : public QSharedData
+{
+public:
+ QMessageDialogOptionsPrivate() :
+ icon(QMessageDialogOptions::NoIcon),
+ buttons(QMessageDialogOptions::Ok)
+ {}
+
+ QString windowTitle;
+ QMessageDialogOptions::Icon icon;
+ QString text;
+ QString informativeText;
+ QString detailedText;
+ QMessageDialogOptions::StandardButtons buttons;
+};
+
+QMessageDialogOptions::QMessageDialogOptions() : d(new QMessageDialogOptionsPrivate)
+{
+}
+
+QMessageDialogOptions::QMessageDialogOptions(const QMessageDialogOptions &rhs) : d(rhs.d)
+{
+}
+
+QMessageDialogOptions &QMessageDialogOptions::operator=(const QMessageDialogOptions &rhs)
+{
+ if (this != &rhs)
+ d = rhs.d;
+ return *this;
+}
+
+QMessageDialogOptions::~QMessageDialogOptions()
+{
+}
+
+QString QMessageDialogOptions::windowTitle() const
+{
+ return d->windowTitle;
+}
+
+void QMessageDialogOptions::setWindowTitle(const QString &title)
+{
+ d->windowTitle = title;
+}
+
+QMessageDialogOptions::Icon QMessageDialogOptions::icon() const
+{
+ return d->icon;
+}
+
+void QMessageDialogOptions::setIcon(Icon icon)
+{
+ d->icon = icon;
+}
+
+QString QMessageDialogOptions::text() const
+{
+ return d->text;
+}
+
+void QMessageDialogOptions::setText(const QString &text)
+{
+ d->text = text;
+}
+
+QString QMessageDialogOptions::informativeText() const
+{
+ return d->informativeText;
+}
+
+void QMessageDialogOptions::setInformativeText(const QString &informativeText)
+{
+ d->informativeText = informativeText;
+}
+
+QString QMessageDialogOptions::detailedText() const
+{
+ return d->detailedText;
+}
+
+void QMessageDialogOptions::setDetailedText(const QString &detailedText)
+{
+ d->detailedText = detailedText;
+}
+
+void QMessageDialogOptions::setStandardButtons(StandardButtons buttons)
+{
+ d->buttons = buttons;
+}
+
+QMessageDialogOptions::StandardButtons QMessageDialogOptions::standardButtons() const
+{
+ return d->buttons;
+}
+
+
+/*!
+ \class QPlatformMessageDialogHelper
+ \since 5.0
+ \internal
+ \ingroup qpa
+
+ \brief The QPlatformMessageDialogHelper class allows for platform-specific customization of Message dialogs.
+
+*/
+const QSharedPointer<QMessageDialogOptions> &QPlatformMessageDialogHelper::options() const
+{
+ return m_options;
+}
+
+void QPlatformMessageDialogHelper::setOptions(const QSharedPointer<QMessageDialogOptions> &options)
+{
+ m_options = options;
+}
+
QT_END_NAMESPACE
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
diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h
index 710e36ae42..4bddac5b1b 100644
--- a/src/gui/kernel/qplatformtheme.h
+++ b/src/gui/kernel/qplatformtheme.h
@@ -112,7 +112,8 @@ public:
enum DialogType {
FileDialog,
ColorDialog,
- FontDialog
+ FontDialog,
+ MessageDialog
};
enum Palette {
diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h
index 32b7027d89..c7c42b1e7a 100644
--- a/src/widgets/dialogs/qmessagebox.h
+++ b/src/widgets/dialogs/qmessagebox.h
@@ -95,7 +95,7 @@ public:
};
enum StandardButton {
- // keep this in sync with QDialogButtonBox::StandardButton
+ // keep this in sync with QDialogButtonBox::StandardButton and QMessageDialogOptions::StandardButton
NoButton = 0x00000000,
Ok = 0x00000400,
Save = 0x00000800,