From 70d21d7eca8a484b0a88fa2864816a983d9613f9 Mon Sep 17 00:00:00 2001 From: shenleban tongying Date: Wed, 6 Nov 2024 15:36:11 -0500 Subject: [PATCH] opt: revise QKeySequenceEdit usages * set Maximum length of global shortcuts to 2 * set Default to something that can be set by user --- src/config.cc | 4 ++-- src/ui/preferences.cc | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/config.cc b/src/config.cc index 23f5ad29..f4e71062 100644 --- a/src/config.cc +++ b/src/config.cc @@ -215,8 +215,8 @@ Preferences::Preferences(): enableMainWindowHotkey( true ), enableClipboardHotkey( true ), #endif - mainWindowHotkey( QKeySequence( "Ctrl+F11,F11" ) ), - clipboardHotkey( QKeySequence( "Ctrl+C,C" ) ), + mainWindowHotkey( QKeySequence( "Ctrl+F11, Ctrl+F11" ) ), + clipboardHotkey( QKeySequence( "Ctrl+C, Ctrl+C" ) ), startWithScanPopupOn( false ), enableScanPopupModifiers( false ), scanPopupModifiers( 0 ), diff --git a/src/ui/preferences.cc b/src/ui/preferences.cc index 5ac6d1ea..5223b3c1 100644 --- a/src/ui/preferences.cc +++ b/src/ui/preferences.cc @@ -205,11 +205,18 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ): ui.darkMode->hide(); #endif + /// Hotkey Tab ui.enableMainWindowHotkey->setChecked( p.enableMainWindowHotkey ); ui.mainWindowHotkey->setKeySequence( p.mainWindowHotkey ); ui.enableClipboardHotkey->setChecked( p.enableClipboardHotkey ); ui.clipboardHotkey->setKeySequence( p.clipboardHotkey ); +#if QT_VERSION >= QT_VERSION_CHECK( 6, 5, 0 ) + // Bound by current global hotkey implementations + ui.mainWindowHotkey->setMaximumSequenceLength( 2 ); + ui.clipboardHotkey->setMaximumSequenceLength( 2 ); +#endif + ui.startWithScanPopupOn->setChecked( p.startWithScanPopupOn ); ui.enableScanPopupModifiers->setChecked( p.enableScanPopupModifiers );