Making sticker height change optional
This commit is contained in:
parent
87d916b2bf
commit
b073e1e102
7 changed files with 31 additions and 11 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ maxWallPaperWidth: 160px;
|
|||
maxWallPaperHeight: 240px;
|
||||
historyThemeSize: size(272px, 176px);
|
||||
|
||||
historyStickerHeight: 128px;
|
||||
|
||||
historyMinimalWidth: 380px;
|
||||
|
||||
historyScroll: ScrollArea(defaultScrollArea) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,3 +209,5 @@ rpl::producer<> UpdatedRecentEmoji() {
|
|||
|
||||
QString gMainFont, gSemiboldFont, gMonospaceFont;
|
||||
bool gSemiboldFontIsBold = false;
|
||||
|
||||
int gStickerHeight = 256;
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue