From 955c273565521d9559e5760ca252a77c53a7aaa9 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sun, 9 Aug 2026 09:54:00 +0200 Subject: feat(ui): make the toolbar icon size configurable Follow-up to item 56. With the toolbar now following the desktop's button style, an "icon only" desktop makes the icon the whole control, and this style reports PM_ToolBarIconSize as 16px, which is a small target for a button with no text beside it. A [general] toolbar_icon_size key, 16 to 64, defaulting to 24 rather than to the style's own metric. Setting it to 16 restores the theme's value. Clamped and reported, unlike message_zoom, which documents a 0.5 to 3.0 range in the README and enforces none of it. Both ends here break the UI that would be used to fix them: too small is an invisible icon, too large is a toolbar taller than the window. The unenforced message_zoom range is recorded as item 58 rather than fixed here, since it is a separate defect that predates this change. Also documents in the README that saved-query button labels are the key names from the user's own [queries] section, which is why the "Flagged" button still read that way after the action was renamed: it is a user's query name, not a string this code owns. The sample config now shows `Important = tag:flagged` to teach the wording the UI uses. Co-Authored-By: Claude Opus 5 --- src/config.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/config.cpp') diff --git a/src/config.cpp b/src/config.cpp index 12c5632..b54d5c6 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -24,6 +24,16 @@ #include #include +namespace { + +/// Bounds for [general] toolbar_icon_size. 16 is the smallest size the icon +/// themes actually ship art for, and is what this desktop's style reports; +/// above 64 the toolbar is taller than the thread rows it sits over. +constexpr int kMinToolbarIconSize = 16; +constexpr int kMaxToolbarIconSize = 64; + +} // namespace + QString Account::scopedQuery(const QString &query) const { const QString prefix = QStringLiteral("path:\"%1/**\"").arg(maildir); @@ -93,6 +103,34 @@ void Config::load(const QString &path) m_completionOnFocus = settings.value(QStringLiteral("completion_on_focus"), false).toBool(); + // Clamped, unlike message_zoom above, which documents a 0.5 to 3.0 range in + // the README and enforces none of it. Both ends here are unrecoverable from + // the UI they break: too small is an invisible icon, too large is a toolbar + // taller than the window, and in either case the control the user would + // reach for to fix it is the one that just broke. + const QVariant iconSize = settings.value(QStringLiteral("toolbar_icon_size")); + if (iconSize.isValid()) { + bool ok = false; + const int value = iconSize.toString().trimmed().toInt(&ok); + if (!ok) { + addProblem(QStringLiteral("Toolbar icon size '%1' is not a number; " + "using %2.") + .arg(iconSize.toString()) + .arg(m_toolbarIconSize)); + } else if (value < kMinToolbarIconSize || value > kMaxToolbarIconSize) { + m_toolbarIconSize = + qBound(kMinToolbarIconSize, value, kMaxToolbarIconSize); + addProblem(QStringLiteral("Toolbar icon size %1 is outside %2 to " + "%3; using %4.") + .arg(value) + .arg(kMinToolbarIconSize) + .arg(kMaxToolbarIconSize) + .arg(m_toolbarIconSize)); + } else { + m_toolbarIconSize = value; + } + } + // Absent is silent, the default being 2000. Present but unparseable warns, // for the same reason message_zoom does: the user asked for something and // is not getting it. -- cgit v1.2.3