Repository navigation
Closed
Description
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
- Lazy-load shortcut settings —
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. - 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 callsScriptingService::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.
Metadata
Metadata
Assignees
Labels
No labels
Activity
#3606 settingsdialog: improved open and close performance
pbek commentedon May 10, 2026
26.5.8
(for #3606)
the user actually navigates to the Shortcuts page, instead of on every
dialog open. This is the largest single win and makes the dialog open nearly
instantly in the common case where shortcuts are not being edited.
storeShortcutSettings()now uses pre-builtQHashlookup maps populatedduring
loadShortcutSettings(), replacing the previous O(n²) recursive treetraversal with O(1) per-action widget lookups.
press; it is now only reloaded when the enabled state of at least one script
actually changed.