diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-02-09 14:19:46 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2018-09-25 14:15:40 +0000 |
commit | 4c631c0bf971f0b41eb319cd3c6d5c723055aac6 (patch) | |
tree | abb82a4a0200bceeff929691ecf9312538879dca /src/plugins/platforms/android | |
parent | 2d587a03eb41cc907660deffeaf6805237706594 (diff) |
Android: add support for custom buttons in native MessageDialog helper
New API in QMessageDialogOptions and implementation on Android.
Task-number: QTBUG-35545
Change-Id: I59567251199f220862d01ba76979266379eecd86
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/plugins/platforms/android')
-rw-r--r-- | src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp b/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp index ced35c4cfa..9218afa7f5 100644 --- a/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp +++ b/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2018 The Qt Company Ltd. ** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org> ** Contact: https://www.qt.io/licensing/ ** @@ -117,6 +118,15 @@ bool QAndroidPlatformMessageDialogHelper::show(Qt::WindowFlags windowFlags void QAndroidPlatformMessageDialogHelper::addButtons(QSharedPointer<QMessageDialogOptions> opt, ButtonRole role) { + for (const QMessageDialogOptions::CustomButton &b : opt->customButtons()) { + if (b.role == role) { + QString label = b.label; + label.remove(QChar('&')); + m_javaMessageDialog.callMethod<void>("addButton", "(ILjava/lang/String;)V", b.id, + QJNIObjectPrivate::fromString(label).object()); + } + } + for (int i = QPlatformDialogHelper::FirstButton; i < QPlatformDialogHelper::LastButton; i<<=1) { StandardButton b = static_cast<StandardButton>(i); if (buttonRole(b) == role && (opt->standardButtons() & i)) { @@ -144,6 +154,12 @@ void QAndroidPlatformMessageDialogHelper::dialogResult(int buttonID) QPlatformDialogHelper::StandardButton standardButton = static_cast<QPlatformDialogHelper::StandardButton>(buttonID); QPlatformDialogHelper::ButtonRole role = QPlatformDialogHelper::buttonRole(standardButton); + if (buttonID > QPlatformDialogHelper::LastButton) { + const QMessageDialogOptions::CustomButton *custom = options()->customButton(buttonID); + Q_ASSERT(custom); + role = custom->role; + } + emit clicked(standardButton, role); } |