From 2dfa58aae2d0e73fbbbee727b3bb31d96025e2a9 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 20 Nov 2024 07:44:36 +0300 Subject: [PATCH] Moved out some constant color indices to separated style file. --- .../boosts/create_giveaway_box.cpp | 6 +++--- .../boosts/giveaway/giveaway_type_row.cpp | 6 ++---- .../boosts/info_boosts_inner_widget.cpp | 4 ++-- .../info_statistics_list_controllers.cpp | 10 ++++------ Telegram/SourceFiles/ui/color_indices.style | 16 ++++++++++++++++ Telegram/cmake/td_ui.cmake | 1 + 6 files changed, 28 insertions(+), 15 deletions(-) create mode 100644 Telegram/SourceFiles/ui/color_indices.style diff --git a/Telegram/SourceFiles/info/channel_statistics/boosts/create_giveaway_box.cpp b/Telegram/SourceFiles/info/channel_statistics/boosts/create_giveaway_box.cpp index b78da5c17..1fbf97797 100644 --- a/Telegram/SourceFiles/info/channel_statistics/boosts/create_giveaway_box.cpp +++ b/Telegram/SourceFiles/info/channel_statistics/boosts/create_giveaway_box.cpp @@ -45,6 +45,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/labels.h" #include "ui/wrap/slide_wrap.h" #include "ui/ui_utility.h" +#include "styles/style_color_indices.h" #include "styles/style_credits.h" #include "styles/style_giveaway.h" #include "styles/style_info.h" @@ -59,7 +60,6 @@ namespace { constexpr auto kDoneTooltipDuration = 5 * crl::time(1000); constexpr auto kAdditionalPrizeLengthMax = 128; -constexpr auto kColorIndexCredits = int(1); [[nodiscard]] QDateTime ThreeDaysAfterToday() { auto dateNow = QDateTime::currentDateTime(); @@ -370,7 +370,7 @@ void CreateGiveawayBox( prepaid->credits ? GiveawayType::PrepaidCredits : GiveawayType::Prepaid, - prepaid->credits ? kColorIndexCredits : prepaid->id, + prepaid->credits ? st::colorIndexOrange : prepaid->id, tr::lng_boosts_prepaid_giveaway_single(), prepaid->credits ? tr::lng_boosts_prepaid_giveaway_credits_status( @@ -508,7 +508,7 @@ void CreateGiveawayBox( object_ptr( box, GiveawayType::Credits, - kColorIndexCredits, + st::colorIndexOrange, tr::lng_credits_summary_title(), tr::lng_giveaway_create_subtitle(), std::move(badge))); diff --git a/Telegram/SourceFiles/info/channel_statistics/boosts/giveaway/giveaway_type_row.cpp b/Telegram/SourceFiles/info/channel_statistics/boosts/giveaway/giveaway_type_row.cpp index b97184dba..60c1814ab 100644 --- a/Telegram/SourceFiles/info/channel_statistics/boosts/giveaway/giveaway_type_row.cpp +++ b/Telegram/SourceFiles/info/channel_statistics/boosts/giveaway/giveaway_type_row.cpp @@ -16,14 +16,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/checkbox.h" #include "styles/style_boxes.h" #include "styles/style_chat.h" +#include "styles/style_color_indices.h" #include "styles/style_giveaway.h" #include "styles/style_statistics.h" namespace Giveaway { -constexpr auto kColorIndexSpecific = int(4); -constexpr auto kColorIndexRandom = int(2); - GiveawayTypeRow::GiveawayTypeRow( not_null parent, Type type, @@ -32,7 +30,7 @@ GiveawayTypeRow::GiveawayTypeRow( : GiveawayTypeRow( parent, type, - (type == Type::SpecificUsers) ? kColorIndexSpecific : kColorIndexRandom, + (type == Type::SpecificUsers) ? st::colorIndexBlue : st::colorIndexGreen, (type == Type::SpecificUsers) ? tr::lng_giveaway_award_option() : (type == Type::Random) diff --git a/Telegram/SourceFiles/info/channel_statistics/boosts/info_boosts_inner_widget.cpp b/Telegram/SourceFiles/info/channel_statistics/boosts/info_boosts_inner_widget.cpp index e2436585c..5b6648220 100644 --- a/Telegram/SourceFiles/info/channel_statistics/boosts/info_boosts_inner_widget.cpp +++ b/Telegram/SourceFiles/info/channel_statistics/boosts/info_boosts_inner_widget.cpp @@ -39,6 +39,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/slider_natural_width.h" #include "ui/wrap/slide_wrap.h" #include "ui/ui_utility.h" +#include "styles/style_color_indices.h" #include "styles/style_dialogs.h" // dialogsSearchTabs #include "styles/style_giveaway.h" #include "styles/style_info.h" @@ -339,7 +340,6 @@ void InnerWidget::fill() { Ui::AddSkip(inner); if (!status.prepaidGiveaway.empty()) { - constexpr auto kColorIndexCredits = int(1); const auto multiplier = Api::PremiumGiftCodeOptions(_peer) .giveawayBoostsPerPremium(); Ui::AddSkip(inner); @@ -352,7 +352,7 @@ void InnerWidget::fill() { g.credits ? GiveawayTypeRow::Type::PrepaidCredits : GiveawayTypeRow::Type::Prepaid, - g.credits ? kColorIndexCredits : g.id, + g.credits ? st::colorIndexOrange : g.id, g.credits ? tr::lng_boosts_prepaid_giveaway_single() : tr::lng_boosts_prepaid_giveaway_quantity( diff --git a/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp b/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp index abbd690c7..1a21f3fd5 100644 --- a/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp +++ b/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp @@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/wrap/slide_wrap.h" #include "ui/wrap/vertical_layout.h" #include "styles/style_boxes.h" +#include "styles/style_color_indices.h" #include "styles/style_credits.h" #include "styles/style_dialogs.h" // dialogsStoriesFull. #include "styles/style_layers.h" // boxRowPadding. @@ -47,9 +48,6 @@ namespace Info::Statistics { namespace { using BoostCallback = Fn; -constexpr auto kColorIndexCredits = int(1); -constexpr auto kColorIndexUnclaimed = int(3); -constexpr auto kColorIndexPending = int(4); [[nodiscard]] PeerListRowId UniqueRowIdFromEntry( const Data::CreditsHistoryEntry &entry) { @@ -475,10 +473,10 @@ BoostRow::BoostRow(const Data::Boost &boost) , _boost(boost) , _userpic( Ui::EmptyUserpic::UserpicColor(boost.credits - ? kColorIndexCredits + ? st::colorIndexOrange : boost.isUnclaimed - ? kColorIndexUnclaimed - : kColorIndexPending), + ? st::colorIndexSea + : st::colorIndexBlue), QString()) { init(); } diff --git a/Telegram/SourceFiles/ui/color_indices.style b/Telegram/SourceFiles/ui/color_indices.style new file mode 100644 index 000000000..3acd347ab --- /dev/null +++ b/Telegram/SourceFiles/ui/color_indices.style @@ -0,0 +1,16 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ + +colorIndexRed: 0; +colorIndexOrange: 1; +colorIndexGreen: 2; +colorIndexSea: 3; +colorIndexBlue: 4; +colorIndexPurple: 5; +colorIndexPink: 6; +colorIndexYellow: 7; diff --git a/Telegram/cmake/td_ui.cmake b/Telegram/cmake/td_ui.cmake index 716d4d6b8..54d8bc92b 100644 --- a/Telegram/cmake/td_ui.cmake +++ b/Telegram/cmake/td_ui.cmake @@ -18,6 +18,7 @@ set(style_files ui/chat/chat.style ui/effects/credits.style ui/effects/premium.style + ui/color_indices.style boxes/boxes.style dialogs/dialogs.style chat_helpers/chat_helpers.style