From bd2f9fd0e09d9274b3bde3377ebcb1710d362b7f Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Mon, 28 Feb 2022 21:50:03 +0800 Subject: [PATCH] Gui: fix shortcut editor --- src/Gui/Widgets.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/Gui/Widgets.cpp b/src/Gui/Widgets.cpp index 69545ee499..db3dfd1233 100644 --- a/src/Gui/Widgets.cpp +++ b/src/Gui/Widgets.cpp @@ -413,18 +413,23 @@ void AccelLineEdit::keyPressEvent (QKeyEvent * e) break; } - // 4 keys are allowed for QShortcut - switch (keyPressedCount) { - case 4: + if (txtLine.isEmpty()) { + // Text maybe cleared by QLineEdit's built in clear button keyPressedCount = 0; - txtLine.clear(); - break; - case 0: - txtLine.clear(); - break; - default: - txtLine += QChar::fromLatin1(','); - break; + } else { + // 4 keys are allowed for QShortcut + switch (keyPressedCount) { + case 4: + keyPressedCount = 0; + txtLine.clear(); + break; + case 0: + txtLine.clear(); + break; + default: + txtLine += QString::fromLatin1(","); + break; + } } // Handles modifiers applying a mask.