Moved out creation of lottie icon in circle to single place.

This commit is contained in:
23rd
2025-12-22 11:03:57 +03:00
committed by John Preston
parent 590421daaa
commit f468666973
3 changed files with 38 additions and 24 deletions

View File

@@ -327,4 +327,31 @@ SliderWithLabel MakeSliderWithLabel(
};
}
void AddLottieIconWithCircle(
not_null<Ui::VerticalLayout*> layout,
object_ptr<Ui::RpWidget> icon,
QMargins iconPadding,
QSize circleSize) {
const auto iconRow = layout->add(
std::move(icon),
iconPadding,
style::al_top);
const auto circle = Ui::CreateChild<Ui::RpWidget>(
iconRow->parentWidget());
circle->lower();
circle->paintOn([=](QPainter &p) {
auto hq = PainterHighQualityEnabler(p);
const auto left = (circle->width() - circleSize.width()) / 2;
const auto top = (circle->height() - circleSize.height()) / 2;
p.setPen(Qt::NoPen);
p.setBrush(st::activeButtonBg);
p.drawEllipse(QRect(QPoint(left, top), circleSize));
});
iconRow->geometryValue() | rpl::on_next([=](const QRect &g) {
circle->setGeometry(g);
}, circle->lifetime());
}
} // namespace Settings

View File

@@ -220,4 +220,10 @@ struct SliderWithLabel {
int minLabelWidth = 0,
bool ignoreWheel = false);
void AddLottieIconWithCircle(
not_null<Ui::VerticalLayout*>,
object_ptr<Ui::RpWidget> icon,
QMargins iconPadding,
QSize circleSize);
} // namespace Settings

View File

@@ -133,30 +133,11 @@ void ShowOrPremiumBox(
- Size(st::showOrTitleIconMargin * 2),
},
{ 0, st::showOrTitleIconMargin, 0, st::showOrTitleIconMargin });
{
const auto iconRow = box->addRow(
std::move(icon.widget),
st::settingsBlockedListIconPadding,
style::al_top);
const auto circle = Ui::CreateChild<Ui::RpWidget>(
iconRow->parentWidget());
circle->lower();
circle->paintRequest() | rpl::on_next([=] {
auto p = QPainter(circle);
auto hq = PainterHighQualityEnabler(p);
const auto size = st::normalBoxLottieSize;
const auto left = (circle->width() - size.width()) / 2;
const auto top = (circle->height() - size.height()) / 2;
p.setPen(Qt::NoPen);
p.setBrush(st::activeButtonBg);
p.drawEllipse(QRect(QPoint(left, top), size));
}, circle->lifetime());
iconRow->geometryValue() | rpl::on_next([=](const QRect &g) {
circle->setGeometry(g);
}, circle->lifetime());
}
Settings::AddLottieIconWithCircle(
box->verticalLayout(),
std::move(icon.widget),
st::settingsBlockedListIconPadding,
st::normalBoxLottieSize);
Ui::AddSkip(box->verticalLayout());
box->addRow(
object_ptr<FlatLabel>(