aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-13 19:35:15 +0200
committerDanilo M. <danix@danix.xyz>2026-08-13 19:35:15 +0200
commit59f5161500ef670421cbba9665bd4aadbbb9ad30 (patch)
tree1e27e7bf854ee4127f1e1101b662df1b99561c72 /src
parent14842cd136e45c551dde4f276af1176bfdf22023 (diff)
downloadqtmaildir-59f5161500ef670421cbba9665bd4aadbbb9ad30.tar.gz
qtmaildir-59f5161500ef670421cbba9665bd4aadbbb9ad30.zip
feat(queries): right-align the More queries menu, and keep the row when nothing is pinned
The saved-query buttons are the row's content and read as a set; the overflow menu is a control over that set, so it belongs apart from them rather than trailing the last button. Moving the stretch above it pushes it to the right edge. Doing that exposed a latent defect in the same function. The row hid itself when its layout held nothing but the stretch, which was written as a count of one and happened to be right only because the stretch went last. With the stretch moved the count changes, and the condition as written would have hidden a row holding only the menu: a config with saved queries but none pinned would have had no route to any of them, the menu buried along with the row. The check now counts the content added before the stretch and treats an unpinned query as content in its own right. Both are mutation-checked. Putting the stretch back at the end fails the alignment test, and restoring the old hide condition fails the new one, which asserts the row survives with nothing but unpinned queries in it. The alignment is asserted on the layout's own ordering rather than on x coordinates, since a geometry assertion would also pass for a row that merely ran out of width. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 9eff3d5..61c883e 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1692,6 +1692,13 @@ void MainWindow::buildSavedQueryRow(QWidget *parent, QVBoxLayout *layout)
box->addWidget(sentButton);
}
+ // Everything above is left-aligned; the stretch here pushes what follows
+ // to the right edge. The buttons are the row's content and read as a set,
+ // while the overflow menu is a control over that set, so it sits apart
+ // from them rather than trailing the last one.
+ const int contentCount = box->count();
+ box->addStretch(1);
+
// The overflow menu, and only when something is in it: an empty menu
// button is a control that always does nothing.
if (!unpinned.isEmpty()) {
@@ -1707,12 +1714,13 @@ void MainWindow::buildSavedQueryRow(QWidget *parent, QVBoxLayout *layout)
box->addWidget(menuButton);
}
- box->addStretch(1);
layout->addWidget(row);
- // Nothing saved and no sent folder leaves an empty strip of padding, so
- // the row goes away rather than sitting there as a gap.
- if (box->count() == 1)
+ // Nothing on either side of the stretch leaves an empty strip of padding,
+ // so the row goes away rather than sitting there as a gap. Counted before
+ // the stretch was added, since the stretch is always there: an unpinned
+ // query with no pinned ones still needs the row for its menu.
+ if (contentCount == 0 && unpinned.isEmpty())
row->hide();
}