2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Take rating info url from appConfig.

This commit is contained in:
John Preston
2025-07-21 09:17:06 +04:00
parent a81b9344cf
commit 20ce2ead75
6 changed files with 23 additions and 3 deletions

View File

@@ -1878,7 +1878,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_stars_rating_tooltip" = "Profile level reflects the user's payment reliability."; "lng_stars_rating_tooltip" = "Profile level reflects the user's payment reliability.";
"lng_stars_rating_learn_more" = "Learn More"; "lng_stars_rating_learn_more" = "Learn More";
"lng_stars_rating_about_url" = "https://telegram.org/";
"lng_manage_discussion_group" = "Discussion"; "lng_manage_discussion_group" = "Discussion";
"lng_manage_discussion_group_add" = "Add a group"; "lng_manage_discussion_group_add" = "Add a group";

View File

@@ -36,12 +36,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/labels.h" #include "ui/widgets/labels.h"
#include "ui/widgets/popup_menu.h" #include "ui/widgets/popup_menu.h"
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
#include "ui/basic_click_handlers.h"
#include "ui/ui_utility.h" #include "ui/ui_utility.h"
#include "ui/painter.h" #include "ui/painter.h"
#include "base/event_filter.h" #include "base/event_filter.h"
#include "base/unixtime.h" #include "base/unixtime.h"
#include "window/window_controller.h" #include "window/window_controller.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "main/main_app_config.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "settings/settings_premium.h" #include "settings/settings_premium.h"
#include "chat_helpers/stickers_lottie.h" #include "chat_helpers/stickers_lottie.h"
@@ -669,6 +671,11 @@ Cover::Cover(
_status->widthValue() | rpl::start_with_next([=](int width) { _status->widthValue() | rpl::start_with_next([=](int width) {
rating->setMinimalAddedWidth(width); rating->setMinimalAddedWidth(width);
}, rating->lifetime()); }, rating->lifetime());
const auto session = &_peer->session();
rating->learnMoreRequests() | rpl::start_with_next([=] {
const auto &appConfig = session->appConfig();
UrlClickHandler::Open(appConfig.starsRatingLearnMoreUrl());
}, rating->lifetime());
_statusShift = rating->collapsedWidthValue(); _statusShift = rating->collapsedWidthValue();
_statusShift.changes() | rpl::start_with_next([=] { _statusShift.changes() | rpl::start_with_next([=] {
refreshStatusGeometry(width()); refreshStatusGeometry(width());

View File

@@ -232,6 +232,12 @@ QString AppConfig::ageVerifyBotUsername() const {
return get<QString>(u"verify_age_bot_username"_q, QString()); return get<QString>(u"verify_age_bot_username"_q, QString());
} }
QString AppConfig::starsRatingLearnMoreUrl() const {
return get<QString>(
u"stars_rating_learnmore_url"_q,
u"https://telegram.org/blog"_q);
}
void AppConfig::refresh(bool force) { void AppConfig::refresh(bool force) {
if (_requestId || !_api) { if (_requestId || !_api) {
if (force) { if (force) {

View File

@@ -109,6 +109,8 @@ public:
[[nodiscard]] int ageVerifyMinAge() const; [[nodiscard]] int ageVerifyMinAge() const;
[[nodiscard]] QString ageVerifyBotUsername() const; [[nodiscard]] QString ageVerifyBotUsername() const;
[[nodiscard]] QString starsRatingLearnMoreUrl() const;
void refresh(bool force = false); void refresh(bool force = false);
private: private:

View File

@@ -13,7 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/widgets/labels.h" #include "ui/widgets/labels.h"
#include "ui/widgets/tooltip.h" #include "ui/widgets/tooltip.h"
#include "ui/basic_click_handlers.h"
#include "ui/painter.h" #include "ui/painter.h"
#include "ui/rp_widget.h" #include "ui/rp_widget.h"
#include "ui/ui_utility.h" #include "ui/ui_utility.h"
@@ -213,7 +212,7 @@ void StarsRating::toggleTooltips(bool shown) {
outer.width()); outer.width());
}, widget->lifetime()); }, widget->lifetime());
button->setClickedCallback([=] { button->setClickedCallback([=] {
UrlClickHandler::Open(tr::lng_stars_rating_about_url(tr::now)); _learnMoreRequests.fire({});
}); });
} }
@@ -346,6 +345,10 @@ rpl::producer<int> StarsRating::collapsedWidthValue() const {
return _collapsedWidthValue.value(); return _collapsedWidthValue.value();
} }
rpl::producer<> StarsRating::learnMoreRequests() const {
return _learnMoreRequests.events();
}
rpl::lifetime &StarsRating::lifetime() { rpl::lifetime &StarsRating::lifetime() {
return _widget->lifetime(); return _widget->lifetime();
} }

View File

@@ -40,6 +40,7 @@ public:
void setMinimalAddedWidth(int addedWidth); void setMinimalAddedWidth(int addedWidth);
[[nodiscard]] rpl::producer<int> collapsedWidthValue() const; [[nodiscard]] rpl::producer<int> collapsedWidthValue() const;
[[nodiscard]] rpl::producer<> learnMoreRequests() const;
[[nodiscard]] rpl::lifetime &lifetime(); [[nodiscard]] rpl::lifetime &lifetime();
@@ -73,6 +74,8 @@ private:
Ui::Animations::Simple _expandedAnimation; Ui::Animations::Simple _expandedAnimation;
mutable int _activeWidth = 0; mutable int _activeWidth = 0;
rpl::event_stream<> _learnMoreRequests;
base::Timer _collapseTimer; base::Timer _collapseTimer;
}; };