Improve style, add zoom controls.

This commit is contained in:
John Preston
2026-05-15 15:08:40 +04:00
parent 7188ab0644
commit e467bc7da9
29 changed files with 1760 additions and 1572 deletions
+17 -11
View File
@@ -24,6 +24,8 @@ namespace Core {
namespace {
constexpr auto kInitialVideoQuality = 480; // Start with SD.
constexpr auto kMinIvZoom = 25;
constexpr auto kMaxIvZoom = 400;
[[nodiscard]] int DefaultIvZoom() {
const auto exact = cScale() * 100 / cScreenScale();
@@ -35,7 +37,10 @@ constexpr auto kInitialVideoQuality = 480; // Start with SD.
}
[[nodiscard]] int ResolveIvZoom(int value) {
return (value > 0) ? value : DefaultIvZoom();
return std::clamp(
(value > 0) ? value : DefaultIvZoom(),
kMinIvZoom,
kMaxIvZoom);
}
[[nodiscard]] WindowPosition Deserialize(const QByteArray &data) {
@@ -1798,25 +1803,26 @@ rpl::producer<int> Settings::ivZoomValue() const {
}
void Settings::setIvZoom(int value) {
if (!value || value == DefaultIvZoom()) {
const auto resolved = ResolveIvZoom(value);
if (!value || resolved == ResolveIvZoom(0)) {
_ivZoom = 0;
return;
}
#ifdef Q_OS_WIN
constexpr auto kMin = 25;
constexpr auto kMax = 500;
#else
constexpr auto kMin = 30;
constexpr auto kMax = 200;
#endif
_ivZoom = std::clamp(value, kMin, kMax);
_ivZoom = resolved;
}
bool Settings::normalizeIvZoom() {
const auto value = _ivZoom.current();
if (value && value == DefaultIvZoom()) {
if (!value) {
return false;
}
const auto resolved = ResolveIvZoom(value);
if (resolved == ResolveIvZoom(0)) {
_ivZoom = 0;
return true;
} else if (resolved != value) {
_ivZoom = resolved;
return true;
}
return false;
}