mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-07 04:05:17 +00:00
Fixed display of userpic builder box on palette changes.
This commit is contained in:
@@ -58,27 +58,41 @@ not_null<Ui::RpWidget*> AddBubbleWrap(
|
||||
bubble->resize(size);
|
||||
bubble->setNaturalWidth(size.width());
|
||||
|
||||
auto cached = QImage(
|
||||
size * style::DevicePixelRatio(),
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
cached.setDevicePixelRatio(style::DevicePixelRatio());
|
||||
cached.fill(Qt::transparent);
|
||||
{
|
||||
auto p = QPainter(&cached);
|
||||
const auto innerRect = BubbleWrapInnerRect(bubble->rect());
|
||||
auto hq = PainterHighQualityEnabler(p);
|
||||
const auto radius = st::bubbleRadiusSmall;
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(st::shadowFg);
|
||||
PaintExcludeTopShadow(p, radius, innerRect);
|
||||
p.setBrush(st::boxBg);
|
||||
p.drawRoundedRect(innerRect, radius, radius);
|
||||
}
|
||||
struct State {
|
||||
QImage cached;
|
||||
};
|
||||
const auto state = bubble->lifetime().make_state<State>();
|
||||
const auto generate = [=] {
|
||||
auto cached = QImage(
|
||||
size * style::DevicePixelRatio(),
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
cached.setDevicePixelRatio(style::DevicePixelRatio());
|
||||
cached.fill(Qt::transparent);
|
||||
{
|
||||
auto p = QPainter(&cached);
|
||||
const auto innerRect = BubbleWrapInnerRect(bubble->rect());
|
||||
auto hq = PainterHighQualityEnabler(p);
|
||||
const auto radius = st::bubbleRadiusSmall;
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(st::shadowFg);
|
||||
PaintExcludeTopShadow(p, radius, innerRect);
|
||||
p.setBrush(st::boxBg);
|
||||
p.drawRoundedRect(innerRect, radius, radius);
|
||||
}
|
||||
state->cached = std::move(cached);
|
||||
};
|
||||
generate();
|
||||
|
||||
style::PaletteChanged(
|
||||
) | rpl::on_next([=] {
|
||||
generate();
|
||||
bubble->update();
|
||||
}, bubble->lifetime());
|
||||
|
||||
bubble->paintRequest(
|
||||
) | rpl::on_next([bubble, cached = std::move(cached)] {
|
||||
) | rpl::on_next([=] {
|
||||
auto p = QPainter(bubble);
|
||||
p.drawImage(0, 0, cached);
|
||||
p.drawImage(0, 0, state->cached);
|
||||
}, bubble->lifetime());
|
||||
|
||||
return bubble;
|
||||
|
||||
@@ -15,6 +15,11 @@ namespace UserpicBuilder {
|
||||
|
||||
LayerWidget::LayerWidget()
|
||||
: _corners(Ui::PrepareCornerPixmaps(st::boxRadius, st::boxDividerBg)) {
|
||||
style::PaletteChanged(
|
||||
) | rpl::on_next([=] {
|
||||
_corners = Ui::PrepareCornerPixmaps(st::boxRadius, st::boxDividerBg);
|
||||
update();
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
void LayerWidget::setContent(not_null<Ui::RpWidget*> content) {
|
||||
|
||||
@@ -31,7 +31,7 @@ protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
private:
|
||||
const Ui::CornersPixmaps _corners;
|
||||
Ui::CornersPixmaps _corners;
|
||||
Ui::RpWidget *_content;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user