From 141fb875f9f4127ecb12f6213adbf84afb935ca5 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 27 Jun 2025 13:23:14 +0400 Subject: [PATCH] Add icons to suggestion buttons. --- Telegram/Resources/icons/chat/paid_approve.svg | 7 +++++++ Telegram/Resources/icons/chat/paid_decline.svg | 7 +++++++ Telegram/Resources/icons/chat/paid_edit.svg | 7 +++++++ .../history/history_item_components.cpp | 17 +++++++++++++---- Telegram/SourceFiles/ui/chat/chat.style | 12 ++++++++++++ 5 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 Telegram/Resources/icons/chat/paid_approve.svg create mode 100644 Telegram/Resources/icons/chat/paid_decline.svg create mode 100644 Telegram/Resources/icons/chat/paid_edit.svg diff --git a/Telegram/Resources/icons/chat/paid_approve.svg b/Telegram/Resources/icons/chat/paid_approve.svg new file mode 100644 index 0000000000..c122dca22d --- /dev/null +++ b/Telegram/Resources/icons/chat/paid_approve.svg @@ -0,0 +1,7 @@ + + + Icon / Filled / paid_approve + + + + \ No newline at end of file diff --git a/Telegram/Resources/icons/chat/paid_decline.svg b/Telegram/Resources/icons/chat/paid_decline.svg new file mode 100644 index 0000000000..66f52af7ea --- /dev/null +++ b/Telegram/Resources/icons/chat/paid_decline.svg @@ -0,0 +1,7 @@ + + + Icon / Filled / paid_decline + + + + \ No newline at end of file diff --git a/Telegram/Resources/icons/chat/paid_edit.svg b/Telegram/Resources/icons/chat/paid_edit.svg new file mode 100644 index 0000000000..5b4ec4a489 --- /dev/null +++ b/Telegram/Resources/icons/chat/paid_edit.svg @@ -0,0 +1,7 @@ + + + Icon / Filled / paid_edit + + + + \ No newline at end of file diff --git a/Telegram/SourceFiles/history/history_item_components.cpp b/Telegram/SourceFiles/history/history_item_components.cpp index 25503abc47..e1a013e786 100644 --- a/Telegram/SourceFiles/history/history_item_components.cpp +++ b/Telegram/SourceFiles/history/history_item_components.cpp @@ -759,17 +759,26 @@ ReplyKeyboard::ReplyKeyboard( for (auto j = 0; j != rowSize; ++j) { auto button = Button(); using Type = HistoryMessageMarkupButton::Type; - const auto isBuy = (row[j].type == Type::Buy); static const auto RegExp = QRegularExpression("\\b" + Ui::kCreditsCurrency + "\\b"); - const auto text = isBuy + const auto type = row[j].type; + const auto text = (type == Type::Buy) ? base::duplicate(row[j].text).replace( RegExp, QChar(0x2B50)) : row[j].text; + const auto withEmoji = [&](const style::IconEmoji &icon) { + return Ui::Text::IconEmoji(&icon).append(text); + }; const auto textWithEntities = [&] { - if (!isBuy) { + if (type == Type::SuggestAccept) { + return withEmoji(st::chatSuggestAcceptIcon); + } else if (type == Type::SuggestDecline) { + return withEmoji(st::chatSuggestDeclineIcon); + } else if (type == Type::SuggestChange) { + return withEmoji(st::chatSuggestChangeIcon); + } else if (type != Type::Buy) { return TextWithEntities(); } auto result = TextWithEntities(); @@ -785,7 +794,7 @@ ReplyKeyboard::ReplyKeyboard( ? TextWithEntities() : result; }(); - button.type = row.at(j).type; + button.type = type; button.link = std::make_shared( owner, i, diff --git a/Telegram/SourceFiles/ui/chat/chat.style b/Telegram/SourceFiles/ui/chat/chat.style index ca30c84f1a..e77c9136c0 100644 --- a/Telegram/SourceFiles/ui/chat/chat.style +++ b/Telegram/SourceFiles/ui/chat/chat.style @@ -1060,6 +1060,18 @@ chatSuggestInfoLastMargin: margins(16px, 4px, 16px, 16px); chatSuggestTableMiddleMargin: margins(8px, 4px, 8px, 4px); chatSuggestTableLastMargin: margins(8px, 4px, 8px, 16px); chatSuggestInfoFullMargin: margins(16px, 16px, 16px, 16px); +chatSuggestAcceptIcon: IconEmoji { + icon: icon{{ "chat/paid_approve", windowFg }}; + padding: margins(0px, -2px, 0px, 0px); +} +chatSuggestDeclineIcon: IconEmoji { + icon: icon{{ "chat/paid_decline", windowFg }}; + padding: margins(0px, -2px, 0px, 0px); +} +chatSuggestChangeIcon: IconEmoji { + icon: icon{{ "chat/paid_edit", windowFg }}; + padding: margins(0px, -2px, 0px, 0px); +} premiumRequiredWidth: 186px; premiumRequiredIcon: icon{{ "chat/large_lockedchat", msgServiceFg }};