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