summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-09 11:06:16 +0200
committerDanilo M. <danix@danix.xyz>2026-08-09 11:06:16 +0200
commit99709c65f674385d6fbe9da53fe91c5f6a715880 (patch)
tree11036afc447201c03f9d4613ff2644291a723207
parent485ae659078c76d2f14fa5b1090241b2ef140b79 (diff)
downloadqtmaildir-99709c65f674385d6fbe9da53fe91c5f6a715880.tar.gz
qtmaildir-99709c65f674385d6fbe9da53fe91c5f6a715880.zip
fix(config): report an out-of-range message_zoom
The documented 0.5 to 3.0 range was already enforced, by MessageView::clampZoom(), so message_zoom = 500 rendered at 3.0 rather than unusably. What was missing is the report: the key parses, so nothing ever told the user that the value in their file is not the value on screen. Reported rather than clamped a second time. MessageView owns the bounds and does the work; a copy of the range in Config would be free to drift from the one that matters, so config.cpp reports against kMinZoom and kMaxZoom directly. This is where it differs from toolbar_icon_size, which has no widget-side enforcement to defer to. Backlog item 58, whose recorded cause was wrong on this point and has been corrected in place.
-rw-r--r--src/config.cpp19
-rw-r--r--tests/test_config.cpp29
2 files changed, 46 insertions, 2 deletions
diff --git a/src/config.cpp b/src/config.cpp
index b54d5c6..4f5831c 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -19,6 +19,9 @@
#include "config.h"
#include "mailsync.h"
+// For kMinZoom/kMaxZoom. The bounds live with the widget that enforces them,
+// so this reports the same numbers rather than keeping a second copy.
+#include "messageview.h"
#include <QFileInfo>
#include <QSettings>
@@ -76,8 +79,8 @@ void Config::load(const QString &path)
// Absent is fine and silent: the default is 1.0. Present but unparseable
// is a problem, since the user asked for something and is not getting it.
- // The range check lives in MessageView::clampZoom(), the one place that
- // knows what the web view can render.
+ // The range is enforced by MessageView::clampZoom(), the one place that
+ // knows what the web view can render; out of range is reported below.
// Empty is treated as unset rather than as "a query named nothing".
const QString startup =
settings.value(QStringLiteral("startup_query")).toString().trimmed();
@@ -92,6 +95,18 @@ void Config::load(const QString &path)
const double value = zoom.toString().toDouble(&ok);
if (ok) {
m_messageZoom = value;
+ // Reported, not clamped: MessageView::clampZoom() owns the bounds
+ // and already stops this reaching the web view, so clamping here
+ // too would be a second copy of the range, free to drift from the
+ // first. What was missing is the report. The value parses, so
+ // nothing ever said the 500 in the file is not what is on screen.
+ if (value < MessageView::kMinZoom || value > MessageView::kMaxZoom) {
+ addProblem(QStringLiteral("Message zoom %1 is outside %2 to %3; "
+ "using the nearest allowed value.")
+ .arg(value)
+ .arg(MessageView::kMinZoom)
+ .arg(MessageView::kMaxZoom));
+ }
} else {
addProblem(QStringLiteral("Message zoom '%1' is not a number; "
"using the default.")
diff --git a/tests/test_config.cpp b/tests/test_config.cpp
index ec630d4..7e0d6fb 100644
--- a/tests/test_config.cpp
+++ b/tests/test_config.cpp
@@ -46,6 +46,7 @@ private slots:
void unknownStartupQueryFallsBackAndReports();
void generalSectionKeysAreActuallyRead();
void messageZoomDefaultsAndValidates();
+ void messageZoomOutOfRangeIsReported();
void completionOnFocusDefaultsToFalse();
void completionOnFocusIsActuallyRead();
void markReadDelayDefaultsToTwoSeconds();
@@ -478,6 +479,34 @@ void TestConfig::messageZoomDefaultsAndValidates()
}
}
+void TestConfig::messageZoomOutOfRangeIsReported()
+{
+ // MessageView::clampZoom() already stops an out-of-range value from
+ // reaching the web view, so this is not about the render. It is about the
+ // silence: the key parses, so nothing ever told the user that the 500 they
+ // wrote is not what they are looking at. Not clamped here, because
+ // clampZoom() owns the bounds and two copies would drift.
+ QTemporaryDir dir;
+ Config config;
+ config.load(writeIni(dir, QStringLiteral("[general]\n"
+ "message_zoom=500\n")));
+ QCOMPARE(config.problems().size(), 1);
+ QVERIFY(config.problems().first().contains(QStringLiteral("500")));
+
+ QTemporaryDir dir2;
+ Config small;
+ small.load(writeIni(dir2, QStringLiteral("[general]\n"
+ "message_zoom=0.1\n")));
+ QCOMPARE(small.problems().size(), 1);
+
+ // In range stays silent.
+ QTemporaryDir dir3;
+ Config ok;
+ ok.load(writeIni(dir3, QStringLiteral("[general]\n"
+ "message_zoom=3.0\n")));
+ QVERIFY(ok.problems().isEmpty());
+}
+
void TestConfig::completionOnFocusDefaultsToFalse()
{
QTemporaryDir dir;