aboutsummaryrefslogtreecommitdiffstats
path: root/src/mainwindow.h
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-03 15:42:40 +0200
committerDanilo M. <danix@danix.xyz>2026-08-03 15:42:40 +0200
commiteb35acda4207392c10b4b1192b3b057bcad99a47 (patch)
treec962e91fc502ec57d92df386e773033fe42fd17b /src/mainwindow.h
parentafd20c9527fa77ba60901707c7bc73b2af926a67 (diff)
parentf62ced3c2c85675e746bff7ef8aca5c75c9737e0 (diff)
downloadqtmaildir-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/mainwindow.h')
-rw-r--r--src/mainwindow.h33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 30679bb..4445894 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -28,8 +28,10 @@
#include "config.h"
#include "keymap.h"
+#include "tagcolors.h"
#include "types.h"
+class QAction;
class QLineEdit;
class QTableView;
class QLabel;
@@ -49,10 +51,10 @@ public:
explicit MainWindow(const Config &config, QWidget *parent = nullptr);
~MainWindow() override;
- /// Every action name registerActions() installs. Exposed so a test can hold
- /// it against KeyMap::knownActions(): the two lists are maintained by hand,
- /// and a drift either way silently breaks a user's key binding.
- static QStringList registeredActionNames();
+ /// Every action name registerActions() installs. Derived from the actions
+ /// themselves rather than hand-maintained, so it cannot drift from what is
+ /// really registered.
+ QStringList registeredActionNames() const;
/// The cid: namespace prefix for the nth message of a thread.
///
@@ -61,9 +63,6 @@ public:
/// cid: references from resolving to another's.
static QString cidPrefixForIndex(int index);
-protected:
- bool eventFilter(QObject *watched, QEvent *event) override;
-
private slots:
void runCurrentQuery();
void onThreadsReady(const QVector<ThreadSummary> &threads, quint64 generation);
@@ -76,8 +75,17 @@ private slots:
private:
void buildUi();
void registerActions();
+ void buildMenus();
void wireWorker();
void showWarnings();
+ void showShortcutReference();
+ void showAbout();
+
+ /// Creates a QAction, binds it to the sequence KeyMap holds for `name`,
+ /// and registers it. `name` is the action name used in [keys].
+ QAction *addAction(const QString &name, const QString &text,
+ const QString &description,
+ const std::function<void()> &handler);
void tagSelected(const QStringList &add, const QStringList &remove,
const QString &description);
@@ -96,6 +104,7 @@ private:
Config m_config;
KeyMap m_keyMap;
+ TagColors m_tagColors;
QThread m_workerThread;
NotmuchWorker *m_worker = nullptr;
@@ -112,7 +121,15 @@ private:
QLabel *m_statusLabel = nullptr;
QPlainTextEdit *m_syncLog = nullptr;
- QHash<QString, std::function<void()>> m_actions;
+ /// Action name (as used in [keys]) to the QAction implementing it. Owned
+ /// by the window through the QObject parent, not by this hash.
+ QHash<QString, QAction *> m_actions;
+
+ /// One-line description per action, for the shortcut reference. Kept
+ /// beside the actions so the dialog is generated, never hand-written in
+ /// parallel with them.
+ QHash<QString, QString> m_actionDescriptions;
+
quint64 m_generation = 0;
QString m_lastQuery;
QString m_currentThreadId;