Skip to content

Improve settings dialog open/close performance #3606

@pbek

Description

@pbek

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

  1. 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

  1. 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.

  2. 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 settingsloadShortcutSettings() 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 reloadstoreScriptListEnabledState() 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions