init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
This commit is contained in:
67
Telegram/SourceFiles/ui/new_badges.cpp
Normal file
67
Telegram/SourceFiles/ui/new_badges.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
#include "ui/new_badges.h"
|
||||
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "styles/style_window.h"
|
||||
#include "styles/style_settings.h"
|
||||
|
||||
namespace Ui::NewBadge {
|
||||
|
||||
not_null<Ui::RpWidget*> CreateNewBadge(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
rpl::producer<QString> text) {
|
||||
const auto badge = Ui::CreateChild<Ui::PaddingWrap<Ui::FlatLabel>>(
|
||||
parent.get(),
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
parent,
|
||||
std::move(text),
|
||||
st::settingsPremiumNewBadge),
|
||||
st::settingsPremiumNewBadgePadding);
|
||||
badge->show();
|
||||
badge->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
badge->paintRequest() | rpl::on_next([=] {
|
||||
auto p = QPainter(badge);
|
||||
auto hq = PainterHighQualityEnabler(p);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(st::windowBgActive);
|
||||
const auto r = st::settingsPremiumNewBadgePadding.left();
|
||||
p.drawRoundedRect(badge->rect(), r, r);
|
||||
}, badge->lifetime());
|
||||
return badge;
|
||||
}
|
||||
|
||||
void AddToRight(not_null<Ui::RpWidget*> parent) {
|
||||
const auto badge = CreateNewBadge(parent, tr::lng_bot_side_menu_new());
|
||||
|
||||
parent->sizeValue(
|
||||
) | rpl::on_next([=](QSize size) {
|
||||
badge->moveToRight(
|
||||
st::mainMenuButton.padding.right(),
|
||||
(size.height() - badge->height()) / 2,
|
||||
size.width());
|
||||
}, badge->lifetime());
|
||||
}
|
||||
|
||||
void AddAfterLabel(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
not_null<Ui::RpWidget*> label) {
|
||||
const auto badge = CreateNewBadge(
|
||||
parent,
|
||||
tr::lng_premium_summary_new_badge());
|
||||
|
||||
label->geometryValue(
|
||||
) | rpl::on_next([=](QRect geometry) {
|
||||
badge->move(st::settingsPremiumNewBadgePosition
|
||||
+ QPoint(label->x() + label->width(), label->y()));
|
||||
}, badge->lifetime());
|
||||
}
|
||||
|
||||
} // namespace Ui::NewBadge
|
||||
Reference in New Issue
Block a user