diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-03 15:42:40 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-03 15:42:40 +0200 |
| commit | eb35acda4207392c10b4b1192b3b057bcad99a47 (patch) | |
| tree | c962e91fc502ec57d92df386e773033fe42fd17b /src/keymap.h | |
| parent | afd20c9527fa77ba60901707c7bc73b2af926a67 (diff) | |
| parent | f62ced3c2c85675e746bff7ef8aca5c75c9737e0 (diff) | |
| download | qtmaildir-eb35acda4207392c10b4b1192b3b057bcad99a47.tar.gz qtmaildir-eb35acda4207392c10b4b1192b3b057bcad99a47.zip | |
Merge branch 'feature/qaction-menus'
Menus, a toolbar and a generated shortcut reference, built on converting
the action registry from a hash of callbacks to QActions. Along the way:
three default key bindings that had never fired, a shortcut dialog taller
than the screen, thread list columns that could not be resized, no visible
feedback that a tag action had landed, and a tags column so wide it was
unreadable.
Backlog items 3, 8, 9, 13 and 14 done; 11 partly.
Diffstat (limited to 'src/keymap.h')
| -rw-r--r-- | src/keymap.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/keymap.h b/src/keymap.h index 564eb10..1c7df5f 100644 --- a/src/keymap.h +++ b/src/keymap.h @@ -20,6 +20,8 @@ #include <QHash> #include <QKeySequence> +#include <QList> +#include <QPair> #include <QStringList> class QSettings; @@ -33,6 +35,11 @@ public: /// anything not in this set, so a typo in the config cannot bind silently. static QStringList knownActions(); + /// The built-in bindings, in menu order: {sequence, action}. The single + /// source of truth for the defaults, so the menus, the shortcut reference + /// and loadDefaults() cannot disagree about them. + static QList<QPair<QString, QString>> defaultBindings(); + void loadDefaults(); /// Reads the [keys] group. Invalid sequences and unknown action names are @@ -42,6 +49,26 @@ public: /// Empty string when nothing is bound. QString actionFor(const QKeySequence &sequence) const; + /// The sequence currently bound to an action, empty if none. The reverse + /// of actionFor(): menus need a shortcut for an action they already know. + /// When several sequences are bound to one action, returns the shortest + /// text, so the menu shows a stable choice rather than a hash-order one. + QKeySequence sequenceFor(const QString &action) const; + + /// The built-in sequence for an action, ignoring any user override. + static QKeySequence defaultSequenceFor(const QString &action); + + /// Every action name carrying a built-in binding. + static QStringList defaultActions(); + + /// Normalizes a configured key string into the sequence a real keypress + /// produces. QKeySequence::fromString() discards the case of a bare + /// letter, so "N" parses to plain Key_N, which no keystroke ever emits: + /// typing a capital sends Shift+N. A bare uppercase letter is therefore + /// rewritten to Shift+<letter>. Returns an empty sequence for input + /// fromString() cannot parse. + static QKeySequence normalizeSequence(const QString &text); + QStringList warnings() const { return m_warnings; } private: |
