mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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());
|
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
|
} // namespace
|
||||||
|
|
||||||
InnerWidget::InnerWidget(
|
InnerWidget::InnerWidget(
|
||||||
|
@ -188,9 +174,9 @@ void InnerWidget::fill() {
|
||||||
line,
|
line,
|
||||||
rpl::duplicate(value) | rpl::map(valueToString),
|
rpl::duplicate(value) | rpl::map(valueToString),
|
||||||
st::channelEarnOverviewMajorLabel);
|
st::channelEarnOverviewMajorLabel);
|
||||||
const auto icon = CreateIconWidget(
|
const auto icon = Ui::CreateSingleStarWidget(
|
||||||
line,
|
line,
|
||||||
Ui::GenerateStars(majorLabel->height(), 1));
|
majorLabel->height());
|
||||||
const auto secondMinorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
const auto secondMinorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
line,
|
line,
|
||||||
std::move(
|
std::move(
|
||||||
|
@ -260,9 +246,9 @@ void InnerWidget::fill() {
|
||||||
labels,
|
labels,
|
||||||
rpl::duplicate(availableBalanceValue) | rpl::map(valueToString),
|
rpl::duplicate(availableBalanceValue) | rpl::map(valueToString),
|
||||||
st::channelEarnBalanceMajorLabel);
|
st::channelEarnBalanceMajorLabel);
|
||||||
const auto icon = CreateIconWidget(
|
const auto icon = Ui::CreateSingleStarWidget(
|
||||||
labels,
|
labels,
|
||||||
Ui::GenerateStars(majorLabel->height(), 1));
|
majorLabel->height());
|
||||||
majorLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
|
majorLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
majorLabel->sizeValue(
|
majorLabel->sizeValue(
|
||||||
) | rpl::start_with_next([=](const QSize &majorSize) {
|
) | rpl::start_with_next([=](const QSize &majorSize) {
|
||||||
|
@ -307,9 +293,9 @@ void InnerWidget::fill() {
|
||||||
input->changeLimit(v);
|
input->changeLimit(v);
|
||||||
input->setText(QString::number(v));
|
input->setText(QString::number(v));
|
||||||
}, input->lifetime());
|
}, input->lifetime());
|
||||||
const auto icon = CreateIconWidget(
|
const auto icon = Ui::CreateSingleStarWidget(
|
||||||
inputContainer,
|
inputContainer,
|
||||||
Ui::GenerateStars(st.style.font->height, 1));
|
st.style.font->height);
|
||||||
inputContainer->sizeValue(
|
inputContainer->sizeValue(
|
||||||
) | rpl::start_with_next([=](const QSize &size) {
|
) | rpl::start_with_next([=](const QSize &size) {
|
||||||
input->resize(
|
input->resize(
|
||||||
|
|
|
@ -90,6 +90,21 @@ QImage GenerateStars(int height, int count) {
|
||||||
return frame;
|
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(
|
PaintRoundImageCallback GenerateCreditsPaintUserpicCallback(
|
||||||
const Data::CreditsHistoryEntry &entry) {
|
const Data::CreditsHistoryEntry &entry) {
|
||||||
const auto bg = [&]() -> Ui::EmptyUserpic::BgColors {
|
const auto bg = [&]() -> Ui::EmptyUserpic::BgColors {
|
||||||
|
|
|
@ -13,10 +13,18 @@ namespace Data {
|
||||||
struct CreditsHistoryEntry;
|
struct CreditsHistoryEntry;
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class RpWidget;
|
||||||
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
||||||
[[nodiscard]] QImage GenerateStars(int height, int count);
|
[[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(
|
Fn<void(Painter &, int, int, int, int)> GenerateCreditsPaintUserpicCallback(
|
||||||
const Data::CreditsHistoryEntry &entry);
|
const Data::CreditsHistoryEntry &entry);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue