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 --- tests/test_mainwindow.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests/test_mainwindow.cpp') diff --git a/tests/test_mainwindow.cpp b/tests/test_mainwindow.cpp index 4a911c9..84a3a7d 100644 --- a/tests/test_mainwindow.cpp +++ b/tests/test_mainwindow.cpp @@ -120,6 +120,7 @@ private slots: void theToolbarDoesNotOverrideTheDesktopButtonStyle(); void theImportantActionIsLabelledImportant(); void theImportantActionStillWritesTheFlaggedTag(); + void theToolbarUsesTheConfiguredIconSize(); }; void TestMainWindow::everyKnownActionIsRegistered() @@ -2513,6 +2514,34 @@ void TestMainWindow::theImportantActionStillWritesTheFlaggedTag() "written, which no other tool reading this Maildir knows"); } +void TestMainWindow::theToolbarUsesTheConfiguredIconSize() +{ + // With the toolbar following the desktop's "Icon only" style, the icons are + // the whole control, and this style reports 16px, which is a small target. + // The size is configurable with a 24px default; this proves the config + // value actually reaches the widget rather than sitting in Config unread. + QTemporaryDir dir; + QVERIFY(dir.isValid()); + const QString path = dir.filePath(QStringLiteral("qtmaildir.conf")); + QFile file(path); + QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text)); + file.write("[general]\ntoolbar_icon_size = 40\n"); + file.close(); + + Config config; + config.load(path); + QCOMPARE(config.toolbarIconSize(), 40); + + MainWindow window(config); + auto *toolBar = window.findChild(QStringLiteral("main_toolbar")); + QVERIFY(toolBar); + + // 40 is deliberately not any of this style's own metrics (16 small, 32 + // large), so the assertion cannot pass by the widget happening to agree + // with the theme. + QCOMPARE(toolBar->iconSize(), QSize(40, 40)); +} + // Constructing a MainWindow needs a QApplication and a platform plugin. The // test has no display under ctest, so it runs offscreen unless the caller // asked for something else. -- cgit v1.2.3