Slightly improved style of some boxes for premium limits.
This commit is contained in:
parent
a73676b3ba
commit
3b379c67ac
|
@ -177,7 +177,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_channels_leave_done" = "You've left the selected communities.";
|
"lng_channels_leave_done" = "You've left the selected communities.";
|
||||||
|
|
||||||
"lng_links_limit_title" = "Too Many Public Links";
|
"lng_links_limit_title" = "Too Many Public Links";
|
||||||
"lng_links_limit_subtitle" = "Your public communitites";
|
|
||||||
"lng_links_limit1#one" = "You have reserved **{count}** public link.";
|
"lng_links_limit1#one" = "You have reserved **{count}** public link.";
|
||||||
"lng_links_limit1#other" = "You have reserved **{count}** public links.";
|
"lng_links_limit1#other" = "You have reserved **{count}** public links.";
|
||||||
"lng_links_limit2#one" = "Try revoking the link from an older group or channel, or upgrade to **Telegram Premium** to double the limit to **{count}** public link.";
|
"lng_links_limit2#one" = "Try revoking the link from an older group or channel, or upgrade to **Telegram Premium** to double the limit to **{count}** public link.";
|
||||||
|
@ -224,7 +223,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_caption_limit_reached#other" = "You've reached the media caption limit. Please make the caption shorter by {count} characters.";
|
"lng_caption_limit_reached#other" = "You've reached the media caption limit. Please make the caption shorter by {count} characters.";
|
||||||
|
|
||||||
"lng_file_size_limit_title" = "File Too Large";
|
"lng_file_size_limit_title" = "File Too Large";
|
||||||
"lng_file_size_limit" = "{total} Gb";
|
"lng_file_size_limit#one" = "{count} Gb";
|
||||||
|
"lng_file_size_limit#other" = "{count} Gb";
|
||||||
"lng_file_size_limit1" = "The document can't be sent, because it is larger than {size}.";
|
"lng_file_size_limit1" = "The document can't be sent, because it is larger than {size}.";
|
||||||
"lng_file_size_limit2" = "You can double this limit to {size} per document by subscribing to **Telegram Premium**.";
|
"lng_file_size_limit2" = "You can double this limit to {size} per document by subscribing to **Telegram Premium**.";
|
||||||
|
|
||||||
|
|
|
@ -1080,7 +1080,8 @@ ringtonesBoxSkip: 7px;
|
||||||
|
|
||||||
premiumBubblePadding: margins(14px, 0px, 14px, 0px);
|
premiumBubblePadding: margins(14px, 0px, 14px, 0px);
|
||||||
premiumBubbleHeight: 40px;
|
premiumBubbleHeight: 40px;
|
||||||
premiumBubbleSkip: 5px;
|
premiumBubbleSkip: 8px;
|
||||||
|
premiumBubbleWidthLimit: 80px;
|
||||||
premiumBubbleTextSkip: 3px;
|
premiumBubbleTextSkip: 3px;
|
||||||
premiumBubbleSlideDuration: 1000;
|
premiumBubbleSlideDuration: 1000;
|
||||||
premiumBubbleTailSize: size(21px, 7px);
|
premiumBubbleTailSize: size(21px, 7px);
|
||||||
|
|
|
@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
#include "styles/style_info.h"
|
#include "styles/style_info.h"
|
||||||
|
#include "styles/style_settings.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ struct InfographicDescriptor {
|
||||||
float64 current = 0;
|
float64 current = 0;
|
||||||
float64 premiumLimit = 0;
|
float64 premiumLimit = 0;
|
||||||
const style::icon *icon;
|
const style::icon *icon;
|
||||||
|
std::optional<tr::phrase<lngtag_count>> phrase;
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<> BoxShowFinishes(not_null<Ui::GenericBox*> box) {
|
[[nodiscard]] rpl::producer<> BoxShowFinishes(not_null<Ui::GenericBox*> box) {
|
||||||
|
@ -54,6 +56,16 @@ struct InfographicDescriptor {
|
||||||
return showFinishes->events();
|
return showFinishes->events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddSubsectionTitle(
|
||||||
|
not_null<Ui::VerticalLayout*> container,
|
||||||
|
rpl::producer<QString> text) {
|
||||||
|
const auto &subtitlePadding = st::settingsButton.padding;
|
||||||
|
Settings::AddSubsectionTitle(
|
||||||
|
container,
|
||||||
|
std::move(text),
|
||||||
|
{ 0, subtitlePadding.top(), 0, -subtitlePadding.bottom() });
|
||||||
|
}
|
||||||
|
|
||||||
class InactiveController final : public PeerListController {
|
class InactiveController final : public PeerListController {
|
||||||
public:
|
public:
|
||||||
explicit InactiveController(not_null<Main::Session*> session);
|
explicit InactiveController(not_null<Main::Session*> session);
|
||||||
|
@ -411,10 +423,10 @@ void SimpleLimitBox(
|
||||||
descriptor.defaultLimit,
|
descriptor.defaultLimit,
|
||||||
descriptor.current,
|
descriptor.current,
|
||||||
descriptor.premiumLimit,
|
descriptor.premiumLimit,
|
||||||
std::nullopt,
|
descriptor.phrase,
|
||||||
descriptor.icon);
|
descriptor.icon);
|
||||||
Settings::AddSkip(top, st::premiumLineTextSkip);
|
Settings::AddSkip(top, st::premiumLineTextSkip);
|
||||||
Ui::Premium::AddLimitRow(top, descriptor.premiumLimit);
|
Ui::Premium::AddLimitRow(top, descriptor.premiumLimit, descriptor.phrase);
|
||||||
Settings::AddSkip(top, st::premiumInfographicPadding.bottom());
|
Settings::AddSkip(top, st::premiumInfographicPadding.bottom());
|
||||||
|
|
||||||
box->setTitle(std::move(title));
|
box->setTitle(std::move(title));
|
||||||
|
@ -443,7 +455,7 @@ void SimpleLimitBox(
|
||||||
});
|
});
|
||||||
|
|
||||||
if (fixed) {
|
if (fixed) {
|
||||||
Settings::AddSkip(top);
|
Settings::AddSkip(top, st::settingsButton.padding.bottom());
|
||||||
Settings::AddDivider(top);
|
Settings::AddDivider(top);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -522,6 +534,8 @@ void ChannelsLimitBox(
|
||||||
premium,
|
premium,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
|
AddSubsectionTitle(box->verticalLayout(), tr::lng_channels_leave_title());
|
||||||
|
|
||||||
const auto delegate = box->lifetime().make_state<InactiveDelegate>();
|
const auto delegate = box->lifetime().make_state<InactiveDelegate>();
|
||||||
const auto controller = box->lifetime().make_state<InactiveController>(
|
const auto controller = box->lifetime().make_state<InactiveController>(
|
||||||
session);
|
session);
|
||||||
|
@ -615,9 +629,7 @@ void PublicLinksLimitBox(
|
||||||
premium,
|
premium,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
Settings::AddSubsectionTitle(
|
AddSubsectionTitle(box->verticalLayout(), tr::lng_links_revoke_title());
|
||||||
box->verticalLayout(),
|
|
||||||
tr::lng_links_limit_subtitle());
|
|
||||||
|
|
||||||
const auto delegate = box->lifetime().make_state<InactiveDelegate>();
|
const auto delegate = box->lifetime().make_state<InactiveDelegate>();
|
||||||
const auto controller = box->lifetime().make_state<PublicsController>(
|
const auto controller = box->lifetime().make_state<PublicsController>(
|
||||||
|
@ -835,10 +847,7 @@ void FileSizeLimitBox(
|
||||||
const auto defaultGb = (defaultLimit + 999) / 2000;
|
const auto defaultGb = (defaultLimit + 999) / 2000;
|
||||||
const auto premiumGb = (premiumLimit + 999) / 2000;
|
const auto premiumGb = (premiumLimit + 999) / 2000;
|
||||||
const auto gb = [](int count) {
|
const auto gb = [](int count) {
|
||||||
return tr::lng_file_size_limit(
|
return tr::lng_file_size_limit(tr::now, lt_count, count);
|
||||||
tr::now,
|
|
||||||
lt_total,
|
|
||||||
QString::number(count));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
auto text = rpl::combine(
|
auto text = rpl::combine(
|
||||||
|
@ -860,7 +869,13 @@ void FileSizeLimitBox(
|
||||||
tr::lng_file_size_limit_title(),
|
tr::lng_file_size_limit_title(),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
"upload_max_fileparts",
|
"upload_max_fileparts",
|
||||||
{ defaultGb, defaultGb, premiumGb, &st::premiumIconFiles },
|
{
|
||||||
|
defaultGb,
|
||||||
|
defaultGb,
|
||||||
|
premiumGb,
|
||||||
|
&st::premiumIconFiles,
|
||||||
|
tr::lng_file_size_limit
|
||||||
|
},
|
||||||
premium);
|
premium);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,12 +23,20 @@ namespace {
|
||||||
|
|
||||||
using TextFactory = Fn<QString(int)>;
|
using TextFactory = Fn<QString(int)>;
|
||||||
|
|
||||||
|
constexpr auto kDeflectionSmall = 20.;
|
||||||
constexpr auto kDeflection = 30.;
|
constexpr auto kDeflection = 30.;
|
||||||
|
|
||||||
constexpr auto kStepBeforeDeflection = 0.75;
|
constexpr auto kStepBeforeDeflection = 0.75;
|
||||||
constexpr auto kStepAfterDeflection = kStepBeforeDeflection
|
constexpr auto kStepAfterDeflection = kStepBeforeDeflection
|
||||||
+ (1. - kStepBeforeDeflection) / 2.;
|
+ (1. - kStepBeforeDeflection) / 2.;
|
||||||
|
|
||||||
|
[[nodiscard]] TextFactory ProcessTextFactory(
|
||||||
|
std::optional<tr::phrase<lngtag_count>> phrase) {
|
||||||
|
return phrase
|
||||||
|
? TextFactory([=](int n) { return (*phrase)(tr::now, lt_count, n); })
|
||||||
|
: TextFactory([=](int n) { return QString::number(n); });
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] QLinearGradient ComputeGradient(
|
[[nodiscard]] QLinearGradient ComputeGradient(
|
||||||
not_null<QWidget*> content,
|
not_null<QWidget*> content,
|
||||||
int left,
|
int left,
|
||||||
|
@ -103,6 +111,7 @@ Bubble::Bubble(
|
||||||
, _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) {
|
||||||
|
_numberAnimation.setDisabledMonospace(true);
|
||||||
_numberAnimation.setWidthChangedCallback([=] {
|
_numberAnimation.setWidthChangedCallback([=] {
|
||||||
_widthChanges.fire({});
|
_widthChanges.fire({});
|
||||||
});
|
});
|
||||||
|
@ -216,6 +225,8 @@ private:
|
||||||
|
|
||||||
QLinearGradient _cachedGradient;
|
QLinearGradient _cachedGradient;
|
||||||
|
|
||||||
|
float64 _deflection;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
BubbleWidget::BubbleWidget(
|
BubbleWidget::BubbleWidget(
|
||||||
|
@ -228,8 +239,12 @@ BubbleWidget::BubbleWidget(
|
||||||
: RpWidget(parent)
|
: RpWidget(parent)
|
||||||
, _currentCounter(current)
|
, _currentCounter(current)
|
||||||
, _maxCounter(maxCounter)
|
, _maxCounter(maxCounter)
|
||||||
, _bubble([=] { update(); }, std::move(textFactory), icon) {
|
, _bubble([=] { update(); }, std::move(textFactory), icon)
|
||||||
|
, _deflection(kDeflection) {
|
||||||
const auto resizeTo = [=](int w, int h) {
|
const auto resizeTo = [=](int w, int h) {
|
||||||
|
_deflection = (w > st::premiumBubbleWidthLimit)
|
||||||
|
? kDeflectionSmall
|
||||||
|
: kDeflection;
|
||||||
_spaceForDeflection = QSize(
|
_spaceForDeflection = QSize(
|
||||||
st::premiumBubbleSkip,
|
st::premiumBubbleSkip,
|
||||||
st::premiumBubbleSkip);
|
st::premiumBubbleSkip);
|
||||||
|
@ -338,8 +353,8 @@ void BubbleWidget::paintEvent(QPaintEvent *e) {
|
||||||
const auto offsetY = bubbleRect.y() + bubbleRect.height();
|
const auto offsetY = bubbleRect.y() + bubbleRect.height();
|
||||||
p.translate(offsetX, offsetY);
|
p.translate(offsetX, offsetY);
|
||||||
p.scale(scale, scale);
|
p.scale(scale, scale);
|
||||||
p.rotate(rotationProgress * kDeflection
|
p.rotate(rotationProgress * _deflection
|
||||||
- rotationProgressReverse * kDeflection);
|
- rotationProgressReverse * _deflection);
|
||||||
p.translate(-offsetX, -offsetY);
|
p.translate(-offsetX, -offsetY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,7 +363,7 @@ void BubbleWidget::paintEvent(QPaintEvent *e) {
|
||||||
|
|
||||||
class Line final : public Ui::RpWidget {
|
class Line final : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
Line(not_null<Ui::RpWidget*> parent, int max);
|
Line(not_null<Ui::RpWidget*> parent, int max, TextFactory textFactory);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
|
@ -368,11 +383,11 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Line::Line(not_null<Ui::RpWidget*> parent, int max)
|
Line::Line(not_null<Ui::RpWidget*> parent, int max, TextFactory textFactory)
|
||||||
: Ui::RpWidget(parent)
|
: Ui::RpWidget(parent)
|
||||||
, _leftText(st::defaultTextStyle, tr::lng_premium_free(tr::now))
|
, _leftText(st::defaultTextStyle, tr::lng_premium_free(tr::now))
|
||||||
, _rightText(st::defaultTextStyle, tr::lng_premium(tr::now))
|
, _rightText(st::defaultTextStyle, tr::lng_premium(tr::now))
|
||||||
, _rightLabel(st::defaultTextStyle, QString::number(max)) {
|
, _rightLabel(st::defaultTextStyle, textFactory(max)) {
|
||||||
resize(width(), st::requestsAcceptButton.height);
|
resize(width(), st::requestsAcceptButton.height);
|
||||||
|
|
||||||
sizeValue(
|
sizeValue(
|
||||||
|
@ -470,15 +485,11 @@ void AddBubbleRow(
|
||||||
int max,
|
int max,
|
||||||
std::optional<tr::phrase<lngtag_count>> phrase,
|
std::optional<tr::phrase<lngtag_count>> phrase,
|
||||||
const style::icon *icon) {
|
const style::icon *icon) {
|
||||||
auto textFactory = phrase
|
|
||||||
? TextFactory([=](int n) { return (*phrase)(tr::now, lt_count, n); })
|
|
||||||
: TextFactory([=](int n) { return QString::number(n); });
|
|
||||||
|
|
||||||
const auto container = parent->add(
|
const auto container = parent->add(
|
||||||
object_ptr<Ui::FixedHeightWidget>(parent, 0));
|
object_ptr<Ui::FixedHeightWidget>(parent, 0));
|
||||||
const auto bubble = Ui::CreateChild<BubbleWidget>(
|
const auto bubble = Ui::CreateChild<BubbleWidget>(
|
||||||
container,
|
container,
|
||||||
std::move(textFactory),
|
ProcessTextFactory(phrase),
|
||||||
current,
|
current,
|
||||||
max,
|
max,
|
||||||
std::move(showFinishes),
|
std::move(showFinishes),
|
||||||
|
@ -491,9 +502,12 @@ void AddBubbleRow(
|
||||||
}, bubble->lifetime());
|
}, bubble->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddLimitRow(not_null<Ui::VerticalLayout*> parent, int max) {
|
void AddLimitRow(
|
||||||
|
not_null<Ui::VerticalLayout*> parent,
|
||||||
|
int max,
|
||||||
|
std::optional<tr::phrase<lngtag_count>> phrase) {
|
||||||
const auto line = parent->add(
|
const auto line = parent->add(
|
||||||
object_ptr<Line>(parent, max),
|
object_ptr<Line>(parent, max, ProcessTextFactory(phrase)),
|
||||||
st::boxRowPadding);
|
st::boxRowPadding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,10 @@ void AddBubbleRow(
|
||||||
std::optional<tr::phrase<lngtag_count>> phrase,
|
std::optional<tr::phrase<lngtag_count>> phrase,
|
||||||
const style::icon *icon);
|
const style::icon *icon);
|
||||||
|
|
||||||
void AddLimitRow(not_null<Ui::VerticalLayout*> parent, int max);
|
void AddLimitRow(
|
||||||
|
not_null<Ui::VerticalLayout*> parent,
|
||||||
|
int max,
|
||||||
|
std::optional<tr::phrase<lngtag_count>> phrase);
|
||||||
|
|
||||||
[[nodiscard]] QGradientStops LimitGradientStops();
|
[[nodiscard]] QGradientStops LimitGradientStops();
|
||||||
[[nodiscard]] QGradientStops ButtonGradientStops();
|
[[nodiscard]] QGradientStops ButtonGradientStops();
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 7133ccd2f9e5176334e597cd7727d69faf944868
|
Subproject commit 79af7c5523ae59d4dd13cc2bde86bb8611bde11c
|
Loading…
Reference in New Issue