Summary
Opening and closing (pressing OK) the settings dialog is noticeably slow, especially in installations with many menu actions or scripts. Several root causes were identified and addressed.
Root Causes Identified
On Open
loadShortcutSettings() ran unconditionally on every dialog open — For every menu action in the entire application menu bar, this created two QKeySequenceWidget instances, a QPushButton, a QFrame, a QHBoxLayout, and called setItemWidget() twice, plus two QSettings reads per action. With a large menu bar this could involve hundreds of widgets being created and destroyed every time the dialog opens, even if the user never visits the Shortcuts page.
On OK
-
storeShortcutSettings() O(n²) tree traversal — For each menu action, findKeySequenceWidget() and findGlobalKeySequenceWidget() both performed full recursive tree searches through the shortcut tree widget, resulting in O(n × tree_depth) recursive widget lookups.
-
ScriptingService::reloadEngine() called unconditionally — Every OK press triggered a full QML scripting engine reload (tearing down and reinitializing all scripts), even when no script settings were changed.
Improvements Implemented
- Lazy-load shortcut settings —
loadShortcutSettings() is now deferred to initializePage(ShortcutPage) and only runs when the user actually navigates to the Shortcuts page for the first time. This is the single largest win for dialog open time.
- O(1) shortcut widget lookup — During
loadShortcutSettings(), QHash<QString, QKeySequenceWidget*> maps are populated for both local and global shortcut widgets. storeShortcutSettings() now iterates these maps directly, eliminating all recursive tree traversal.
- Conditional scripting engine reload —
storeScriptListEnabledState() now tracks whether any script's enabled state actually changed and only calls ScriptingService::reloadEngine() when necessary.
- Progress bar feedback — A progress bar is shown on the Shortcuts page while the shortcut tree is being built, giving visual feedback during the loading process.
Impact
- Dialog opens instantly for users who never visit the Shortcuts page (the common case).
- Pressing OK is significantly faster when no shortcuts or scripts were modified.
- The scripting engine is no longer restarted on every OK press when no scripts changed.
Summary
Opening and closing (pressing OK) the settings dialog is noticeably slow, especially in installations with many menu actions or scripts. Several root causes were identified and addressed.
Root Causes Identified
On Open
loadShortcutSettings()ran unconditionally on every dialog open — For every menu action in the entire application menu bar, this created twoQKeySequenceWidgetinstances, aQPushButton, aQFrame, aQHBoxLayout, and calledsetItemWidget()twice, plus twoQSettingsreads per action. With a large menu bar this could involve hundreds of widgets being created and destroyed every time the dialog opens, even if the user never visits the Shortcuts page.On OK
storeShortcutSettings()O(n²) tree traversal — For each menu action,findKeySequenceWidget()andfindGlobalKeySequenceWidget()both performed full recursive tree searches through the shortcut tree widget, resulting in O(n × tree_depth) recursive widget lookups.ScriptingService::reloadEngine()called unconditionally — Every OK press triggered a full QML scripting engine reload (tearing down and reinitializing all scripts), even when no script settings were changed.Improvements Implemented
loadShortcutSettings()is now deferred toinitializePage(ShortcutPage)and only runs when the user actually navigates to the Shortcuts page for the first time. This is the single largest win for dialog open time.loadShortcutSettings(),QHash<QString, QKeySequenceWidget*>maps are populated for both local and global shortcut widgets.storeShortcutSettings()now iterates these maps directly, eliminating all recursive tree traversal.storeScriptListEnabledState()now tracks whether any script's enabled state actually changed and only callsScriptingService::reloadEngine()when necessary.Impact