mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added boost badge to buttons for prepaid giveaways.
This commit is contained in:
parent
97bd865916
commit
ca1a548fb8
4 changed files with 38 additions and 7 deletions
|
@ -312,7 +312,8 @@ void CreateGiveawayBox(
|
||||||
lt_duration,
|
lt_duration,
|
||||||
tr::lng_premium_gift_duration_months(
|
tr::lng_premium_gift_duration_months(
|
||||||
lt_count,
|
lt_count,
|
||||||
rpl::single(prepaid->months) | tr::to_count())))
|
rpl::single(prepaid->months) | tr::to_count())),
|
||||||
|
QImage())
|
||||||
)->setAttribute(Qt::WA_TransparentForMouseEvents);
|
)->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
}
|
}
|
||||||
if (!prepaid) {
|
if (!prepaid) {
|
||||||
|
|
|
@ -36,7 +36,8 @@ GiveawayTypeRow::GiveawayTypeRow(
|
||||||
: (type == Type::AllMembers)
|
: (type == Type::AllMembers)
|
||||||
? tr::lng_giveaway_users_all()
|
? tr::lng_giveaway_users_all()
|
||||||
: tr::lng_giveaway_users_new(),
|
: tr::lng_giveaway_users_new(),
|
||||||
std::move(subtitle)) {
|
std::move(subtitle),
|
||||||
|
QImage()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
GiveawayTypeRow::GiveawayTypeRow(
|
GiveawayTypeRow::GiveawayTypeRow(
|
||||||
|
@ -44,7 +45,8 @@ GiveawayTypeRow::GiveawayTypeRow(
|
||||||
Type type,
|
Type type,
|
||||||
int colorIndex,
|
int colorIndex,
|
||||||
rpl::producer<QString> title,
|
rpl::producer<QString> title,
|
||||||
rpl::producer<QString> subtitle)
|
rpl::producer<QString> subtitle,
|
||||||
|
QImage badge)
|
||||||
: RippleButton(parent, st::defaultRippleAnimation)
|
: RippleButton(parent, st::defaultRippleAnimation)
|
||||||
, _type(type)
|
, _type(type)
|
||||||
, _st((_type == Type::SpecificUsers || _type == Type::Random)
|
, _st((_type == Type::SpecificUsers || _type == Type::Random)
|
||||||
|
@ -54,7 +56,8 @@ GiveawayTypeRow::GiveawayTypeRow(
|
||||||
: st::giveawayGiftCodeMembersPeerList.item)
|
: st::giveawayGiftCodeMembersPeerList.item)
|
||||||
, _userpic(
|
, _userpic(
|
||||||
Ui::EmptyUserpic::UserpicColor(Ui::EmptyUserpic::ColorIndex(colorIndex)),
|
Ui::EmptyUserpic::UserpicColor(Ui::EmptyUserpic::ColorIndex(colorIndex)),
|
||||||
QString()) {
|
QString())
|
||||||
|
, _badge(std::move(badge)) {
|
||||||
std::move(
|
std::move(
|
||||||
subtitle
|
subtitle
|
||||||
) | rpl::start_with_next([=] (const QString &s) {
|
) | rpl::start_with_next([=] (const QString &s) {
|
||||||
|
@ -111,8 +114,19 @@ void GiveawayTypeRow::paintEvent(QPaintEvent *e) {
|
||||||
const auto namey = _st.namePosition.y();
|
const auto namey = _st.namePosition.y();
|
||||||
const auto namew = outerWidth - namex - skipRight;
|
const auto namew = outerWidth - namex - skipRight;
|
||||||
|
|
||||||
|
const auto badgew = _badge.width() / style::DevicePixelRatio();
|
||||||
|
|
||||||
p.setPen(_st.nameFg);
|
p.setPen(_st.nameFg);
|
||||||
_name.drawLeftElided(p, namex, namey, namew, width());
|
_name.drawLeftElided(p, namex, namey, namew - badgew, width());
|
||||||
|
|
||||||
|
if (!_badge.isNull()) {
|
||||||
|
p.drawImage(
|
||||||
|
std::min(
|
||||||
|
namex + _name.maxWidth() + st::boostsListBadgePadding.left(),
|
||||||
|
outerWidth - badgew - skipRight),
|
||||||
|
namey + st::boostsListMiniIconSkip,
|
||||||
|
_badge);
|
||||||
|
}
|
||||||
|
|
||||||
const auto statusx = _st.statusPosition.x();
|
const auto statusx = _st.statusPosition.x();
|
||||||
const auto statusy = _st.statusPosition.y();
|
const auto statusy = _st.statusPosition.y();
|
||||||
|
|
|
@ -39,7 +39,8 @@ public:
|
||||||
Type type,
|
Type type,
|
||||||
int colorIndex,
|
int colorIndex,
|
||||||
rpl::producer<QString> title,
|
rpl::producer<QString> title,
|
||||||
rpl::producer<QString> subtitle);
|
rpl::producer<QString> subtitle,
|
||||||
|
QImage badge);
|
||||||
|
|
||||||
void addRadio(std::shared_ptr<Ui::RadioenumGroup<Type>> typeGroup);
|
void addRadio(std::shared_ptr<Ui::RadioenumGroup<Type>> typeGroup);
|
||||||
|
|
||||||
|
@ -56,6 +57,8 @@ private:
|
||||||
Ui::Text::String _status;
|
Ui::Text::String _status;
|
||||||
Ui::Text::String _name;
|
Ui::Text::String _name;
|
||||||
|
|
||||||
|
QImage _badge;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Giveaway
|
} // namespace Giveaway
|
||||||
|
|
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "info/boosts/create_giveaway_box.h"
|
#include "info/boosts/create_giveaway_box.h"
|
||||||
|
#include "info/boosts/giveaway/boost_badge.h"
|
||||||
#include "info/boosts/giveaway/giveaway_type_row.h"
|
#include "info/boosts/giveaway/giveaway_type_row.h"
|
||||||
#include "info/boosts/info_boosts_widget.h"
|
#include "info/boosts/info_boosts_widget.h"
|
||||||
#include "info/info_controller.h"
|
#include "info/info_controller.h"
|
||||||
|
@ -326,6 +327,8 @@ void InnerWidget::fill() {
|
||||||
::Settings::AddSkip(inner);
|
::Settings::AddSkip(inner);
|
||||||
|
|
||||||
if (!status.prepaidGiveaway.empty()) {
|
if (!status.prepaidGiveaway.empty()) {
|
||||||
|
const auto multiplier = Api::PremiumGiftCodeOptions(_peer)
|
||||||
|
.giveawayBoostsPerPremium();
|
||||||
::Settings::AddSkip(inner);
|
::Settings::AddSkip(inner);
|
||||||
AddHeader(inner, tr::lng_boosts_prepaid_giveaway_title);
|
AddHeader(inner, tr::lng_boosts_prepaid_giveaway_title);
|
||||||
::Settings::AddSkip(inner);
|
::Settings::AddSkip(inner);
|
||||||
|
@ -340,7 +343,17 @@ void InnerWidget::fill() {
|
||||||
rpl::single(g.quantity) | tr::to_count()),
|
rpl::single(g.quantity) | tr::to_count()),
|
||||||
tr::lng_boosts_prepaid_giveaway_moths(
|
tr::lng_boosts_prepaid_giveaway_moths(
|
||||||
lt_count,
|
lt_count,
|
||||||
rpl::single(g.months) | tr::to_count())));
|
rpl::single(g.months) | tr::to_count()),
|
||||||
|
Info::Statistics::CreateBadge(
|
||||||
|
st::statisticsDetailsBottomCaptionStyle,
|
||||||
|
QString::number(g.quantity * multiplier),
|
||||||
|
st::boostsListBadgeHeight,
|
||||||
|
st::boostsListBadgeTextPadding,
|
||||||
|
st::premiumButtonBg2,
|
||||||
|
st::premiumButtonFg,
|
||||||
|
1.,
|
||||||
|
st::boostsListMiniIconPadding,
|
||||||
|
st::boostsListMiniIcon)));
|
||||||
button->setClickedCallback([=] {
|
button->setClickedCallback([=] {
|
||||||
_controller->uiShow()->showBox(Box(
|
_controller->uiShow()->showBox(Box(
|
||||||
CreateGiveawayBox,
|
CreateGiveawayBox,
|
||||||
|
|
Loading…
Add table
Reference in a new issue