summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-03 09:15:07 +0200
committerDanilo M. <danix@danix.xyz>2026-08-04 12:52:48 +0200
commitd358e3ea59cfad6a7c93f80290bab0e19bde7bbb (patch)
tree095ac1a493d5dafed37bc3b831c2645f0500a815 /src/main.cpp
parent2caf15d2d032ec6fff0ca732f6ba4759ee91685d (diff)
downloadqtmaildir-d358e3ea59cfad6a7c93f80290bab0e19bde7bbb.tar.gz
qtmaildir-d358e3ea59cfad6a7c93f80290bab0e19bde7bbb.zip
feat: add MainWindow wiring query, list, message, and sync
Wires the worker thread, thread list, message pane, sync process and undo stack together, and replaces the placeholder main() with real startup: custom URL schemes registered before QApplication, a libnotmuch ABI check, and config loading. Four fixes against the drafted version: - onWorkerError() only set a status label. Its own comment elsewhere claimed it reverted the optimistic update, and the spec requires that; it did not, so a rejected write left the list showing a tag the database never received. The pending change is now recorded and rolled back, and a confirmed tagsApplied clears it so a later unrelated error cannot undo a write that succeeded. - runCurrentQuery() cleared the model but left the undo stack pointing at rows that no longer exist. Undoing after a new query would have written to the database while the visible list stayed put. The stack is cleared with the model. - m_currentMessages was assigned on every thread load and never read. Removed. - buildUi() connected sync output to m_syncLog and errors to m_statusLabel before either existed. Both are constructed before the wiring now. cidPrefix generation lives here, this being its only producer in the application, and is pinned by tests: it must never contain '!' and must be distinct per message, which are the invariants the cid: namespacing rests on. A second test holds registeredActionNames() against KeyMap::knownActions(), since those two hand-maintained lists drifting either way silently breaks a user's key binding. Mutation-verified that dropping an action fails the test by name. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 9c7b977..2c5dc13 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,10 +1,43 @@
#include <QApplication>
-#include <QLabel>
+#include <QMessageBox>
+#include <QWebEngineUrlScheme>
+
+#include <notmuch.h>
+
+#include "config.h"
+#include "mainwindow.h"
int main(int argc, char *argv[])
{
+ // Custom schemes must be registered before QApplication is constructed.
+ {
+ QWebEngineUrlScheme scheme(QByteArrayLiteral("cid"));
+ scheme.setFlags(QWebEngineUrlScheme::SecureScheme
+ | QWebEngineUrlScheme::ContentSecurityPolicyIgnored);
+ QWebEngineUrlScheme::registerScheme(scheme);
+ }
+ {
+ QWebEngineUrlScheme scheme(QByteArrayLiteral("qtmaildir"));
+ scheme.setFlags(QWebEngineUrlScheme::SecureScheme);
+ QWebEngineUrlScheme::registerScheme(scheme);
+ }
+
QApplication app(argc, argv);
- QLabel label(QStringLiteral("qtmaildir"));
- label.show();
+ app.setApplicationName(QStringLiteral("qtmaildir"));
+ app.setOrganizationName(QStringLiteral("qtmaildir"));
+
+ // Fail loudly on an ABI mismatch rather than crashing later.
+ if (LIBNOTMUCH_MAJOR_VERSION < 5) {
+ QMessageBox::critical(nullptr, QObject::tr("qtmaildir"),
+ QObject::tr("libnotmuch 5 or newer is required."));
+ return 1;
+ }
+
+ Config config;
+ config.load(Config::defaultPath());
+
+ MainWindow window(config);
+ window.show();
+
return app.exec();
}