summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.cpp38
-rw-r--r--src/config.h13
-rw-r--r--src/mainwindow.cpp8
3 files changed, 59 insertions, 0 deletions
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 <QSettings>
#include <QStandardPaths>
+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<SavedQuery> 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<Qt::ToolButtonStyle>(
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