mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-03 12:58:11 +00:00
Slightly improved style of Premium Settings.
This commit is contained in:
parent
fa4801ac94
commit
fa6b4f9b52
BIN
Telegram/Resources/icons/settings/premium/arrow.png
Normal file
BIN
Telegram/Resources/icons/settings/premium/arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 268 B |
BIN
Telegram/Resources/icons/settings/premium/arrow@2x.png
Normal file
BIN
Telegram/Resources/icons/settings/premium/arrow@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 470 B |
BIN
Telegram/Resources/icons/settings/premium/arrow@3x.png
Normal file
BIN
Telegram/Resources/icons/settings/premium/arrow@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 610 B |
@ -11,7 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/chat/chat_style.h"
|
||||
#include "ui/text/text_options.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/text/text_block.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "history/history_message.h"
|
||||
|
@ -485,9 +485,9 @@ settingsPremiumAbout: FlatLabel(defaultFlatLabel) {
|
||||
textFg: premiumButtonFg;
|
||||
minWidth: 190px;
|
||||
}
|
||||
settingsPremiumArrowShift: point(-4px, -1px);
|
||||
settingsPremiumArrow: icon{{ "fast_to_original", menuIconFg }};
|
||||
settingsPremiumArrowOver: icon{{ "fast_to_original", menuIconFgOver }};
|
||||
settingsPremiumArrowShift: point(-5px, -1px);
|
||||
settingsPremiumArrow: icon{{ "settings/premium/arrow", menuIconFg }};
|
||||
settingsPremiumArrowOver: icon{{ "settings/premium/arrow", menuIconFgOver }};
|
||||
settingsPremiumStatusPadding: margins(22px, 8px, 22px, 2px);
|
||||
|
||||
settingsPremiumOptionsPadding: margins(0px, 9px, 0px, 2px);
|
||||
|
@ -383,13 +383,18 @@ public:
|
||||
|
||||
protected:
|
||||
void paintEdges(QPainter &p, const QBrush &brush) const;
|
||||
void paintEdges(QPainter &p) const;
|
||||
|
||||
[[nodiscard]] QRectF starRect(
|
||||
float64 topProgress,
|
||||
float64 sizeProgress) const;
|
||||
|
||||
[[nodiscard]] bool isDark() const;
|
||||
void computeIsDark();
|
||||
|
||||
private:
|
||||
bool _roundEdges = true;
|
||||
bool _isDark = false;
|
||||
|
||||
};
|
||||
|
||||
@ -414,6 +419,14 @@ void TopBarAbstract::paintEdges(QPainter &p, const QBrush &brush) const {
|
||||
}
|
||||
}
|
||||
|
||||
void TopBarAbstract::paintEdges(QPainter &p) const {
|
||||
paintEdges(p, st::boxBg);
|
||||
if (isDark()) {
|
||||
paintEdges(p, st::shadowFg);
|
||||
paintEdges(p, st::shadowFg);
|
||||
}
|
||||
}
|
||||
|
||||
QRectF TopBarAbstract::starRect(
|
||||
float64 topProgress,
|
||||
float64 sizeProgress) const {
|
||||
@ -425,6 +438,17 @@ QRectF TopBarAbstract::starRect(
|
||||
starSize);
|
||||
};
|
||||
|
||||
bool TopBarAbstract::isDark() const {
|
||||
return _isDark;
|
||||
}
|
||||
|
||||
void TopBarAbstract::computeIsDark() {
|
||||
const auto contrast = Ui::CountContrast(
|
||||
st::boxBg->c,
|
||||
st::premiumButtonFg->c);
|
||||
_isDark = (contrast > kMinAcceptableContrast);
|
||||
}
|
||||
|
||||
class EmojiStatusTopBar final {
|
||||
public:
|
||||
EmojiStatusTopBar(
|
||||
@ -611,6 +635,13 @@ TopBarUser::TopBarUser(
|
||||
}) {
|
||||
_starRect = TopBarAbstract::starRect(1., 1.);
|
||||
|
||||
rpl::single() | rpl::then(
|
||||
style::PaletteChanged()
|
||||
) | rpl::start_with_next([=] {
|
||||
TopBarAbstract::computeIsDark();
|
||||
update();
|
||||
}, lifetime());
|
||||
|
||||
auto documentValue = Info::Profile::EmojiStatusIdValue(
|
||||
peer
|
||||
) | rpl::map([=](DocumentId id) -> DocumentData* {
|
||||
@ -749,7 +780,7 @@ TopBarUser::TopBarUser(
|
||||
Painter p(_smallTop.widget);
|
||||
|
||||
p.setOpacity(_smallTop.animation.value(_smallTop.shown ? 1. : 0.));
|
||||
paintEdges(p, st::boxBg);
|
||||
TopBarAbstract::paintEdges(p);
|
||||
|
||||
p.setPen(st::boxTitleFg);
|
||||
_smallTop.text.drawLeft(
|
||||
@ -859,7 +890,7 @@ void TopBarUser::setTextPosition(int x, int y) {
|
||||
void TopBarUser::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
|
||||
TopBarAbstract::paintEdges(p, st::boxBg);
|
||||
TopBarAbstract::paintEdges(p);
|
||||
}
|
||||
|
||||
void TopBarUser::resizeEvent(QResizeEvent *e) {
|
||||
@ -901,8 +932,6 @@ private:
|
||||
float64 scaleTitle = 0.;
|
||||
} _progress;
|
||||
|
||||
bool _isDark = false;
|
||||
|
||||
QRectF _starRect;
|
||||
|
||||
QPoint _titlePosition;
|
||||
@ -944,12 +973,9 @@ TopBar::TopBar(
|
||||
rpl::single() | rpl::then(
|
||||
style::PaletteChanged()
|
||||
) | rpl::start_with_next([=] {
|
||||
const auto contrast = Ui::CountContrast(
|
||||
st::boxBg->c,
|
||||
st::premiumButtonFg->c);
|
||||
_isDark = (contrast > kMinAcceptableContrast);
|
||||
TopBarAbstract::computeIsDark();
|
||||
|
||||
if (!_isDark) {
|
||||
if (!TopBarAbstract::isDark()) {
|
||||
_star.load(Svg());
|
||||
_ministars.setColorOverride(st::premiumButtonFg->c);
|
||||
} else {
|
||||
@ -1008,7 +1034,7 @@ void TopBar::paintEvent(QPaintEvent *e) {
|
||||
|
||||
const auto r = rect();
|
||||
|
||||
if (!_isDark) {
|
||||
if (!TopBarAbstract::isDark()) {
|
||||
const auto gradientPointTop = r.height() / 3. * 2.;
|
||||
auto gradient = QLinearGradient(
|
||||
QPointF(0, gradientPointTop),
|
||||
@ -1017,9 +1043,7 @@ void TopBar::paintEvent(QPaintEvent *e) {
|
||||
|
||||
TopBarAbstract::paintEdges(p, gradient);
|
||||
} else {
|
||||
TopBarAbstract::paintEdges(p, st::boxBg);
|
||||
TopBarAbstract::paintEdges(p, st::shadowFg);
|
||||
TopBarAbstract::paintEdges(p, st::shadowFg);
|
||||
TopBarAbstract::paintEdges(p);
|
||||
}
|
||||
|
||||
p.setOpacity(_progress.body);
|
||||
@ -1099,7 +1123,7 @@ private:
|
||||
|
||||
rpl::event_stream<> _showBack;
|
||||
rpl::event_stream<> _showFinished;
|
||||
rpl::event_stream<QString> _buttonText;
|
||||
rpl::variable<QString> _buttonText;
|
||||
|
||||
};
|
||||
|
||||
@ -1560,14 +1584,15 @@ QPointer<Ui::RpWidget> Premium::createPinnedToBottom(
|
||||
if (const auto peer = data.peer(emojiStatusData.peerId)) {
|
||||
return Info::Profile::EmojiStatusIdValue(
|
||||
peer
|
||||
) | rpl::map([](DocumentId id) {
|
||||
) | rpl::map([=](DocumentId id) {
|
||||
return id
|
||||
? tr::lng_premium_emoji_status_button()
|
||||
: tr::lng_premium_summary_user_button();
|
||||
: _buttonText.value();
|
||||
// : tr::lng_premium_summary_user_button();
|
||||
}) | rpl::flatten_latest();
|
||||
}
|
||||
}
|
||||
return _buttonText.events();
|
||||
return _buttonText.value();
|
||||
}();
|
||||
|
||||
_subscribe = CreateSubscribeButton({
|
||||
@ -1583,6 +1608,7 @@ QPointer<Ui::RpWidget> Premium::createPinnedToBottom(
|
||||
: QString();
|
||||
},
|
||||
});
|
||||
#if 0
|
||||
if (emojiStatusData) {
|
||||
// "Learn More" should open the general Premium Settings
|
||||
// so we override the button callback.
|
||||
@ -1595,6 +1621,8 @@ QPointer<Ui::RpWidget> Premium::createPinnedToBottom(
|
||||
controller->setPremiumRef(ref);
|
||||
});
|
||||
} else {
|
||||
#endif
|
||||
{
|
||||
_radioGroup->setChangedCallback([=](int value) {
|
||||
const auto options =
|
||||
_controller->session().api().premium().subscriptionOptions();
|
||||
@ -1603,7 +1631,7 @@ QPointer<Ui::RpWidget> Premium::createPinnedToBottom(
|
||||
tr::now,
|
||||
lt_cost,
|
||||
options[value].costPerMonth);
|
||||
_buttonText.fire(std::move(text));
|
||||
_buttonText = std::move(text);
|
||||
});
|
||||
_radioGroup->setValue(0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user