diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2013-11-07 13:43:02 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-07 18:40:33 +0100 |
commit | 8aab8ccc0ffba504078deb7b4371d2f98c834df3 (patch) | |
tree | a243f04984102b8d7ec5af777d3d49f37c50ef54 /src/widgets | |
parent | 42670c7c45db8032a15607124d177c8f454d6f5a (diff) |
Dialogs: provide the StandardButton->ButtonRole mapping in QPA
As the QPlatformMessageDialogHelper will be implemented repeatedly,
it's useful to have this mapping in one place for reuse. Also, since
we do not guarantee that either accepted() or rejected() will be
emitted for every possible button on a QtQuick MessageDialog, it's
useful for the QtQuick.Dialogs module to have access to this mapping
to interpret individual button presses and emit the role-specific
signals such as yes(), apply(), help(), etc.
Change-Id: I7be753080794adabb784df9b95ac04aa1c29151c
Reviewed-by: BogDan Vatra <bogdan@kde.org>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/widgets/qdialogbuttonbox.cpp | 43 |
1 files changed, 3 insertions, 40 deletions
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 9789c453f3..6b183d3759 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -46,6 +46,7 @@ #include <QtWidgets/qdialog.h> #include <QtWidgets/qapplication.h> #include <private/qwidget_p.h> +#include <QtGui/qpa/qplatformdialoghelper.h> #include <QtWidgets/qaction.h> #include "qdialogbuttonbox.h" @@ -166,46 +167,8 @@ enum { static QDialogButtonBox::ButtonRole roleFor(QDialogButtonBox::StandardButton button) { - switch (button) { - case QDialogButtonBox::Ok: - case QDialogButtonBox::Save: - case QDialogButtonBox::Open: - case QDialogButtonBox::SaveAll: - case QDialogButtonBox::Retry: - case QDialogButtonBox::Ignore: - return QDialogButtonBox::AcceptRole; - - case QDialogButtonBox::Cancel: - case QDialogButtonBox::Close: - case QDialogButtonBox::Abort: - return QDialogButtonBox::RejectRole; - - case QDialogButtonBox::Discard: - return QDialogButtonBox::DestructiveRole; - - case QDialogButtonBox::Help: - return QDialogButtonBox::HelpRole; - - case QDialogButtonBox::Apply: - return QDialogButtonBox::ApplyRole; - - case QDialogButtonBox::Yes: - case QDialogButtonBox::YesToAll: - return QDialogButtonBox::YesRole; - - case QDialogButtonBox::No: - case QDialogButtonBox::NoToAll: - return QDialogButtonBox::NoRole; - - case QDialogButtonBox::RestoreDefaults: - case QDialogButtonBox::Reset: - return QDialogButtonBox::ResetRole; - - case QDialogButtonBox::NoButton: // NoButton means zero buttons, not "No" button - ; - } - - return QDialogButtonBox::InvalidRole; + return static_cast<QDialogButtonBox::ButtonRole>(QMessageDialogOptions::buttonRole( + static_cast<QMessageDialogOptions::StandardButton>(button))); } static const uint layouts[2][5][14] = |