diff --git a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp index cfda977414..706c0b7dfa 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp @@ -369,7 +369,8 @@ void TopBar::updateCollectibleStatus() { const auto collectible = _peer->emojiStatusId().collectible; const auto colorProfile = _peer->session().api().peerColors().colorProfileFor(_peer); - _hasCollectible = collectible != nullptr; + _hasGradientBg = (collectible != nullptr) + || (colorProfile && colorProfile->bg.size() > 1); _solidBg = (colorProfile && colorProfile->bg.size() == 1) ? std::make_optional(colorProfile->bg.front()) : std::nullopt; @@ -394,7 +395,7 @@ void TopBar::updateCollectibleStatus() { update(); adjustColors(collectible ? std::optional(collectible->edgeColor) - : colorProfile + : (colorProfile && !colorProfile->bg.empty()) ? std::optional(colorProfile->bg.front()) : std::nullopt); } @@ -941,10 +942,10 @@ void TopBar::updateLabelsPosition() { void TopBar::resizeEvent(QResizeEvent *e) { _cachedClipPath = QPainterPath(); - if (_hasCollectible && !_animatedPoints.empty()) { + if (_peer->emojiStatusId().collectible && !_animatedPoints.empty()) { setupAnimatedPattern(); } - if (_hasCollectible && e->oldSize().width() != e->size().width()) { + if (_hasGradientBg && e->oldSize().width() != e->size().width()) { _cachedClipPath = QPainterPath(); _cachedGradient = QImage(); } @@ -1040,7 +1041,7 @@ void TopBar::paintEvent(QPaintEvent *e) { auto p = QPainter(this); const auto geometry = userpicGeometry(); - if (_hasCollectible && _cachedGradient.isNull()) { + if (_hasGradientBg && _cachedGradient.isNull()) { _cachedGradient = Ui::CreateTopBgGradient( QSize(width(), maximumHeight()), _peer, @@ -1050,7 +1051,7 @@ void TopBar::paintEvent(QPaintEvent *e) { ? -st::infoProfileTopBarPhotoBgShift : -st::infoProfileTopBarPhotoBgNoActionsShift)); } - if (!_hasCollectible) { + if (!_hasGradientBg) { paintEdges(p); } else { const auto x = (width() diff --git a/Telegram/SourceFiles/info/profile/info_profile_top_bar.h b/Telegram/SourceFiles/info/profile/info_profile_top_bar.h index 1a98f1941f..c40c5c739d 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_top_bar.h +++ b/Telegram/SourceFiles/info/profile/info_profile_top_bar.h @@ -200,8 +200,7 @@ private: bool _roundEdges = true; rpl::variable> _edgeColor; - bool _hasBackground = false; - bool _hasCollectible = false; + bool _hasGradientBg = false; std::optional _solidBg; QImage _cachedGradient; QPainterPath _cachedClipPath; diff --git a/Telegram/SourceFiles/ui/top_background_gradient.cpp b/Telegram/SourceFiles/ui/top_background_gradient.cpp index 159a2a2482..af54e5a96b 100644 --- a/Telegram/SourceFiles/ui/top_background_gradient.cpp +++ b/Telegram/SourceFiles/ui/top_background_gradient.cpp @@ -7,11 +7,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "ui/top_background_gradient.h" +#include "apiwrap.h" +#include "api/api_peer_colors.h" #include "data/data_emoji_statuses.h" #include "data/data_credits.h" #include "data/data_peer.h" #include "data/data_star_gift.h" #include "data/stickers/data_custom_emoji.h" +#include "main/main_session.h" #include "ui/image/image_prepare.h" #include "ui/painter.h" #include "ui/rect.h" @@ -106,9 +109,19 @@ QImage CreateTopBgGradient( collectible->edgeColor, false, offset); - } else { - return QImage(); } + if (const auto color = peer->session().api().peerColors().colorProfileFor( + peer)) { + if (color->bg.size() > 1) { + return CreateTopBgGradient( + size, + color->bg[1], + color->bg[0], + false, + offset); + } + } + return QImage(); } const std::vector &PatternBgPoints() {