diff --git a/Telegram/SourceFiles/info/profile/info_profile_status_label.cpp b/Telegram/SourceFiles/info/profile/info_profile_status_label.cpp index a8474ae5da..14bc72c86f 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_status_label.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_status_label.cpp @@ -140,6 +140,10 @@ void StatusLabel::setMembersLinkCallback(Fn callback) { _membersLinkCallback = std::move(callback); } +Fn StatusLabel::membersLinkCallback() const { + return _membersLinkCallback; +} + void StatusLabel::setColorized(bool enabled) { _colorized = enabled; refresh(); diff --git a/Telegram/SourceFiles/info/profile/info_profile_status_label.h b/Telegram/SourceFiles/info/profile/info_profile_status_label.h index d95cd0d2f5..90741424dc 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_status_label.h +++ b/Telegram/SourceFiles/info/profile/info_profile_status_label.h @@ -23,6 +23,7 @@ public: void refresh(); void setMembersLinkCallback(Fn callback); + [[nodiscard]] Fn membersLinkCallback() const; void setOnlineCount(int count); void setColorized(bool enabled); diff --git a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp index 818bc42b86..498b02e645 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp @@ -246,12 +246,7 @@ TopBar::TopBar( ? [=] { return _peer->owner().pendingStarsRating(); } : Fn())) : nullptr) -, _status( - this, - QString(), - _peer->isMegagroup() - ? st::infoProfileMegagroupCover.status - : st::infoProfileCover.status) +, _status(this, QString(), statusStyle()) , _statusLabel(std::make_unique(_status.data(), _peer)) , _showLastSeen( this, @@ -371,10 +366,34 @@ void TopBar::adjustColors(const std::optional &edgeColor) { _title->setTextColorOverride(shouldOverrideTitle ? std::optional(st::groupCallMembersFg->c) : std::nullopt); - _status->setTextColorOverride(shouldOverrideStatus - ? std::optional(st::groupCallVideoSubTextFg->c) - : std::nullopt); - _statusLabel->setColorized(!shouldOverrideStatus); + { + const auto statusPosition = _status->pos(); + const auto membersLinkCallback = _statusLabel->membersLinkCallback(); + { + _statusLabel = nullptr; + delete _status.release(); + } + if (shouldOverrideStatus) { + const auto copySt = [&](const style::FlatLabel &st) { + auto result = std::make_unique( + base::duplicate(st)); + result->palette.linkFg = st::groupCallVideoSubTextFg; + return result; + }; + _statusSt = copySt(statusStyle()); + _status.create(this, QString(), *(_statusSt.get())); + } else { + _status.create(this, QString(), statusStyle()); + } + _status->moveToLeft(statusPosition.x(), statusPosition.y()); + _status->show(); + _statusLabel = std::make_unique(_status.data(), _peer); + _statusLabel->setMembersLinkCallback(membersLinkCallback); + _status->setTextColorOverride(shouldOverrideStatus + ? std::optional(st::groupCallVideoSubTextFg->c) + : std::nullopt); + _statusLabel->setColorized(!shouldOverrideStatus); + } const auto shouldOverrideBadges = shouldOverride( st::infoBotVerifyBadge.premiumFg); @@ -1983,4 +2002,10 @@ rpl::producer> TopBar::edgeColor() const { return _edgeColor.value(); } +const style::FlatLabel &TopBar::statusStyle() const { + return _peer->isMegagroup() + ? st::infoProfileMegagroupCover.status + : st::infoProfileCover.status; +} + } // namespace Info::Profile diff --git a/Telegram/SourceFiles/info/profile/info_profile_top_bar.h b/Telegram/SourceFiles/info/profile/info_profile_top_bar.h index baecc3dfe2..61825a846d 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_top_bar.h +++ b/Telegram/SourceFiles/info/profile/info_profile_top_bar.h @@ -45,6 +45,7 @@ class Timer; namespace style { struct InfoTopBar; struct InfoPeerBadge; +struct FlatLabel; } //namespace style class QGraphicsOpacityEffect; @@ -171,6 +172,7 @@ private: void setupStoryOutline(const QRect &geometry = QRect()); void updateStoryOutline(std::optional edgeColor); void paintStoryOutline(QPainter &p, const QRect &geometry); + [[nodiscard]] const style::FlatLabel &statusStyle() const; const not_null _peer; Data::ForumTopic *_topic = nullptr; @@ -198,6 +200,7 @@ private: object_ptr _showLastSeen = { nullptr }; QGraphicsOpacityEffect *_showLastSeenOpacity = nullptr; + std::shared_ptr _statusSt; std::shared_ptr _botVerifySt; std::shared_ptr _badgeSt; std::shared_ptr _verifiedSt;