Replaced heavy Qt opacity effect with FadeWrap in info profile top bar.

This commit is contained in:
23rd
2026-04-04 17:30:49 +03:00
committed by John Preston
parent ec312a1f15
commit 5d557b44e4
3 changed files with 24 additions and 31 deletions
@@ -103,7 +103,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_menu_icons.h"
#include "styles/style_settings.h"
#include <QGraphicsOpacityEffect>
#include <QtGui/QClipboard>
#include <QtGui/QGuiApplication>
@@ -326,8 +325,10 @@ TopBar::TopBar(
, _statusLabel(std::make_unique<StatusLabel>(_status.data(), _peer))
, _showLastSeen(
this,
tr::lng_status_lastseen_when(),
st::infoProfileTopBarShowLastSeen)
object_ptr<Ui::RoundButton>(
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<QColor> &edgeColor) {
: shouldOverrideTitle
? std::optional<QColor>(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<QGraphicsOpacityEffect>(
_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,
@@ -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<Ui::FlatLabel> _status;
std::unique_ptr<StatusLabel> _statusLabel;
rpl::variable<int> _statusShift = 0;
object_ptr<Ui::RoundButton> _showLastSeen = { nullptr };
object_ptr<Ui::FadeWrap<Ui::RoundButton>> _showLastSeen = { nullptr };
object_ptr<Ui::RoundButton> _forumButton = { nullptr };
QGraphicsOpacityEffect *_showLastSeenOpacity = nullptr;
std::shared_ptr<style::FlatLabel> _statusSt;
std::shared_ptr<style::InfoPeerBadge> _botVerifySt;