From c136cb1e9aa8f4b6a0903ff2ef881fec4e469d89 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Fri, 5 Apr 2024 12:46:52 +0300 Subject: [PATCH] UI: Options: Fix Hot Key Shortcuts clearing --- src/ui/form/opt/pages/optionspage.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/ui/form/opt/pages/optionspage.cpp b/src/ui/form/opt/pages/optionspage.cpp index 89092630..84b4c631 100644 --- a/src/ui/form/opt/pages/optionspage.cpp +++ b/src/ui/form/opt/pages/optionspage.cpp @@ -777,13 +777,26 @@ QLayout *OptionsPage::setupEditShortcutLayout() m_editShortcut->setClearButtonEnabled(true); m_editShortcut->setFixedWidth(200); - connect(m_editShortcut, &QKeySequenceEdit::editingFinished, [&] { + const auto onEditShortcut = [&](const QKeySequence &shortcut) { const auto &key = HotKey::list[m_comboHotKey->currentIndex()]; - const auto value = m_editShortcut->keySequence().toString(); + const auto value = shortcut.toString(); + + if (value == iniUser()->hotKeyValue(key)) + return; iniUser()->setHotKeyValue(key, value); ctrl()->setIniUserEdited(); - }); + }; + + connect(m_editShortcut, &QKeySequenceEdit::editingFinished, + [=, this] { onEditShortcut(m_editShortcut->keySequence()); }); + + connect(m_editShortcut, &QKeySequenceEdit::keySequenceChanged, + [=, this](const QKeySequence &shortcut) { + if (shortcut.isEmpty()) { + onEditShortcut({}); + } + }); return ControlUtil::createRowLayout(m_labelShortcut, m_editShortcut); }