diff --git a/Telegram/Resources/icons/levels/level10_inner.svg b/Telegram/Resources/icons/levels/level10_inner.svg
new file mode 100644
index 0000000000..8ce8b2c9b2
--- /dev/null
+++ b/Telegram/Resources/icons/levels/level10_inner.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/Resources/icons/levels/level1_inner.svg b/Telegram/Resources/icons/levels/level1_inner.svg
new file mode 100644
index 0000000000..37959bcb5d
--- /dev/null
+++ b/Telegram/Resources/icons/levels/level1_inner.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/Resources/icons/levels/level20_inner.svg b/Telegram/Resources/icons/levels/level20_inner.svg
new file mode 100644
index 0000000000..055e99e5c3
--- /dev/null
+++ b/Telegram/Resources/icons/levels/level20_inner.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/Resources/icons/levels/level2_inner.svg b/Telegram/Resources/icons/levels/level2_inner.svg
new file mode 100644
index 0000000000..2cd67761cc
--- /dev/null
+++ b/Telegram/Resources/icons/levels/level2_inner.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/Resources/icons/levels/level30_inner.svg b/Telegram/Resources/icons/levels/level30_inner.svg
new file mode 100644
index 0000000000..b74a2e6efb
--- /dev/null
+++ b/Telegram/Resources/icons/levels/level30_inner.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/Resources/icons/levels/level3_inner.svg b/Telegram/Resources/icons/levels/level3_inner.svg
new file mode 100644
index 0000000000..3bc0ef3505
--- /dev/null
+++ b/Telegram/Resources/icons/levels/level3_inner.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/Resources/icons/levels/level40_inner.svg b/Telegram/Resources/icons/levels/level40_inner.svg
new file mode 100644
index 0000000000..f7fef2c167
--- /dev/null
+++ b/Telegram/Resources/icons/levels/level40_inner.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/Resources/icons/levels/level4_inner.svg b/Telegram/Resources/icons/levels/level4_inner.svg
new file mode 100644
index 0000000000..b23971ce55
--- /dev/null
+++ b/Telegram/Resources/icons/levels/level4_inner.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/Resources/icons/levels/level50_inner.svg b/Telegram/Resources/icons/levels/level50_inner.svg
new file mode 100644
index 0000000000..23aa9e3107
--- /dev/null
+++ b/Telegram/Resources/icons/levels/level50_inner.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/Resources/icons/levels/level5_inner.svg b/Telegram/Resources/icons/levels/level5_inner.svg
new file mode 100644
index 0000000000..e28cd650ab
--- /dev/null
+++ b/Telegram/Resources/icons/levels/level5_inner.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/Resources/icons/levels/level60_inner.svg b/Telegram/Resources/icons/levels/level60_inner.svg
new file mode 100644
index 0000000000..b006ec3280
--- /dev/null
+++ b/Telegram/Resources/icons/levels/level60_inner.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/Resources/icons/levels/level6_inner.svg b/Telegram/Resources/icons/levels/level6_inner.svg
new file mode 100644
index 0000000000..1b8a68d0da
--- /dev/null
+++ b/Telegram/Resources/icons/levels/level6_inner.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/Resources/icons/levels/level70_inner.svg b/Telegram/Resources/icons/levels/level70_inner.svg
new file mode 100644
index 0000000000..d6bc1b8b4a
--- /dev/null
+++ b/Telegram/Resources/icons/levels/level70_inner.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/Resources/icons/levels/level7_inner.svg b/Telegram/Resources/icons/levels/level7_inner.svg
new file mode 100644
index 0000000000..d0a0c79299
--- /dev/null
+++ b/Telegram/Resources/icons/levels/level7_inner.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/Resources/icons/levels/level80_inner.svg b/Telegram/Resources/icons/levels/level80_inner.svg
new file mode 100644
index 0000000000..a469b74988
--- /dev/null
+++ b/Telegram/Resources/icons/levels/level80_inner.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/Resources/icons/levels/level8_inner.svg b/Telegram/Resources/icons/levels/level8_inner.svg
new file mode 100644
index 0000000000..f4a0d3b7d1
--- /dev/null
+++ b/Telegram/Resources/icons/levels/level8_inner.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/Resources/icons/levels/level90_inner.svg b/Telegram/Resources/icons/levels/level90_inner.svg
new file mode 100644
index 0000000000..d25a731d93
--- /dev/null
+++ b/Telegram/Resources/icons/levels/level90_inner.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/Resources/icons/levels/level9_inner.svg b/Telegram/Resources/icons/levels/level9_inner.svg
new file mode 100644
index 0000000000..27fe8c25a2
--- /dev/null
+++ b/Telegram/Resources/icons/levels/level9_inner.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/SourceFiles/info/info.style b/Telegram/SourceFiles/info/info.style
index 6904786101..1899f02414 100644
--- a/Telegram/SourceFiles/info/info.style
+++ b/Telegram/SourceFiles/info/info.style
@@ -1191,22 +1191,6 @@ topicsLayoutButtonIconSize: 140px;
topicsLayoutButtonPadding: margins(4px, 0px, 4px, 12px);
topicsLayoutButtonSkip: 0px;
-StarsRating {
- margin: margins;
- padding: margins;
- style: TextStyle;
- activeBg: color;
- activeFg: color;
-}
-infoStarsRating: StarsRating {
- margin: margins(6px, 6px, 6px, 6px);
- padding: margins(6px, 1px, 6px, 1px);
- style: TextStyle(defaultTextStyle) {
- font: font(11px semibold);
- }
- activeBg: windowBgActive;
- activeFg: windowFgActive;
-}
infoStarsTitle: FlatLabel(defaultFlatLabel) {
minWidth: 40px;
textFg: windowBoldFg;
diff --git a/Telegram/SourceFiles/info/profile/info_levels.style b/Telegram/SourceFiles/info/profile/info_levels.style
new file mode 100644
index 0000000000..e1d38d51a8
--- /dev/null
+++ b/Telegram/SourceFiles/info/profile/info_levels.style
@@ -0,0 +1,76 @@
+/*
+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
+*/
+using "ui/basic.style";
+
+LevelShape {
+ icon: icon;
+ position: point;
+}
+levelStyle: TextStyle(defaultTextStyle) {
+ font: font(11px semibold);
+}
+levelTextFg: windowFgActive;
+levelMargin: margins(6px, 6px, 6px, 6px);
+
+levelBase: LevelShape {
+ position: point(0px, 8px);
+}
+level1: LevelShape(levelBase) {
+ icon: icon {{ "levels/level1_inner-31x31", windowBgActive }};
+}
+level2: LevelShape(levelBase) {
+ icon: icon {{ "levels/level2_inner-31x31", windowBgActive }};
+}
+level3: LevelShape(levelBase) {
+ icon: icon {{ "levels/level3_inner-31x31", windowBgActive }};
+}
+level4: LevelShape(levelBase) {
+ icon: icon {{ "levels/level4_inner-31x31", windowBgActive }};
+}
+level5: LevelShape(levelBase) {
+ icon: icon {{ "levels/level5_inner-31x31", windowBgActive }};
+}
+level6: LevelShape(levelBase) {
+ icon: icon {{ "levels/level6_inner-31x31", windowBgActive }};
+}
+level7: LevelShape(levelBase) {
+ icon: icon {{ "levels/level7_inner-31x31", windowBgActive }};
+}
+level8: LevelShape(levelBase) {
+ icon: icon {{ "levels/level8_inner-31x31", windowBgActive }};
+}
+level9: LevelShape(levelBase) {
+ icon: icon {{ "levels/level9_inner-31x31", windowBgActive }};
+}
+level10: LevelShape(levelBase) {
+ icon: icon {{ "levels/level10_inner-31x31", windowBgActive }};
+}
+level20: LevelShape(levelBase) {
+ icon: icon {{ "levels/level20_inner-31x31", windowBgActive }};
+}
+level30: LevelShape(levelBase) {
+ icon: icon {{ "levels/level30_inner-31x31", windowBgActive }};
+}
+level40: LevelShape(levelBase) {
+ icon: icon {{ "levels/level40_inner-31x31", windowBgActive }};
+}
+level50: LevelShape(levelBase) {
+ icon: icon {{ "levels/level50_inner-31x31", windowBgActive }};
+}
+level60: LevelShape(levelBase) {
+ icon: icon {{ "levels/level60_inner-31x31", windowBgActive }};
+}
+level70: LevelShape(levelBase) {
+ icon: icon {{ "levels/level70_inner-31x31", windowBgActive }};
+}
+level80: LevelShape(levelBase) {
+ icon: icon {{ "levels/level80_inner-31x31", windowBgActive }};
+}
+level90: LevelShape(levelBase) {
+ icon: icon {{ "levels/level90_inner-31x31", windowBgActive }};
+}
diff --git a/Telegram/SourceFiles/info/profile/info_profile_cover.cpp b/Telegram/SourceFiles/info/profile/info_profile_cover.cpp
index 33d4ab8dad..f4bfaa946c 100644
--- a/Telegram/SourceFiles/info/profile/info_profile_cover.cpp
+++ b/Telegram/SourceFiles/info/profile/info_profile_cover.cpp
@@ -650,7 +650,6 @@ Cover::Cover(
, _starsRating(_peer->isUser()
? std::make_unique(
this,
- st::infoStarsRating,
_controller->uiShow(),
_peer->isSelf() ? QString() : _peer->shortName(),
Data::StarsRatingValue(_peer))
@@ -669,7 +668,7 @@ Cover::Cover(
if (!_peer->isMegagroup()) {
_status->setAttribute(Qt::WA_TransparentForMouseEvents);
if (const auto rating = _starsRating.get()) {
- _statusShift = rating->collapsedWidthValue();
+ _statusShift = rating->widthValue();
_statusShift.changes() | rpl::start_with_next([=] {
refreshStatusGeometry(width());
}, _status->lifetime());
diff --git a/Telegram/SourceFiles/ui/controls/stars_rating.cpp b/Telegram/SourceFiles/ui/controls/stars_rating.cpp
index e06a91748a..b66584697e 100644
--- a/Telegram/SourceFiles/ui/controls/stars_rating.cpp
+++ b/Telegram/SourceFiles/ui/controls/stars_rating.cpp
@@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/rp_widget.h"
#include "ui/ui_utility.h"
#include "styles/style_info.h"
+#include "styles/style_info_levels.h"
#include "styles/style_layers.h"
#include "styles/style_premium.h"
#include "styles/style_settings.h"
@@ -355,16 +356,47 @@ void AboutRatingBox(
).append(' ').append(tr::lng_stars_rating_understood(tr::now))));
}
+[[nodiscard]] not_null SelectShape(int level) {
+ struct Shape {
+ int level = 0;
+ not_null shape;
+ };
+ const auto list = std::vector{
+ { 1, &st::level1 },
+ { 2, &st::level2 },
+ { 3, &st::level3 },
+ { 4, &st::level4 },
+ { 5, &st::level5 },
+ { 6, &st::level6 },
+ { 7, &st::level7 },
+ { 8, &st::level8 },
+ { 9, &st::level9 },
+ { 10, &st::level10 },
+ { 20, &st::level20 },
+ { 30, &st::level30 },
+ { 40, &st::level40 },
+ { 50, &st::level50 },
+ { 60, &st::level60 },
+ { 70, &st::level70 },
+ { 80, &st::level80 },
+ { 90, &st::level90 },
+ };
+ const auto i = ranges::lower_bound(
+ list,
+ level + 1,
+ ranges::less(),
+ &Shape::level);
+ return (i != begin(list)) ? (i - 1)->shape : list.front().shape;
+}
+
} // namespace
StarsRating::StarsRating(
QWidget *parent,
- const style::StarsRating &st,
std::shared_ptr show,
const QString &name,
rpl::producer value)
: _widget(std::make_unique(parent))
-, _st(st)
, _show(std::move(show))
, _name(name)
, _value(std::move(value)) {
@@ -388,40 +420,35 @@ void StarsRating::init() {
_show->show(Box(AboutRatingBox, _name, _value.current()));
});
- const auto added = _st.margin + _st.padding;
- const auto fontHeight = _st.style.font->height;
- const auto height = added.top() + fontHeight + added.bottom();
- _widget->resize(_widget->width(), height);
+ _widget->resize(_widget->width(), st::level1.icon.height());
_value.value() | rpl::start_with_next([=](Counters rating) {
- if (!rating) {
- _widget->resize(0, _widget->height());
- _collapsedWidthValue = 0;
- return;
- }
- updateTexts(rating);
+ updateData(rating);
}, lifetime());
}
-void StarsRating::updateTexts(Counters rating) {
- _collapsedText.setText(
- _st.style,
- Lang::FormatCountDecimal(rating.level));
-
- const auto added = _st.padding;
- const auto add = added.left() + added.right();
- const auto height = _widget->height();
- _collapsedWidthValue = _st.margin.right()
- + std::max(
- add + _collapsedText.maxWidth(),
- height - _st.margin.top() - _st.margin.bottom());
+void StarsRating::updateData(Data::StarsRating rating) {
+ if (!rating) {
+ _shape = nullptr;
+ _widthValue = 0;
+ } else {
+ _shape = SelectShape(rating.level);
+ _collapsedText.setText(
+ st::levelStyle,
+ Lang::FormatCountDecimal(rating.level));
+ _widthValue = _shape->icon.width() - st::levelMargin.left();
+ }
updateWidth();
}
void StarsRating::updateWidth() {
- const auto widthToRight = _collapsedWidthValue.current();
- _widget->resize(_st.margin.left() + widthToRight, _widget->height());
- _widget->update();
+ if (const auto widthToRight = _widthValue.current()) {
+ const auto &margin = st::levelMargin;
+ _widget->resize(margin.left() + widthToRight, _widget->height());
+ _widget->update();
+ } else {
+ _widget->resize(0, _widget->height());
+ }
}
void StarsRating::raise() {
@@ -429,32 +456,25 @@ void StarsRating::raise() {
}
void StarsRating::moveTo(int x, int y) {
- _widget->move(x - _st.margin.left(), y - _st.margin.top());
+ _widget->move(x - st::levelMargin.left(), y - st::levelMargin.top());
}
void StarsRating::paint(QPainter &p) {
- const auto outer = _widget->rect().marginsRemoved(_st.margin);
- if (outer.isEmpty()) {
+ if (!_shape) {
return;
}
- const auto inner = outer.marginsRemoved(_st.padding);
+ _shape->icon.paint(p, 0, 0, _widget->width());
- auto hq = PainterHighQualityEnabler(p);
- p.setPen(Qt::NoPen);
- p.setBrush(_st.activeBg);
-
- const auto radius = outer.height() / 2.;
- p.drawRoundedRect(outer, radius, radius);
- p.setPen(_st.activeFg);
- const auto skip = (inner.width() - _collapsedText.maxWidth()) / 2;
+ const auto x = (_widget->width() - _collapsedText.maxWidth()) / 2;
+ p.setPen(st::levelTextFg);
_collapsedText.draw(p, {
- .position = inner.topLeft() + QPoint(skip, 0),
+ .position = QPoint(x, 0) + _shape->position,
.availableWidth = _collapsedText.maxWidth(),
});
}
-rpl::producer StarsRating::collapsedWidthValue() const {
- return _collapsedWidthValue.value();
+rpl::producer StarsRating::widthValue() const {
+ return _widthValue.value();
}
rpl::lifetime &StarsRating::lifetime() {
diff --git a/Telegram/SourceFiles/ui/controls/stars_rating.h b/Telegram/SourceFiles/ui/controls/stars_rating.h
index b72f061d8f..4393c81e5f 100644
--- a/Telegram/SourceFiles/ui/controls/stars_rating.h
+++ b/Telegram/SourceFiles/ui/controls/stars_rating.h
@@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace style {
struct Toast;
-struct StarsRating;
+struct LevelShape;
} // namespace style
namespace Ui::Toast {
@@ -30,7 +30,6 @@ class StarsRating final {
public:
StarsRating(
QWidget *parent,
- const style::StarsRating &st,
std::shared_ptr show,
const QString &name,
rpl::producer value);
@@ -39,25 +38,25 @@ public:
void raise();
void moveTo(int x, int y);
- [[nodiscard]] rpl::producer collapsedWidthValue() const;
+ [[nodiscard]] rpl::producer widthValue() const;
[[nodiscard]] rpl::lifetime &lifetime();
private:
void init();
void paint(QPainter &p);
- void updateTexts(Data::StarsRating rating);
+ void updateData(Data::StarsRating rating);
void updateWidth();
const std::unique_ptr _widget;
- const style::StarsRating &_st;
const std::shared_ptr _show;
const QString _name;
Ui::Text::String _collapsedText;
rpl::variable _value;
- rpl::variable _collapsedWidthValue;
+ rpl::variable _widthValue;
+ const style::LevelShape *_shape = nullptr;
};
diff --git a/Telegram/cmake/td_ui.cmake b/Telegram/cmake/td_ui.cmake
index 6c2473e35c..25d13f8750 100644
--- a/Telegram/cmake/td_ui.cmake
+++ b/Telegram/cmake/td_ui.cmake
@@ -27,6 +27,7 @@ set(style_files
info/info.style
info/channel_statistics/boosts/giveaway/giveaway.style
info/channel_statistics/earn/channel_earn.style
+ info/profile/info_levels.style
info/userpic/info_userpic_builder.style
intro/intro.style
iv/iv.style