From 37d32b32f88729f1e81d4d76072c8dfc096c0df5 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 7 Jan 2025 20:47:43 +0400 Subject: [PATCH] Show gifts inside media view in stories. --- .../SourceFiles/boxes/gift_premium_box.cpp | 118 ++++++++++-------- Telegram/SourceFiles/boxes/gift_premium_box.h | 9 ++ .../boxes/peers/edit_peer_invite_link.cpp | 2 +- Telegram/SourceFiles/boxes/share_box.cpp | 62 +++++++-- Telegram/SourceFiles/boxes/share_box.h | 27 ++-- Telegram/SourceFiles/boxes/star_gift_box.cpp | 5 +- Telegram/SourceFiles/boxes/star_gift_box.h | 5 + .../calls/group/calls_group_settings.cpp | 24 +--- .../SourceFiles/core/local_url_handlers.cpp | 11 +- .../SourceFiles/core/local_url_handlers.h | 8 ++ .../bot/starref/info_bot_starref_common.cpp | 4 +- .../boosts/giveaway/giveaway.style | 78 +++++++----- .../stories/media_stories_controller.cpp | 6 +- .../media/stories/media_stories_share.cpp | 29 +---- .../settings/settings_credits_graphics.cpp | 56 ++++++--- .../settings/settings_credits_graphics.h | 28 ++++- Telegram/lib_ui | 2 +- 17 files changed, 299 insertions(+), 175 deletions(-) diff --git a/Telegram/SourceFiles/boxes/gift_premium_box.cpp b/Telegram/SourceFiles/boxes/gift_premium_box.cpp index 4bdc788e3..976e6e8bd 100644 --- a/Telegram/SourceFiles/boxes/gift_premium_box.cpp +++ b/Telegram/SourceFiles/boxes/gift_premium_box.cpp @@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwidget.h" #include "payments/payments_checkout_process.h" #include "payments/payments_form.h" +#include "settings/settings_credits_graphics.h" #include "settings/settings_premium.h" #include "ui/basic_click_handlers.h" // UrlClickHandler::Open. #include "ui/boxes/boost_box.h" // StartFireworks. @@ -128,12 +129,12 @@ constexpr auto kRarityTooltipDuration = 3 * crl::time(1000); } [[nodiscard]] object_ptr MakePeerTableValue( - not_null parent, + not_null table, std::shared_ptr show, PeerId id, rpl::producer button = nullptr, Fn handler = nullptr) { - auto result = object_ptr(parent); + auto result = object_ptr(table); const auto raw = result.data(); const auto &st = st::giveawayGiftCodeUserpic; @@ -144,12 +145,12 @@ constexpr auto kRarityTooltipDuration = 3 * crl::time(1000); const auto label = Ui::CreateChild( raw, (button && handler) ? peer->shortName() : peer->name(), - st::giveawayGiftCodeValue); + table->st().defaultValue); const auto send = (button && handler) ? Ui::CreateChild( raw, std::move(button), - st::starGiftSmallButton) + table->st().smallButton) : nullptr; if (send) { send->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); @@ -171,8 +172,8 @@ constexpr auto kRarityTooltipDuration = 3 * crl::time(1000); send->moveToLeft( position.x() + label->width() + st::normalFont->spacew, (position.y() - + st::giveawayGiftCodeValue.style.font->ascent - - st::starGiftSmallButton.style.font->ascent), + + table->st().defaultValue.style.font->ascent + - table->st().smallButton.style.font->ascent), width); } }, label->lifetime()); @@ -189,8 +190,8 @@ constexpr auto kRarityTooltipDuration = 3 * crl::time(1000); } [[nodiscard]] object_ptr MakeHiddenPeerTableValue( - not_null parent) { - auto result = object_ptr(parent); + not_null table) { + auto result = object_ptr(table); const auto raw = result.data(); const auto &st = st::giveawayGiftCodeUserpic; @@ -207,7 +208,7 @@ constexpr auto kRarityTooltipDuration = 3 * crl::time(1000); const auto label = Ui::CreateChild( raw, tr::lng_gift_from_hidden(), - st::giveawayGiftCodeValue); + table->st().defaultValue); raw->widthValue( ) | rpl::start_with_next([=](int width) { const auto position = st::giveawayGiftCodeNamePosition; @@ -234,7 +235,7 @@ void AddTableRow( ? object_ptr( table, std::move(label), - st::giveawayGiftCodeLabel) + table->st().defaultLabel) : object_ptr(nullptr)), std::move(value), st::giveawayGiftCodeLabelMargin, @@ -242,23 +243,23 @@ void AddTableRow( } [[nodiscard]] object_ptr MakeAttributeValue( - not_null parent, + not_null table, const Data::UniqueGiftAttribute &attribute, Fn, int)> showTooltip) { - auto result = object_ptr(parent); + auto result = object_ptr(table); const auto raw = result.data(); const auto label = Ui::CreateChild( raw, attribute.name, - st::giveawayGiftCodeValue); + table->st().defaultValue); const auto permille = attribute.rarityPermille; const auto text = QString::number(permille / 10.) + '%'; const auto rarity = Ui::CreateChild( raw, rpl::single(text), - st::starGiftSmallButton); + table->st().smallButton); rarity->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); rpl::combine( @@ -272,8 +273,8 @@ void AddTableRow( label->moveToLeft(0, 0, width); rarity->moveToLeft( label->width() + st::normalFont->spacew, - (st::giveawayGiftCodeValue.style.font->ascent - - st::starGiftSmallButton.style.font->ascent), + (table->st().defaultValue.style.font->ascent + - table->st().smallButton.style.font->ascent), width); }, label->lifetime()); @@ -293,11 +294,11 @@ void AddTableRow( } [[nodiscard]] object_ptr MakeStarGiftStarsValue( - not_null parent, + not_null table, std::shared_ptr show, const Data::CreditsHistoryEntry &entry, Fn convertToStars) { - auto result = object_ptr(parent); + auto result = object_ptr(table); const auto raw = result.data(); const auto session = &show->session(); @@ -312,7 +313,7 @@ void AddTableRow( raw, rpl::single(star.append( ' ' + Lang::FormatStarsAmountDecimal(entry.credits))), - st::giveawayGiftCodeValue, + table->st().defaultValue, st::defaultPopupMenu, std::move(makeContext)); @@ -322,7 +323,7 @@ void AddTableRow( tr::lng_gift_sell_small( lt_count_decimal, rpl::single(entry.starsConverted * 1.)), - st::starGiftSmallButton) + table->st().smallButton) : nullptr; if (convert) { convert->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); @@ -340,8 +341,8 @@ void AddTableRow( if (convert) { convert->moveToLeft( label->width() + st::normalFont->spacew, - (st::giveawayGiftCodeValue.style.font->ascent - - st::starGiftSmallButton.style.font->ascent), + (table->st().defaultValue.style.font->ascent + - table->st().smallButton.style.font->ascent), width); } }, label->lifetime()); @@ -358,10 +359,10 @@ void AddTableRow( } [[nodiscard]] object_ptr MakeVisibilityTableValue( - not_null parent, + not_null table, bool savedToProfile, Fn toggleVisibility) { - auto result = object_ptr(parent); + auto result = object_ptr(table); const auto raw = result.data(); const auto label = Ui::CreateChild( @@ -369,7 +370,7 @@ void AddTableRow( (savedToProfile ? tr::lng_gift_visibility_shown() : tr::lng_gift_visibility_hidden()), - st::giveawayGiftCodeValue, + table->st().defaultValue, st::defaultPopupMenu); const auto toggle = Ui::CreateChild( @@ -377,7 +378,7 @@ void AddTableRow( (savedToProfile ? tr::lng_gift_visibility_hide() : tr::lng_gift_visibility_show()), - st::starGiftSmallButton); + table->st().smallButton); toggle->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); toggle->setClickedCallback([=] { toggleVisibility(!savedToProfile); @@ -394,8 +395,8 @@ void AddTableRow( label->moveToLeft(0, 0, width); toggle->moveToLeft( label->width() + st::normalFont->spacew, - (st::giveawayGiftCodeValue.style.font->ascent - - st::starGiftSmallButton.style.font->ascent), + (table->st().defaultValue.style.font->ascent + - table->st().smallButton.style.font->ascent), width); }, label->lifetime()); @@ -411,21 +412,21 @@ void AddTableRow( } [[nodiscard]] object_ptr MakeNonUniqueStatusTableValue( - not_null parent, + not_null table, Fn startUpgrade) { - auto result = object_ptr(parent); + auto result = object_ptr(table); const auto raw = result.data(); const auto label = Ui::CreateChild( raw, tr::lng_gift_unique_status_non(), - st::giveawayGiftCodeValue, + table->st().defaultValue, st::defaultPopupMenu); const auto upgrade = Ui::CreateChild( raw, tr::lng_gift_unique_status_upgrade(), - st::starGiftSmallButton); + table->st().smallButton); upgrade->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); upgrade->setClickedCallback(startUpgrade); @@ -440,8 +441,8 @@ void AddTableRow( label->moveToLeft(0, 0, width); upgrade->moveToLeft( label->width() + st::normalFont->spacew, - (st::giveawayGiftCodeValue.style.font->ascent - - st::starGiftSmallButton.style.font->ascent), + (table->st().defaultValue.style.font->ascent + - table->st().smallButton.style.font->ascent), width); }, label->lifetime()); @@ -464,7 +465,7 @@ not_null AddTableRow( auto widget = object_ptr( table, std::move(value), - st::giveawayGiftCodeValue, + table->st().defaultValue, st::defaultPopupMenu, std::move(makeContext)); const auto result = widget.data(); @@ -494,12 +495,13 @@ void AddTableRow( void AddTable( not_null container, std::shared_ptr show, + Settings::CreditsEntryBoxStyleOverrides st, const Api::GiftCode ¤t, bool skipReason) { auto table = container->add( object_ptr( container, - st::giveawayGiftCodeTable), + st.table ? *st.table : st::giveawayGiftCodeTable), st::giveawayGiftCodeTableMargin); if (current.from) { AddTableRow( @@ -678,7 +680,7 @@ void GiftCodeBox( st::giveawayGiftCodeLinkMargin); const auto show = controller->uiShow(); - AddTable(box->verticalLayout(), show, state->data.current(), false); + AddTable(box->verticalLayout(), show, {}, state->data.current(), false); auto shareLink = tr::lng_gift_link_also_send_link( ) | rpl::map([](const QString &text) { @@ -760,7 +762,6 @@ void GiftCodeBox( }, button->lifetime()); } - void GiftCodePendingBox( not_null box, not_null controller, @@ -839,7 +840,7 @@ void GiftCodePendingBox( } const auto show = controller->uiShow(); - AddTable(box->verticalLayout(), show, data, true); + AddTable(box->verticalLayout(), show, {}, data, true); box->addRow( object_ptr( @@ -1192,6 +1193,7 @@ void ResolveGiveawayInfo( void AddStarGiftTable( std::shared_ptr show, not_null container, + Settings::CreditsEntryBoxStyleOverrides st, const Data::CreditsHistoryEntry &entry, Fn toggleVisibility, Fn convertToStars, @@ -1199,7 +1201,7 @@ void AddStarGiftTable( auto table = container->add( object_ptr( container, - st::giveawayGiftCodeTable), + st.table ? *st.table : st::giveawayGiftCodeTable), st::giveawayGiftCodeTableMargin); const auto peerId = PeerId(entry.barePeerId); const auto session = &show->session(); @@ -1344,17 +1346,17 @@ void AddStarGiftTable( AddTableRow( table, tr::lng_gift_unique_model(), - MakeAttributeValue(container, unique->model, showTooltip), + MakeAttributeValue(table, unique->model, showTooltip), marginWithButton); AddTableRow( table, tr::lng_gift_unique_backdrop(), - MakeAttributeValue(container, unique->backdrop, showTooltip), + MakeAttributeValue(table, unique->backdrop, showTooltip), marginWithButton); AddTableRow( table, tr::lng_gift_unique_symbol(), - MakeAttributeValue(container, unique->pattern, showTooltip), + MakeAttributeValue(table, unique->pattern, showTooltip), marginWithButton); } else { AddTableRow( @@ -1458,7 +1460,9 @@ void AddStarGiftTable( lt_text, rpl::single(original.message), Ui::Text::WithEntities))), - st::giveawayGiftMessage, + (st.tableValueMessage + ? *st.tableValueMessage + : st::giveawayGiftMessage), st::defaultPopupMenu, makeContext); const auto showBoxLink = [=](not_null peer) { @@ -1487,7 +1491,9 @@ void AddStarGiftTable( auto label = object_ptr( table, rpl::single(entry.description), - st::giveawayGiftMessage, + (st.tableValueMessage + ? *st.tableValueMessage + : st::giveawayGiftMessage), st::defaultPopupMenu, makeContext); label->setSelectable(true); @@ -1502,6 +1508,7 @@ void AddStarGiftTable( void AddCreditsHistoryEntryTable( std::shared_ptr show, not_null container, + Settings::CreditsEntryBoxStyleOverrides st, const Data::CreditsHistoryEntry &entry) { if (!entry) { return; @@ -1509,7 +1516,7 @@ void AddCreditsHistoryEntryTable( auto table = container->add( object_ptr( container, - st::giveawayGiftCodeTable), + st.table ? *st.table : st::giveawayGiftCodeTable), st::giveawayGiftCodeTableMargin); const auto peerId = PeerId(entry.barePeerId); const auto actorId = PeerId(entry.bareActorId); @@ -1570,7 +1577,7 @@ void AddCreditsHistoryEntryTable( auto label = object_ptr( table, rpl::single(Ui::Text::Link(link)), - st::giveawayGiftCodeValue); + table->st().defaultValue); label->setClickHandlerFilter([=](const auto &...) { if (const auto window = show->resolveWindow()) { window->showPeerHistory(channel, {}, msgId); @@ -1666,9 +1673,11 @@ void AddCreditsHistoryEntryTable( table, rpl::single( Ui::Text::Wrapped({ entry.id }, EntityType::Code, {})), - oneLine - ? st::giveawayGiftCodeValue - : st::giveawayGiftCodeValueMultiline); + (oneLine + ? table->st().defaultValue + : st.tableValueMultiline + ? *st.tableValueMultiline + : st::giveawayGiftCodeValueMultiline)); label->setClickHandlerFilter([=](const auto &...) { TextUtilities::SetClipboardText( TextForMimeData::Simple(entry.id)); @@ -1714,6 +1723,7 @@ void AddCreditsHistoryEntryTable( void AddSubscriptionEntryTable( std::shared_ptr show, not_null container, + Settings::CreditsEntryBoxStyleOverrides st, const Data::SubscriptionEntry &s) { if (!s) { return; @@ -1721,7 +1731,7 @@ void AddSubscriptionEntryTable( auto table = container->add( object_ptr( container, - st::giveawayGiftCodeTable), + st.table ? *st.table : st::giveawayGiftCodeTable), st::giveawayGiftCodeTableMargin); const auto peerId = PeerId(s.barePeerId); const auto user = peerIsUser(peerId) @@ -1767,12 +1777,13 @@ void AddSubscriptionEntryTable( void AddSubscriberEntryTable( std::shared_ptr show, not_null container, + Settings::CreditsEntryBoxStyleOverrides st, not_null peer, TimeId date) { auto table = container->add( object_ptr( container, - st::giveawayGiftCodeTable), + st.table ? *st.table : st::giveawayGiftCodeTable), st::giveawayGiftCodeTableMargin); AddTableRow( table, @@ -1790,11 +1801,12 @@ void AddSubscriberEntryTable( void AddCreditsBoostTable( std::shared_ptr show, not_null container, + Settings::CreditsEntryBoxStyleOverrides st, const Data::Boost &b) { auto table = container->add( object_ptr( container, - st::giveawayGiftCodeTable), + st.table ? *st.table : st::giveawayGiftCodeTable), st::giveawayGiftCodeTableMargin); const auto peerId = b.giveawayMessage.peer; if (!peerId) { diff --git a/Telegram/SourceFiles/boxes/gift_premium_box.h b/Telegram/SourceFiles/boxes/gift_premium_box.h index 8aea2e6f9..2d04b99a6 100644 --- a/Telegram/SourceFiles/boxes/gift_premium_box.h +++ b/Telegram/SourceFiles/boxes/gift_premium_box.h @@ -25,6 +25,10 @@ struct GiveawayResults; struct SubscriptionEntry; } // namespace Data +namespace Settings { +struct CreditsEntryBoxStyleOverrides; +} // namespace Settings + namespace Ui { class GenericBox; class VerticalLayout; @@ -61,6 +65,7 @@ void ResolveGiveawayInfo( void AddStarGiftTable( std::shared_ptr show, not_null container, + Settings::CreditsEntryBoxStyleOverrides st, const Data::CreditsHistoryEntry &entry, Fn toggleVisibility, Fn convertToStars, @@ -68,19 +73,23 @@ void AddStarGiftTable( void AddCreditsHistoryEntryTable( std::shared_ptr show, not_null container, + Settings::CreditsEntryBoxStyleOverrides st, const Data::CreditsHistoryEntry &entry); void AddSubscriptionEntryTable( std::shared_ptr show, not_null container, + Settings::CreditsEntryBoxStyleOverrides st, const Data::SubscriptionEntry &s); void AddSubscriberEntryTable( std::shared_ptr show, not_null container, + Settings::CreditsEntryBoxStyleOverrides st, not_null peer, TimeId date); void AddCreditsBoostTable( std::shared_ptr show, not_null container, + Settings::CreditsEntryBoxStyleOverrides st, const Data::Boost &boost); diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp index e771275a8..2797b5394 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp @@ -1020,7 +1020,7 @@ void Controller::rowClicked(not_null row) { Ui::AddSkip(content); const auto show = controller->uiShow(); - AddSubscriberEntryTable(show, content, row->peer(), data.date); + AddSubscriberEntryTable(show, content, {}, row->peer(), data.date); Ui::AddSkip(content); Ui::AddSkip(content); diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index ca3d9a934..f79ee88f8 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -53,6 +53,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "core/application.h" #include "core/core_settings.h" +#include "styles/style_calls.h" #include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_menu_icons.h" @@ -197,16 +198,16 @@ ShareBox::ShareBox(QWidget*, Descriptor &&descriptor) , _api(&_descriptor.session->mtp()) , _select( this, - (_descriptor.stMultiSelect - ? *_descriptor.stMultiSelect + (_descriptor.st.multiSelect + ? *_descriptor.st.multiSelect : st::defaultMultiSelect), tr::lng_participant_filter()) , _comment( this, object_ptr( this, - (_descriptor.stComment - ? *_descriptor.stComment + (_descriptor.st.comment + ? *_descriptor.st.comment : st::shareComment), Ui::InputField::Mode::MultiLine, tr::lng_photos_comment()), @@ -251,7 +252,7 @@ void ShareBox::prepareCommentField() { .session = _descriptor.session, .show = Main::MakeSessionShow(show, _descriptor.session), .field = field, - .fieldStyle = _descriptor.stLabel, + .fieldStyle = _descriptor.st.label, }); } field->setSubmitSettings(Core::App().settings().sendSubmitWay()); @@ -569,7 +570,7 @@ void ShareBox::showMenu(not_null parent) { [=](Api::SendOptions options) { submit(options); }, action.options, HistoryView::DefaultScheduleTime(), - _descriptor.scheduleBoxStyle)); + *_descriptor.st.scheduleBox)); }); _menu->setForcedVerticalOrigin(Ui::PopupMenu::VerticalOrigin::Bottom); const auto result = FillSendMenu( @@ -704,7 +705,9 @@ ShareBox::Inner::Inner( : RpWidget(parent) , _descriptor(descriptor) , _show(std::move(show)) -, _st(_descriptor.st ? *_descriptor.st : st::shareBoxList) +, _st(_descriptor.st.peerList + ? *_descriptor.st.peerList + : st::shareBoxList) , _defaultChatsIndexed( std::make_unique( Dialogs::SortMode::Add)) @@ -1612,9 +1615,37 @@ ShareBox::SubmitCallback ShareBox::DefaultForwardCallback( }; } +ShareBoxStyleOverrides DarkShareBoxStyle() { + using namespace HistoryView; + + const auto schedule = [&] { + auto date = Ui::ChooseDateTimeStyleArgs(); + date.labelStyle = &st::groupCallBoxLabel; + date.dateFieldStyle = &st::groupCallScheduleDateField; + date.timeFieldStyle = &st::groupCallScheduleTimeField; + date.separatorStyle = &st::callMuteButtonLabel; + date.atStyle = &st::callMuteButtonLabel; + date.calendarStyle = &st::groupCallCalendarColors; + + auto st = ScheduleBoxStyleArgs(); + st.topButtonStyle = &st::groupCallMenuToggle; + st.popupMenuStyle = &st::groupCallPopupMenu; + st.chooseDateTimeArgs = std::move(date); + return st; + }; + return { + .multiSelect = &st::groupCallMultiSelect, + .comment = &st::groupCallShareBoxComment, + .peerList = &st::groupCallShareBoxList, + .label = &st::groupCallField, + .scheduleBox = std::make_shared(schedule()), + }; +} + void FastShareMessage( std::shared_ptr show, - not_null item) { + not_null item, + ShareBoxStyleOverrides st) { const auto history = item->history(); const auto owner = &history->owner(); const auto session = &history->session(); @@ -1683,6 +1714,7 @@ void FastShareMessage( history, msgIds), .filterCallback = std::move(filterCallback), + .st = st, .forwardOptions = { .sendersCount = ItemsForwardSendersCount(items), .captionsCount = ItemsForwardCaptionsCount(items), @@ -1694,19 +1726,22 @@ void FastShareMessage( void FastShareMessage( not_null controller, - not_null item) { - FastShareMessage(controller->uiShow(), item); + not_null item, + ShareBoxStyleOverrides st) { + FastShareMessage(controller->uiShow(), item, st); } void FastShareLink( not_null controller, - const QString &url) { - FastShareLink(controller->uiShow(), url); + const QString &url, + ShareBoxStyleOverrides st) { + FastShareLink(controller->uiShow(), url, st); } void FastShareLink( std::shared_ptr show, - const QString &url) { + const QString &url, + ShareBoxStyleOverrides st) { const auto box = std::make_shared>(); const auto sending = std::make_shared(); auto copyCallback = [=] { @@ -1770,6 +1805,7 @@ void FastShareLink( .copyCallback = std::move(copyCallback), .submitCallback = std::move(submitCallback), .filterCallback = std::move(filterCallback), + .st = st, .premiumRequiredError = SharePremiumRequiredError(), }), Ui::LayerOption::KeepOther, diff --git a/Telegram/SourceFiles/boxes/share_box.h b/Telegram/SourceFiles/boxes/share_box.h index ef6960af0..f21b4505b 100644 --- a/Telegram/SourceFiles/boxes/share_box.h +++ b/Telegram/SourceFiles/boxes/share_box.h @@ -61,18 +61,31 @@ class PopupMenu; class ShareBox; +struct ShareBoxStyleOverrides { + const style::MultiSelect *multiSelect = nullptr; + const style::InputField *comment = nullptr; + const style::PeerList *peerList = nullptr; + const style::InputField *label = nullptr; + std::shared_ptr scheduleBox; +}; +[[nodiscard]] ShareBoxStyleOverrides DarkShareBoxStyle(); + void FastShareMessage( std::shared_ptr show, - not_null item); + not_null item, + ShareBoxStyleOverrides st = {}); void FastShareMessage( not_null controller, - not_null item); + not_null item, + ShareBoxStyleOverrides st = {}); void FastShareLink( not_null controller, - const QString &url); + const QString &url, + ShareBoxStyleOverrides st = {}); void FastShareLink( std::shared_ptr show, - const QString &url); + const QString &url, + ShareBoxStyleOverrides st = {}); struct RecipientPremiumRequiredError; [[nodiscard]] auto SharePremiumRequiredError() @@ -100,16 +113,12 @@ public: FilterCallback filterCallback; object_ptr bottomWidget = { nullptr }; rpl::producer copyLinkText; - const style::MultiSelect *stMultiSelect = nullptr; - const style::InputField *stComment = nullptr; - const style::PeerList *st = nullptr; - const style::InputField *stLabel = nullptr; + ShareBoxStyleOverrides st; struct { int sendersCount = 0; int captionsCount = 0; bool show = false; } forwardOptions; - HistoryView::ScheduleBoxStyleArgs scheduleBoxStyle; using PremiumRequiredError = RecipientPremiumRequiredError; Fn)> premiumRequiredError; diff --git a/Telegram/SourceFiles/boxes/star_gift_box.cpp b/Telegram/SourceFiles/boxes/star_gift_box.cpp index ccbbe6f7e..158f322e8 100644 --- a/Telegram/SourceFiles/boxes/star_gift_box.cpp +++ b/Telegram/SourceFiles/boxes/star_gift_box.cpp @@ -2345,7 +2345,7 @@ void UpgradeBox( } }, box->lifetime()); - AddUniqueCloseButton(box); + AddUniqueCloseButton(box, {}); } const std::vector &PatternPoints() { @@ -2502,6 +2502,7 @@ void ShowStarGiftUpgradeBox(StarGiftUpgradeArgs &&args) { void AddUniqueCloseButton( not_null box, + Settings::CreditsEntryBoxStyleOverrides st, Fn)> fillMenu) { const auto close = Ui::CreateChild( box, @@ -2537,7 +2538,7 @@ void AddUniqueCloseButton( } *state = base::make_unique_q( menu, - st::popupMenuWithIcons); + st.menu ? *st.menu : st::popupMenuWithIcons); fillMenu(state->get()); if (!(*state)->empty()) { (*state)->popup(QCursor::pos()); diff --git a/Telegram/SourceFiles/boxes/star_gift_box.h b/Telegram/SourceFiles/boxes/star_gift_box.h index 5a06bfc35..59b201e66 100644 --- a/Telegram/SourceFiles/boxes/star_gift_box.h +++ b/Telegram/SourceFiles/boxes/star_gift_box.h @@ -17,6 +17,10 @@ namespace Payments { enum class CheckoutResult; } // namespace Payments +namespace Settings { +struct CreditsEntryBoxStyleOverrides; +} // namespace Settings + namespace Window { class SessionController; } // namespace Window @@ -76,6 +80,7 @@ void ShowStarGiftUpgradeBox(StarGiftUpgradeArgs &&args); void AddUniqueCloseButton( not_null box, + Settings::CreditsEntryBoxStyleOverrides st, Fn)> fillMenu = nullptr); void RequestStarsFormAndSubmit( diff --git a/Telegram/SourceFiles/calls/group/calls_group_settings.cpp b/Telegram/SourceFiles/calls/group/calls_group_settings.cpp index 980842b99..269339355 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_settings.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_settings.cpp @@ -44,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "webrtc/webrtc_audio_input_tester.h" #include "webrtc/webrtc_device_resolver.h" #include "settings/settings_calls.h" +#include "settings/settings_credits_graphics.h" #include "main/main_session.h" #include "apiwrap.h" #include "api/api_invite_links.h" @@ -183,22 +184,7 @@ object_ptr ShareInviteLinkBox( return Data::CanSend(thread, ChatRestriction::SendOther); }; - const auto scheduleStyle = [&] { - auto date = Ui::ChooseDateTimeStyleArgs(); - date.labelStyle = &st::groupCallBoxLabel; - date.dateFieldStyle = &st::groupCallScheduleDateField; - date.timeFieldStyle = &st::groupCallScheduleTimeField; - date.separatorStyle = &st::callMuteButtonLabel; - date.atStyle = &st::callMuteButtonLabel; - date.calendarStyle = &st::groupCallCalendarColors; - - auto st = HistoryView::ScheduleBoxStyleArgs(); - st.topButtonStyle = &st::groupCallMenuToggle; - st.popupMenuStyle = &st::groupCallPopupMenu; - st.chooseDateTimeArgs = std::move(date); - return st; - }; - + const auto st = ::Settings::DarkCreditsEntryBoxStyle(); auto result = Box(ShareBox::Descriptor{ .session = &peer->session(), .copyCallback = std::move(copyCallback), @@ -211,11 +197,7 @@ object_ptr ShareInviteLinkBox( : rpl::single(false)), tr::lng_group_call_copy_speaker_link(), tr::lng_group_call_copy_listener_link()), - .stMultiSelect = &st::groupCallMultiSelect, - .stComment = &st::groupCallShareBoxComment, - .st = &st::groupCallShareBoxList, - .stLabel = &st::groupCallField, - .scheduleBoxStyle = scheduleStyle(), + .st = st.shareBox ? *st.shareBox : ShareBoxStyleOverrides(), .premiumRequiredError = SharePremiumRequiredError(), }); *box = result.data(); diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index 7a07c26dd..3eda30a36 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -1702,7 +1702,8 @@ bool StartUrlRequiresActivate(const QString &url) { void ResolveAndShowUniqueGift( std::shared_ptr show, - const QString &slug) { + const QString &slug, + ::Settings::CreditsEntryBoxStyleOverrides st) { struct Request { base::weak_ptr weak; QString slug; @@ -1732,7 +1733,7 @@ void ResolveAndShowUniqueGift( session->data().processUsers(data.vusers()); if (const auto gift = Api::FromTL(session, data.vgift())) { using namespace ::Settings; - show->show(Box(GlobalStarGiftBox, show, *gift)); + show->show(Box(GlobalStarGiftBox, show, *gift, st)); } }).fail([=](const MTP::Error &error) { clear(); @@ -1740,4 +1741,10 @@ void ResolveAndShowUniqueGift( }).send(); } +void ResolveAndShowUniqueGift( + std::shared_ptr show, + const QString &slug) { + ResolveAndShowUniqueGift(std::move(show), slug, {}); +} + } // namespace Core diff --git a/Telegram/SourceFiles/core/local_url_handlers.h b/Telegram/SourceFiles/core/local_url_handlers.h index 50af3c2d1..4f9b68003 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.h +++ b/Telegram/SourceFiles/core/local_url_handlers.h @@ -15,6 +15,10 @@ namespace ChatHelpers { class Show; } // namespace ChatHelpers +namespace Settings { +struct CreditsEntryBoxStyleOverrides; +} // namespace Settings + namespace Window { class SessionController; } // namespace Window @@ -38,6 +42,10 @@ struct LocalUrlHandler { [[nodiscard]] bool StartUrlRequiresActivate(const QString &url); +void ResolveAndShowUniqueGift( + std::shared_ptr show, + const QString &slug, + ::Settings::CreditsEntryBoxStyleOverrides st); void ResolveAndShowUniqueGift( std::shared_ptr show, const QString &slug); diff --git a/Telegram/SourceFiles/info/bot/starref/info_bot_starref_common.cpp b/Telegram/SourceFiles/info/bot/starref/info_bot_starref_common.cpp index 524243638..049b84e09 100644 --- a/Telegram/SourceFiles/info/bot/starref/info_bot_starref_common.cpp +++ b/Telegram/SourceFiles/info/bot/starref/info_bot_starref_common.cpp @@ -983,11 +983,11 @@ void ConfirmUpdate( object_ptr( table, std::move(label), - st::giveawayGiftCodeLabel), + table->st().defaultLabel), object_ptr( table, value, - st::giveawayGiftCodeValue, + table->st().defaultValue, st::defaultPopupMenu), st::giveawayGiftCodeLabelMargin, st::giveawayGiftCodeValueMargin); diff --git a/Telegram/SourceFiles/info/channel_statistics/boosts/giveaway/giveaway.style b/Telegram/SourceFiles/info/channel_statistics/boosts/giveaway/giveaway.style index ca7d302e6..fccb91fcd 100644 --- a/Telegram/SourceFiles/info/channel_statistics/boosts/giveaway/giveaway.style +++ b/Telegram/SourceFiles/info/channel_statistics/boosts/giveaway/giveaway.style @@ -78,22 +78,8 @@ giveawayGiftCodeTable: Table(defaultTable) { labelMinWidth: 91px; } giveawayGiftCodeTableMargin: margins(24px, 4px, 24px, 4px); -giveawayGiftCodeLabel: FlatLabel(defaultFlatLabel) { - textFg: menuIconColor; - maxHeight: 24px; - style: TextStyle(semiboldTextStyle) { - font: font(12px semibold); - } -} giveawayGiftCodeLabelMargin: margins(13px, 10px, 13px, 10px); -giveawayGiftCodeValue: FlatLabel(defaultFlatLabel) { - maxHeight: 24px; - style: TextStyle(defaultTextStyle) { - font: font(12px); - linkUnderline: kLinkUnderlineNever; - } -} -giveawayGiftCodeValueMultiline: FlatLabel(giveawayGiftCodeValue) { +giveawayGiftCodeValueMultiline: FlatLabel(defaultTableValue) { minWidth: 128px; maxHeight: 100px; style: TextStyle(defaultTextStyle) { @@ -101,7 +87,7 @@ giveawayGiftCodeValueMultiline: FlatLabel(giveawayGiftCodeValue) { linkUnderline: kLinkUnderlineNever; } } -giveawayGiftMessage: FlatLabel(giveawayGiftCodeValue) { +giveawayGiftMessage: FlatLabel(defaultTableValue) { minWidth: 128px; maxHeight: 0px; } @@ -217,19 +203,53 @@ starConvertButtonLoading: InfiniteRadialAnimation(startGiveawayButtonLoading) { thickness: 2px; } -starGiftSmallButton: RoundButton(defaultActiveButton) { - textFg: windowActiveTextFg; - textFgOver: windowActiveTextFg; - textBg: lightButtonBgOver; - textBgOver: lightButtonBgOver; - width: -12px; - height: 18px; - radius: 9px; - textTop: 0px; - style: TextStyle(defaultTextStyle) { - font: font(12px); +starGiftSmallButton: defaultTableSmallButton; +darkGiftCodeBox: Box(giveawayGiftCodeBox) { + button: RoundButton(defaultActiveButton) { + height: 42px; + textTop: 12px; + style: semiboldTextStyle; } - ripple: RippleAnimation(defaultRippleAnimation) { - color: lightButtonBgRipple; + bg: groupCallMembersBg; + title: FlatLabel(boxTitle) { + textFg: groupCallMembersFg; + } + titleAdditionalFg: groupCallMemberNotJoinedStatus; +} +darkGiftLink: icon {{ "menu/copy", groupCallMembersFg }}; +darkGiftShare: icon {{ "menu/share", groupCallMembersFg }}; +darkGiftTransfer: icon {{ "chat/input_replace", groupCallMembersFg }}; +darkGiftPalette: TextPalette(defaultTextPalette) { + linkFg: mediaviewTextLinkFg; + monoFg: groupCallMembersFg; + spoilerFg: groupCallMembersFg; +} +darkGiftTable: Table(giveawayGiftCodeTable) { + headerBg: groupCallMembersBgOver; + borderFg: mediaviewMenuBgOver; + smallButton: RoundButton(defaultTableSmallButton) { + textFg: groupCallMembersFg; + textFgOver: groupCallMembersFg; + textBg: groupCallMenuBgRipple; + textBgOver: groupCallMenuBgRipple; + ripple: RippleAnimation(defaultRippleAnimation) { + color: mediaviewMenuBgOver; + } + } + defaultLabel: FlatLabel(defaultTableLabel) { + textFg: groupCallMembersFg; + palette: darkGiftPalette; + } + defaultValue: FlatLabel(defaultTableValue) { + textFg: groupCallMembersFg; + palette: darkGiftPalette; } } +darkGiftTableValueMultiline: FlatLabel(giveawayGiftCodeValueMultiline) { + textFg: groupCallMembersFg; + palette: darkGiftPalette; +} +darkGiftTableMessage: FlatLabel(giveawayGiftMessage) { + textFg: groupCallMembersFg; + palette: darkGiftPalette; +} diff --git a/Telegram/SourceFiles/media/stories/media_stories_controller.cpp b/Telegram/SourceFiles/media/stories/media_stories_controller.cpp index 444a2d15c..3f136872e 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_controller.cpp +++ b/Telegram/SourceFiles/media/stories/media_stories_controller.cpp @@ -41,6 +41,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "media/stories/media_stories_stealth.h" #include "media/stories/media_stories_view.h" #include "media/audio/media_audio.h" +#include "settings/settings_credits_graphics.h" #include "ui/boxes/confirm_box.h" #include "ui/boxes/report_box_graphics.h" #include "ui/text/text_utilities.h" @@ -1959,7 +1960,10 @@ ClickHandlerPtr MakeUrlAreaHandler( const auto slug = raw.mid( prefix.size() ).split('&').front().split('#').front(); - Core::ResolveAndShowUniqueGift(strong->uiShow(), slug); + Core::ResolveAndShowUniqueGift( + strong->uiShow(), + slug, + ::Settings::DarkCreditsEntryBoxStyle()); } else { HiddenUrlClickHandler::onClick(context); } diff --git a/Telegram/SourceFiles/media/stories/media_stories_share.cpp b/Telegram/SourceFiles/media/stories/media_stories_share.cpp index 46e0520d1..02b379ed0 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_share.cpp +++ b/Telegram/SourceFiles/media/stories/media_stories_share.cpp @@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/history_view_context_menu.h" // CopyStoryLink. #include "lang/lang_keys.h" #include "main/main_session.h" +#include "settings/settings_credits_graphics.h" #include "ui/boxes/confirm_box.h" #include "ui/text/text_utilities.h" #include "styles/style_calls.h" @@ -167,35 +168,15 @@ namespace Media::Stories { ++state->requests; } }; - - const auto viewerScheduleStyle = [&] { - auto date = Ui::ChooseDateTimeStyleArgs(); - date.labelStyle = &st::groupCallBoxLabel; - date.dateFieldStyle = &st::groupCallScheduleDateField; - date.timeFieldStyle = &st::groupCallScheduleTimeField; - date.separatorStyle = &st::callMuteButtonLabel; - date.atStyle = &st::callMuteButtonLabel; - date.calendarStyle = &st::groupCallCalendarColors; - - auto st = HistoryView::ScheduleBoxStyleArgs(); - st.topButtonStyle = &st::groupCallMenuToggle; - st.popupMenuStyle = &st::groupCallPopupMenu; - st.chooseDateTimeArgs = std::move(date); - return st; - }; - + const auto st = viewerStyle + ? ::Settings::DarkCreditsEntryBoxStyle() + : ::Settings::CreditsEntryBoxStyleOverrides(); return Box(ShareBox::Descriptor{ .session = session, .copyCallback = std::move(copyLinkCallback), .submitCallback = std::move(submitCallback), .filterCallback = std::move(filterCallback), - .stMultiSelect = viewerStyle ? &st::groupCallMultiSelect : nullptr, - .stComment = viewerStyle ? &st::groupCallShareBoxComment : nullptr, - .st = viewerStyle ? &st::groupCallShareBoxList : nullptr, - .stLabel = viewerStyle ? &st::groupCallField : nullptr, - .scheduleBoxStyle = (viewerStyle - ? viewerScheduleStyle() - : HistoryView::ScheduleBoxStyleArgs()), + .st = st.shareBox ? *st.shareBox : ShareBoxStyleOverrides(), .premiumRequiredError = SharePremiumRequiredError(), }); } diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index 9e51f202b..7d49abc92 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -86,12 +86,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/wrap/vertical_layout.h" #include "ui/ui_utility.h" #include "window/window_session_controller.h" +#include "styles/style_calls.h" #include "styles/style_channel_earn.h" #include "styles/style_chat.h" #include "styles/style_credits.h" #include "styles/style_giveaway.h" #include "styles/style_info.h" #include "styles/style_layers.h" +#include "styles/style_media_view.h" #include "styles/style_menu_icons.h" #include "styles/style_premium.h" #include "styles/style_settings.h" @@ -775,7 +777,7 @@ void BoostCreditsBox( Ui::AddSkip(content); } - AddCreditsBoostTable(controller->uiShow(), content, b); + AddCreditsBoostTable(controller->uiShow(), content, {}, b); Ui::AddSkip(content); box->addRow(object_ptr>( @@ -826,9 +828,10 @@ void ProcessReceivedSubscriptions( } void FillUniqueGiftMenu( - std::shared_ptr show, + std::shared_ptr show, not_null menu, - const Data::CreditsHistoryEntry &e) { + const Data::CreditsHistoryEntry &e, + CreditsEntryBoxStyleOverrides st) { Expects(e.uniqueGift != nullptr); const auto unique = e.uniqueGift; @@ -837,11 +840,15 @@ void FillUniqueGiftMenu( menu->addAction(tr::lng_context_copy_link(tr::now), [=] { TextUtilities::SetClipboardText({ url }); show->showToast(tr::lng_channel_public_link_copied(tr::now)); - }, &st::menuIconLink); + }, st.link ? st.link : &st::menuIconLink); + const auto shareBoxSt = st.shareBox; menu->addAction(tr::lng_chat_link_share(tr::now), [=] { - FastShareLink(show, url); - }, &st::menuIconShare); + FastShareLink( + show, + url, + shareBoxSt ? *shareBoxSt : ShareBoxStyleOverrides()); + }, st.share ? st.share : &st::menuIconShare); const auto messageId = MsgId(e.bareMsgId); const auto transfer = e.in @@ -852,15 +859,31 @@ void FillUniqueGiftMenu( if (const auto window = show->resolveWindow()) { ShowTransferGiftBox(window, unique, messageId); } - }, &st::menuIconReplace); + }, st.transfer ? st.transfer : &st::menuIconReplace); } } +CreditsEntryBoxStyleOverrides DarkCreditsEntryBoxStyle() { + return { + .box = &st::darkGiftCodeBox, + .menu = &st::mediaviewPopupMenu, + .table = &st::darkGiftTable, + .tableValueMultiline = &st::darkGiftTableValueMultiline, + .tableValueMessage = &st::darkGiftTableMessage, + .link = &st::darkGiftLink, + .share = &st::darkGiftShare, + .transfer = &st::darkGiftTransfer, + .shareBox = std::make_shared( + DarkShareBoxStyle()), + }; +} + void GenericCreditsEntryBox( not_null box, std::shared_ptr show, const Data::CreditsHistoryEntry &e, - const Data::SubscriptionEntry &s) { + const Data::SubscriptionEntry &s, + CreditsEntryBoxStyleOverrides st) { const auto session = &show->session(); const auto owner = &session->data(); const auto item = owner->message( @@ -889,7 +912,7 @@ void GenericCreditsEntryBox( const auto couldConvert = forConvert && timeExceeded; const auto nonConvertible = (gotStarGift && !e.starsConverted); - box->setStyle(st::giveawayGiftCodeBox); + box->setStyle(st.box ? *st.box : st::giveawayGiftCodeBox); box->setWidth(st::boxWideWidth); box->setNoContentMargin(true); @@ -925,8 +948,8 @@ void GenericCreditsEntryBox( AddSkip(content, st::defaultVerticalListSkip * 2); - AddUniqueCloseButton(box, [=](not_null menu) { - FillUniqueGiftMenu(show, menu, e); + AddUniqueCloseButton(box, st, [=](not_null menu) { + FillUniqueGiftMenu(show, menu, e, st); }); } else if (const auto callback = Ui::PaintPreviewCallback(session, e)) { const auto thumb = content->add(object_ptr>( @@ -1423,13 +1446,14 @@ void GenericCreditsEntryBox( AddStarGiftTable( show, content, + st, e, canToggle ? toggleVisibility : Fn(), canConvert ? convert : Fn(), canUpgrade ? upgrade : Fn()); } else { - AddCreditsHistoryEntryTable(show, content, e); - AddSubscriptionEntryTable(show, content, s); + AddCreditsHistoryEntryTable(show, content, st, e); + AddSubscriptionEntryTable(show, content, st, s); } Ui::AddSkip(content); @@ -1678,7 +1702,8 @@ void CreditsPrizeBox( void GlobalStarGiftBox( not_null box, std::shared_ptr show, - const Data::StarGift &data) { + const Data::StarGift &data, + CreditsEntryBoxStyleOverrides st) { const auto ownerId = data.unique ? data.unique->ownerId.value : 0; Settings::GenericCreditsEntryBox( box, @@ -1697,7 +1722,8 @@ void GlobalStarGiftBox( .in = (ownerId == show->session().userPeerId().value), .gift = true, }, - Data::SubscriptionEntry()); + Data::SubscriptionEntry(), + st); } void UserStarGiftBox( diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.h b/Telegram/SourceFiles/settings/settings_credits_graphics.h index b9db70447..849d439a9 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.h +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.h @@ -11,6 +11,7 @@ template class object_ptr; class PeerData; +struct ShareBoxStyleOverrides; namespace ChatHelpers { class Show; @@ -26,6 +27,10 @@ struct UserStarGift; struct StarGift; } // namespace Data +namespace HistoryView { +struct ScheduleBoxStyleArgs; +} // namespace HistoryView + namespace Main { class Session; class SessionShow; @@ -36,6 +41,10 @@ class SessionController; } // namespace Window namespace style { +struct Box; +struct Table; +struct FlatLabel; +struct PopupMenu; struct PeerListItem; } // namespace style @@ -81,11 +90,25 @@ void AddWithdrawalWidget( bool withdrawalEnabled, rpl::producer usdValue); +struct CreditsEntryBoxStyleOverrides { + const style::Box *box = nullptr; + const style::PopupMenu *menu = nullptr; + const style::Table *table = nullptr; + const style::FlatLabel *tableValueMultiline = nullptr; + const style::FlatLabel *tableValueMessage = nullptr; + const style::icon *link = nullptr; + const style::icon *share = nullptr; + const style::icon *transfer = nullptr; + std::shared_ptr shareBox; +}; +[[nodiscard]] CreditsEntryBoxStyleOverrides DarkCreditsEntryBoxStyle(); + void GenericCreditsEntryBox( not_null box, std::shared_ptr show, const Data::CreditsHistoryEntry &e, - const Data::SubscriptionEntry &s); + const Data::SubscriptionEntry &s, + CreditsEntryBoxStyleOverrides st = {}); void ReceiptCreditsBox( not_null box, not_null controller, @@ -110,7 +133,8 @@ void CreditsPrizeBox( void GlobalStarGiftBox( not_null box, std::shared_ptr show, - const Data::StarGift &data); + const Data::StarGift &data, + CreditsEntryBoxStyleOverrides st = {}); void UserStarGiftBox( not_null box, not_null controller, diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 517be4551..e052a8bff 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 517be45510ffde54ccb928788d700f93cfba3b65 +Subproject commit e052a8bff00c24d19c12e61b0adeb5fdf18770f0