mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-20 15:17:41 +00:00
Support non-premium-supported limit boxes.
This commit is contained in:
parent
1572af3a71
commit
368a1e4231
@ -411,10 +411,10 @@ void SimpleLimitBox(
|
|||||||
rpl::producer<TextWithEntities> text,
|
rpl::producer<TextWithEntities> text,
|
||||||
const QString &refAddition,
|
const QString &refAddition,
|
||||||
const InfographicDescriptor &descriptor,
|
const InfographicDescriptor &descriptor,
|
||||||
bool premium,
|
|
||||||
bool fixed = false) {
|
bool fixed = false) {
|
||||||
box->setWidth(st::boxWideWidth);
|
box->setWidth(st::boxWideWidth);
|
||||||
|
|
||||||
|
const auto premiumPossible = session->premiumPossible();
|
||||||
const auto top = fixed
|
const auto top = fixed
|
||||||
? box->setPinnedToTopContent(object_ptr<Ui::VerticalLayout>(box))
|
? box->setPinnedToTopContent(object_ptr<Ui::VerticalLayout>(box))
|
||||||
: box->verticalLayout();
|
: box->verticalLayout();
|
||||||
@ -426,11 +426,17 @@ void SimpleLimitBox(
|
|||||||
descriptor.defaultLimit,
|
descriptor.defaultLimit,
|
||||||
descriptor.current,
|
descriptor.current,
|
||||||
descriptor.premiumLimit,
|
descriptor.premiumLimit,
|
||||||
|
premiumPossible,
|
||||||
descriptor.phrase,
|
descriptor.phrase,
|
||||||
descriptor.icon);
|
descriptor.icon);
|
||||||
Settings::AddSkip(top, st::premiumLineTextSkip);
|
Settings::AddSkip(top, st::premiumLineTextSkip);
|
||||||
Ui::Premium::AddLimitRow(top, descriptor.premiumLimit, descriptor.phrase);
|
if (premiumPossible) {
|
||||||
Settings::AddSkip(top, st::premiumInfographicPadding.bottom());
|
Ui::Premium::AddLimitRow(
|
||||||
|
top,
|
||||||
|
descriptor.premiumLimit,
|
||||||
|
descriptor.phrase);
|
||||||
|
Settings::AddSkip(top, st::premiumInfographicPadding.bottom());
|
||||||
|
}
|
||||||
|
|
||||||
box->setTitle(std::move(title));
|
box->setTitle(std::move(title));
|
||||||
|
|
||||||
@ -443,7 +449,7 @@ void SimpleLimitBox(
|
|||||||
st::aboutRevokePublicLabel),
|
st::aboutRevokePublicLabel),
|
||||||
padding);
|
padding);
|
||||||
|
|
||||||
if (premium) {
|
if (session->premium() || !premiumPossible) {
|
||||||
box->addButton(tr::lng_box_ok(), [=] {
|
box->addButton(tr::lng_box_ok(), [=] {
|
||||||
box->closeBox();
|
box->closeBox();
|
||||||
});
|
});
|
||||||
@ -451,11 +457,11 @@ void SimpleLimitBox(
|
|||||||
box->addButton(tr::lng_limits_increase(), [=] {
|
box->addButton(tr::lng_limits_increase(), [=] {
|
||||||
Settings::ShowPremium(session, LimitsPremiumRef(refAddition));
|
Settings::ShowPremium(session, LimitsPremiumRef(refAddition));
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
box->addButton(tr::lng_cancel(), [=] {
|
box->addButton(tr::lng_cancel(), [=] {
|
||||||
box->closeBox();
|
box->closeBox();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (fixed) {
|
if (fixed) {
|
||||||
Settings::AddSkip(top, st::settingsButton.padding.bottom());
|
Settings::AddSkip(top, st::settingsButton.padding.bottom());
|
||||||
@ -477,6 +483,7 @@ void SimplePinsLimitBox(
|
|||||||
int limitPremium,
|
int limitPremium,
|
||||||
int currentCount) {
|
int currentCount) {
|
||||||
const auto premium = session->premium();
|
const auto premium = session->premium();
|
||||||
|
const auto premiumPossible = session->premiumPossible();
|
||||||
|
|
||||||
const auto defaultLimit = Limit(session, keyDefault, limitDefault);
|
const auto defaultLimit = Limit(session, keyDefault, limitDefault);
|
||||||
const auto premiumLimit = Limit(session, keyPremium, limitPremium);
|
const auto premiumLimit = Limit(session, keyPremium, limitPremium);
|
||||||
@ -490,7 +497,7 @@ void SimplePinsLimitBox(
|
|||||||
lt_count,
|
lt_count,
|
||||||
rpl::single(premium ? premiumLimit : defaultLimit),
|
rpl::single(premium ? premiumLimit : defaultLimit),
|
||||||
Ui::Text::RichLangValue),
|
Ui::Text::RichLangValue),
|
||||||
(premium
|
((premium || !premiumPossible)
|
||||||
? rpl::single(TextWithEntities())
|
? rpl::single(TextWithEntities())
|
||||||
: tr::lng_filter_pin_limit2(
|
: tr::lng_filter_pin_limit2(
|
||||||
lt_count,
|
lt_count,
|
||||||
@ -507,8 +514,7 @@ void SimplePinsLimitBox(
|
|||||||
tr::lng_filter_pin_limit_title(),
|
tr::lng_filter_pin_limit_title(),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
refAddition,
|
refAddition,
|
||||||
{ defaultLimit, current, premiumLimit, &st::premiumIconPins },
|
{ defaultLimit, current, premiumLimit, &st::premiumIconPins });
|
||||||
premium);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@ -517,6 +523,7 @@ void ChannelsLimitBox(
|
|||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Main::Session*> session) {
|
not_null<Main::Session*> session) {
|
||||||
const auto premium = session->premium();
|
const auto premium = session->premium();
|
||||||
|
const auto premiumPossible = session->premiumPossible();
|
||||||
|
|
||||||
const auto defaultLimit = Limit(session, "channels_limit_default", 500);
|
const auto defaultLimit = Limit(session, "channels_limit_default", 500);
|
||||||
const auto premiumLimit = Limit(session, "channels_limit_premium", 1000);
|
const auto premiumLimit = Limit(session, "channels_limit_premium", 1000);
|
||||||
@ -527,7 +534,7 @@ void ChannelsLimitBox(
|
|||||||
lt_count,
|
lt_count,
|
||||||
rpl::single(current),
|
rpl::single(current),
|
||||||
Ui::Text::RichLangValue),
|
Ui::Text::RichLangValue),
|
||||||
(premium
|
((premium || !premiumPossible)
|
||||||
? tr::lng_channels_limit2_final(Ui::Text::RichLangValue)
|
? tr::lng_channels_limit2_final(Ui::Text::RichLangValue)
|
||||||
: tr::lng_channels_limit2(
|
: tr::lng_channels_limit2(
|
||||||
lt_count,
|
lt_count,
|
||||||
@ -544,7 +551,6 @@ void ChannelsLimitBox(
|
|||||||
std::move(text),
|
std::move(text),
|
||||||
"channels",
|
"channels",
|
||||||
{ defaultLimit, current, premiumLimit, &st::premiumIconGroups },
|
{ defaultLimit, current, premiumLimit, &st::premiumIconGroups },
|
||||||
premium,
|
|
||||||
true);
|
true);
|
||||||
|
|
||||||
AddSubsectionTitle(box->verticalLayout(), tr::lng_channels_leave_title());
|
AddSubsectionTitle(box->verticalLayout(), tr::lng_channels_leave_title());
|
||||||
@ -607,6 +613,7 @@ void PublicLinksLimitBox(
|
|||||||
Fn<void()> retry) {
|
Fn<void()> retry) {
|
||||||
const auto session = &navigation->session();
|
const auto session = &navigation->session();
|
||||||
const auto premium = session->premium();
|
const auto premium = session->premium();
|
||||||
|
const auto premiumPossible = session->premiumPossible();
|
||||||
|
|
||||||
const auto defaultLimit = Limit(
|
const auto defaultLimit = Limit(
|
||||||
session,
|
session,
|
||||||
@ -623,7 +630,7 @@ void PublicLinksLimitBox(
|
|||||||
lt_count,
|
lt_count,
|
||||||
rpl::single(current),
|
rpl::single(current),
|
||||||
Ui::Text::RichLangValue),
|
Ui::Text::RichLangValue),
|
||||||
(premium
|
((premium || !premiumPossible)
|
||||||
? tr::lng_links_limit2_final(Ui::Text::RichLangValue)
|
? tr::lng_links_limit2_final(Ui::Text::RichLangValue)
|
||||||
: tr::lng_links_limit2(
|
: tr::lng_links_limit2(
|
||||||
lt_count,
|
lt_count,
|
||||||
@ -640,7 +647,6 @@ void PublicLinksLimitBox(
|
|||||||
std::move(text),
|
std::move(text),
|
||||||
"channels_public",
|
"channels_public",
|
||||||
{ defaultLimit, current, premiumLimit, &st::premiumIconLinks },
|
{ defaultLimit, current, premiumLimit, &st::premiumIconLinks },
|
||||||
premium,
|
|
||||||
true);
|
true);
|
||||||
|
|
||||||
AddSubsectionTitle(box->verticalLayout(), tr::lng_links_revoke_title());
|
AddSubsectionTitle(box->verticalLayout(), tr::lng_links_revoke_title());
|
||||||
@ -673,6 +679,7 @@ void FilterChatsLimitBox(
|
|||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
int currentCount) {
|
int currentCount) {
|
||||||
const auto premium = session->premium();
|
const auto premium = session->premium();
|
||||||
|
const auto premiumPossible = session->premiumPossible();
|
||||||
|
|
||||||
const auto defaultLimit = Limit(
|
const auto defaultLimit = Limit(
|
||||||
session,
|
session,
|
||||||
@ -692,7 +699,7 @@ void FilterChatsLimitBox(
|
|||||||
lt_count,
|
lt_count,
|
||||||
rpl::single(premium ? premiumLimit : defaultLimit),
|
rpl::single(premium ? premiumLimit : defaultLimit),
|
||||||
Ui::Text::RichLangValue),
|
Ui::Text::RichLangValue),
|
||||||
(premium
|
((premium || !premiumPossible)
|
||||||
? rpl::single(TextWithEntities())
|
? rpl::single(TextWithEntities())
|
||||||
: tr::lng_filter_chats_limit2(
|
: tr::lng_filter_chats_limit2(
|
||||||
lt_count,
|
lt_count,
|
||||||
@ -710,14 +717,14 @@ void FilterChatsLimitBox(
|
|||||||
tr::lng_filter_chats_limit_title(),
|
tr::lng_filter_chats_limit_title(),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
"dialog_filters_chats",
|
"dialog_filters_chats",
|
||||||
{ defaultLimit, current, premiumLimit, &st::premiumIconChats },
|
{ defaultLimit, current, premiumLimit, &st::premiumIconChats });
|
||||||
premium);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FiltersLimitBox(
|
void FiltersLimitBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Main::Session*> session) {
|
not_null<Main::Session*> session) {
|
||||||
const auto premium = session->premium();
|
const auto premium = session->premium();
|
||||||
|
const auto premiumPossible = session->premiumPossible();
|
||||||
|
|
||||||
const auto defaultLimit = Limit(
|
const auto defaultLimit = Limit(
|
||||||
session,
|
session,
|
||||||
@ -736,7 +743,7 @@ void FiltersLimitBox(
|
|||||||
lt_count,
|
lt_count,
|
||||||
rpl::single(premium ? premiumLimit : defaultLimit),
|
rpl::single(premium ? premiumLimit : defaultLimit),
|
||||||
Ui::Text::RichLangValue),
|
Ui::Text::RichLangValue),
|
||||||
(premium
|
((premium || !premiumPossible)
|
||||||
? rpl::single(TextWithEntities())
|
? rpl::single(TextWithEntities())
|
||||||
: tr::lng_filters_limit2(
|
: tr::lng_filters_limit2(
|
||||||
lt_count,
|
lt_count,
|
||||||
@ -753,8 +760,7 @@ void FiltersLimitBox(
|
|||||||
tr::lng_filters_limit_title(),
|
tr::lng_filters_limit_title(),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
"dialog_filters",
|
"dialog_filters",
|
||||||
{ defaultLimit, current, premiumLimit, &st::premiumIconFolders },
|
{ defaultLimit, current, premiumLimit, &st::premiumIconFolders });
|
||||||
premium);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilterPinsLimitBox(
|
void FilterPinsLimitBox(
|
||||||
@ -805,6 +811,7 @@ void CaptionLimitBox(
|
|||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
int remove) {
|
int remove) {
|
||||||
const auto premium = session->premium();
|
const auto premium = session->premium();
|
||||||
|
const auto premiumPossible = session->premiumPossible();
|
||||||
|
|
||||||
const auto defaultLimit = Limit(
|
const auto defaultLimit = Limit(
|
||||||
session,
|
session,
|
||||||
@ -825,12 +832,16 @@ void CaptionLimitBox(
|
|||||||
lt_count,
|
lt_count,
|
||||||
rpl::single(currentLimit),
|
rpl::single(currentLimit),
|
||||||
Ui::Text::RichLangValue),
|
Ui::Text::RichLangValue),
|
||||||
tr::lng_caption_limit2(
|
(!premiumPossible
|
||||||
|
? rpl::single(TextWithEntities())
|
||||||
|
: tr::lng_caption_limit2(
|
||||||
lt_count,
|
lt_count,
|
||||||
rpl::single(premiumLimit),
|
rpl::single(premiumLimit),
|
||||||
Ui::Text::RichLangValue)
|
Ui::Text::RichLangValue))
|
||||||
) | rpl::map([](TextWithEntities &&a, TextWithEntities &&b) {
|
) | rpl::map([](TextWithEntities &&a, TextWithEntities &&b) {
|
||||||
return a.append(QChar(' ')).append(std::move(b));
|
return b.text.isEmpty()
|
||||||
|
? a
|
||||||
|
: a.append(QChar(' ')).append(std::move(b));
|
||||||
});
|
});
|
||||||
|
|
||||||
SimpleLimitBox(
|
SimpleLimitBox(
|
||||||
@ -839,8 +850,7 @@ void CaptionLimitBox(
|
|||||||
tr::lng_caption_limit_title(),
|
tr::lng_caption_limit_title(),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
"caption_length",
|
"caption_length",
|
||||||
{ defaultLimit, current, premiumLimit, &st::premiumIconChats },
|
{ defaultLimit, current, premiumLimit, &st::premiumIconChats });
|
||||||
premium);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CaptionLimitReachedBox(
|
void CaptionLimitReachedBox(
|
||||||
@ -867,6 +877,7 @@ void FileSizeLimitBox(
|
|||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
uint64 fileSizeBytes) {
|
uint64 fileSizeBytes) {
|
||||||
const auto premium = session->premium();
|
const auto premium = session->premium();
|
||||||
|
const auto premiumPossible = session->premiumPossible();
|
||||||
|
|
||||||
const auto defaultLimit = Limit(
|
const auto defaultLimit = Limit(
|
||||||
session,
|
session,
|
||||||
@ -894,10 +905,12 @@ void FileSizeLimitBox(
|
|||||||
lt_size,
|
lt_size,
|
||||||
rpl::single(Ui::Text::Bold(gb(defaultGb))),
|
rpl::single(Ui::Text::Bold(gb(defaultGb))),
|
||||||
Ui::Text::RichLangValue),
|
Ui::Text::RichLangValue),
|
||||||
tr::lng_file_size_limit2(
|
(!premiumPossible
|
||||||
lt_size,
|
? rpl::single(TextWithEntities())
|
||||||
rpl::single(Ui::Text::Bold(gb(premiumGb))),
|
: tr::lng_file_size_limit2(
|
||||||
Ui::Text::RichLangValue)
|
lt_size,
|
||||||
|
rpl::single(Ui::Text::Bold(gb(premiumGb))),
|
||||||
|
Ui::Text::RichLangValue))
|
||||||
) | rpl::map([](TextWithEntities &&a, TextWithEntities &&b) {
|
) | rpl::map([](TextWithEntities &&a, TextWithEntities &&b) {
|
||||||
return a.append(QChar(' ')).append(std::move(b));
|
return a.append(QChar(' ')).append(std::move(b));
|
||||||
});
|
});
|
||||||
@ -914,8 +927,7 @@ void FileSizeLimitBox(
|
|||||||
premiumGb,
|
premiumGb,
|
||||||
&st::premiumIconFiles,
|
&st::premiumIconFiles,
|
||||||
tr::lng_file_size_limit
|
tr::lng_file_size_limit
|
||||||
},
|
});
|
||||||
premium);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountsLimitBox(
|
void AccountsLimitBox(
|
||||||
@ -925,6 +937,7 @@ void AccountsLimitBox(
|
|||||||
const auto premiumLimit = Main::Domain::kPremiumMaxAccounts;
|
const auto premiumLimit = Main::Domain::kPremiumMaxAccounts;
|
||||||
|
|
||||||
const auto accounts = session->domain().orderedAccounts();
|
const auto accounts = session->domain().orderedAccounts();
|
||||||
|
const auto premiumPossible = session->premiumPossible();
|
||||||
const auto current = int(accounts.size());
|
const auto current = int(accounts.size());
|
||||||
|
|
||||||
auto text = rpl::combine(
|
auto text = rpl::combine(
|
||||||
@ -953,6 +966,7 @@ void AccountsLimitBox(
|
|||||||
0,
|
0,
|
||||||
current,
|
current,
|
||||||
(current > defaultLimit) ? current : (defaultLimit * 2),
|
(current > defaultLimit) ? current : (defaultLimit * 2),
|
||||||
|
premiumPossible,
|
||||||
std::nullopt,
|
std::nullopt,
|
||||||
&st::premiumIconAccounts);
|
&st::premiumIconAccounts);
|
||||||
Settings::AddSkip(top, st::premiumLineTextSkip);
|
Settings::AddSkip(top, st::premiumLineTextSkip);
|
||||||
|
@ -429,6 +429,10 @@ void ReactionsSettingsBox(
|
|||||||
st::settingsButton);
|
st::settingsButton);
|
||||||
|
|
||||||
const auto premium = r.premium;
|
const auto premium = r.premium;
|
||||||
|
if (premium && !controller->session().premiumPossible()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const auto iconSize = st::settingsReactionSize;
|
const auto iconSize = st::settingsReactionSize;
|
||||||
AddReactionLottieIcon(
|
AddReactionLottieIcon(
|
||||||
button,
|
button,
|
||||||
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
#include "main/main_domain.h"
|
#include "main/main_domain.h"
|
||||||
#include "main/main_session_settings.h"
|
#include "main/main_session_settings.h"
|
||||||
|
#include "main/main_app_config.h"
|
||||||
#include "main/session/send_as_peers.h"
|
#include "main/session/send_as_peers.h"
|
||||||
#include "mtproto/mtproto_config.h"
|
#include "mtproto/mtproto_config.h"
|
||||||
#include "chat_helpers/stickers_emoji_pack.h"
|
#include "chat_helpers/stickers_emoji_pack.h"
|
||||||
@ -222,6 +223,12 @@ bool Session::premium() const {
|
|||||||
return _user->isPremium();
|
return _user->isPremium();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Session::premiumPossible() const {
|
||||||
|
return !_account->appConfig().get<bool>(
|
||||||
|
"premium_purchase_blocked",
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
|
||||||
uint64 Session::uniqueId() const {
|
uint64 Session::uniqueId() const {
|
||||||
// See also Account::willHaveSessionUniqueId.
|
// See also Account::willHaveSessionUniqueId.
|
||||||
return userId().bare
|
return userId().bare
|
||||||
|
@ -81,6 +81,7 @@ public:
|
|||||||
[[nodiscard]] Storage::Domain &domainLocal() const;
|
[[nodiscard]] Storage::Domain &domainLocal() const;
|
||||||
|
|
||||||
[[nodiscard]] bool premium() const;
|
[[nodiscard]] bool premium() const;
|
||||||
|
[[nodiscard]] bool premiumPossible() const;
|
||||||
[[nodiscard]] uint64 uniqueId() const; // userId() with TestDC shift.
|
[[nodiscard]] uint64 uniqueId() const; // userId() with TestDC shift.
|
||||||
[[nodiscard]] UserId userId() const;
|
[[nodiscard]] UserId userId() const;
|
||||||
[[nodiscard]] PeerId userPeerId() const;
|
[[nodiscard]] PeerId userPeerId() const;
|
||||||
|
@ -72,7 +72,8 @@ public:
|
|||||||
Bubble(
|
Bubble(
|
||||||
Fn<void()> updateCallback,
|
Fn<void()> updateCallback,
|
||||||
TextFactory textFactory,
|
TextFactory textFactory,
|
||||||
const style::icon *icon);
|
const style::icon *icon,
|
||||||
|
bool premiumPossible);
|
||||||
|
|
||||||
[[nodiscard]] int counter() const;
|
[[nodiscard]] int counter() const;
|
||||||
[[nodiscard]] int height() const;
|
[[nodiscard]] int height() const;
|
||||||
@ -85,7 +86,6 @@ public:
|
|||||||
void paintBubble(Painter &p, const QRect &r, const QBrush &brush);
|
void paintBubble(Painter &p, const QRect &r, const QBrush &brush);
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<> widthChanges() const;
|
[[nodiscard]] rpl::producer<> widthChanges() const;
|
||||||
[[nodiscard]] rpl::producer<> updateRequests() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
[[nodiscard]] int filledWidth() const;
|
[[nodiscard]] int filledWidth() const;
|
||||||
@ -100,6 +100,7 @@ private:
|
|||||||
const QSize _tailSize;
|
const QSize _tailSize;
|
||||||
const int _height;
|
const int _height;
|
||||||
const int _textTop;
|
const int _textTop;
|
||||||
|
const bool _premiumPossible;
|
||||||
|
|
||||||
int _counter = -1;
|
int _counter = -1;
|
||||||
EdgeProgress _tailEdge = 0.;
|
EdgeProgress _tailEdge = 0.;
|
||||||
@ -111,7 +112,8 @@ private:
|
|||||||
Bubble::Bubble(
|
Bubble::Bubble(
|
||||||
Fn<void()> updateCallback,
|
Fn<void()> updateCallback,
|
||||||
TextFactory textFactory,
|
TextFactory textFactory,
|
||||||
const style::icon *icon)
|
const style::icon *icon,
|
||||||
|
bool premiumPossible)
|
||||||
: _updateCallback(std::move(updateCallback))
|
: _updateCallback(std::move(updateCallback))
|
||||||
, _textFactory(std::move(textFactory))
|
, _textFactory(std::move(textFactory))
|
||||||
, _font(st::premiumBubbleFont)
|
, _font(st::premiumBubbleFont)
|
||||||
@ -120,7 +122,8 @@ Bubble::Bubble(
|
|||||||
, _numberAnimation(_font, _updateCallback)
|
, _numberAnimation(_font, _updateCallback)
|
||||||
, _tailSize(st::premiumBubbleTailSize)
|
, _tailSize(st::premiumBubbleTailSize)
|
||||||
, _height(st::premiumBubbleHeight + _tailSize.height())
|
, _height(st::premiumBubbleHeight + _tailSize.height())
|
||||||
, _textTop((_height - _tailSize.height() - _font->height) / 2) {
|
, _textTop((_height - _tailSize.height() - _font->height) / 2)
|
||||||
|
, _premiumPossible(premiumPossible) {
|
||||||
_numberAnimation.setDisabledMonospace(true);
|
_numberAnimation.setDisabledMonospace(true);
|
||||||
_numberAnimation.setWidthChangedCallback([=] {
|
_numberAnimation.setWidthChangedCallback([=] {
|
||||||
_widthChanges.fire({});
|
_widthChanges.fire({});
|
||||||
@ -208,13 +211,14 @@ void Bubble::paintBubble(Painter &p, const QRect &r, const QBrush &brush) {
|
|||||||
? std::max(float64(tailCenter), float64(bottomMax))
|
? std::max(float64(tailCenter), float64(bottomMax))
|
||||||
: right;
|
: right;
|
||||||
}();
|
}();
|
||||||
pathTail.moveTo(tailLeftFull, tailTop);
|
if (_premiumPossible) {
|
||||||
pathTail.lineTo(tailLeft, tailTop);
|
pathTail.moveTo(tailLeftFull, tailTop);
|
||||||
pathTail.lineTo(tailCenter, tailTop + _tailSize.height());
|
pathTail.lineTo(tailLeft, tailTop);
|
||||||
pathTail.lineTo(tailRight, tailTop);
|
pathTail.lineTo(tailCenter, tailTop + _tailSize.height());
|
||||||
pathTail.lineTo(tailRight, tailTop - radius);
|
pathTail.lineTo(tailRight, tailTop);
|
||||||
pathTail.moveTo(tailLeftFull, tailTop);
|
pathTail.lineTo(tailRight, tailTop - radius);
|
||||||
|
pathTail.moveTo(tailLeftFull, tailTop);
|
||||||
|
}
|
||||||
auto pathBubble = QPainterPath();
|
auto pathBubble = QPainterPath();
|
||||||
pathBubble.setFillRule(Qt::WindingFill);
|
pathBubble.setFillRule(Qt::WindingFill);
|
||||||
pathBubble.addRoundedRect(bubbleRect, radius, radius);
|
pathBubble.addRoundedRect(bubbleRect, radius, radius);
|
||||||
@ -255,6 +259,7 @@ public:
|
|||||||
TextFactory textFactory,
|
TextFactory textFactory,
|
||||||
int current,
|
int current,
|
||||||
int maxCounter,
|
int maxCounter,
|
||||||
|
bool premiumPossible,
|
||||||
rpl::producer<> showFinishes,
|
rpl::producer<> showFinishes,
|
||||||
const style::icon *icon);
|
const style::icon *icon);
|
||||||
|
|
||||||
@ -268,6 +273,7 @@ private:
|
|||||||
const int _maxCounter;
|
const int _maxCounter;
|
||||||
Bubble _bubble;
|
Bubble _bubble;
|
||||||
const int _maxBubbleWidth;
|
const int _maxBubbleWidth;
|
||||||
|
const bool _premiumPossible;
|
||||||
|
|
||||||
Ui::Animations::Simple _appearanceAnimation;
|
Ui::Animations::Simple _appearanceAnimation;
|
||||||
QSize _spaceForDeflection;
|
QSize _spaceForDeflection;
|
||||||
@ -287,13 +293,15 @@ BubbleWidget::BubbleWidget(
|
|||||||
TextFactory textFactory,
|
TextFactory textFactory,
|
||||||
int current,
|
int current,
|
||||||
int maxCounter,
|
int maxCounter,
|
||||||
|
bool premiumPossible,
|
||||||
rpl::producer<> showFinishes,
|
rpl::producer<> showFinishes,
|
||||||
const style::icon *icon)
|
const style::icon *icon)
|
||||||
: RpWidget(parent)
|
: RpWidget(parent)
|
||||||
, _currentCounter(current)
|
, _currentCounter(current)
|
||||||
, _maxCounter(maxCounter)
|
, _maxCounter(maxCounter)
|
||||||
, _bubble([=] { update(); }, std::move(textFactory), icon)
|
, _bubble([=] { update(); }, std::move(textFactory), icon, premiumPossible)
|
||||||
, _maxBubbleWidth(_bubble.countMaxWidth(_maxCounter))
|
, _maxBubbleWidth(_bubble.countMaxWidth(_maxCounter))
|
||||||
|
, _premiumPossible(premiumPossible)
|
||||||
, _deflection(kDeflection)
|
, _deflection(kDeflection)
|
||||||
, _stepBeforeDeflection(kStepBeforeDeflection)
|
, _stepBeforeDeflection(kStepBeforeDeflection)
|
||||||
, _stepAfterDeflection(kStepAfterDeflection) {
|
, _stepAfterDeflection(kStepAfterDeflection) {
|
||||||
@ -430,7 +438,10 @@ void BubbleWidget::paintEvent(QPaintEvent *e) {
|
|||||||
p.translate(-offsetX, -offsetY);
|
p.translate(-offsetX, -offsetY);
|
||||||
}
|
}
|
||||||
|
|
||||||
_bubble.paintBubble(p, bubbleRect, QBrush(_cachedGradient));
|
_bubble.paintBubble(
|
||||||
|
p,
|
||||||
|
bubbleRect,
|
||||||
|
_premiumPossible ? QBrush(_cachedGradient) : st::windowBgActive->b);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Line final : public Ui::RpWidget {
|
class Line final : public Ui::RpWidget {
|
||||||
@ -575,6 +586,7 @@ void AddBubbleRow(
|
|||||||
int min,
|
int min,
|
||||||
int current,
|
int current,
|
||||||
int max,
|
int max,
|
||||||
|
bool premiumPossible,
|
||||||
std::optional<tr::phrase<lngtag_count>> phrase,
|
std::optional<tr::phrase<lngtag_count>> phrase,
|
||||||
const style::icon *icon) {
|
const style::icon *icon) {
|
||||||
const auto container = parent->add(
|
const auto container = parent->add(
|
||||||
@ -584,6 +596,7 @@ void AddBubbleRow(
|
|||||||
ProcessTextFactory(phrase),
|
ProcessTextFactory(phrase),
|
||||||
current,
|
current,
|
||||||
max,
|
max,
|
||||||
|
premiumPossible,
|
||||||
std::move(showFinishes),
|
std::move(showFinishes),
|
||||||
icon);
|
icon);
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
|
@ -34,6 +34,7 @@ void AddBubbleRow(
|
|||||||
int min,
|
int min,
|
||||||
int current,
|
int current,
|
||||||
int max,
|
int max,
|
||||||
|
bool premiumPossible,
|
||||||
std::optional<tr::phrase<lngtag_count>> phrase,
|
std::optional<tr::phrase<lngtag_count>> phrase,
|
||||||
const style::icon *icon);
|
const style::icon *icon);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user