diff --git a/Telegram/SourceFiles/profile/profile_block_group_members.cpp b/Telegram/SourceFiles/profile/profile_block_group_members.cpp index 936cfa7bae..0b93601187 100644 --- a/Telegram/SourceFiles/profile/profile_block_group_members.cpp +++ b/Telegram/SourceFiles/profile/profile_block_group_members.cpp @@ -44,10 +44,8 @@ GroupMembersWidget::GroupMembersWidget( QWidget *parent, not_null peer, const style::PeerListItem &st) -: PeerListWidget(parent, peer, QString(), st, tr::lng_profile_kick(tr::now)) { - _updateOnlineTimer.setSingleShot(true); - connect(&_updateOnlineTimer, SIGNAL(timeout()), this, SLOT(onUpdateOnlineDisplay())); - +: PeerListWidget(parent, peer, QString(), st, tr::lng_profile_kick(tr::now)) +, _updateOnlineTimer([=] { updateOnlineDisplay(); }) { peer->session().changes().peerUpdates( UpdateFlag::Admins | UpdateFlag::Members @@ -186,7 +184,7 @@ void GroupMembersWidget::updateItemStatusText(Item *item) { } if (_updateOnlineAt <= _now || _updateOnlineAt > member->onlineTextTill) { _updateOnlineAt = member->onlineTextTill; - _updateOnlineTimer.start((_updateOnlineAt - _now + 1) * 1000); + _updateOnlineTimer.callOnce((_updateOnlineAt - _now + 1) * 1000); } } @@ -256,7 +254,6 @@ void GroupMembersWidget::updateOnlineCount() { } if (_onlineCount != newOnlineCount) { _onlineCount = newOnlineCount; - onlineCountUpdated(_onlineCount); } } @@ -432,7 +429,7 @@ auto GroupMembersWidget::computeMember(not_null user) return it->second; } -void GroupMembersWidget::onUpdateOnlineDisplay() { +void GroupMembersWidget::updateOnlineDisplay() { if (_sortByOnline) { _now = base::unixtime::now(); diff --git a/Telegram/SourceFiles/profile/profile_block_group_members.h b/Telegram/SourceFiles/profile/profile_block_group_members.h index e7a794cef5..5420df7ff2 100644 --- a/Telegram/SourceFiles/profile/profile_block_group_members.h +++ b/Telegram/SourceFiles/profile/profile_block_group_members.h @@ -7,10 +7,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once +#include "base/timer.h" #include "profile/profile_block_peer_list.h" -#include - namespace Ui { class FlatLabel; } // namespace Ui @@ -22,7 +21,6 @@ struct PeerUpdate; namespace Profile { class GroupMembersWidget : public PeerListWidget { - Q_OBJECT public: GroupMembersWidget( @@ -36,13 +34,9 @@ public: ~GroupMembersWidget(); -Q_SIGNALS: - void onlineCountUpdated(int onlineCount); - -private Q_SLOTS: - void onUpdateOnlineDisplay(); - private: + void updateOnlineDisplay(); + // Observed notifications. void notifyPeerUpdated(const Data::PeerUpdate &update); @@ -85,7 +79,7 @@ private: int _onlineCount = 0; TimeId _updateOnlineAt = 0; - QTimer _updateOnlineTimer; + base::Timer _updateOnlineTimer; };