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 ++++++++++++++++++++++++++++++++++++++ src/config.h | 13 +++++++++++++ src/mainwindow.cpp | 8 ++++++++ 3 files changed, 59 insertions(+) (limited to 'src') 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. diff --git a/src/config.h b/src/config.h index 3174a03..3dd9011 100644 --- a/src/config.h +++ b/src/config.h @@ -90,6 +90,18 @@ public: /// Empty when unset; the caller disables the Sync button in that case. QString syncCommand() const { return m_syncCommand; } + /// Toolbar icon size in pixels, 16 to 64, defaulting to 24. + /// + /// The desktop's own PM_ToolBarIconSize was the obvious default and was + /// rejected empirically: it reports 16 here, which is a small target now + /// that the toolbar follows the platform's "icon only" style and the icon + /// is the whole control. Setting this to 16 restores the theme's value. + /// + /// Clamped rather than trusted: a 4px icon is invisible and a 4000px one + /// makes the toolbar taller than the window, and neither is recoverable + /// from the UI the value just broke. + int toolbarIconSize() const { return m_toolbarIconSize; } + /// The sync script's log file, read to learn the outcome of a sync this /// process did not start (item 54). /// @@ -171,6 +183,7 @@ private: QList m_savedQueries; QString m_syncCommand; QString m_syncLog; + int m_toolbarIconSize = 24; QString m_notmuchConfig; qreal m_messageZoom = 1.0; bool m_completionOnFocus = false; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 865c691..a176d71 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -988,6 +988,14 @@ void MainWindow::buildMenus() // which would ignore the setting just as thoroughly in the other direction. toolBar->setToolButtonStyle(static_cast( style()->styleHint(QStyle::SH_ToolButtonStyle, nullptr, toolBar))); + + // Set explicitly rather than left to the style. With the button style above + // resolving to icon-only on this desktop, the icon IS the control, and this + // style's PM_ToolBarIconSize is 16px, which is a small target for it. + // Configurable because the right answer depends on the display, not on + // anything this code can see. + const int iconSize = m_config.toolbarIconSize(); + toolBar->setIconSize(QSize(iconSize, iconSize)); QAction *syncAction = m_actions.value(QStringLiteral("sync")); // Carried over from the QPushButton this replaced: with no command // configured the control is disabled, and the tooltip is the only thing -- cgit v1.2.3