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
|
// You can see full list of settings in the 'kotato-settings-default.json' file
|
||||||
|
|
||||||
{
|
{
|
||||||
// "fonts": {
|
// "fonts": {
|
||||||
// "main": "Open Sans",
|
// "main": "Open Sans",
|
||||||
// "semibold": "Open Sans Semibold",
|
// "semibold": "Open Sans Semibold",
|
||||||
// "semibold_is_bold": false,
|
// "semibold_is_bold": false,
|
||||||
// "monospaced": "Consolas"
|
// "monospaced": "Consolas"
|
||||||
// }
|
// },
|
||||||
|
// "sticker_height": 256
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,14 @@ bool Manager::readCustomFile() {
|
||||||
cSetMonospaceFont((*settingsFontsMonospace).toString());
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -181,6 +189,8 @@ void Manager::writeDefaultFile() {
|
||||||
|
|
||||||
settings.insert(qsl("fonts"), settingsFonts);
|
settings.insert(qsl("fonts"), settingsFonts);
|
||||||
|
|
||||||
|
settings.insert(qsl("sticker_height"), cStickerHeight());
|
||||||
|
|
||||||
auto document = QJsonDocument();
|
auto document = QJsonDocument();
|
||||||
document.setObject(settings);
|
document.setObject(settings);
|
||||||
file.write(document.toJson(QJsonDocument::Indented));
|
file.write(document.toJson(QJsonDocument::Indented));
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,6 @@ maxWallPaperWidth: 160px;
|
||||||
maxWallPaperHeight: 240px;
|
maxWallPaperHeight: 240px;
|
||||||
historyThemeSize: size(272px, 176px);
|
historyThemeSize: size(272px, 176px);
|
||||||
|
|
||||||
historyStickerHeight: 128px;
|
|
||||||
|
|
||||||
historyMinimalWidth: 380px;
|
historyMinimalWidth: 380px;
|
||||||
|
|
||||||
historyScroll: ScrollArea(defaultScrollArea) {
|
historyScroll: ScrollArea(defaultScrollArea) {
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ QSize UnwrappedMedia::countOptimalSize() {
|
||||||
_content->refreshLink();
|
_content->refreshLink();
|
||||||
_contentSize = NonEmptySize(DownscaledSize(
|
_contentSize = NonEmptySize(DownscaledSize(
|
||||||
_content->size(),
|
_content->size(),
|
||||||
{ st::maxStickerSize, st::historyStickerHeight }));
|
{ st::maxStickerSize, cStickerHeight() }));
|
||||||
auto maxWidth = _contentSize.width();
|
auto maxWidth = _contentSize.width();
|
||||||
const auto minimal = st::largeEmojiSize + 2 * st::largeEmojiOutline;
|
const auto minimal = st::largeEmojiSize + 2 * st::largeEmojiOutline;
|
||||||
auto minHeight = std::max(_contentSize.height(), minimal);
|
auto minHeight = std::max(_contentSize.height(), minimal);
|
||||||
|
|
|
||||||
|
|
@ -60,13 +60,13 @@ QSize Sticker::size() {
|
||||||
constexpr auto kIdealStickerSize = 512;
|
constexpr auto kIdealStickerSize = 512;
|
||||||
const auto zoom = GetEmojiStickerZoom(&_document->session());
|
const auto zoom = GetEmojiStickerZoom(&_document->session());
|
||||||
const auto convert = [&](int size) {
|
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()));
|
_size = QSize(convert(_size.width()), convert(_size.height()));
|
||||||
} else {
|
} else {
|
||||||
_size = DownscaledSize(
|
_size = DownscaledSize(
|
||||||
_size,
|
_size,
|
||||||
{ st::maxStickerSize, st::historyStickerHeight });
|
{ st::maxStickerSize, cStickerHeight() });
|
||||||
}
|
}
|
||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -209,3 +209,5 @@ rpl::producer<> UpdatedRecentEmoji() {
|
||||||
|
|
||||||
QString gMainFont, gSemiboldFont, gMonospaceFont;
|
QString gMainFont, gSemiboldFont, gMonospaceFont;
|
||||||
bool gSemiboldFontIsBold = false;
|
bool gSemiboldFontIsBold = false;
|
||||||
|
|
||||||
|
int gStickerHeight = 256;
|
||||||
|
|
@ -183,3 +183,12 @@ DeclareSetting(QString, MainFont);
|
||||||
DeclareSetting(QString, SemiboldFont);
|
DeclareSetting(QString, SemiboldFont);
|
||||||
DeclareSetting(bool, SemiboldFontIsBold);
|
DeclareSetting(bool, SemiboldFontIsBold);
|
||||||
DeclareSetting(QString, MonospaceFont);
|
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