diff --git a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp index ba6f2fdc66..be55f17a7f 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp @@ -103,7 +103,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_menu_icons.h" #include "styles/style_settings.h" -#include #include #include @@ -326,8 +325,10 @@ TopBar::TopBar( , _statusLabel(std::make_unique(_status.data(), _peer)) , _showLastSeen( this, - tr::lng_status_lastseen_when(), - st::infoProfileTopBarShowLastSeen) + object_ptr( + this, + tr::lng_status_lastseen_when(), + st::infoProfileTopBarShowLastSeen)) , _forumButton([&, controller = descriptor.controller] { const auto topic = _key.topic(); if (!topic) { @@ -511,14 +512,14 @@ void TopBar::adjustColors(const std::optional &edgeColor) { : shouldOverrideTitle ? std::optional(st::groupCallMembersFg->c) : std::nullopt); - if (!_showLastSeen->isHidden()) { + if (_showLastSeen->toggled()) { if (shouldOverrideTitle) { const auto st = mapActionStyle(edgeColor); - _showLastSeen->setBrushOverride(st.bgColor); - _showLastSeen->setTextFgOverride(st.fgColor); + _showLastSeen->entity()->setBrushOverride(st.bgColor); + _showLastSeen->entity()->setTextFgOverride(st.fgColor); } else { - _showLastSeen->setBrushOverride(std::nullopt); - _showLastSeen->setTextFgOverride(std::nullopt); + _showLastSeen->entity()->setBrushOverride(std::nullopt); + _showLastSeen->entity()->setTextFgOverride(std::nullopt); } } { @@ -1677,7 +1678,7 @@ void TopBar::updateStatusPosition(float64 progressCurrent) { _status->hide(); // _starsRating->hide(); - _showLastSeen->hide(); + _showLastSeen->hide(anim::type::instant); return; } @@ -1687,7 +1688,7 @@ void TopBar::updateStatusPosition(float64 progressCurrent) { progressCurrent); const auto totalElementsWidth = _status->width() + (_starsRating ? _starsRating->width() : 0) - + (!_showLastSeen->isHidden() ? _showLastSeen->width() : 0); + + (_showLastSeen->toggled() ? _showLastSeen->width() : 0); const auto statusLeft = anim::interpolate( statusMostLeft(), (width() - totalElementsWidth) / 2, @@ -1702,17 +1703,15 @@ void TopBar::updateStatusPosition(float64 progressCurrent) { _status->moveToLeft(statusLeft + statusShift, statusTop); - if (!_showLastSeen->isHidden()) { + if (_showLastSeen->toggled()) { _showLastSeen->moveToLeft( statusLeft + statusShift + _status->textMaxWidth() + st::infoProfileTopBarLastSeenSkip.x(), statusTop + st::infoProfileTopBarLastSeenSkip.y()); - if (_showLastSeenOpacity) { - _showLastSeenOpacity->setOpacity(progressCurrent); - } - _showLastSeen->setAttribute( + _showLastSeen->setOpacity(progressCurrent); + _showLastSeen->entity()->setAttribute( Qt::WA_TransparentForMouseEvents, !progressCurrent); } @@ -2092,7 +2091,7 @@ void TopBar::setupShowLastSeen( || user->isBot() || user->isServiceUser() || !user->session().premiumPossible()) { - _showLastSeen->hide(); + _showLastSeen->hide(anim::type::instant); return; } @@ -2100,7 +2099,7 @@ void TopBar::setupShowLastSeen( if (user->lastseen().isHiddenByMe()) { user->updateFullForced(); } - _showLastSeen->hide(); + _showLastSeen->hide(anim::type::instant); return; } @@ -2110,13 +2109,13 @@ void TopBar::setupShowLastSeen( Data::PeerUpdate::Flag::OnlineStatus), Data::AmPremiumValue(&user->session()) ) | rpl::on_next([=](auto, bool premium) { - const auto wasShown = !_showLastSeen->isHidden(); + const auto wasShown = _showLastSeen->toggled(); const auto hiddenByMe = user->lastseen().isHiddenByMe(); const auto shown = hiddenByMe && !user->lastseen().isOnline(base::unixtime::now()) && !premium && user->session().premiumPossible(); - _showLastSeen->setVisible(shown); + _showLastSeen->toggle(shown, anim::type::instant); if (wasShown && premium && hiddenByMe) { user->updateFullForced(); } @@ -2132,16 +2131,13 @@ void TopBar::setupShowLastSeen( } }, _showLastSeen->lifetime()); - _showLastSeenOpacity = Ui::CreateChild( - _showLastSeen.get()); - _showLastSeen->setGraphicsEffect(_showLastSeenOpacity); - _showLastSeenOpacity->setOpacity(0.); + _showLastSeen->setOpacity(0.); using TextTransform = Ui::RoundButton::TextTransform; - _showLastSeen->setTextTransform(TextTransform::NoTransform); - _showLastSeen->setFullRadius(true); + _showLastSeen->entity()->setTextTransform(TextTransform::NoTransform); + _showLastSeen->entity()->setFullRadius(true); - _showLastSeen->setClickedCallback([=] { + _showLastSeen->entity()->setClickedCallback([=] { const auto type = Ui::ShowOrPremium::LastSeen; controller->show(Box( Ui::ShowOrPremiumBox, diff --git a/Telegram/SourceFiles/info/profile/info_profile_top_bar.h b/Telegram/SourceFiles/info/profile/info_profile_top_bar.h index 201f90e675..9139387242 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_top_bar.h +++ b/Telegram/SourceFiles/info/profile/info_profile_top_bar.h @@ -52,8 +52,6 @@ struct InfoPeerBadge; struct FlatLabel; } //namespace style -class QGraphicsOpacityEffect; - namespace Ui { class FlatLabel; class IconButton; @@ -223,9 +221,8 @@ private: object_ptr _status; std::unique_ptr _statusLabel; rpl::variable _statusShift = 0; - object_ptr _showLastSeen = { nullptr }; + object_ptr> _showLastSeen = { nullptr }; object_ptr _forumButton = { nullptr }; - QGraphicsOpacityEffect *_showLastSeenOpacity = nullptr; std::shared_ptr _statusSt; std::shared_ptr _botVerifySt; diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 68fe8040bf..b76a4f4a59 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 68fe8040bf29b4c477069c80c99b4859e874c6e0 +Subproject commit b76a4f4a59c5a1c635aa455361aef8075ceeec4b