aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_config.cpp
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-09 09:54:00 +0200
committerDanilo M. <danix@danix.xyz>2026-08-09 09:54:00 +0200
commit955c273565521d9559e5760ca252a77c53a7aaa9 (patch)
tree08ff85b9b46c5c823851acffa41ff11940ac6630 /tests/test_config.cpp
parent2e66bb8b66df016164d44bf72a2d53b8c4a67dde (diff)
downloadqtmaildir-955c273565521d9559e5760ca252a77c53a7aaa9.tar.gz
qtmaildir-955c273565521d9559e5760ca252a77c53a7aaa9.zip
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 <noreply@anthropic.com>
Diffstat (limited to 'tests/test_config.cpp')
-rw-r--r--tests/test_config.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/test_config.cpp b/tests/test_config.cpp
index 079ba3b..ec630d4 100644
--- a/tests/test_config.cpp
+++ b/tests/test_config.cpp
@@ -31,6 +31,10 @@ private slots:
void missingSyncCommandIsEmpty();
void syncLogDefaultsToTheScriptsOwnPath();
void syncLogCanBeOverridden();
+ void toolbarIconSizeDefaultsTo24();
+ void toolbarIconSizeIsActuallyRead();
+ void toolbarIconSizeIsClampedAndReported();
+ void toolbarIconSizeRejectsGarbage();
void accountWithoutMaildirIsRejected();
void scopedQueryWrapsCorrectly();
void absentSyncCommandIsNoticeNotProblem();
@@ -170,6 +174,85 @@ void TestConfig::syncLogCanBeOverridden()
QCOMPARE(config.syncLog(), QStringLiteral("/var/log/mail/sync.log"));
}
+void TestConfig::toolbarIconSizeDefaultsTo24()
+{
+ // The desktop's own metric is the obvious default and was rejected: this
+ // style reports PM_ToolBarIconSize as 16, which is a small click target for
+ // a toolbar that now shows icons with no text beside them. 24 is a normal
+ // toolbar size, and setting the key back to 16 restores the theme's value.
+ QTemporaryDir dir;
+ const QString path = writeIni(dir, QStringLiteral("[general]\n"));
+
+ Config config;
+ config.load(path);
+
+ QCOMPARE(config.toolbarIconSize(), 24);
+ QVERIFY(config.problems().isEmpty());
+}
+
+void TestConfig::toolbarIconSizeIsActuallyRead()
+{
+ // [general] keys are read WITHOUT the general/ prefix, per the note at the
+ // top of Config::load(). A key that silently matched nothing would leave
+ // the default in place and look exactly like a working default.
+ QTemporaryDir dir;
+ const QString path = writeIni(dir, QStringLiteral(
+ "[general]\n"
+ "toolbar_icon_size = 32\n"
+ ));
+
+ Config config;
+ config.load(path);
+
+ QCOMPARE(config.toolbarIconSize(), 32);
+}
+
+void TestConfig::toolbarIconSizeIsClampedAndReported()
+{
+ // Out of range is clamped rather than honoured: 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. Reported, because silently
+ // ignoring what the user asked for is how message_zoom's documented 0.5-3.0
+ // range came to be unenforced without anyone noticing.
+ QTemporaryDir dir;
+ const QString tooBig = writeIni(dir, QStringLiteral(
+ "[general]\n"
+ "toolbar_icon_size = 4000\n"
+ ));
+
+ Config big;
+ big.load(tooBig);
+ QCOMPARE(big.toolbarIconSize(), 64);
+ QVERIFY(!big.warnings().isEmpty() || !big.problems().isEmpty());
+
+ QTemporaryDir dir2;
+ const QString tooSmall = writeIni(dir2, QStringLiteral(
+ "[general]\n"
+ "toolbar_icon_size = 2\n"
+ ));
+
+ Config small;
+ small.load(tooSmall);
+ QCOMPARE(small.toolbarIconSize(), 16);
+}
+
+void TestConfig::toolbarIconSizeRejectsGarbage()
+{
+ // Unparseable falls back to the default and says so, matching how
+ // mark_read_delay_ms treats the same mistake.
+ QTemporaryDir dir;
+ const QString path = writeIni(dir, QStringLiteral(
+ "[general]\n"
+ "toolbar_icon_size = enormous\n"
+ ));
+
+ Config config;
+ config.load(path);
+
+ QCOMPARE(config.toolbarIconSize(), 24);
+ QVERIFY(!config.problems().isEmpty());
+}
+
void TestConfig::accountWithoutMaildirIsRejected()
{
QTemporaryDir dir;