Push non-default app scale to IV.

This commit is contained in:
John Preston
2026-03-13 14:33:20 +04:00
parent 4ba2581df8
commit 1610ad345f
4 changed files with 38 additions and 7 deletions
+29 -3
View File
@@ -25,6 +25,19 @@ namespace {
constexpr auto kInitialVideoQuality = 480; // Start with SD.
[[nodiscard]] int DefaultIvZoom() {
const auto exact = cScale() * 100 / cScreenScale();
const auto snap10 = ((exact + 5) / 10) * 10;
const auto snap25 = ((exact + 12) / 25) * 25;
return (std::abs(exact - snap25) <= std::abs(exact - snap10))
? snap25
: snap10;
}
[[nodiscard]] int ResolveIvZoom(int value) {
return (value > 0) ? value : DefaultIvZoom();
}
[[nodiscard]] WindowPosition Deserialize(const QByteArray &data) {
QDataStream stream(data);
stream.setVersion(QDataStream::Qt_5_1);
@@ -1518,7 +1531,7 @@ void Settings::resetOnLastLogout() {
_hiddenGroupCallTooltips = 0;
_storiesClickTooltipHidden = false;
_ttlVoiceClickTooltipHidden = false;
_ivZoom = 100;
_ivZoom = 0;
_recordVideoMessages = false;
_videoQuality = {};
_chatFiltersHorizontal = false;
@@ -1681,14 +1694,18 @@ bool Settings::rememberedDeleteMessageOnlyForYou() const {
}
int Settings::ivZoom() const {
return _ivZoom.current();
return ResolveIvZoom(_ivZoom.current());
}
rpl::producer<int> Settings::ivZoomValue() const {
return _ivZoom.value();
return _ivZoom.value() | rpl::map(ResolveIvZoom);
}
void Settings::setIvZoom(int value) {
if (!value || value == DefaultIvZoom()) {
_ivZoom = 0;
return;
}
#ifdef Q_OS_WIN
constexpr auto kMin = 25;
constexpr auto kMax = 500;
@@ -1699,6 +1716,15 @@ void Settings::setIvZoom(int value) {
_ivZoom = std::clamp(value, kMin, kMax);
}
bool Settings::normalizeIvZoom() {
const auto value = _ivZoom.current();
if (value && value == DefaultIvZoom()) {
_ivZoom = 0;
return true;
}
return false;
}
Media::VideoQuality Settings::videoQuality() const {
return _videoQuality;
}
+2 -1
View File
@@ -958,6 +958,7 @@ public:
[[nodiscard]] int ivZoom() const;
[[nodiscard]] rpl::producer<int> ivZoomValue() const;
void setIvZoom(int value);
bool normalizeIvZoom();
[[nodiscard]] bool chatFiltersHorizontal() const;
[[nodiscard]] rpl::producer<bool> chatFiltersHorizontalChanges() const;
@@ -1117,7 +1118,7 @@ private:
bool _systemUnlockEnabled = false;
std::optional<bool> _weatherInCelsius;
QByteArray _tonsiteStorageToken;
rpl::variable<int> _ivZoom = 100;
rpl::variable<int> _ivZoom = 0;
Media::VideoQuality _videoQuality;
rpl::variable<bool> _chatFiltersHorizontal = false;
+3 -3
View File
@@ -106,7 +106,7 @@ public:
resetLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
reset->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
reset->setClickedCallback([this] {
_delegate->ivSetZoom(kDefaultZoom);
_delegate->ivSetZoom(0);
});
reset->show();
const auto plus = Ui::CreateSimpleCircleButton(
@@ -699,7 +699,7 @@ void Controller::createWebview(const Webview::StorageId &storageId) {
_delegate->ivSetZoom(_delegate->ivZoom() - kZoomStep);
return base::EventFilterResult::Cancel;
} else if (event->key() == Qt::Key_0) {
_delegate->ivSetZoom(kDefaultZoom);
_delegate->ivSetZoom(0);
return base::EventFilterResult::Cancel;
}
}
@@ -1016,7 +1016,7 @@ void Controller::processKey(const QString &key, const QString &modifier) {
} else if (key == u"q"_q && modifier == ctrl) {
quit();
} else if (key == u"0"_q && modifier == ctrl) {
_delegate->ivSetZoom(kDefaultZoom);
_delegate->ivSetZoom(0);
}
}
+4
View File
@@ -848,6 +848,10 @@ void Instance::show(
Core::App().hideMediaView();
}
if (Core::App().settings().normalizeIvZoom()) {
Core::App().saveSettingsDelayed();
}
const auto guard = gsl::finally([&] {
requestFull(session, data->id());
});