QKeySequenceEdit: don't finish when opening a context menu

Right-clicking in a QKeySequenceEdit opens the usual context menu for a
line edit, which generates a focusOut event. QKeySequenceEdit finishes
the recording when it loses focus, which includes deselecting the text.

We should not finish or deselect if the focusOut event has focusReason
FocusReasonPopup, as otherwise users cannot copy the text (keyboard
shortcuts don't work for that, obviously).

Task-number: QTBUG-114624
Change-Id: I0b3c535c189151daa29cf17640493f3353e6394b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 89566bf7491cd717a6f64a0a8b82306309bb0701)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Volker Hilsheimer 2023-06-19 12:44:37 +02:00 committed by Qt Cherry-pick Bot
parent 848c017165
commit bdeb45c2e2

View File

@ -414,7 +414,8 @@ void QKeySequenceEdit::timerEvent(QTimerEvent *e)
void QKeySequenceEdit::focusOutEvent(QFocusEvent *e)
{
Q_D(QKeySequenceEdit);
d->finishEditing();
if (e->reason() != Qt::PopupFocusReason)
d->finishEditing();
QWidget::focusOutEvent(e);
}