Skip to content

Improve settings dialog open/close performance #3606

Closed

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

Activity

  1. added a commit that references this issue on May 9, 2026
  2. pbek commented on May 10, 2026

    @pbek
    OwnerAuthor

    26.5.8

    • Improved settings dialog open and close performance
      (for #3606)
      • The shortcut settings tree is now built lazily — it is only constructed when
        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-built QHash lookup maps populated
        during loadShortcutSettings(), replacing the previous O(n²) recursive tree
        traversal with O(1) per-action widget lookups.
      • The QML scripting engine is no longer restarted unconditionally on every OK
        press; it is now only reloaded when the enabled state of at least one script
        actually changed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions