Added new section for premium settings.

This commit is contained in:
23rd 2022-05-18 21:53:25 +03:00
parent e7cc8ff44b
commit 51ed3af14c
27 changed files with 321 additions and 0 deletions

View File

@ -1118,6 +1118,8 @@ PRIVATE
settings/settings_main.h
settings/settings_notifications.cpp
settings/settings_notifications.h
settings/settings_premium.cpp
settings/settings_premium.h
settings/settings_privacy_controllers.cpp
settings/settings_privacy_controllers.h
settings/settings_privacy_security.cpp

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 685 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 729 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 911 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 741 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1662,6 +1662,32 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_premium" = "Premium";
"lng_premium_free" = "Free";
"lng_premium_summary_title" = "Telegram Premium";
"lng_premium_summary_top_about" = "Go **beyond the limits**, get **exclusive features** and support us by subscribing to **Telegram Premium**.";
"lng_premium_summary_subtitle1" = "Doubled Limits";
"lng_premium_summary_about1" = "Up to 1000 channels, 20 folders, 10 pins, 20 public links, 4 accounts and more.";
"lng_premium_summary_subtitle2" = "4Gb Upload Size";
"lng_premium_summary_about2" = "Increased upload size from 2Gb to 4Gb to per document, unlimited storage overall.";
"lng_premium_summary_subtitle3" = "Faster Download Speed";
"lng_premium_summary_about3" = "No more limits on the speed with which media and documents are downloaded.";
"lng_premium_summary_subtitle4" = "Voice-to-Text Conversion";
"lng_premium_summary_about4" = "Ability to read the transcript of any incoming voice message.";
"lng_premium_summary_subtitle5" = "No Ads";
"lng_premium_summary_about5" = "No more ads in public channels where Telegram sometimes shows ads.";
"lng_premium_summary_subtitle6" = "Unique Reactions";
"lng_premium_summary_about6" = "Additional animated reactions on messages available only to the Premium subscribers.";
"lng_premium_summary_subtitle7" = "Premium Stickers";
"lng_premium_summary_about7" = "Exclusive enlarged stickers featuring additional effects, updated monthly.";
"lng_premium_summary_subtitle8" = "Advanced Chat Management";
"lng_premium_summary_about8" = "Tools to set default folder, auto-archive and hide new chats from non-contacts.";
"lng_premium_summary_subtitle9" = "Profile Badge";
"lng_premium_summary_about9" = "A badge next to your name showing that you are helping support Telegram.";
"lng_premium_summary_subtitle10" = "Animated Profile Pictures";
"lng_premium_summary_about10" = "Video avatars animated in chat lists and chats to allow for additional self-expression.";
"lng_premium_summary_bottom_subtitle" = "About Telegram Premium";
"lng_premium_summary_bottom_about" = "While the free version of Telegram already gives its users more than any other messaging application, **Telegram Premium** pushes its capabilities even further.\n\n**Telegram Premium** is a paid option, because most Premium Features require additional expenses from Telegram to third parties such as data center providers and server manufacturers. Contributions from **Telegram Premium** users allow us to cover such costs and also help Telegram stay free for everyone.";
"lng_premium_summary_button" = "Subscribe for {cost} per month.";
"lng_group_about_header" = "You have created a group.";
"lng_group_about_text" = "Groups can have:";
"lng_group_about1" = "Up to 100,000 members";

View File

@ -93,6 +93,14 @@ settingsIconPin: icon {{ "settings/pin", settingsIconFg }};
settingsIconDownload: icon {{ "settings/download", settingsIconFg }};
settingsIconMention: icon {{ "settings/mention", settingsIconFg }};
settingsPremiumIconChannelsOff: icon {{ "settings/premium/channels_off", settingsIconFg }};
settingsPremiumIconDouble: icon {{ "settings/premium/double", settingsIconFg }};
settingsPremiumIconLike: icon {{ "settings/premium/like", settingsIconFg }};
settingsPremiumIconPlay: icon {{ "settings/premium/play", settingsIconFg }};
settingsPremiumIconSpeed: icon {{ "settings/premium/speed", settingsIconFg }};
settingsPremiumIconStar: icon {{ "settings/premium/star", settingsIconFg }};
settingsPremiumIconVoice: icon {{ "settings/premium/voice", settingsIconFg }};
settingsIconAdd: icon {{ "settings/add", windowFgActive }};
settingsIconRemove: icon {{ "settings/remove", windowFgActive }};
@ -411,3 +419,7 @@ notifyPreviewTitlePosition: point(64px, 9px);
notifyPreviewTextPosition: point(64px, 30px);
notifyPreviewChecksSkip: 12px;
notifyPreviewBottomSkip: 9px;
settingsPremiumDescriptionSkip: 3px;
settingsPremiumButtonPadding: margins(11px, 11px, 11px, 11px);

