From 82293c98eb5ca1088fbab9e2073aeee7a49195cf Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 26 Apr 2024 04:05:02 +0300 Subject: [PATCH] Added arrow icon to divider link in moderation box. --- Telegram/Resources/langs/lang.strings | 8 +-- Telegram/SourceFiles/boxes/boxes.style | 7 +++ .../boxes/moderate_messages_box.cpp | 57 ++++++++++++++----- 3 files changed, 55 insertions(+), 17 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 1174605db..eb3f33fc7 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2858,10 +2858,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_restrict_users" = "Restrict users"; "lng_delete_all_from_user" = "Delete all from {user}"; "lng_delete_all_from_users" = "Delete all from users"; -"lng_restrict_user_part" = "Partially restrict this user"; -"lng_restrict_users_part" = "Partially restrict users"; -"lng_restrict_user_full" = "Fully ban this user"; -"lng_restrict_users_full" = "Fully ban users"; +"lng_restrict_user_part" = "Partially restrict this user {emoji}"; +"lng_restrict_users_part" = "Partially restrict users {emoji}"; +"lng_restrict_user_full" = "Fully ban this user {emoji}"; +"lng_restrict_users_full" = "Fully ban users {emoji}"; "lng_restrict_users_part_single_header" = "What can this user do?"; "lng_restrict_users_part_header#one" = "What can {count} selected user do?"; "lng_restrict_users_part_header#other" = "What can {count} selected users do?"; diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index ef166d580..582468070 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -1087,3 +1087,10 @@ moderateBoxExpandInnerSkip: 2px; moderateBoxExpandFont: font(11px); moderateBoxExpandToggleSize: 4px; moderateBoxExpandToggleFourStrokes: 3px; +moderateBoxExpandIcon: icon{{ "info/edit/expand_arrow_small-flip_vertical", windowActiveTextFg }}; +moderateBoxExpandIconDown: icon{{ "info/edit/expand_arrow_small", windowActiveTextFg }}; +moderateBoxDividerLabel: FlatLabel(boxDividerLabel) { + palette: TextPalette(defaultTextPalette) { + selectLinkFg: windowActiveTextFg; + } +} diff --git a/Telegram/SourceFiles/boxes/moderate_messages_box.cpp b/Telegram/SourceFiles/boxes/moderate_messages_box.cpp index a06fff512..8117c7e77 100644 --- a/Telegram/SourceFiles/boxes/moderate_messages_box.cpp +++ b/Telegram/SourceFiles/boxes/moderate_messages_box.cpp @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/timer.h" #include "boxes/delete_messages_box.h" #include "boxes/peers/edit_peer_permissions_box.h" +#include "core/ui_integration.h" #include "data/data_channel.h" #include "data/data_chat.h" #include "data/data_chat_participant_status.h" @@ -19,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_peer.h" #include "data/data_session.h" #include "data/data_user.h" +#include "data/stickers/data_custom_emoji.h" #include "history/history.h" #include "history/history_item.h" #include "lang/lang_keys.h" @@ -481,21 +483,29 @@ void CreateModerateMessagesBox( const auto wrap = inner->add(std::move(ownedWrap)); const auto container = wrap->entity(); wrap->toggle(false, anim::type::instant); + + const auto session = &users.front()->session(); + const auto emojiMargin = QMargins( + -st::moderateBoxExpandInnerSkip, + -st::moderateBoxExpandInnerSkip / 2, + 0, + 0); + const auto emojiUp = Ui::Text::SingleCustomEmoji( + session->data().customEmojiManager().registerInternalEmoji( + st::moderateBoxExpandIcon, + emojiMargin, + false)); + const auto emojiDown = Ui::Text::SingleCustomEmoji( + session->data().customEmojiManager().registerInternalEmoji( + st::moderateBoxExpandIconDown, + emojiMargin, + false)); + auto label = object_ptr( inner, - wrap->toggledValue( - ) | rpl::map([isSingle](bool toggled) { - return Ui::Text::Link( - ((toggled && isSingle) - ? tr::lng_restrict_user_part - : (toggled && !isSingle) - ? tr::lng_restrict_users_part - : isSingle - ? tr::lng_restrict_user_full - : tr::lng_restrict_users_full)(tr::now), - u"internal:"_q); - }), - st::boxDividerLabel); + QString(), + st::moderateBoxDividerLabel); + const auto raw = label.data(); auto &lifetime = wrap->lifetime(); const auto scrollLifetime = lifetime.make_state(); @@ -521,6 +531,27 @@ void CreateModerateMessagesBox( } return true; }); + wrap->toggledValue( + ) | rpl::map([isSingle, emojiUp, emojiDown](bool toggled) { + return ((toggled && isSingle) + ? tr::lng_restrict_user_part + : (toggled && !isSingle) + ? tr::lng_restrict_users_part + : isSingle + ? tr::lng_restrict_user_full + : tr::lng_restrict_users_full)( + lt_emoji, + rpl::single(toggled ? emojiUp : emojiDown), + Ui::Text::WithEntities); + }) | rpl::flatten_latest( + ) | rpl::start_with_next([=](const TextWithEntities &text) { + raw->setMarkedText( + Ui::Text::Link(text, u"internal:"_q), + Core::MarkedTextContext{ + .session = session, + .customEmojiRepaint = [=] { raw->update(); }, + }); + }, label->lifetime()); Ui::AddSkip(inner); inner->add(object_ptr(