[Option][GUI] Sticker size
This commit is contained in:
parent
c8e8a47f97
commit
01623cfa75
8 changed files with 100 additions and 5 deletions
|
|
@ -28,6 +28,9 @@
|
|||
"ktg_mac_menu_show": "Show Kotatogram",
|
||||
"ktg_settings_kotato": "Kotatogram Settings",
|
||||
"ktg_settings_chats": "Chats",
|
||||
"ktg_settings_sticker_height": "Sticker height: {pixels}px",
|
||||
"ktg_settings_sticker_scale_both": "Apply to sticker width",
|
||||
"ktg_settings_sticker_scale_both_about": "When enabled, sticker maximum width will be changed along with sticker height.",
|
||||
"ktg_settings_emoji_outline": "Big emoji outline",
|
||||
"ktg_fonts_title": "Fonts",
|
||||
"ktg_settings_fonts": "Change application fonts",
|
||||
|
|
|
|||
|
|
@ -643,6 +643,22 @@ HistoryWidget::HistoryWidget(
|
|||
});
|
||||
}, lifetime());
|
||||
|
||||
::Kotato::JsonSettings::Events(
|
||||
"sticker_height"
|
||||
) | rpl::start_with_next([=] {
|
||||
crl::on_main(this, [=] {
|
||||
updateHistoryGeometry();
|
||||
});
|
||||
}, lifetime());
|
||||
|
||||
::Kotato::JsonSettings::Events(
|
||||
"sticker_scale_both"
|
||||
) | rpl::start_with_next([=] {
|
||||
crl::on_main(this, [=] {
|
||||
updateHistoryGeometry();
|
||||
});
|
||||
}, lifetime());
|
||||
|
||||
session().data().channelDifferenceTooLong(
|
||||
) | rpl::filter([=](not_null<ChannelData*> channel) {
|
||||
return _peer == channel.get();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "history/view/media/history_view_media_unwrapped.h"
|
||||
|
||||
#include "kotato/kotato_settings.h"
|
||||
#include "data/data_session.h"
|
||||
#include "history/history.h"
|
||||
#include "history/view/media/history_view_media_common.h"
|
||||
|
|
@ -14,9 +15,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/view/history_view_element.h"
|
||||
#include "history/view/history_view_cursor_state.h"
|
||||
#include "history/view/history_view_reply.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "lottie/lottie_single_player.h"
|
||||
#include "data/data_session.h"
|
||||
#include "ui/cached_round_corners.h"
|
||||
#include "ui/chat/chat_style.h"
|
||||
#include "ui/painter.h"
|
||||
|
|
@ -44,6 +47,17 @@ UnwrappedMedia::UnwrappedMedia(
|
|||
std::unique_ptr<Content> content)
|
||||
: Media(parent)
|
||||
, _content(std::move(content)) {
|
||||
::Kotato::JsonSettings::Events(
|
||||
"sticker_height"
|
||||
) | rpl::start_with_next([=] {
|
||||
history()->owner().requestItemViewRefresh(_parent->data());
|
||||
}, _lifetime);
|
||||
|
||||
::Kotato::JsonSettings::Events(
|
||||
"sticker_scale_both"
|
||||
) | rpl::start_with_next([=] {
|
||||
history()->owner().requestItemViewRefresh(_parent->data());
|
||||
}, _lifetime);
|
||||
}
|
||||
|
||||
QSize UnwrappedMedia::countOptimalSize() {
|
||||
|
|
@ -605,7 +619,7 @@ int UnwrappedMedia::calculateFullRight(const QRect &inner) const {
|
|||
const auto rightActionWidth = rightActionSize
|
||||
? (st::historyFastShareLeft * 2
|
||||
+ rightActionSize->width())
|
||||
: 0;
|
||||
: st::msgMargin.left() + st::msgMargin.right();
|
||||
auto fullRight = inner.x()
|
||||
+ inner.width()
|
||||
+ (rightAligned ? 0 : infoWidth);
|
||||
|
|
|
|||
|
|
@ -162,6 +162,8 @@ private:
|
|||
int _topAdded = 0;
|
||||
bool _additionalOnTop = false;
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
};
|
||||
|
||||
} // namespace HistoryView
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "history/view/media/history_view_sticker.h"
|
||||
|
||||
#include "kotato/kotato_settings.h"
|
||||
#include "boxes/sticker_set_box.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item_components.h"
|
||||
|
|
@ -187,8 +188,11 @@ bool Sticker::readyToDrawAnimationFrame() {
|
|||
}
|
||||
|
||||
QSize Sticker::Size() {
|
||||
const auto side = std::min(st::maxStickerSize, kMaxSizeFixed);
|
||||
return { side, side };
|
||||
const auto currentStickerHeight = ::Kotato::JsonSettings::GetInt("sticker_height");
|
||||
const auto currentScaleBoth = ::Kotato::JsonSettings::GetBool("sticker_scale_both");
|
||||
const auto maxHeight = int(st::maxStickerSize / 256.0 * currentStickerHeight);
|
||||
const auto maxWidth = currentScaleBoth ? maxHeight : st::maxStickerSize;
|
||||
return { maxWidth, maxHeight };
|
||||
}
|
||||
|
||||
QSize Sticker::Size(not_null<DocumentData*> document) {
|
||||
|
|
@ -209,7 +213,9 @@ QSize Sticker::EmojiEffectSize() {
|
|||
}
|
||||
|
||||
QSize Sticker::EmojiSize() {
|
||||
const auto side = std::min(st::maxAnimatedEmojiSize, kMaxEmojiSizeFixed);
|
||||
const auto currentStickerHeight = ::Kotato::JsonSettings::GetInt("sticker_height");
|
||||
const auto maxHeight = int(st::maxStickerSize / 256.0 * currentStickerHeight / 2);
|
||||
const auto side = std::min(maxHeight, kMaxEmojiSizeFixed);
|
||||
return { side, side };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -229,6 +229,13 @@ const std::map<QString, Definition, std::greater<QString>> DefinitionMap {
|
|||
{ "big_emoji_outline", {
|
||||
.type = SettingType::BoolSetting,
|
||||
.defaultValue = true, }},
|
||||
{ "sticker_height", {
|
||||
.type = SettingType::IntSetting,
|
||||
.defaultValue = 170,
|
||||
.limitHandler = IntLimit(64, 256, 170), }},
|
||||
{ "sticker_scale_both", {
|
||||
.type = SettingType::BoolSetting,
|
||||
.defaultValue = true, }},
|
||||
};
|
||||
|
||||
using OldOptionKey = QString;
|
||||
|
|
|
|||
|
|
@ -88,6 +88,53 @@ void SetupKotatoChats(
|
|||
void SetupKotatoMessages(not_null<Ui::VerticalLayout*> container) {
|
||||
Ui::AddSubsectionTitle(container, rktr("ktg_settings_messages"));
|
||||
|
||||
const auto stickerHeightLabel = container->add(
|
||||
object_ptr<Ui::LabelSimple>(
|
||||
container,
|
||||
st::ktgSettingsSliderLabel),
|
||||
st::groupCallDelayLabelMargin);
|
||||
const auto stickerHeightSlider = container->add(
|
||||
object_ptr<Ui::MediaSlider>(
|
||||
container,
|
||||
st::defaultContinuousSlider),
|
||||
st::localStorageLimitMargin);
|
||||
const auto updateStickerHeightLabel = [=](int value) {
|
||||
const auto pixels = QString::number(value);
|
||||
stickerHeightLabel->setText(
|
||||
ktr("ktg_settings_sticker_height", { "pixels", pixels }));
|
||||
};
|
||||
const auto updateStickerHeight = [=](int value) {
|
||||
updateStickerHeightLabel(value);
|
||||
::Kotato::JsonSettings::Set("sticker_height", value);
|
||||
::Kotato::JsonSettings::Write();
|
||||
};
|
||||
stickerHeightSlider->resize(st::defaultContinuousSlider.seekSize);
|
||||
stickerHeightSlider->setPseudoDiscrete(
|
||||
193,
|
||||
[](int val) { return val + 64; },
|
||||
::Kotato::JsonSettings::GetInt("sticker_height"),
|
||||
updateStickerHeight);
|
||||
updateStickerHeightLabel(::Kotato::JsonSettings::GetInt("sticker_height"));
|
||||
|
||||
container->add(
|
||||
object_ptr<Ui::Checkbox>(
|
||||
container,
|
||||
ktr("ktg_settings_sticker_scale_both"),
|
||||
::Kotato::JsonSettings::GetBool("sticker_scale_both"),
|
||||
st::settingsCheckbox),
|
||||
st::settingsCheckboxPadding
|
||||
)->checkedChanges(
|
||||
) | rpl::filter([](bool checked) {
|
||||
return (checked != ::Kotato::JsonSettings::GetBool("sticker_scale_both"));
|
||||
}) | rpl::start_with_next([](bool checked) {
|
||||
::Kotato::JsonSettings::Set("sticker_scale_both", checked);
|
||||
::Kotato::JsonSettings::Write();
|
||||
}, container->lifetime());
|
||||
|
||||
Ui::AddSkip(container);
|
||||
Ui::AddDividerText(container, rktr("ktg_settings_sticker_scale_both_about"));
|
||||
Ui::AddSkip(container);
|
||||
|
||||
SettingsMenuJsonSwitch(ktg_settings_emoji_outline, big_emoji_outline);
|
||||
|
||||
Ui::AddSkip(container);
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ mediaInPaletteSelected: TextPalette(defaultTextPalette) {
|
|||
|
||||
minPhotoSize: 100px;
|
||||
maxMediaSize: 430px;
|
||||
maxStickerSize: 224px;
|
||||
maxStickerSize: 256px;
|
||||
maxAnimatedEmojiSize: 112px;
|
||||
maxGifSize: 320px;
|
||||
maxVideoMessageSize: 240px;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue