diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-15 11:24:07 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-15 11:24:07 +0200 |
| commit | a15505d408895d53f2fb4321836931a1b0742b7d (patch) | |
| tree | 169e926120b245d162b7c444f2343883c4291181 /src | |
| parent | 6bdf5039fa5232206f4f55db6e269038ca83358a (diff) | |
| download | qtmaildir-a15505d408895d53f2fb4321836931a1b0742b7d.tar.gz qtmaildir-a15505d408895d53f2fb4321836931a1b0742b7d.zip | |
fix(filters): label the flagged filter Important, and give the four icons
Item 57 renamed the `flag` action to "Important" in 0.14.0, chosen over
"Starred" partly because &I was free where &S collided with Mark spam. Item 93
then shipped the filter for the same tag as "Flagged", so one window offered
both names for one thing. The generator keeps its own name, `flagged`: that
string is stored in queries.json and matched against a closed set, so it is
wire format rather than a label.
The filters are QToolButtons now, like the Save button at the other end of the
row, carrying a themed icon with the text beside it. Icon AND text for the
reason the Save button already records: this row is a row of text buttons, so
an icon alone reads as a different kind of control than it is. Theme icons
rather than the shipped SVGs in Marks, because item 70's split is that the
panes are ours and the chrome is the system's, and the query row is chrome.
mail-mark-important matches the `flag` action's own icon, since the filter
finds what the action marks.
The icon test asserts a NAME was requested rather than that the icon resolved:
QIcon::fromTheme returns null where no icon theme is installed, so isNull()
would fail for a reason unrelated to this code. Dropping the setIcon call fails
it.
Widening the buttons to QToolButton broke eleven tests that reached them
through findChild<QPushButton *>, which does not match a sibling type. The
helpers and the filter lookups take QAbstractButton; savedQueryButton() stays
on QPushButton, since the user's own queries really are those.
Diffstat (limited to 'src')
| -rw-r--r-- | src/config.cpp | 7 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 31 |
2 files changed, 35 insertions, 3 deletions
diff --git a/src/config.cpp b/src/config.cpp index ece1fb9..0b7fe86 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -719,7 +719,12 @@ SavedQuery Config::builtinFilter(const QString &generator) } else if (generator == QStringLiteral("inbox")) { filter.name = tr("Inbox"); } else if (generator == QStringLiteral("flagged")) { - filter.name = tr("Flagged"); + // "Important", matching the `flag` action, which item 57 renamed from + // "Flag" for exactly this reason. Shipping the filter as "Flagged" + // beside it put the same tag under two names in one window. The + // GENERATOR stays `flagged`: that string is stored in queries.json and + // matched against a closed set, so it is wire format, not a label. + filter.name = tr("Important"); } else if (generator == QStringLiteral("sent")) { filter.name = tr("Sent"); // Messages rather than threads, and the only filter that sets this. A diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bf1a33b..4343479 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1731,11 +1731,38 @@ void MainWindow::buildSavedQueryRow(QWidget *parent, QVBoxLayout *layout) == Config::matchNothingQuery()) continue; - auto *button = new QPushButton(filter.name, row); + // A QToolButton, like the Save button at the other end of the row, so + // the two shipped controls carry icons the same way. The user's own + // queries stay plain QPushButtons: they have no icon to carry and + // nothing to say about which is which. + auto *button = new QToolButton(row); + button->setText(filter.name); // A stable object name per filter, so a test finds the button without // depending on the label, which is translated. button->setObjectName(filter.generated + QStringLiteral("Button")); - connect(button, &QPushButton::clicked, this, + + // Theme icons, not the shipped SVGs in Marks: item 70's split is that + // the panes are ours and the chrome is the system's, and the query row + // is chrome. A name the running theme lacks degrades to text on its + // own, which is why nothing here checks whether it resolved. + // + // mail-mark-important matches the `flag` action's own icon, since both + // reach the same tag: the filter finds what the action marks. + static const QHash<QString, QString> filterIcons = { + { QStringLiteral("unread"), QStringLiteral("mail-mark-unread") }, + { QStringLiteral("inbox"), QStringLiteral("mail-inbox") }, + { QStringLiteral("flagged"), QStringLiteral("mail-mark-important") }, + { QStringLiteral("sent"), QStringLiteral("mail-sent") }, + }; + button->setIcon( + QIcon::fromTheme(filterIcons.value(filter.generated))); + + // Icon AND text, for the reason the Save button records: this row is a + // row of text buttons, so an icon on its own reads as a different kind + // of control than it is. + button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + + connect(button, &QToolButton::clicked, this, [this, filter]() { runFilter(filter); }); box->addWidget(button); } |
