aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickdialogs/quickdialogsquickimpl/qquickmessagedialogimpl.cpp
diff options
context:
space:
mode:
authorOliver Eftevaag <oliver.eftevaag@qt.io>2023-10-20 07:57:07 +0200
committerOliver Eftevaag <oliver.eftevaag@qt.io>2023-12-10 02:50:58 +0100
commit8dd68783642e6ea42e9a7b32e1671424d1d0eeed (patch)
tree675f318671e177f88bdf2a0fb771ed25925f1714 /src/quickdialogs/quickdialogsquickimpl/qquickmessagedialogimpl.cpp
parent97485da9feb3093f3160de1def206d310415b6c6 (diff)
MessageDialog: make QQuickAbstractDialog::result return button pressed
The widgets QMessageBox returns either the StandardButton value of the last button pressed, or the index, in the case of custom buttons. This differs from how we did things in quick, where we'd always return either 0 or 1 (Accepted or Rejected). The documentation even states the following: MessageDialog sets the result to the value of the clicked standard button instead of using the standard result codes Which was incorrect, since the result property functioned the same, regardless of dialog type. The goal of this patch is to make the result property for MessageDialog behave the same as QMessageBox, without changing the behavior for other dialog types. In order to accomplish this, the type has to be changed from StandardCode to int, since the result value can either be a StandardCode value, or a StandardButton value. The widget QMessageBox also differs in that it will not emit rejected when the user presses a button with a role that isn't NoRole or RejectRole. I've decided to make the MessageDialog behave the same way. [ChangeLog][QtQuick][Dialogs][Important Behavior Changes] The MessageDialog will no longer emit rejected when the user presses a button that doesn't have the role NoRole or RejectedRole. Task-number: QTBUG-118445 Task-number: QTBUG-118689 Task-number: QTBUG-118212 Change-Id: I7084a889210027f5c057f5c22eee2e08867ce741 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'src/quickdialogs/quickdialogsquickimpl/qquickmessagedialogimpl.cpp')
-rw-r--r--src/quickdialogs/quickdialogsquickimpl/qquickmessagedialogimpl.cpp18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/quickdialogs/quickdialogsquickimpl/qquickmessagedialogimpl.cpp b/src/quickdialogs/quickdialogsquickimpl/qquickmessagedialogimpl.cpp
index d80011d127..578da61559 100644
--- a/src/quickdialogs/quickdialogsquickimpl/qquickmessagedialogimpl.cpp
+++ b/src/quickdialogs/quickdialogsquickimpl/qquickmessagedialogimpl.cpp
@@ -21,8 +21,6 @@ void QQuickMessageDialogImplPrivate::handleClick(QQuickAbstractButton *button)
emit q->buttonClicked(standardButton, role);
}
-
- QQuickDialogPrivate::handleClick(button);
}
QQuickMessageDialogImplAttached *QQuickMessageDialogImplPrivate::attachedOrWarn()
@@ -125,13 +123,9 @@ void QQuickMessageDialogImplAttached::setButtonBox(QQuickDialogButtonBox *button
QQuickMessageDialogImpl *messageDialogImpl =
qobject_cast<QQuickMessageDialogImpl *>(parent());
if (messageDialogImpl) {
- auto dialogPrivate = QQuickDialogPrivate::get(messageDialogImpl);
- QObjectPrivate::disconnect(d->buttonBox, &QQuickDialogButtonBox::accepted,
- dialogPrivate, &QQuickDialogPrivate::handleAccept);
- QObjectPrivate::disconnect(d->buttonBox, &QQuickDialogButtonBox::rejected,
- dialogPrivate, &QQuickDialogPrivate::handleReject);
+ auto dialogPrivate = QQuickMessageDialogImplPrivate::get(messageDialogImpl);
QObjectPrivate::disconnect(d->buttonBox, &QQuickDialogButtonBox::clicked, dialogPrivate,
- &QQuickDialogPrivate::handleClick);
+ &QQuickMessageDialogImplPrivate::handleClick);
}
}
@@ -141,13 +135,9 @@ void QQuickMessageDialogImplAttached::setButtonBox(QQuickDialogButtonBox *button
QQuickMessageDialogImpl *messageDialogImpl =
qobject_cast<QQuickMessageDialogImpl *>(parent());
if (messageDialogImpl) {
- auto dialogPrivate = QQuickDialogPrivate::get(messageDialogImpl);
- QObjectPrivate::connect(d->buttonBox, &QQuickDialogButtonBox::accepted, dialogPrivate,
- &QQuickDialogPrivate::handleAccept);
- QObjectPrivate::connect(d->buttonBox, &QQuickDialogButtonBox::rejected, dialogPrivate,
- &QQuickDialogPrivate::handleReject);
+ auto dialogPrivate = QQuickMessageDialogImplPrivate::get(messageDialogImpl);
QObjectPrivate::connect(d->buttonBox, &QQuickDialogButtonBox::clicked, dialogPrivate,
- &QQuickDialogPrivate::handleClick);
+ &QQuickMessageDialogImplPrivate::handleClick);
}
}