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>bb10
parent
060b862b61
commit
209a5f1e8d
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -112,7 +112,8 @@ public:
|
|||
enum DialogType {
|
||||
FileDialog,
|
||||
ColorDialog,
|
||||
FontDialog
|
||||
FontDialog,
|
||||
MessageDialog
|
||||
};
|
||||
|
||||
enum Palette {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue