diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2013-11-07 18:31:47 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-08 09:10:07 +0100 |
commit | c286b4fccb2d83fcc01b21913b95c5e4f21f2982 (patch) | |
tree | 4c0d6d915b225583ffe3d509141909730fafc046 /src/imports/dialogs/qquickabstractmessagedialog.cpp | |
parent | 8c6a34133c07f28f62bf9a06a3952affd239424e (diff) |
MessageDialog: handle clicked(button, role) signal properly
Depends on I7be753080794adabb784df9b95ac04aa1c29151c in qtbase.
Now the Android native dialog can provide the same functionality as
the QML and QMessageBox implementations.
Change-Id: Icc9c610669742199d48497096524f6cf8ed4d835
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: BogDan Vatra <bogdan@kde.org>
Diffstat (limited to 'src/imports/dialogs/qquickabstractmessagedialog.cpp')
-rw-r--r-- | src/imports/dialogs/qquickabstractmessagedialog.cpp | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/src/imports/dialogs/qquickabstractmessagedialog.cpp b/src/imports/dialogs/qquickabstractmessagedialog.cpp index cfcf056e6c..a44464962a 100644 --- a/src/imports/dialogs/qquickabstractmessagedialog.cpp +++ b/src/imports/dialogs/qquickabstractmessagedialog.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qquickabstractmessagedialog_p.h" +#include <QtGui/qpa/qplatformdialoghelper.h> QT_BEGIN_NAMESPACE @@ -133,10 +134,46 @@ void QQuickAbstractMessageDialog::setStandardButtons(StandardButtons buttons) } } -void QQuickAbstractMessageDialog::click(QQuickAbstractMessageDialog::StandardButton button) +void QQuickAbstractMessageDialog::click(QMessageDialogOptions::StandardButton button, QMessageDialogOptions::ButtonRole role) { - m_clickedButton = button; + setVisible(false); + m_clickedButton = static_cast<StandardButton>(button); emit buttonClicked(); + switch (role) { + case QMessageDialogOptions::AcceptRole: + emit accept(); + break; + case QMessageDialogOptions::RejectRole: + emit reject(); + break; + case QMessageDialogOptions::DestructiveRole: + emit discard(); + break; + case QMessageDialogOptions::HelpRole: + emit help(); + break; + case QMessageDialogOptions::YesRole: + emit yes(); + break; + case QMessageDialogOptions::NoRole: + emit no(); + break; + case QMessageDialogOptions::ApplyRole: + emit apply(); + break; + case QMessageDialogOptions::ResetRole: + emit reset(); + break; + default: + qWarning("unhandled MessageDialog button %d with role %d", button, role); + } +} + +void QQuickAbstractMessageDialog::click(QQuickAbstractMessageDialog::StandardButton button) +{ + click(static_cast<QMessageDialogOptions::StandardButton>(button), + static_cast<QMessageDialogOptions::ButtonRole>( + QMessageDialogOptions::buttonRole(static_cast<QMessageDialogOptions::StandardButton>(button)))); } QT_END_NAMESPACE |