From 4fab6bc13dfd5bbed93fd6d124e2abed3e011079 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 9 Jun 2026 16:14:41 +0300 Subject: [PATCH] Fixed display of userpic builder box on palette changes. --- .../info/userpic/info_userpic_bubble_wrap.cpp | 50 ++++++++++++------- .../info_userpic_emoji_builder_layer.cpp | 5 ++ .../info_userpic_emoji_builder_layer.h | 2 +- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/Telegram/SourceFiles/info/userpic/info_userpic_bubble_wrap.cpp b/Telegram/SourceFiles/info/userpic/info_userpic_bubble_wrap.cpp index dfac8ec479..00065e9186 100644 --- a/Telegram/SourceFiles/info/userpic/info_userpic_bubble_wrap.cpp +++ b/Telegram/SourceFiles/info/userpic/info_userpic_bubble_wrap.cpp @@ -58,27 +58,41 @@ not_null 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(); + 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; diff --git a/Telegram/SourceFiles/info/userpic/info_userpic_emoji_builder_layer.cpp b/Telegram/SourceFiles/info/userpic/info_userpic_emoji_builder_layer.cpp index c251c7b66f..526fca10db 100644 --- a/Telegram/SourceFiles/info/userpic/info_userpic_emoji_builder_layer.cpp +++ b/Telegram/SourceFiles/info/userpic/info_userpic_emoji_builder_layer.cpp @@ -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 content) { diff --git a/Telegram/SourceFiles/info/userpic/info_userpic_emoji_builder_layer.h b/Telegram/SourceFiles/info/userpic/info_userpic_emoji_builder_layer.h index 8889982517..d07dc52ce7 100644 --- a/Telegram/SourceFiles/info/userpic/info_userpic_emoji_builder_layer.h +++ b/Telegram/SourceFiles/info/userpic/info_userpic_emoji_builder_layer.h @@ -31,7 +31,7 @@ protected: void paintEvent(QPaintEvent *e) override; private: - const Ui::CornersPixmaps _corners; + Ui::CornersPixmaps _corners; Ui::RpWidget *_content; };