mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Added star icons with gradient to main settings for premium buttons.
This commit is contained in:
parent
9b11b95c5b
commit
1a393ddebb
1 changed files with 86 additions and 10 deletions
|
@ -28,12 +28,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/basic_click_handlers.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/controls/userpic_button.h"
|
||||
#include "ui/effects/premium_graphics.h"
|
||||
#include "ui/effects/premium_top_bar.h" // Ui::Premium::ColorizedSvg.
|
||||
#include "ui/wrap/slide_wrap.h"
|
||||
#include "ui/widgets/menu/menu_add_action_callback.h"
|
||||
#include "ui/widgets/continuous_sliders.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/new_badges.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/vertical_list.h"
|
||||
#include "info/profile/info_profile_badge.h"
|
||||
#include "info/profile/info_profile_emoji_status_panel.h"
|
||||
|
@ -254,6 +257,77 @@ void Cover::refreshUsernameGeometry(int newWidth) {
|
|||
_username->moveToLeft(usernameLeft, usernameTop, newWidth);
|
||||
}
|
||||
|
||||
[[nodiscard]] not_null<Ui::SettingsButton*> AddPremiumStar(
|
||||
not_null<Ui::SettingsButton*> button,
|
||||
bool credits) {
|
||||
const auto stops = credits
|
||||
? Ui::Premium::CreditsIconGradientStops()
|
||||
: Ui::Premium::ButtonGradientStops();
|
||||
|
||||
const auto ministarsContainer = Ui::CreateChild<Ui::RpWidget>(button);
|
||||
const auto &buttonSt = button->st();
|
||||
const auto fullHeight = buttonSt.height
|
||||
+ rect::m::sum::v(buttonSt.padding);
|
||||
using MiniStars = Ui::Premium::ColoredMiniStars;
|
||||
const auto ministars = button->lifetime().make_state<MiniStars>(
|
||||
ministarsContainer,
|
||||
false);
|
||||
ministars->setColorOverride(stops);
|
||||
|
||||
ministarsContainer->paintRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
auto p = QPainter(ministarsContainer);
|
||||
{
|
||||
constexpr auto kScale = 0.35;
|
||||
const auto r = ministarsContainer->rect();
|
||||
p.translate(r.center());
|
||||
p.scale(kScale, kScale);
|
||||
p.translate(-r.center());
|
||||
}
|
||||
ministars->paint(p);
|
||||
}, ministarsContainer->lifetime());
|
||||
|
||||
const auto badge = Ui::CreateChild<Ui::RpWidget>(button.get());
|
||||
|
||||
auto star = [&] {
|
||||
const auto factor = style::DevicePixelRatio();
|
||||
const auto size = Size(st::settingsButtonNoIcon.style.font->ascent);
|
||||
auto image = QImage(
|
||||
size * factor,
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
image.setDevicePixelRatio(factor);
|
||||
image.fill(Qt::transparent);
|
||||
{
|
||||
auto p = QPainter(&image);
|
||||
auto star = QSvgRenderer(Ui::Premium::ColorizedSvg(stops));
|
||||
star.render(&p, Rect(size));
|
||||
}
|
||||
return image;
|
||||
}();
|
||||
badge->resize(star.size() / style::DevicePixelRatio());
|
||||
badge->paintRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
auto p = QPainter(badge);
|
||||
p.drawImage(0, 0, star);
|
||||
}, badge->lifetime());
|
||||
|
||||
button->sizeValue(
|
||||
) | rpl::start_with_next([=](const QSize &s) {
|
||||
badge->moveToLeft(
|
||||
button->st().iconLeft
|
||||
+ (st::menuIconShop.width() - badge->width()) / 2,
|
||||
(s.height() - badge->height()) / 2);
|
||||
ministarsContainer->moveToLeft(
|
||||
badge->x() - (fullHeight - badge->height()) / 2,
|
||||
0);
|
||||
}, badge->lifetime());
|
||||
|
||||
ministarsContainer->resize(fullHeight, fullHeight);
|
||||
ministars->setCenter(ministarsContainer->rect());
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void SetupPowerSavingButton(
|
||||
|
@ -406,20 +480,22 @@ void SetupPremium(
|
|||
Ui::AddDivider(container);
|
||||
Ui::AddSkip(container);
|
||||
|
||||
AddButtonWithIcon(
|
||||
container,
|
||||
tr::lng_premium_summary_title(),
|
||||
st::settingsButton,
|
||||
{ .icon = &st::menuIconPremium }
|
||||
AddPremiumStar(
|
||||
AddButtonWithIcon(
|
||||
container,
|
||||
tr::lng_premium_summary_title(),
|
||||
st::settingsButton),
|
||||
false
|
||||
)->addClickHandler([=] {
|
||||
controller->setPremiumRef("settings");
|
||||
showOther(PremiumId());
|
||||
});
|
||||
AddButtonWithIcon(
|
||||
container,
|
||||
tr::lng_credits_summary_title(),
|
||||
st::settingsButton,
|
||||
{ .icon = &st::menuIconPremium }
|
||||
AddPremiumStar(
|
||||
AddButtonWithIcon(
|
||||
container,
|
||||
tr::lng_credits_summary_title(),
|
||||
st::settingsButton),
|
||||
true
|
||||
)->addClickHandler([=] {
|
||||
controller->setPremiumRef("settings");
|
||||
showOther(CreditsId());
|
||||
|
|
Loading…
Add table
Reference in a new issue