From ab26e3d4fa66c481af1d5be46492d72b5c1b7d1a Mon Sep 17 00:00:00 2001 From: AlexeyZavar Date: Wed, 15 Jan 2025 15:48:53 +0300 Subject: [PATCH] feat: replace "edited" & "deleted" with icons --- Telegram/Resources/icons/ayu/edited.png | Bin 0 -> 264 bytes Telegram/Resources/icons/ayu/edited@2x.png | Bin 0 -> 401 bytes Telegram/Resources/icons/ayu/edited@3x.png | Bin 0 -> 527 bytes Telegram/Resources/icons/ayu/trash_bin.png | Bin 0 -> 285 bytes Telegram/Resources/icons/ayu/trash_bin@2x.png | Bin 0 -> 417 bytes Telegram/Resources/icons/ayu/trash_bin@3x.png | Bin 0 -> 492 bytes Telegram/SourceFiles/ayu/ayu_settings.cpp | 5 + Telegram/SourceFiles/ayu/ayu_settings.h | 3 + Telegram/SourceFiles/ayu/ui/ayu_icons.style | 6 + .../ayu/ui/settings/settings_ayu.cpp | 21 +++ Telegram/SourceFiles/history/history_item.cpp | 27 +--- .../history/view/history_view_bottom_info.cpp | 143 ++++++++++++++---- .../history/view/history_view_bottom_info.h | 1 + 13 files changed, 148 insertions(+), 58 deletions(-) create mode 100644 Telegram/Resources/icons/ayu/edited.png create mode 100644 Telegram/Resources/icons/ayu/edited@2x.png create mode 100644 Telegram/Resources/icons/ayu/edited@3x.png create mode 100644 Telegram/Resources/icons/ayu/trash_bin.png create mode 100644 Telegram/Resources/icons/ayu/trash_bin@2x.png create mode 100644 Telegram/Resources/icons/ayu/trash_bin@3x.png diff --git a/Telegram/Resources/icons/ayu/edited.png b/Telegram/Resources/icons/ayu/edited.png new file mode 100644 index 0000000000000000000000000000000000000000..d14626a9d04e001f5d237ebbf4304e5447a7f66d GIT binary patch literal 264 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VXMsm#F#`j)FbFd;%$g$s6l5$8 za(7}_cTVOdki(Mh=531A?Slp7BZ*&Ms zGzv``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&eBIW9E{I78{Hf3a7>V9EK+vJ zo5S?jqAgJ(VV0W1k*9Nx`84bCu^udxDU@$Ls^aPM?kQVDsOUV`&`s^#u| zeeZY{e^C9?%6)Urf96SzZ0e18Yq^RqG+%c8>t6u}*S-Fu_p#3TOYQ%{y&7F_t^QuB z$v?39?k$tEiF%H_g*Fc)-|d}b?oieczQfeSJy&MGL+qWi^ByzWK0ed_kv zGwF1;CH4{LEsP(8zPCK^l6n2K>wdKq>KDwrQ+jz8<$Ymlh+O&S=244$rjF6*2Ung9r(oD~27 literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/ayu/edited@3x.png b/Telegram/Resources/icons/ayu/edited@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..26e7cc543bde87db85b85f622fa5c43e24c0cb85 GIT binary patch literal 527 zcmeAS@N?(olHy`uVBq!ia0vp^HXzKw1|+Ti+$;i8oCO|{#S9GG!XV7ZFl&wkP>``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&eBxh0-1jv*C{Z*M-l=|P6+f4||M=`-QMwBqdhGk;H><0-ejoR6O&pkVQzgJ+cz-U%9f=a^B= za>kbFnH*zre}k`jm(q$=T)WmWFBQ2`%Ii7lz~`SVt5#@lVO+wtBFgLbwo`>NUH5mf zl}UJh)$Ta9?^<*1{qXF`%U1qP$hm*&XYrKChV4C@N)zU^CrbF)>7Sk?UlFsQ?ew`6 z#;DB|i7%s>|FJx+w0qe+U2e{D@0qK6yql)G+J1f8CZkY~Hs^@7{de z7JEH=%g2hQ><=Fwn122wEj9ajWyp=>gW2T)%Ci#cW-;d<+{gZ0@8Z0lHXq{NNX*&3 zLvSP0n(m_ldI86qbPrqt;l|B6!B&=>-pt2BuL`YEs$6EeX2k|`-^&gHEEm4p&JlgP zdE2*Vcb}YK3iW)io9-M@YmoOr_t2~6?b9|Vu92(AwtRfju;(iCdfoIr!b%l;vgH1( zp7ZgyMc;aZRVE4D6HF3xg1slK|0Z#@ymOB{Bmj51AGo6o3)g>)o4YCsW7fu51LKdu M)78&qol`;+08D)4fdBvi literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/ayu/trash_bin.png b/Telegram/Resources/icons/ayu/trash_bin.png new file mode 100644 index 0000000000000000000000000000000000000000..056b7d8dc2e1bc271c8f5a67e66ecbfe2c1c4b44 GIT binary patch literal 285 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VXMsm#F#`j)FbFd;%$g$s6l5$8 za(7}_cTVOdki(Mh=0C09&* zGh?qGvGjM>@XLBSQ9>$vvhar7+Z(tPS=MX~-IM8Y=5tT&{nb0Z@0)S)=Hf^z+ttT6 z>D*QSpMPrYzdf9aHTf2YEU)i<&DVP3ZI-&>HSdGQ-N_F3Jda464)LrsU%2(yO0M$- e|IPM)X8N?cVVCTb#4AA8GkCiCxvX``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&eBIWtce$B+ufx6|+DHV5#y?GLGK=S^U~!C=k;a4H|JFbMz0W;zTEunHARhBW1}5uQtUBef@4xjA`FqCSg9;+WHm8TF zR9Nfep7<=|C~!wU*z@JDom@-h9jNdhTGJt@^@Bts|KA z|Ko3|+};JZ&2}6*X|>R{Vu9@s4)+2Hwt__8is?raW!%5*I%=n~MfY~lb<-Uirn5GE zJE+kmaQx%^>nnIQGQ{8P;)`)DP7WlY^&1PoCIPgg&ebxsLQ E0KieJYybcN literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/ayu/trash_bin@3x.png b/Telegram/Resources/icons/ayu/trash_bin@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..02a715435d14bd69dd81f30bc05dc86bd5cbb82a GIT binary patch literal 492 zcmeAS@N?(olHy`uVBq!ia0vp^HXzKw1|+Ti+$;i8oCO|{#S9GG!XV7ZFl&wkP>``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&eBxkgVH$B+ufw=@5*b#V}AcpewW=yicnHp7wK zOHlMe;|hlm2Tm&o))fi!D=okG?{2vrxiNX4i(X;po9)J%?d2I3JaGGS;H*I6yAFeL zml@VdXJiGR^>GwGFFUlqfGJVJNr2^n#kptuGiNQxjn?R5I_EUAW|K~E^^0A8y0S@I zbk85ZbA0-VRmw*SbG8@Ed+uIy)uQhk*Y0({^$VtGboFrAhrP~^Jfh%x`E0|J-~Vnq zX7T%8&bg=R`RUtV^Ng<&*X~MAN%a&;e4EL+TzGEAJI3XDJqE0|G;^glUAn}|zH#Zg zt(R(IYZIlu*YaPP!1uc}R$J>s^p&^D{+T^GqBC@_OyEwoij%y_|Jq41QJ8t!k}Y~u z0u3)#PG6U(-J+?S!lHI9FgThh{jPm&WJN&C zY#np41g_La7cI}4R5B-i5#TrfFz@+ZK32Qj7uTbX-e0wac|kFeCUo~ e;=4P3KlmlLN5^;R-fIFz4uhwwpUXO@geCy^ugKc~ literal 0 HcmV?d00001 diff --git a/Telegram/SourceFiles/ayu/ayu_settings.cpp b/Telegram/SourceFiles/ayu/ayu_settings.cpp index 30d220297..a588c3447 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.cpp +++ b/Telegram/SourceFiles/ayu/ayu_settings.cpp @@ -240,6 +240,7 @@ AyuGramSettings::AyuGramSettings() { #endif ; simpleQuotesAndReplies = true; + replaceBottomInfoWithIcons = true; deletedMark = "🧹"; editedMark = Core::IsAppLaunched() ? tr::lng_edited(tr::now) : QString("edited"); recentStickersCount = 100; @@ -419,6 +420,10 @@ void AyuGramSettings::set_simpleQuotesAndReplies(bool val) { simpleQuotesAndReplies = val; } +void AyuGramSettings::set_replaceBottomInfoWithIcons(bool val) { + replaceBottomInfoWithIcons = val; +} + void AyuGramSettings::set_deletedMark(QString val) { deletedMark = std::move(val); deletedMarkReactive = deletedMark; diff --git a/Telegram/SourceFiles/ayu/ayu_settings.h b/Telegram/SourceFiles/ayu/ayu_settings.h index c9ddc58c6..bed0615c7 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.h +++ b/Telegram/SourceFiles/ayu/ayu_settings.h @@ -51,6 +51,7 @@ public: QString appIcon; bool simpleQuotesAndReplies; + bool replaceBottomInfoWithIcons; QString deletedMark; QString editedMark; int recentStickersCount; @@ -130,6 +131,7 @@ public: void set_appIcon(QString val); void set_simpleQuotesAndReplies(bool val); + void set_replaceBottomInfoWithIcons(bool val); void set_deletedMark(QString val); void set_editedMark(QString val); void set_recentStickersCount(int val); @@ -201,6 +203,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT( localPremium, appIcon, simpleQuotesAndReplies, + replaceBottomInfoWithIcons, deletedMark, editedMark, recentStickersCount, diff --git a/Telegram/SourceFiles/ayu/ui/ayu_icons.style b/Telegram/SourceFiles/ayu/ui/ayu_icons.style index 2cf747de7..b03fad2f8 100644 --- a/Telegram/SourceFiles/ayu/ui/ayu_icons.style +++ b/Telegram/SourceFiles/ayu/ui/ayu_icons.style @@ -34,3 +34,9 @@ infoExteraOfficialBadge: icon {{ "ayu/extera_official", profileVerifiedCheckBg } infoExteraSupporterBadge: icon {{ "ayu/extera_badge", profileVerifiedCheckBg }}; winEnterWithGuestIcon: icon {{ "ayu/ghost_tray", windowFg }}; + +editedIcon: icon {{ "ayu/edited", windowFg }}; +editedIconPadding: margins(0px, 0px, 0px, 0px); + +deletedIcon: icon {{ "ayu/trash_bin", windowFg }}; +deletedIconPadding: margins(0px, 0px, 0px, 0px); diff --git a/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.cpp b/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.cpp index 50fe19ca9..cf5971dfa 100644 --- a/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.cpp +++ b/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.cpp @@ -1456,6 +1456,27 @@ void SetupSendConfirmations(not_null container) { } void SetupMarks(not_null container) { + auto settings = &AyuSettings::getInstance(); + + AddButtonWithIcon( + container, + rpl::single(QString("Replace with Icons")), + st::settingsButtonNoIcon + )->toggleOn( + rpl::single(settings->replaceBottomInfoWithIcons) + )->toggledValue( + ) | rpl::filter( + [=](bool enabled) + { + return (enabled != settings->replaceBottomInfoWithIcons); + }) | start_with_next( + [=](bool enabled) + { + settings->set_replaceBottomInfoWithIcons(enabled); + AyuSettings::save(); + }, + container->lifetime()); + AddButtonWithLabel( container, tr::ayu_DeletedMarkText(), diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index f49b0832f..4af2e4228 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -3092,31 +3092,7 @@ bool HistoryItem::isDeleted() const { void HistoryItem::setAyuHint(const QString &hint) { try { - if (!(_flags & MessageFlag::HasPostAuthor)) { - _flags |= MessageFlag::HasPostAuthor; - } - - auto msgsigned = Get(); - if (hint.isEmpty()) { - if (!msgsigned) { - return; - } - RemoveComponents(HistoryMessageSigned::Bit()); - history()->owner().requestItemResize(this); - return; - } - - if (!isService()) { - if (!msgsigned) { - AddComponents(HistoryMessageSigned::Bit()); - msgsigned = Get(); - } else if (msgsigned->author == hint) { - return; - } - msgsigned->author = hint; - msgsigned->isAnonymousRank = !isDiscussionPost() - && this->author()->isMegagroup(); - } else { + if (isService()) { const auto data = Get(); const auto postfix = QString(" (%1)").arg(hint); if (!_text.text.endsWith(postfix)) { // fix stacking for TTL messages @@ -3128,6 +3104,7 @@ void HistoryItem::setAyuHint(const QString &hint) { } } + // update bottom info history()->owner().requestItemViewRefresh(this); history()->owner().requestItemResize(this); } catch (...) { diff --git a/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp b/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp index d98c5d16a..d9abd270f 100644 --- a/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp +++ b/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp @@ -33,6 +33,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL // AyuGram includes #include "ayu/ayu_settings.h" #include "ayu/features/messageshot/message_shot.h" +#include "core/ui_integration.h" +#include "styles/style_ayu_icons.h" namespace HistoryView { @@ -412,39 +414,111 @@ void BottomInfo::layout() { void BottomInfo::layoutDateText() { const auto settings = &AyuSettings::getInstance(); - const auto edited = (_data.flags & Data::Flag::Edited) - ? (settings->editedMark + ' ') - : (_data.flags & Data::Flag::EstimateDate) - ? (tr::lng_approximate(tr::now) + ' ') - : QString(); - const auto author = _data.author; - const auto prefix = !author.isEmpty() ? (author == settings->deletedMark ? u" "_q : u", "_q) : QString(); - const auto date = edited + QLocale().toString( - _data.date.time(), - settings->showMessageSeconds - ? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t") - : QLocale::system().timeFormat(QLocale::ShortFormat) - ); - const auto afterAuthor = prefix + date; - const auto afterAuthorWidth = st::msgDateFont->width(afterAuthor); - const auto authorWidth = st::msgDateFont->width(author); - const auto maxWidth = st::maxSignatureSize; - _authorElided = !author.isEmpty() - && (authorWidth + afterAuthorWidth > maxWidth); - const auto name = _authorElided - ? st::msgDateFont->elided(author, maxWidth - afterAuthorWidth) - : author; - const auto full = (_data.flags & Data::Flag::Sponsored) - ? QString() - : (_data.flags & Data::Flag::Imported) - ? (date + ' ' + tr::lng_imported(tr::now)) - : name.isEmpty() - ? date - : (name + afterAuthor); - _authorEditedDate.setText( - st::msgDateTextStyle, - full, - Ui::NameTextOptions()); + if (!settings->replaceBottomInfoWithIcons) { + const auto deleted = (_data.flags & Data::Flag::AyuDeleted) + ? (settings->deletedMark + ' ') + : QString(); + const auto edited = (_data.flags & Data::Flag::Edited) + ? (settings->editedMark + ' ') + : (_data.flags & Data::Flag::EstimateDate) + ? (tr::lng_approximate(tr::now) + ' ') + : QString(); + const auto author = _data.author; + const auto prefix = !author.isEmpty() ? u", "_q : QString(); + const auto date = edited + QLocale().toString( + _data.date.time(), + settings->showMessageSeconds + ? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t") + : QLocale::system().timeFormat(QLocale::ShortFormat) + ); + const auto afterAuthor = prefix + date; + const auto afterAuthorWidth = st::msgDateFont->width(afterAuthor); + const auto authorWidth = st::msgDateFont->width(author); + const auto maxWidth = st::maxSignatureSize; + _authorElided = !author.isEmpty() + && (authorWidth + afterAuthorWidth > maxWidth); + const auto name = _authorElided + ? st::msgDateFont->elided(author, maxWidth - afterAuthorWidth) + : author; + const auto full = (_data.flags & Data::Flag::Sponsored) + ? QString() + : (_data.flags & Data::Flag::Imported) + ? (deleted + date + ' ' + tr::lng_imported(tr::now)) + : name.isEmpty() + ? (deleted + date) + : (deleted + name + afterAuthor); + _authorEditedDate.setText( + st::msgDateTextStyle, + full, + Ui::NameTextOptions()); + } else { + TextWithEntities deleted; + if (_data.flags & Data::Flag::AyuDeleted) { + const auto &icon = st::deletedIcon; + const auto padding = st::deletedIconPadding; + const auto owner = &_reactionsOwner->owner(); + auto added = Ui::Text::SingleCustomEmoji( + owner->customEmojiManager().registerInternalEmoji(icon, padding) + ); + deleted = Ui::Text::Colorized(added, 1); + } + + TextWithEntities edited; + if (_data.flags & Data::Flag::Edited) { + const auto &icon = st::editedIcon; + const auto padding = st::editedIconPadding; + const auto owner = &_reactionsOwner->owner(); + auto added = Ui::Text::SingleCustomEmoji( + owner->customEmojiManager().registerInternalEmoji(icon, padding) + ); + edited = Ui::Text::Colorized(added, 1); + } else if (_data.flags & Data::Flag::EstimateDate) { + edited = TextWithEntities{ tr::lng_approximate(tr::now) + ' ' }; + } + + const auto author = _data.author; + const auto prefix = !author.isEmpty() ? u", "_q : QString(); + + const auto date = TextWithEntities{}.append(edited).append(QLocale().toString( + _data.date.time(), + settings->showMessageSeconds + ? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t") + : QLocale::system().timeFormat(QLocale::ShortFormat) + )); + + const auto afterAuthor = TextWithEntities{}.append(prefix).append(date); + const auto afterAuthorWidth = st::msgDateFont->width(afterAuthor.text); + const auto authorWidth = st::msgDateFont->width(author); + const auto maxWidth = st::maxSignatureSize; + _authorElided = !author.isEmpty() + && (authorWidth + afterAuthorWidth > maxWidth); + const auto name = _authorElided + ? st::msgDateFont->elided(author, maxWidth - afterAuthorWidth) + : author; + + auto full = TextWithEntities{}; + if (_data.flags & Data::Flag::Sponsored) { + // ... + } else if (_data.flags & Data::Flag::Imported) { + full.append(deleted).append(date).append(' ').append(tr::lng_imported(tr::now)); + } else if (name.isEmpty()) { + full.append(deleted).append(date); + } else { + full.append(deleted).append(name).append(afterAuthor); + } + + const auto context = Core::MarkedTextContext{ + .session = &_reactionsOwner->session(), + .customEmojiRepaint = [] {}, + .customEmojiLoopLimit = 0, + }; + + _authorEditedDate.setMarkedText( + st::msgDateTextStyle, + full, + Ui::NameTextOptions(), + context); + } } void BottomInfo::layoutViewsText() { @@ -616,6 +690,9 @@ BottomInfo::Data BottomInfoDataFromMessage(not_null message) { if (item->awaitingVideoProcessing()) { result.flags |= Flag::EstimateDate; } + if (item->isDeleted()) { + result.flags |= Flag::AyuDeleted; + } // We don't want to pass and update it in Data for now. //if (item->unread()) { // result.flags |= Flag::Unread; diff --git a/Telegram/SourceFiles/history/view/history_view_bottom_info.h b/Telegram/SourceFiles/history/view/history_view_bottom_info.h index 32e3e8fcd..f7ea3e089 100644 --- a/Telegram/SourceFiles/history/view/history_view_bottom_info.h +++ b/Telegram/SourceFiles/history/view/history_view_bottom_info.h @@ -42,6 +42,7 @@ public: Imported = 0x040, Shortcut = 0x080, EstimateDate = 0x100, + AyuDeleted = 0x200, //Unread, // We don't want to pass and update it in Date for now. }; friend inline constexpr bool is_flag_type(Flag) { return true; };