diff --git a/Telegram/Resources/icons/ayu/edited.png b/Telegram/Resources/icons/ayu/edited.png new file mode 100644 index 000000000..d14626a9d Binary files /dev/null and b/Telegram/Resources/icons/ayu/edited.png differ diff --git a/Telegram/Resources/icons/ayu/edited@2x.png b/Telegram/Resources/icons/ayu/edited@2x.png new file mode 100644 index 000000000..f3140cf6a Binary files /dev/null and b/Telegram/Resources/icons/ayu/edited@2x.png differ diff --git a/Telegram/Resources/icons/ayu/edited@3x.png b/Telegram/Resources/icons/ayu/edited@3x.png new file mode 100644 index 000000000..26e7cc543 Binary files /dev/null and b/Telegram/Resources/icons/ayu/edited@3x.png differ diff --git a/Telegram/Resources/icons/ayu/trash_bin.png b/Telegram/Resources/icons/ayu/trash_bin.png new file mode 100644 index 000000000..056b7d8dc Binary files /dev/null and b/Telegram/Resources/icons/ayu/trash_bin.png differ diff --git a/Telegram/Resources/icons/ayu/trash_bin@2x.png b/Telegram/Resources/icons/ayu/trash_bin@2x.png new file mode 100644 index 000000000..323f42a66 Binary files /dev/null and b/Telegram/Resources/icons/ayu/trash_bin@2x.png differ 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 000000000..02a715435 Binary files /dev/null and b/Telegram/Resources/icons/ayu/trash_bin@3x.png differ 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; };