View File

@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "settings/settings_advanced.h"
#include "settings/settings_folders.h"
#include "settings/settings_calls.h"
#include "settings/settings_premium.h"
#include "boxes/language_box.h"
#include "boxes/username_box.h"
#include "ui/boxes/confirm_box.h"
@ -330,6 +331,15 @@ void SetupSections(
SetupLanguageButton(container);
AddSkip(container);
AddDivider(container);
AddSkip(container);
addSection(
tr::lng_premium_summary_title(),
PremiumId(),
{ &st::settingsIconCalls, kIconGreen });
AddSkip(container);
}

View File

@ -0,0 +1,254 @@
/*
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
*/
#include "settings/settings_premium.h"
#include "lang/lang_keys.h"
#include "settings/settings_common.h"
#include "ui/abstract_button.h"
#include "ui/effects/gradient.h"
#include "ui/text/text_utilities.h"
#include "ui/widgets/gradient_round_button.h"
#include "ui/widgets/labels.h"
#include "ui/wrap/padding_wrap.h"
#include "ui/wrap/vertical_layout.h"
#include "window/window_session_controller.h"
#include "styles/style_boxes.h"
#include "styles/style_chat_helpers.h"
#include "styles/style_layers.h"
#include "styles/style_settings.h"
namespace Settings {
namespace {
class Premium : public Section<Premium> {
public:
Premium(
QWidget *parent,
not_null<Window::SessionController*> controller);
[[nodiscard]] rpl::producer<QString> title() override;
[[nodiscard]] QPointer<Ui::RpWidget> createPinnedToBottom(
not_null<Ui::RpWidget*> parent) override;
private:
void setupContent(not_null<Window::SessionController*> controller);
};
Premium::Premium(
QWidget *parent,
not_null<Window::SessionController*> controller)
: Section(parent) {
setupContent(controller);
}
rpl::producer<QString> Premium::title() {
return tr::lng_premium_summary_title();
}
void Premium::setupContent(not_null<Window::SessionController*> controller) {
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
content->add(
object_ptr<Ui::CenterWrap<>>(
content,
object_ptr<Ui::FlatLabel>(
content,
tr::lng_premium_summary_title(),
st::changePhoneTitle)),
st::changePhoneTitlePadding);
const auto wrap = content->add(
object_ptr<Ui::CenterWrap<>>(
content,
object_ptr<Ui::FlatLabel>(
content,
tr::lng_premium_summary_top_about(Ui::Text::RichLangValue),
st::changePhoneDescription)),
st::changePhoneDescriptionPadding);
wrap->resize(
wrap->width(),
st::settingLocalPasscodeDescriptionHeight);
AddSkip(content);
AddDivider(content);
AddSkip(content);
const auto &st = st::settingsButton;
const auto &stLabel = st::defaultFlatLabel;
const auto iconSize = st::settingsPremiumIconDouble.size();
const auto icons = std::array<const style::icon *, 10>{ {
&st::settingsPremiumIconDouble,
&st::premiumIconFolders, //
&st::settingsPremiumIconSpeed,
&st::settingsPremiumIconVoice,
&st::settingsPremiumIconChannelsOff,
&st::settingsPremiumIconLike,
&st::settingsIconStickers,
&st::settingsIconChat,
&st::settingsPremiumIconStar,
&st::settingsPremiumIconPlay,
} };
auto iconContainers = std::vector<Ui::AbstractButton*>();
iconContainers.reserve(int(icons.size()));
auto titlePadding = st.padding;
titlePadding.setBottom(0);
auto descriptionPadding = st.padding;
descriptionPadding.setTop(0);
const auto addRow = [&](
rpl::producer<QString> &&title,
rpl::producer<QString> &&text) {
const auto labelAscent = stLabel.style.font->ascent;
const auto label = content->add(
object_ptr<Ui::FlatLabel>(
content,
std::move(title) | rpl::map(Ui::Text::Bold),
stLabel),
titlePadding);
AddSkip(content, st::settingsPremiumDescriptionSkip);
content->add(
object_ptr<Ui::FlatLabel>(
content,
std::move(text),
st::boxDividerLabel),
descriptionPadding);
const auto dummy = Ui::CreateChild<Ui::AbstractButton>(content);
dummy->setAttribute(Qt::WA_TransparentForMouseEvents);
content->sizeValue(
) | rpl::start_with_next([=](const QSize &s) {
dummy->resize(s.width(), iconSize.height());
}, dummy->lifetime());
label->geometryValue(
) | rpl::start_with_next([=](const QRect &r) {
dummy->moveToLeft(0, r.y() + (r.height() - labelAscent));
}, dummy->lifetime());
iconContainers.push_back(dummy);
};
using namespace tr;
addRow(lng_premium_summary_subtitle1(), lng_premium_summary_about1());
addRow(lng_premium_summary_subtitle2(), lng_premium_summary_about2());
addRow(lng_premium_summary_subtitle3(), lng_premium_summary_about3());
addRow(lng_premium_summary_subtitle4(), lng_premium_summary_about4());
addRow(lng_premium_summary_subtitle5(), lng_premium_summary_about5());
addRow(lng_premium_summary_subtitle6(), lng_premium_summary_about6());
addRow(lng_premium_summary_subtitle7(), lng_premium_summary_about7());
addRow(lng_premium_summary_subtitle8(), lng_premium_summary_about8());
addRow(lng_premium_summary_subtitle9(), lng_premium_summary_about9());
addRow(lng_premium_summary_subtitle10(), lng_premium_summary_about10());
content->resizeToWidth(content->height());
// Icons.
Assert(iconContainers.size() > 2);
const auto from = iconContainers.front()->y();
const auto to = iconContainers.back()->y() + iconSize.height();
auto gradient = QLinearGradient(0, 0, 0, to - from);
gradient.setColorAt(.0, st::premiumButtonBg3->c);
gradient.setColorAt(.5, st::premiumButtonBg2->c);
gradient.setColorAt(1., st::premiumButtonBg1->c);
for (auto i = 0; i < int(icons.size()); i++) {
const auto &iconContainer = iconContainers[i];
const auto pointTop = iconContainer->y() - from;
const auto pointBottom = pointTop + iconContainer->height();
const auto ratioTop = pointTop / float64(to - from);
const auto ratioBottom = pointBottom / float64(to - from);
auto resultGradient = QLinearGradient(
QPointF(),
QPointF(0, pointBottom - pointTop));
resultGradient.setColorAt(
.0,
anim::gradient_color_at(gradient, ratioTop));
resultGradient.setColorAt(
.1,
anim::gradient_color_at(gradient, ratioBottom));
const auto brush = QBrush(resultGradient);
AddButtonIcon(
iconContainer,
st,
{ .icon = icons[i], .backgroundBrush = brush });
}
AddSkip(content);
AddDivider(content);
AddSkip(content);
content->add(
object_ptr<Ui::FlatLabel>(
content,
tr::lng_premium_summary_bottom_subtitle(
) | rpl::map(Ui::Text::Bold),
stLabel),
st::settingsSubsectionTitlePadding);
content->add(
object_ptr<Ui::FlatLabel>(
content,
tr::lng_premium_summary_bottom_about(Ui::Text::RichLangValue),
st::aboutLabel),
st::boxRowPadding);
AddSkip(content);
Ui::ResizeFitChild(this, content);
}
QPointer<Ui::RpWidget> Premium::createPinnedToBottom(
not_null<Ui::RpWidget*> parent) {
const auto content = Ui::CreateChild<Ui::VerticalLayout>(parent.get());
auto result = object_ptr<Ui::GradientButton>(
content,
QGradientStops{
{ 0., st::premiumButtonBg1->c },
{ .6, st::premiumButtonBg2->c },
{ 1., st::premiumButtonBg3->c },
});
const auto &st = st::premiumPreviewBox.button;
result->resize(content->width(), st.height);
const auto label = Ui::CreateChild<Ui::FlatLabel>(
result.data(),
tr::lng_premium_summary_button(tr::now, lt_cost, "$5"),
st::premiumPreviewButtonLabel);
label->setAttribute(Qt::WA_TransparentForMouseEvents);
rpl::combine(
result->widthValue(),
label->widthValue()
) | rpl::start_with_next([=](int outer, int width) {
label->moveToLeft(
(outer - width) / 2,
st::premiumPreviewBox.button.textTop,
outer);
}, label->lifetime());
content->add(std::move(result), st::settingsPremiumButtonPadding);
return Ui::MakeWeak(not_null<Ui::RpWidget*>{ content });
}
} // namespace
Type PremiumId() {
return Premium::Id();
}
} // namespace Settings

View File

@ -0,0 +1,17 @@
/*
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
*/
#pragma once
#include "settings/settings_type.h"
namespace Settings {
Type PremiumId();
} // namespace Settings