mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Added line info about limits for premium boxes.
This commit is contained in:
parent
bc5c85655d
commit
52904b6d58
4 changed files with 127 additions and 0 deletions
|
@ -1658,6 +1658,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_premium_unlock_button" = "Unlock Premium Stickers";
|
||||
"lng_premium_unlock_about" = "Unlock this sticker and more by subscribing to Telegram Premium.";
|
||||
|
||||
"lng_premium" = "Premium";
|
||||
"lng_premium_free" = "Free";
|
||||
|
||||
"lng_group_about_header" = "You have created a group.";
|
||||
"lng_group_about_text" = "Groups can have:";
|
||||
"lng_group_about1" = "Up to 100,000 members";
|
||||
|
|
|
@ -1084,3 +1084,4 @@ premiumBubbleSkip: 5px;
|
|||
premiumBubbleSlideDuration: 500;
|
||||
premiumBubbleTailSize: size(21px, 7px);
|
||||
premiumBubbleFont: font(19px);
|
||||
premiumLineTextSkip: 11px;
|
||||
|
|
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/wrap/padding_wrap.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_widgets.h"
|
||||
|
||||
namespace Ui {
|
||||
|
@ -354,6 +355,120 @@ void BubbleWidget::paintEvent(QPaintEvent *e) {
|
|||
_bubble.paintBubble(p, bubbleRect, QBrush(_cachedGradient));
|
||||
}
|
||||
|
||||
class Line final : public Ui::RpWidget {
|
||||
public:
|
||||
Line(not_null<Ui::RpWidget*> parent, int max);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private:
|
||||
void recache(const QSize &s);
|
||||
|
||||
int _leftWidth = 0;
|
||||
int _rightWidth = 0;
|
||||
|
||||
QPixmap _leftPixmap;
|
||||
QPixmap _rightPixmap;
|
||||
|
||||
Ui::Text::String _leftText;
|
||||
Ui::Text::String _rightText;
|
||||
Ui::Text::String _rightLabel;
|
||||
|
||||
};
|
||||
|
||||
Line::Line(not_null<Ui::RpWidget*> parent, int max)
|
||||
: Ui::RpWidget(parent)
|
||||
, _leftText(st::defaultTextStyle, tr::lng_premium_free(tr::now))
|
||||
, _rightText(st::defaultTextStyle, tr::lng_premium(tr::now))
|
||||
, _rightLabel(st::defaultTextStyle, QString::number(max)) {
|
||||
resize(width(), st::requestsAcceptButton.height);
|
||||
|
||||
sizeValue(
|
||||
) | rpl::start_with_next([=](const QSize &s) {
|
||||
_leftWidth = (s.width() / 2);
|
||||
_rightWidth = (s.width() - _leftWidth);
|
||||
recache(s);
|
||||
update();
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
void Line::paintEvent(QPaintEvent *event) {
|
||||
Painter p(this);
|
||||
|
||||
p.drawPixmap(0, 0, _leftPixmap);
|
||||
p.drawPixmap(_leftWidth, 0, _rightPixmap);
|
||||
|
||||
p.setFont(st::normalFont);
|
||||
|
||||
const auto textPadding = st::premiumLineTextSkip;
|
||||
const auto textTop = (height() - _leftText.minHeight()) / 2;
|
||||
|
||||
p.setPen(st::windowFg);
|
||||
_leftText.drawLeft(
|
||||
p,
|
||||
textPadding,
|
||||
textTop,
|
||||
_leftWidth - textPadding,
|
||||
_leftWidth);
|
||||
|
||||
p.setPen(st::activeButtonFg);
|
||||
_rightLabel.drawRight(
|
||||
p,
|
||||
textPadding,
|
||||
textTop,
|
||||
_rightWidth - textPadding,
|
||||
width(),
|
||||
style::al_right);
|
||||
_rightText.drawLeftElided(
|
||||
p,
|
||||
_leftWidth + textPadding,
|
||||
textTop,
|
||||
_rightWidth - _rightLabel.countWidth(_rightWidth) - textPadding * 2,
|
||||
_rightWidth);
|
||||
}
|
||||
|
||||
void Line::recache(const QSize &s) {
|
||||
const auto r = QRect(0, 0, _leftWidth, s.height());
|
||||
auto pixmap = QPixmap(r.size() * style::DevicePixelRatio());
|
||||
pixmap.setDevicePixelRatio(style::DevicePixelRatio());
|
||||
pixmap.fill(Qt::transparent);
|
||||
|
||||
auto pathRound = QPainterPath();
|
||||
pathRound.addRoundedRect(r, st::buttonRadius, st::buttonRadius);
|
||||
|
||||
{
|
||||
auto leftPixmap = pixmap;
|
||||
Painter p(&leftPixmap);
|
||||
PainterHighQualityEnabler hq(p);
|
||||
auto pathRect = QPainterPath();
|
||||
auto halfRect = r;
|
||||
halfRect.setLeft(r.center().x());
|
||||
pathRect.addRect(halfRect);
|
||||
|
||||
p.fillPath(pathRound + pathRect, st::windowShadowFgFallback);
|
||||
|
||||
_leftPixmap = std::move(leftPixmap);
|
||||
}
|
||||
{
|
||||
auto rightPixmap = pixmap;
|
||||
Painter p(&rightPixmap);
|
||||
PainterHighQualityEnabler hq(p);
|
||||
auto pathRect = QPainterPath();
|
||||
auto halfRect = r;
|
||||
halfRect.setRight(r.center().x());
|
||||
pathRect.addRect(halfRect);
|
||||
|
||||
auto gradient = ComputeGradient(
|
||||
this,
|
||||
(_leftPixmap.width() / style::DevicePixelRatio()) + r.x(),
|
||||
r.width());
|
||||
p.fillPath(pathRound + pathRect, QBrush(std::move(gradient)));
|
||||
|
||||
_rightPixmap = std::move(rightPixmap);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void AddBubbleRow(
|
||||
|
@ -385,5 +500,11 @@ void AddBubbleRow(
|
|||
}, bubble->lifetime());
|
||||
}
|
||||
|
||||
void AddLimitRow(not_null<Ui::VerticalLayout*> parent, int max) {
|
||||
const auto line = parent->add(
|
||||
object_ptr<Line>(parent, max),
|
||||
st::boxRowPadding);
|
||||
}
|
||||
|
||||
} // namespace Premium
|
||||
} // namespace Ui
|
||||
|
|
|
@ -29,5 +29,7 @@ void AddBubbleRow(
|
|||
std::optional<tr::phrase<lngtag_count>> phrase,
|
||||
const style::icon *icon);
|
||||
|
||||
void AddLimitRow(not_null<Ui::VerticalLayout*> parent, int max);
|
||||
|
||||
} // namespace Premium
|
||||
} // namespace Ui
|
||||
|
|
Loading…
Add table
Reference in a new issue