Skip to content

Commit b00798d

Browse files
author
Oliver Eftevaag
committed
MessageDialog: Dont rely on accept or reject signal emissions from QPA
Currently, all native dialog implementations need to emit the QPlatformDialogHelper::accept and QPlatformDialogHelper::reject signals, in order for the QQuickAbstractDialog to be able to react to changes and update its visibility property. This makes sense for most dialogs, that have 2 buttons ("Ok" and "Cancel"). The MessageDialog however, is more complicated in that it can have an arbitrary number of buttons. To further complicate things, it can also have buttons with other roles than simply YesRole|AcceptRole|NoRole|RejectRole. Because of this, the native message dialogs will sometimes only emit QPlatformMessageDialogHelper::clicked, which makes QQuickMessageDialog responsible for figuring out what to do next. This patch fixes the issue by calling close() in handleClick(). This is safe to do, since currently all of our native message dialog implementations close after any button is pressed. It is very important that the QQuickAbstractDialog and native dialog are in agreement as to whether a dialog is currently open or not. In cases where there is a mismatch, a new dialog will never be able to be opened again, since QQuickAbstractDialog will return early when the user attempt to open a dialog that it believes is already showing. [ChangeLog][QtQuick][Dialogs] The MessageDialog will now close when a button is pressed, regardless of the button's role. Pick-to: 6.6 6.5 Task-number: QTBUG-118689 Fixes: QTBUG-118445 Fixes: QTBUG-118212 Change-Id: I67a7c575fe5ce8a595eb71cf7056a1d8709ff50d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
1 parent 33299c2 commit b00798d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/quickdialogs/quickdialogs/qquickmessagedialog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ void QQuickMessageDialog::handleClick(QPlatformDialogHelper::StandardButton butt
219219
QPlatformDialogHelper::ButtonRole role)
220220
{
221221
emit buttonClicked(button, role);
222+
close();
222223
}
223224

224225
void QQuickMessageDialog::onCreate(QPlatformDialogHelper *dialog)

0 commit comments

Comments
 (0)