From b073e1e102adae55fcf033daf3c79d1d437de144 Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Fri, 4 Oct 2019 16:15:45 +0300 Subject: [PATCH] Making sticker height change optional --- .../Resources/default_kotato-settings-custom.json | 13 +++++++------ Telegram/SourceFiles/core/kotato_settings.cpp | 10 ++++++++++ Telegram/SourceFiles/history/history.style | 2 -- .../view/media/history_view_media_unwrapped.cpp | 2 +- .../history/view/media/history_view_sticker.cpp | 4 ++-- Telegram/SourceFiles/settings.cpp | 2 ++ Telegram/SourceFiles/settings.h | 9 +++++++++ 7 files changed, 31 insertions(+), 11 deletions(-) diff --git a/Telegram/Resources/default_kotato-settings-custom.json b/Telegram/Resources/default_kotato-settings-custom.json index 46fa536b5..6463fd6ef 100644 --- a/Telegram/Resources/default_kotato-settings-custom.json +++ b/Telegram/Resources/default_kotato-settings-custom.json @@ -2,10 +2,11 @@ // You can see full list of settings in the 'kotato-settings-default.json' file { - // "fonts": { - // "main": "Open Sans", - // "semibold": "Open Sans Semibold", - // "semibold_is_bold": false, - // "monospaced": "Consolas" - // } + // "fonts": { + // "main": "Open Sans", + // "semibold": "Open Sans Semibold", + // "semibold_is_bold": false, + // "monospaced": "Consolas" + // }, + // "sticker_height": 256 } diff --git a/Telegram/SourceFiles/core/kotato_settings.cpp b/Telegram/SourceFiles/core/kotato_settings.cpp index 237cffd7e..0d7372bfd 100644 --- a/Telegram/SourceFiles/core/kotato_settings.cpp +++ b/Telegram/SourceFiles/core/kotato_settings.cpp @@ -154,6 +154,14 @@ bool Manager::readCustomFile() { cSetMonospaceFont((*settingsFontsMonospace).toString()); } } + + const auto settingsStickerHeightIterator = settings.constFind(qsl("sticker_height")); + if (settingsStickerHeightIterator != settingsFonts.constEnd()) { + const auto settingsStickerHeight = (*settingsStickerHeightIterator).toInt(); + if (settingsStickerHeight > 0) { + cSetStickerHeight(settingsStickerHeight); + } + } return true; } @@ -181,6 +189,8 @@ void Manager::writeDefaultFile() { settings.insert(qsl("fonts"), settingsFonts); + settings.insert(qsl("sticker_height"), cStickerHeight()); + auto document = QJsonDocument(); document.setObject(settings); file.write(document.toJson(QJsonDocument::Indented)); diff --git a/Telegram/SourceFiles/history/history.style b/Telegram/SourceFiles/history/history.style index e0ef7cae5..d7050d4bb 100644 --- a/Telegram/SourceFiles/history/history.style +++ b/Telegram/SourceFiles/history/history.style @@ -20,8 +20,6 @@ maxWallPaperWidth: 160px; maxWallPaperHeight: 240px; historyThemeSize: size(272px, 176px); -historyStickerHeight: 128px; - historyMinimalWidth: 380px; historyScroll: ScrollArea(defaultScrollArea) { diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp b/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp index 3278259ec..b7ddf9e3e 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp @@ -32,7 +32,7 @@ QSize UnwrappedMedia::countOptimalSize() { _content->refreshLink(); _contentSize = NonEmptySize(DownscaledSize( _content->size(), - { st::maxStickerSize, st::historyStickerHeight })); + { st::maxStickerSize, cStickerHeight() })); auto maxWidth = _contentSize.width(); const auto minimal = st::largeEmojiSize + 2 * st::largeEmojiOutline; auto minHeight = std::max(_contentSize.height(), minimal); diff --git a/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp b/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp index ac2a506d6..5e567dc66 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp @@ -60,13 +60,13 @@ QSize Sticker::size() { constexpr auto kIdealStickerSize = 512; const auto zoom = GetEmojiStickerZoom(&_document->session()); const auto convert = [&](int size) { - return int(size * st::historyStickerHeight * zoom / kIdealStickerSize); + return int(size * cStickerHeight() * zoom / kIdealStickerSize); }; _size = QSize(convert(_size.width()), convert(_size.height())); } else { _size = DownscaledSize( _size, - { st::maxStickerSize, st::historyStickerHeight }); + { st::maxStickerSize, cStickerHeight() }); } return _size; } diff --git a/Telegram/SourceFiles/settings.cpp b/Telegram/SourceFiles/settings.cpp index bf26090bf..0c05a94f3 100644 --- a/Telegram/SourceFiles/settings.cpp +++ b/Telegram/SourceFiles/settings.cpp @@ -209,3 +209,5 @@ rpl::producer<> UpdatedRecentEmoji() { QString gMainFont, gSemiboldFont, gMonospaceFont; bool gSemiboldFontIsBold = false; + +int gStickerHeight = 256; \ No newline at end of file diff --git a/Telegram/SourceFiles/settings.h b/Telegram/SourceFiles/settings.h index 4e9abe661..e6e8b3b7b 100644 --- a/Telegram/SourceFiles/settings.h +++ b/Telegram/SourceFiles/settings.h @@ -183,3 +183,12 @@ DeclareSetting(QString, MainFont); DeclareSetting(QString, SemiboldFont); DeclareSetting(bool, SemiboldFontIsBold); DeclareSetting(QString, MonospaceFont); + +inline int cSetStickerHeight(int height) { + gStickerHeight = (height > 256) ? 256 : (height < 128) ? 128 : height; +} + +inline int cStickerHeight() { + return gStickerHeight; +} +