From 70939c4b9cac80412aa2b9fa800e756bbee53b60 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 27 Oct 2025 15:00:27 +0400 Subject: [PATCH] Correctly edit video stream comment price. --- Telegram/Resources/langs/lang.strings | 2 + Telegram/SourceFiles/boxes/send_files_box.cpp | 4 +- .../calls/group/calls_group_messages.cpp | 2 +- .../calls/group/calls_group_messages_ui.cpp | 25 +++--- .../calls/group/calls_group_messages_ui.h | 11 +-- .../group/ui/calls_group_stars_coloring.cpp | 76 +++++-------------- .../group/ui/calls_group_stars_coloring.h | 8 +- .../chat_helpers/chat_helpers.style | 4 +- Telegram/SourceFiles/data/data_group_call.cpp | 1 + Telegram/SourceFiles/data/data_group_call.h | 7 ++ .../history_view_compose_controls.cpp | 51 ++++++++++++- .../controls/history_view_compose_controls.h | 2 + .../media/stories/media_stories_reply.cpp | 23 +++++- .../SourceFiles/media/view/media_view.style | 14 ++-- Telegram/SourceFiles/menu/menu_send.cpp | 63 +++++++++++++-- Telegram/SourceFiles/menu/menu_send.h | 9 ++- .../payments/ui/payments_reaction_box.cpp | 2 +- .../SourceFiles/ui/controls/send_button.cpp | 20 ++--- .../SourceFiles/ui/controls/send_button.h | 1 - 19 files changed, 207 insertions(+), 118 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index b3c7bf2686..757cc2d8ce 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -4161,6 +4161,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_video_stream_live" = "LIVE"; "lng_video_stream_watched#one" = "{count} watching"; "lng_video_stream_watched#other" = "{count} watching"; +"lng_video_stream_edit_stars" = "Edit Stars"; +"lng_video_stream_remove_stars" = "Remove Stars"; "lng_message_stars_ph#one" = "Message for {count} Star"; "lng_message_stars_ph#other" = "Message for {count} Stars"; "lng_send_text_no" = "Text not allowed."; diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index 37ecd0abd4..3f4c770a9d 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -747,7 +747,9 @@ void SendFilesBox::refreshButtons() { _send, _show, _sendMenuDetails, - _sendMenuCallback); + _sendMenuCallback, + &_st.tabbed.menu, + &_st.tabbed.icons); } addButton(tr::lng_cancel(), [=] { closeBox(); }); _addFile = addLeftButton( diff --git a/Telegram/SourceFiles/calls/group/calls_group_messages.cpp b/Telegram/SourceFiles/calls/group/calls_group_messages.cpp index 3326872124..4cf60973e7 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_messages.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_messages.cpp @@ -54,7 +54,7 @@ constexpr auto kMaxShownVideoStreamMessages = 100; if (!date || !stars) { return 0; } - return date + (Ui::StarsColoringForCount(stars).minutesPin * TimeId(60)); + return date + Ui::StarsColoringForCount(stars).secondsPin; } [[nodiscard]] TimeId PinFinishDate(const Message &message) { diff --git a/Telegram/SourceFiles/calls/group/calls_group_messages_ui.cpp b/Telegram/SourceFiles/calls/group/calls_group_messages_ui.cpp index 50ca9aa9ab..895813038e 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_messages_ui.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_messages_ui.cpp @@ -52,6 +52,7 @@ namespace Calls::Group { namespace { constexpr auto kMessageBgOpacity = 0.8; +constexpr auto kDarkOverOpacity = 0.25; constexpr auto kColoredMessageBgOpacity = 0.65; [[nodiscard]] int CountMessageRadius() { @@ -69,7 +70,8 @@ constexpr auto kColoredMessageBgOpacity = 0.65; } [[nodiscard]] uint64 ColoringKey(const Ui::StarsColoring &value) { - return (uint64(uint32(value.bg1)) << 32) | uint64(uint32(value.bg2)); + return uint64(uint32(value.bgLight)) + | (uint64(uint32(value.bgDark)) << 32); } void ReceiveSomeMouseEvents( @@ -199,11 +201,12 @@ struct MessagesUi::PinnedView { }; MessagesUi::PayedBg::PayedBg(const Ui::StarsColoring &coloring) -: color1(Ui::ColorFromSerialized(coloring.bg1)) -, color2(Ui::ColorFromSerialized(coloring.bg2)) -, rounded1(CountPinnedRadius(), color1.color()) -, rounded2(CountPinnedRadius(), color2.color()) -, rounded(CountMessageRadius(), color2.color()) { +: light(Ui::ColorFromSerialized(coloring.bgLight)) +, dark(Ui::ColorFromSerialized(coloring.bgDark)) +, pinnedLight(CountPinnedRadius(), light.color()) +, pinnedDark(CountPinnedRadius(), dark.color()) +, messageLight(CountMessageRadius(), light.color()) +, badgeDark(st::roundRadiusLarge, dark.color()) { } MessagesUi::MessagesUi( @@ -988,7 +991,7 @@ void MessagesUi::setupMessagesWidget() { bg = std::make_unique(coloring); } p.setOpacity(kColoredMessageBgOpacity); - bg->rounded.paint(p, { x, y, width, use }); + bg->messageLight.paint(p, { x, y, width, use }); p.setOpacity(1.); if (_highlightAnimation.animating() && entry.id == _highlightId) { @@ -1221,14 +1224,16 @@ void MessagesUi::setupPinnedWidget() { const auto part = int(base::SafeRound(still * use)); const auto line = st::lineWidth; if (part > 0) { - p.setClipRect(x - line, y, part + line, height); - bg->rounded1.paint(p, { x, y, use, height }); + p.setOpacity(kColoredMessageBgOpacity); + bg->pinnedLight.paint(p, { x, y, use, height }); } if (part < use) { p.setClipRect(x + part, y, use - part + line, height); - bg->rounded2.paint(p, { x, y, use, height }); + p.setOpacity(kDarkOverOpacity); + bg->pinnedDark.paint(p, { x, y, use, height }); } p.setClipping(false); + p.setOpacity(1.); const auto userpicSize = st::groupCallPinnedUserpic; const auto userpicPadding = st::groupCallUserpicPadding; diff --git a/Telegram/SourceFiles/calls/group/calls_group_messages_ui.h b/Telegram/SourceFiles/calls/group/calls_group_messages_ui.h index 05ddf4965a..acfe97b293 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_messages_ui.h +++ b/Telegram/SourceFiles/calls/group/calls_group_messages_ui.h @@ -68,11 +68,12 @@ private: struct PayedBg { explicit PayedBg(const Ui::StarsColoring &coloring); - style::owned_color color1; - style::owned_color color2; - Ui::RoundRect rounded1; - Ui::RoundRect rounded2; - Ui::RoundRect rounded; + style::owned_color light; + style::owned_color dark; + Ui::RoundRect pinnedLight; + Ui::RoundRect pinnedDark; + Ui::RoundRect messageLight; + Ui::RoundRect badgeDark; }; void setupList( diff --git a/Telegram/SourceFiles/calls/group/ui/calls_group_stars_coloring.cpp b/Telegram/SourceFiles/calls/group/ui/calls_group_stars_coloring.cpp index 6dfd7efb00..a4ea3962b8 100644 --- a/Telegram/SourceFiles/calls/group/ui/calls_group_stars_coloring.cpp +++ b/Telegram/SourceFiles/calls/group/ui/calls_group_stars_coloring.cpp @@ -70,63 +70,23 @@ namespace { } // namespace StarsColoring StarsColoringForCount(int stars) { - //name: "Purple" [STRING], - //center_color: 11431086 [INT], - //edge_color: 8669060 [INT], - //pattern_color: 4656199 [INT], - //text_color: 15977459 [INT], - - //name: "Celtic Blue" [STRING], - //center_color: 4569325 [INT], - //edge_color: 3704537 [INT], - //pattern_color: 16005 [INT], - //text_color: 12773375 [INT], - - //name: "Mint Green" [STRING], - //center_color: 8309634 [INT], - //edge_color: 4562522 [INT], - //pattern_color: 158498 [INT], - //text_color: 12451788 [INT], - - //name: "Pure Gold" [STRING], - //center_color: 13413185 [INT], - //edge_color: 9993010 [INT], - //pattern_color: 7355392 [INT], - //text_color: 16770475 [INT], - - //name: "Orange" [STRING], - //center_color: 13736506 [INT], - //edge_color: 12611399 [INT], - //pattern_color: 10303751 [INT], - //text_color: 16769475 [INT], - - //name: "Strawberry" [STRING], - //center_color: 14519919 [INT], - //edge_color: 12016224 [INT], - //pattern_color: 11078668 [INT], - //text_color: 16765907 [INT], - - //name: "Steel Grey" [STRING], - //center_color: 9937580 [INT], - //edge_color: 6517372 [INT], - //pattern_color: 3360082 [INT], - //text_color: 14673128 [INT], - const auto list = std::vector{ - { 11431086, 8669060, 50, 1, 60, 1 }, - { 4569325, 3704537, 100, 1, 80, 2 }, - { 8309634, 4562522, 250, 5, 110, 3 }, - { 13413185, 9993010, 500, 10, 150, 4 }, - { 13736506, 12611399, 2000, 15, 200, 7 }, - { 14519919, 12016224, 7500, 30, 280, 10 }, - { 9937580, 6517372, 0, 60, 400, 20 }, + { 0x955CDB, 0x49079B, 0, 30, 30, 0 }, // purple + { 0x955CDB, 0x49079B, 10, 60, 60, 1 }, // still purple + { 0x46A3EB, 0x00508E, 50, 120, 80, 2 }, // blue + { 0x40A920, 0x176200, 100, 300, 110, 3 }, // green + { 0xE29A09, 0x9A3E00, 250, 600, 150, 4 }, // yellow + { 0xED771E, 0x9B3100, 500, 900, 200, 7 }, // orange + { 0xE14542, 0x8B0503, 2'000, 1800, 280, 10 }, // red + { 0x596473, 0x252C36, 10'000, 3600, 400, 20 }, // silver }; - for (const auto &entry : list) { - if (!entry.tillStars || stars < entry.tillStars) { - return entry; + for (auto i = begin(list), e = end(list); i != e; ++i) { + if (i->fromStars > stars) { + Assert(i != begin(list)); + return *(std::prev(i)); } } - Unexpected("StarsColoringForCount: should not reach here."); + return list.back(); } object_ptr VideoStreamStarsLevel( @@ -149,10 +109,12 @@ object_ptr VideoStreamStarsLevel( state->blocks.push_back(MakeInfoBlock(raw, state->coloring.value( ) | rpl::map([=](const StarsColoring &value) { - const auto minutes = value.minutesPin; - return (minutes >= 60) - ? tr::lng_hours_tiny(tr::now, lt_count, minutes / 60) - : tr::lng_minutes_tiny(tr::now, lt_count, minutes); + const auto seconds = value.secondsPin; + return (seconds >= 3600) + ? tr::lng_hours_tiny(tr::now, lt_count, seconds / 3600) + : (seconds >= 60) + ? tr::lng_minutes_tiny(tr::now, lt_count, seconds / 60) + : tr::lng_seconds_tiny(tr::now, lt_count, seconds); }), tr::lng_paid_comment_pin_about())); state->blocks.push_back(MakeInfoBlock(raw, state->coloring.value( diff --git a/Telegram/SourceFiles/calls/group/ui/calls_group_stars_coloring.h b/Telegram/SourceFiles/calls/group/ui/calls_group_stars_coloring.h index 51a0e695cb..5bf3ba571e 100644 --- a/Telegram/SourceFiles/calls/group/ui/calls_group_stars_coloring.h +++ b/Telegram/SourceFiles/calls/group/ui/calls_group_stars_coloring.h @@ -16,10 +16,10 @@ namespace Calls::Group::Ui { using namespace ::Ui; struct StarsColoring { - int bg1 = 0; - int bg2 = 0; - int tillStars = 0; - int minutesPin = 0; + int bgLight = 0; + int bgDark = 0; + int fromStars = 0; + TimeId secondsPin = 0; int charactersMax = 0; int emojiLimit = 0; diff --git a/Telegram/SourceFiles/chat_helpers/chat_helpers.style b/Telegram/SourceFiles/chat_helpers/chat_helpers.style index d06362019a..90866038e8 100644 --- a/Telegram/SourceFiles/chat_helpers/chat_helpers.style +++ b/Telegram/SourceFiles/chat_helpers/chat_helpers.style @@ -73,6 +73,7 @@ ComposeIcons { menuBelow: icon; menuAbove: icon; menuPrice: icon; + menuEditStars: icon; stripBubble: icon; stripExpandPanel: icon; @@ -156,8 +157,6 @@ SendButton { recordOver: icon; round: icon; roundOver: icon; - editPrice: icon; - editPriceOver: icon; sendDisabledFg: color; } @@ -214,6 +213,7 @@ ComposeControls { emoji: EmojiButton; like: IconButton; liked: icon; + editStars: IconButton; commentsShow: IconButton; commentsShown: icon; commentsSkip: pixels; diff --git a/Telegram/SourceFiles/data/data_group_call.cpp b/Telegram/SourceFiles/data/data_group_call.cpp index 9b2f123555..809956f464 100644 --- a/Telegram/SourceFiles/data/data_group_call.cpp +++ b/Telegram/SourceFiles/data/data_group_call.cpp @@ -533,6 +533,7 @@ void GroupCall::applyCallFields(const MTPDgroupCall &data) { _canChangeMessagesEnabled = data.is_can_change_messages_enabled(); _messagesEnabled = data.is_messages_enabled(); } + _messagesMinPrice = data.vsend_paid_messages_stars().value_or_empty(); _joinedToTop = !data.is_join_date_asc(); setServerParticipantsCount(data.vparticipants_count().v); changePeerEmptyCallFlag(); diff --git a/Telegram/SourceFiles/data/data_group_call.h b/Telegram/SourceFiles/data/data_group_call.h index 27615f83c9..69637c5978 100644 --- a/Telegram/SourceFiles/data/data_group_call.h +++ b/Telegram/SourceFiles/data/data_group_call.h @@ -206,6 +206,12 @@ public: [[nodiscard]] rpl::producer messagesEnabledValue() const { return _messagesEnabled.value(); } + [[nodiscard]] int messagesMinPrice() const { + return _messagesMinPrice.current(); + } + [[nodiscard]] rpl::producer messagesMinPriceValue() const { + return _messagesMinPrice.value(); + } private: enum class ApplySliceSource { @@ -269,6 +275,7 @@ private: rpl::variable _fullCount = 0; rpl::variable _unmutedVideoLimit = 0; rpl::variable _messagesEnabled = false; + rpl::variable _messagesMinPrice = 0; rpl::variable _recordStartDate = 0; rpl::variable _scheduleDate = 0; rpl::variable _scheduleStartSubscribed = false; diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index 43f34f04d0..6b53b676fa 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -909,6 +909,9 @@ ComposeControls::ComposeControls( , _mode(descriptor.mode) , _wrap(std::make_unique(parent)) , _send(std::make_shared(_wrap.get(), _st.send)) +, _editStars(_features.editMessageStars + ? Ui::CreateChild(_wrap.get(), _st.editStars) + : nullptr) , _like(_features.likes ? Ui::CreateChild(_wrap.get(), _st.like) : nullptr) @@ -1080,6 +1083,22 @@ void ComposeControls::initLikeButton() { } } +void ComposeControls::initEditStarsButton() { + if (_editStars) { + _editStars->setClickedCallback([=] { + _show->show(Calls::Group::MakeVideoStreamStarsBox({ + .show = _show, + .current = _chosenStarsCount.value_or(0), + .save = crl::guard(_editStars, [=](int count) { + _chosenStarsCount = count; + updateSendButtonType(); + }), + .name = _history ? _history->peer->shortName() : QString(), + })); + }); + } +} + void ComposeControls::updateLikeParent() { if (_like) { using namespace Controls; @@ -1115,8 +1134,19 @@ void ComposeControls::updateFeatures(ChatHelpers::ComposeFeatures features) { } changed = true; } - if (was.editMessageStars != features.editMessageStars - || was.recordMediaMessage != features.recordMediaMessage) { + if (was.editMessageStars != features.editMessageStars) { + if (!features.editMessageStars) { + delete base::take(_editStars); + _chosenStarsCount = std::nullopt; + } else { + _editStars = Ui::CreateChild( + _wrap.get(), + _st.editStars); + initEditStarsButton(); + } + changed = true; + } + if (was.recordMediaMessage != features.recordMediaMessage) { _chosenStarsCount = features.editMessageStars ? 0 : std::optional(); @@ -2457,7 +2487,10 @@ void ComposeControls::initSendButton() { using namespace SendMenu; const auto sendAction = [=](Action action, Details details) { - if (action.type == ActionType::CaptionUp + if (action.type == ActionType::ChangePrice) { + _chosenStarsCount = details.price.value_or(0); + updateSendButtonType(); + } else if (action.type == ActionType::CaptionUp || action.type == ActionType::CaptionDown || action.type == ActionType::SpoilerOn || action.type == ActionType::SpoilerOff) { @@ -2471,7 +2504,9 @@ void ComposeControls::initSendButton() { _send.get(), _show, [=] { return sendButtonMenuDetails(); }, - sendAction); + sendAction, + &_st.tabbed.menu, + &_st.tabbed.icons); _send->widthValue() | rpl::skip(1) | rpl::start_with_next([=] { updateControlsGeometry(_wrap->size()); @@ -2913,6 +2948,7 @@ void ComposeControls::updateControlsGeometry(QSize size) { - (_sendAs ? _sendAs->width() : 0) - _st.padding.right() - _send->width() + - (_editStars ? _editStars->width() : 0) - _tabbedSelectorToggle->width() - (_likeShown ? _like->width() : 0) - (_botCommandShown ? _botCommandStart->width() : 0) @@ -2968,6 +3004,10 @@ void ComposeControls::updateControlsGeometry(QSize size) { right += _st.padding.right(); _send->moveToRight(right, buttonsTop); right += _send->width(); + if (_editStars) { + _editStars->moveToRight(right, buttonsTop); + right += _editStars->width(); + } _tabbedSelectorToggle->moveToRight(right, buttonsTop); right += _tabbedSelectorToggle->width(); if (_like) { @@ -3012,6 +3052,9 @@ void ComposeControls::updateControlsVisibility() { if (_like) { _like->setVisible(_likeShown); } + if (_editStars) { + _editStars->show(); + } if (_ttlInfo) { _ttlInfo->show(); } diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h index c4bd1cb57c..ad164dc49a 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h @@ -294,6 +294,7 @@ private: void initVoiceRecordBar(); void initKeyHandler(); void initLikeButton(); + void initEditStarsButton(); void updateLikeParent(); void updateSubmitSettings(); void updateSendButtonType(); @@ -403,6 +404,7 @@ private: std::optional _backgroundRect; const std::shared_ptr _send; + Ui::IconButton *_editStars = nullptr; Ui::IconButton *_like = nullptr; std::optional _chosenStarsCount; Ui::IconButton *_commentsShown = nullptr; diff --git a/Telegram/SourceFiles/media/stories/media_stories_reply.cpp b/Telegram/SourceFiles/media/stories/media_stories_reply.cpp index 9ac7900b5e..e773f52f26 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_reply.cpp +++ b/Telegram/SourceFiles/media/stories/media_stories_reply.cpp @@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_changes.h" #include "data/data_chat_participant_status.h" #include "data/data_document.h" +#include "data/data_group_call.h" #include "data/data_message_reaction_id.h" #include "data/data_peer_values.h" #include "data/data_session.h" @@ -599,9 +600,27 @@ void ReplyArea::chooseAttach( Fn ReplyArea::sendMenuDetails() const { return crl::guard(this, [=] { + const auto call = _videoStream + ? _videoStream->lookupReal() + : nullptr; return SendMenu::Details{ - .type = SendMenu::Type::SilentOnly, - .effectAllowed = _data.peer && _data.peer->isUser(), + .type = (!_data.videoStream + ? SendMenu::Type::SilentOnly + : !call + ? SendMenu::Type::Disabled + : SendMenu::Type::EditCommentPrice), + .commentStreamerName = (call + ? call->peer()->shortName() + : QString()), + .price = (_data.videoStream + ? uint64(_controls->chosenStarsForMessage()) + : std::optional()), + .commentPriceMin = (call + ? uint64(call->messagesMinPrice()) + : std::optional()), + .effectAllowed = (!_data.videoStream + && _data.peer + && _data.peer->isUser()), }; }); } diff --git a/Telegram/SourceFiles/media/view/media_view.style b/Telegram/SourceFiles/media/view/media_view.style index f9103ea5f8..2cc5fe5ea2 100644 --- a/Telegram/SourceFiles/media/view/media_view.style +++ b/Telegram/SourceFiles/media/view/media_view.style @@ -495,12 +495,10 @@ storiesRecordVoice: icon {{ "chat/input_record", storiesComposeGrayIcon }}; storiesRecordVoiceOver: icon {{ "chat/input_record", storiesComposeGrayIcon }}; storiesRecordRound: icon {{ "chat/input_video", storiesComposeGrayIcon }}; storiesRecordRoundOver: icon {{ "chat/input_video", storiesComposeGrayIcon }}; -storiesEditPrice: icon{{ "chat/input_paid", storiesComposeGrayIcon }}; -storiesEditPriceOver: icon{{ "chat/input_paid", storiesComposeGrayIcon }}; -//storiesEditStars: IconButton(storiesAttach) { -// icon: storiesEditPrice; -// iconOver: storiesEditPriceOver; -//} +storiesEditStars: IconButton(storiesAttach) { + icon: icon{{ "chat/input_paid", storiesComposeGrayIcon }}; + iconOver: icon{{ "chat/input_paid", storiesComposeGrayIcon }}; +} storiesRemoveSet: IconButton(stickerPanRemoveSet) { icon: icon {{ "simple_close", storiesComposeGrayIcon }}; iconOver: icon {{ "simple_close", storiesComposeGrayIcon }}; @@ -665,6 +663,7 @@ storiesEmojiPan: EmojiPan(defaultEmojiPan) { menuBelow: icon {{ "menu/link_below", storiesComposeWhiteText }}; menuAbove: icon {{ "menu/link_above", storiesComposeWhiteText }}; menuPrice: icon {{ "menu/earn", storiesComposeWhiteText }}; + menuEditStars: icon {{ "chat/input_paid", storiesComposeWhiteText }}; stripBubble: icon{ { "chat/reactions_bubble_shadow", windowShadowFg }, @@ -719,14 +718,13 @@ storiesComposeControls: ComposeControls(defaultComposeControls) { recordOver: storiesRecordVoiceOver; round: storiesRecordRound; roundOver: storiesRecordRoundOver; - editPrice: storiesEditPrice; - editPriceOver: storiesEditPriceOver; sendDisabledFg: storiesComposeGrayText; } attach: storiesAttach; emoji: storiesAttachEmoji; like: storiesLike; liked: icon{}; + editStars: storiesEditStars; commentsShow: IconButton(storiesAttach) { icon: icon {{ "chat/input_comments_expand", storiesComposeGrayIcon }}; iconOver: icon {{ "chat/input_comments_expand", storiesComposeGrayIcon }}; diff --git a/Telegram/SourceFiles/menu/menu_send.cpp b/Telegram/SourceFiles/menu/menu_send.cpp index c69aea17e8..6dabbdb600 100644 --- a/Telegram/SourceFiles/menu/menu_send.cpp +++ b/Telegram/SourceFiles/menu/menu_send.cpp @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/unixtime.h" #include "boxes/abstract_box.h" #include "boxes/premium_preview_box.h" +#include "calls/group/calls_group_stars_box.h" #include "chat_helpers/compose/compose_show.h" #include "chat_helpers/stickers_emoji_pack.h" #include "core/shortcuts.h" @@ -670,9 +671,44 @@ FillMenuResult AttachSendMenuEffect( return FillMenuResult::Prepared; } +FillMenuResult FillEditCommentPriceMenu( + not_null menu, + std::shared_ptr show, + Details details, + Fn action, + const style::ComposeIcons *iconsOverride, + std::optional desiredPositionOverride) { + const auto &icons = iconsOverride + ? *iconsOverride + : st::defaultComposeIcons; + menu->addAction(tr::lng_video_stream_edit_stars(tr::now), [=] { + show->show(Calls::Group::MakeVideoStreamStarsBox({ + .show = show, + .current = int(details.price.value_or(0)), + .save = [=](int count) { + auto copy = details; + copy.price = count; + action({ {}, Action::Type::ChangePrice }, copy); + }, + .name = details.commentStreamerName, + //.preview = details.commentPreview, + })); + }, &icons.menuEditStars); + if (details.price.value_or(0) > details.commentPriceMin.value_or(0)) { + auto copy = details; + copy.price = details.commentPriceMin.value_or(0); + menu->addAction(tr::lng_video_stream_remove_stars(tr::now), [=] { + action({ {}, Action::Type::ChangePrice }, copy); + }, &icons.menuGifRemove); + } + const auto position = desiredPositionOverride.value_or(QCursor::pos()); + menu->prepareGeometryFor(position); + return FillMenuResult::Prepared; +} + FillMenuResult FillSendMenu( not_null menu, - std::shared_ptr showForEffect, + std::shared_ptr show, Details details, Fn action, const style::ComposeIcons *iconsOverride, @@ -685,6 +721,14 @@ FillMenuResult FillSendMenu( && !details.price.has_value(); if (empty || !action) { return FillMenuResult::Skipped; + } else if (type == Type::EditCommentPrice) { + return FillEditCommentPriceMenu( + menu, + show, + details, + action, + iconsOverride, + desiredPositionOverride); } const auto &icons = iconsOverride ? *iconsOverride @@ -752,10 +796,10 @@ FillMenuResult FillSendMenu( &icons.menuPrice); } - if (showForEffect) { + if (show) { return AttachSendMenuEffect( menu, - showForEffect, + show, details, action, desiredPositionOverride); @@ -769,13 +813,20 @@ void SetupMenuAndShortcuts( not_null button, std::shared_ptr show, Fn details, - Fn action) { + Fn action, + const style::PopupMenu *stOverride, + const style::ComposeIcons *iconsOverride) { const auto menu = std::make_shared>(); const auto showMenu = [=] { *menu = base::make_unique_q( button, - st::popupMenuWithIcons); - const auto result = FillSendMenu(*menu, show, details(), action); + stOverride ? *stOverride : st::popupMenuWithIcons); + const auto result = FillSendMenu( + *menu, + show, + details(), + action, + iconsOverride); if (result != FillMenuResult::Prepared) { return false; } diff --git a/Telegram/SourceFiles/menu/menu_send.h b/Telegram/SourceFiles/menu/menu_send.h index a361dc1165..ec5be76791 100644 --- a/Telegram/SourceFiles/menu/menu_send.h +++ b/Telegram/SourceFiles/menu/menu_send.h @@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace style { struct ComposeIcons; +struct PopupMenu; } // namespace style namespace ChatHelpers { @@ -35,6 +36,7 @@ enum class Type : uchar { Scheduled, ScheduledToUser, // For "Send when online". Reminder, + EditCommentPrice, }; enum class SpoilerState : uchar { @@ -53,7 +55,10 @@ struct Details { Type type = Type::Disabled; SpoilerState spoiler = SpoilerState::None; CaptionState caption = CaptionState::None; + TextWithTags commentPreview; + QString commentStreamerName; std::optional price; + std::optional commentPriceMin; bool effectAllowed = false; }; @@ -101,7 +106,9 @@ void SetupMenuAndShortcuts( not_null button, std::shared_ptr show, Fn details, - Fn action); + Fn action, + const style::PopupMenu *stOverride = nullptr, + const style::ComposeIcons *iconsOverride = nullptr); void SetupUnreadMentionsMenu( not_null button, diff --git a/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp b/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp index 708d08b4a3..31d296a62b 100644 --- a/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp @@ -540,7 +540,7 @@ void PaidReactionsBox( }); const auto activeFgOverride = [=](int count) { const auto coloring = Calls::Group::Ui::StarsColoringForCount(count); - return Ui::ColorFromSerialized(coloring.bg2); + return Ui::ColorFromSerialized(coloring.bgLight); }; const auto bubble = Premium::AddBubbleRow( diff --git a/Telegram/SourceFiles/ui/controls/send_button.cpp b/Telegram/SourceFiles/ui/controls/send_button.cpp index ea86c7e670..060b3bc274 100644 --- a/Telegram/SourceFiles/ui/controls/send_button.cpp +++ b/Telegram/SourceFiles/ui/controls/send_button.cpp @@ -142,7 +142,7 @@ void SendButton::paintEvent(QPaintEvent *e) { break; case Type::Schedule: paintSchedule(p, over); break; case Type::Slowmode: paintSlowmode(p); break; - case Type::EditPrice: paintEditPrice(p, over); break; + case Type::EditPrice: break; } } @@ -281,6 +281,10 @@ SendButton::StarsGeometry SendButton::starsGeometry() const { } void SendButton::updateSize() { + if (_state.type == Type::EditPrice) { + resize(0, _st.inner.height); + return; + } const auto finalWidth = _starsToSendText.isEmpty() ? _st.inner.width : starsGeometry().outer.width(); @@ -318,20 +322,6 @@ QPoint SendButton::prepareRippleStartPosition() const { return real - QPoint((width() - size) / 2, y); } -void SendButton::paintEditPrice(QPainter &p, bool over) { - if (!isDisabled()) { - paintRipple( - p, - (width() - _st.inner.rippleAreaSize) / 2, - _st.inner.rippleAreaPosition.y()); - } - - const auto &icon = (isDisabled() || !over) - ? _st.editPrice - : _st.editPriceOver; - icon.paintInCenter(p, rect()); -} - SendStarButton::SendStarButton( QWidget *parent, const style::RoundButton &st, diff --git a/Telegram/SourceFiles/ui/controls/send_button.h b/Telegram/SourceFiles/ui/controls/send_button.h index 78acd76859..2e2c4e73b9 100644 --- a/Telegram/SourceFiles/ui/controls/send_button.h +++ b/Telegram/SourceFiles/ui/controls/send_button.h @@ -72,7 +72,6 @@ private: void paintSend(QPainter &p, bool over); void paintSchedule(QPainter &p, bool over); void paintSlowmode(QPainter &p); - void paintEditPrice(QPainter &p, bool over); void paintStarsToSend(QPainter &p, bool over); const style::SendButton &_st;