aboutsummaryrefslogtreecommitdiffstats
path: root/src/tagrulesdialog.h
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-13 16:15:57 +0200
committerDanilo M. <danix@danix.xyz>2026-08-13 16:15:57 +0200
commit3b771d03f2df572de29af3156817de3cb7ef6bef (patch)
treeefd17e55320e472ee27160d935034afe31add6e4 /src/tagrulesdialog.h
parenta52e4e41c2bc8fc8eb23c4bc99f9b8724212bd23 (diff)
downloadqtmaildir-3b771d03f2df572de29af3156817de3cb7ef6bef.tar.gz
qtmaildir-3b771d03f2df572de29af3156817de3cb7ef6bef.zip
feat(rules): the rules window keeps its size and column widths
Item 75. saveGeometry() and the rule list header's saveState() go to uistate.conf under keys of their own, written on closeEvent so a size survives Cancel as well as Save. The 760x520 resize stays as the first-run fallback. The backlog's approach was wrong on one point and a test caught it. It said to drop the resizeColumnToContents calls once a saved header state exists, which fixes the restore and leaves the original defect standing: with nothing saved, a width the user had just dragged was still discarded by the next add or delete. Each column is instead auto-sized once, on its first fill, after which the width belongs to the user however it was set. Two flags, because the count column is filled later by a reply from the worker. The window stays a QDialog. Making it a top-level window needs the unsaved-edit story that being modal currently sidesteps, and that is its own decision rather than part of this item. Both tests redirect XDG_STATE_HOME as well as XDG_CONFIG_HOME, so they cannot write the real uistate.conf. The geometry is asserted on the stored value rather than the reopened frame, per item 46: the offscreen platform does not honour a resize. Also corrects setFolders' doc comment, which still described the folder list as coming from Config. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src/tagrulesdialog.h')
-rw-r--r--src/tagrulesdialog.h39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/tagrulesdialog.h b/src/tagrulesdialog.h
index 9559918..f86d210 100644
--- a/src/tagrulesdialog.h
+++ b/src/tagrulesdialog.h
@@ -56,9 +56,14 @@ public:
/// handle and notmuch permits one per process.
QStringList countQueries() const;
- /// Account subdirectory names, for the Folder row's dropdown. Supplied by
- /// the caller rather than read here: Config knows them, and this dialog
- /// deliberately holds no Config of its own.
+ /// Maildir folder paths, for the Folder row's dropdown, relative to the
+ /// database root. Supplied by the caller rather than read here: they come
+ /// from a scan of the tree under notmuch's database.path, which only
+ /// NotmuchWorker can answer for, and this dialog reaches neither it nor
+ /// Config.
+ ///
+ /// Arrives AFTER the dialog is on screen, since the scan crosses to the
+ /// worker on a queued call, so this refills the rows that already exist.
void setFolders(const QStringList &folders);
/// Test seams. The builder's state is otherwise reachable only through
@@ -88,6 +93,20 @@ public:
/// when the widget is not.
bool textModeToggleIsReachableForTest() const;
+ /// Width of one rule-list column. The geometry restore is asserted on the
+ /// saved and reread VALUE rather than on the resulting frame: item 46
+ /// records that the offscreen platform does not honour a window resize,
+ /// so a test comparing frames there passes or fails for reasons that have
+ /// nothing to do with the code.
+ int columnWidthForTest(int column) const;
+ void setColumnWidthForTest(int column, int width);
+
+ /// Repopulates the rule list, as adding or deleting a rule does. Exposed
+ /// because a restored column width has to survive one of these, not only
+ /// a close and reopen: `resizeColumnToContents` on every reload discarded
+ /// the width the user had dragged.
+ void reloadListForTest();
+
signals:
/// Asks the owner to run countQueries() through the worker.
void countsRequested();
@@ -104,8 +123,13 @@ private slots:
void applyEditsToCurrentRule();
void onSave();
+protected:
+ void closeEvent(QCloseEvent *event) override;
+
private:
void reloadList();
+ void restoreUiState();
+ void saveUiState();
void showWarnings();
int currentIndex() const;
@@ -160,6 +184,15 @@ private:
/// row's text, which applyEditsToCurrentRule() has no chance to flush.
bool m_reloading = false;
+ /// Each column is auto-sized to its contents ONCE, on its first fill.
+ /// After that its width belongs to the user, whether it came from a
+ /// restored header or from a drag, and resizeColumnToContents on every
+ /// repopulate threw both away on the next add or delete. Two flags rather
+ /// than one because the count column is filled later than the rest, by a
+ /// reply from the worker.
+ bool m_columnsSized = false;
+ bool m_countColumnSized = false;
+
QTreeWidget *m_list = nullptr;
QLineEdit *m_id = nullptr;
QLineEdit *m_add = nullptr;