2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 14:17:45 +00:00

Automatic applying of emoji outline change

This commit is contained in:
RadRussianRus
2019-10-11 00:54:02 +03:00
parent 5a784a360b
commit 7393cb5221
6 changed files with 40 additions and 8 deletions

View File

@@ -327,7 +327,7 @@ QImage EmojiImageLoader::prepare(EmojiPtr emoji) {
auto tinted = QImage( auto tinted = QImage(
QSize(st::largeEmojiSize, st::largeEmojiSize) * factor, QSize(st::largeEmojiSize, st::largeEmojiSize) * factor,
QImage::Format_ARGB32_Premultiplied); QImage::Format_ARGB32_Premultiplied);
tinted.fill(cBigEmojiOutline() ? Qt::white : QColor(0, 0, 0, 0)); tinted.fill(BigEmojiOutline() ? Qt::white : QColor(0, 0, 0, 0));
if (loaded) { if (loaded) {
QPainter p(&tinted); QPainter p(&tinted);
p.setCompositionMode(QPainter::CompositionMode_DestinationIn); p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
@@ -413,6 +413,17 @@ EmojiPack::EmojiPack(not_null<Main::Session*> session)
refreshAll(); refreshAll();
}, _lifetime); }, _lifetime);
BigEmojiOutlineChanges(
) | rpl::start_with_next([=] {
_images.clear();
_imageLoader.with([
source = prepareSourceImages()
](details::EmojiImageLoader &loader) mutable {
loader.switchTo(std::move(source));
});
refreshAll();
}, _lifetime);
Ui::Emoji::Updated( Ui::Emoji::Updated(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
_images.clear(); _images.clear();

View File

@@ -166,7 +166,7 @@ bool Manager::readCustomFile() {
const auto settingsBigEmojiOutlineIt = settings.constFind(qsl("big_emoji_outline")); const auto settingsBigEmojiOutlineIt = settings.constFind(qsl("big_emoji_outline"));
if (settingsBigEmojiOutlineIt != settings.constEnd() && (*settingsBigEmojiOutlineIt).isBool()) { if (settingsBigEmojiOutlineIt != settings.constEnd() && (*settingsBigEmojiOutlineIt).isBool()) {
cSetBigEmojiOutline((*settingsBigEmojiOutlineIt).toBool()); SetBigEmojiOutline((*settingsBigEmojiOutlineIt).toBool());
} }
const auto settingsAlwaysShowScheduledIt = settings.constFind(qsl("always_show_scheduled")); const auto settingsAlwaysShowScheduledIt = settings.constFind(qsl("always_show_scheduled"));
@@ -247,7 +247,7 @@ void Manager::writeDefaultFile() {
settings.insert(qsl("fonts"), settingsFonts); settings.insert(qsl("fonts"), settingsFonts);
settings.insert(qsl("sticker_height"), cStickerHeight()); settings.insert(qsl("sticker_height"), cStickerHeight());
settings.insert(qsl("big_emoji_outline"), cBigEmojiOutline()); settings.insert(qsl("big_emoji_outline"), BigEmojiOutline());
settings.insert(qsl("always_show_scheduled"), cAlwaysShowScheduled()); settings.insert(qsl("always_show_scheduled"), cAlwaysShowScheduled());
settings.insert(qsl("show_chat_id"), cShowChatId()); settings.insert(qsl("show_chat_id"), cShowChatId());
settings.insert(qsl("net_speed_boost"), QJsonValue(QJsonValue::Null)); settings.insert(qsl("net_speed_boost"), QJsonValue(QJsonValue::Null));

View File

@@ -504,6 +504,13 @@ HistoryWidget::HistoryWidget(
}); });
}, lifetime()); }, lifetime());
BigEmojiOutlineChanges(
) | rpl::start_with_next([=] {
crl::on_main(this, [=] {
updateHistoryGeometry();
});
}, lifetime());
session().data().animationPlayInlineRequest( session().data().animationPlayInlineRequest(
) | rpl::start_with_next([=](not_null<HistoryItem*> item) { ) | rpl::start_with_next([=](not_null<HistoryItem*> item) {
if (const auto view = item->mainView()) { if (const auto view = item->mainView()) {

View File

@@ -211,7 +211,18 @@ QString gMainFont, gSemiboldFont, gMonospaceFont;
bool gSemiboldFontIsBold = false; bool gSemiboldFontIsBold = false;
int gStickerHeight = 128; int gStickerHeight = 128;
bool gBigEmojiOutline = false;
rpl::variable<bool> gBigEmojiOutline = false;
void SetBigEmojiOutline(bool enabled) {
gBigEmojiOutline = enabled;
}
bool BigEmojiOutline() {
return gBigEmojiOutline.current();
}
rpl::producer<bool> BigEmojiOutlineChanges() {
return gBigEmojiOutline.changes();
}
bool gAlwaysShowScheduled = true; bool gAlwaysShowScheduled = true;
bool gShowChatId = true; bool gShowChatId = true;

View File

@@ -184,8 +184,11 @@ DeclareSetting(QString, SemiboldFont);
DeclareSetting(bool, SemiboldFontIsBold); DeclareSetting(bool, SemiboldFontIsBold);
DeclareSetting(QString, MonospaceFont); DeclareSetting(QString, MonospaceFont);
void SetBigEmojiOutline(bool enabled);
[[nodiscard]] bool BigEmojiOutline();
[[nodiscard]] rpl::producer<bool> BigEmojiOutlineChanges();
DeclareSetting(int, StickerHeight); DeclareSetting(int, StickerHeight);
DeclareSetting(bool, BigEmojiOutline);
DeclareSetting(bool, AlwaysShowScheduled); DeclareSetting(bool, AlwaysShowScheduled);
DeclareSetting(bool, ShowChatId); DeclareSetting(bool, ShowChatId);

View File

@@ -71,12 +71,12 @@ void SetupKotatoChats(not_null<Ui::VerticalLayout*> container) {
tr::ktg_settings_emoji_outline(), tr::ktg_settings_emoji_outline(),
st::settingsButton st::settingsButton
)->toggleOn( )->toggleOn(
rpl::single(cBigEmojiOutline()) rpl::single(BigEmojiOutline())
)->toggledValue( )->toggledValue(
) | rpl::filter([](bool enabled) { ) | rpl::filter([](bool enabled) {
return (enabled != cBigEmojiOutline()); return (enabled != BigEmojiOutline());
}) | rpl::start_with_next([](bool enabled) { }) | rpl::start_with_next([](bool enabled) {
cSetBigEmojiOutline(enabled); SetBigEmojiOutline(enabled);
}, container->lifetime()); }, container->lifetime());
AddButton( AddButton(