mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
Moved out util for wrapping credits icon to widget.
This commit is contained in:
parent
b15f5f8596
commit
68bf6f991c
3 changed files with 29 additions and 20 deletions
|
@ -70,20 +70,6 @@ void AddHeader(
|
|||
header->resizeToWidth(header->width());
|
||||
}
|
||||
|
||||
[[nodiscard]] not_null<Ui::RpWidget*> CreateIconWidget(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
QImage image) {
|
||||
const auto widget = Ui::CreateChild<Ui::RpWidget>(parent);
|
||||
widget->resize(image.size() / style::DevicePixelRatio());
|
||||
widget->paintRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
auto p = QPainter(widget);
|
||||
p.drawImage(0, 0, image);
|
||||
}, widget->lifetime());
|
||||
widget->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
return widget;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
InnerWidget::InnerWidget(
|
||||
|
@ -188,9 +174,9 @@ void InnerWidget::fill() {
|
|||
line,
|
||||
rpl::duplicate(value) | rpl::map(valueToString),
|
||||
st::channelEarnOverviewMajorLabel);
|
||||
const auto icon = CreateIconWidget(
|
||||
const auto icon = Ui::CreateSingleStarWidget(
|
||||
line,
|
||||
Ui::GenerateStars(majorLabel->height(), 1));
|
||||
majorLabel->height());
|
||||
const auto secondMinorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||
line,
|
||||
std::move(
|
||||
|
@ -260,9 +246,9 @@ void InnerWidget::fill() {
|
|||
labels,
|
||||
rpl::duplicate(availableBalanceValue) | rpl::map(valueToString),
|
||||
st::channelEarnBalanceMajorLabel);
|
||||
const auto icon = CreateIconWidget(
|
||||
const auto icon = Ui::CreateSingleStarWidget(
|
||||
labels,
|
||||
Ui::GenerateStars(majorLabel->height(), 1));
|
||||
majorLabel->height());
|
||||
majorLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
majorLabel->sizeValue(
|
||||
) | rpl::start_with_next([=](const QSize &majorSize) {
|
||||
|
@ -307,9 +293,9 @@ void InnerWidget::fill() {
|
|||
input->changeLimit(v);
|
||||
input->setText(QString::number(v));
|
||||
}, input->lifetime());
|
||||
const auto icon = CreateIconWidget(
|
||||
const auto icon = Ui::CreateSingleStarWidget(
|
||||
inputContainer,
|
||||
Ui::GenerateStars(st.style.font->height, 1));
|
||||
st.style.font->height);
|
||||
inputContainer->sizeValue(
|
||||
) | rpl::start_with_next([=](const QSize &size) {
|
||||
input->resize(
|
||||
|
|
|
@ -90,6 +90,21 @@ QImage GenerateStars(int height, int count) {
|
|||
return frame;
|
||||
}
|
||||
|
||||
not_null<Ui::RpWidget*> CreateSingleStarWidget(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
int height) {
|
||||
const auto widget = Ui::CreateChild<Ui::RpWidget>(parent);
|
||||
const auto image = GenerateStars(height, 1);
|
||||
widget->resize(image.size() / style::DevicePixelRatio());
|
||||
widget->paintRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
auto p = QPainter(widget);
|
||||
p.drawImage(0, 0, image);
|
||||
}, widget->lifetime());
|
||||
widget->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
return widget;
|
||||
}
|
||||
|
||||
PaintRoundImageCallback GenerateCreditsPaintUserpicCallback(
|
||||
const Data::CreditsHistoryEntry &entry) {
|
||||
const auto bg = [&]() -> Ui::EmptyUserpic::BgColors {
|
||||
|
|
|
@ -13,10 +13,18 @@ namespace Data {
|
|||
struct CreditsHistoryEntry;
|
||||
} // namespace Data
|
||||
|
||||
namespace Ui {
|
||||
class RpWidget;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Ui {
|
||||
|
||||
[[nodiscard]] QImage GenerateStars(int height, int count);
|
||||
|
||||
[[nodiscard]] not_null<Ui::RpWidget*> CreateSingleStarWidget(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
int height);
|
||||
|
||||
Fn<void(Painter &, int, int, int, int)> GenerateCreditsPaintUserpicCallback(
|
||||
const Data::CreditsHistoryEntry &entry);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue