diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp index bb8fc79eb..57a1dcf89 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp @@ -172,7 +172,7 @@ void PeerListRowWithLink::rightActionPaint( int outerWidth, bool selected, bool actionSelected) { - if (!_action.isEmpty() && (_actionPlaceholder.isEmpty() || selected)) { + if (!_action.isEmpty() && ((_actionPlaceholder.isEmpty() && _adminRank.isEmpty()) || selected)) { p.setFont(actionSelected ? st::linkOverFont : st::linkFont); p.setPen(actionSelected ? st::defaultLinkButton.overColor : st::defaultLinkButton.color); p.drawTextLeft(x, y, outerWidth, _action, _actionWidth); @@ -187,6 +187,32 @@ void PeerListRowWithLink::rightActionPaint( } } +void PeerListRowWithLink::setAdminRank(const QString &rank, bool isCreator) { + _adminRank = rank; + _isCreator = isCreator; +} + +int PeerListRowWithLink::adminRankWidth() const { + return st::normalFont->width(_adminRank); +} + +void PeerListRowWithLink::paintAdminRank( + Painter &p, + int x, + int y, + int outerWidth, + bool selected) { + if (hasAction() && selected) { + return; + } + p.setPen(_isCreator + ? st::defaultPeerListItem.statusFgActive + : selected + ? st::defaultPeerListItem.statusFgOver + : st::defaultPeerListItem.statusFg); + p.drawTextLeft(x, y, outerWidth, _adminRank, adminRankWidth()); +} + PeerListGlobalSearchController::PeerListGlobalSearchController( not_null session) : _session(session) diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.h b/Telegram/SourceFiles/boxes/peer_list_controllers.h index 8f708f272..b6e89a577 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.h +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.h @@ -47,6 +47,15 @@ public: void lazyInitialize(const style::PeerListItem &st) override; bool hasAction() override; + void setAdminRank(const QString &rank, bool isCreator = false); + int adminRankWidth() const override; + void paintAdminRank( + Painter &p, + int x, + int y, + int outerWidth, + bool selected) override; + private: void refreshActionLink(); QSize rightActionSize() const override; @@ -66,6 +75,8 @@ private: int _actionWidth = 0; int _actionPlaceholderWidth = 0; + QString _adminRank; + bool _isCreator = false; }; class PeerListGlobalSearchController : public PeerListSearchController { diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index 3b4977b2d..4e37e711a 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -1917,7 +1917,7 @@ std::unique_ptr ParticipantsBoxController::createRow( if (_additional.canEditAdmin(user) && !_additional.isCreator(user)) { row->setActionLink(tr::lng_profile_kick(tr::now)); } - row->setActionPlaceholder(channel + row->setAdminRank(channel ? channel->adminRank(user) : (chat && _additional.isCreator(user)) ? tr::lng_owner_badge(tr::now) @@ -1976,9 +1976,8 @@ void ParticipantsBoxController::recomputeTypeFor( void ParticipantsBoxController::refreshCustomStatus( not_null row) const { const auto participant = row->peer(); - // const auto user = participant->asUser(); + /* const auto user = participant->asUser(); if (_role == Role::Admins) { - /* Assert(user != nullptr); if (const auto by = _additional.adminPromotedBy(user)) { row->setCustomStatus(tr::lng_channel_admin_status_promoted_by( @@ -1994,8 +1993,7 @@ void ParticipantsBoxController::refreshCustomStatus( tr::lng_channel_admin_status_not_admin(tr::now)); } } - */ - } else if (_role == Role::Kicked || _role == Role::Restricted) { + } else */if (_role == Role::Kicked || _role == Role::Restricted) { const auto by = _additional.restrictedBy(participant); row->setCustomStatus((_role == Role::Kicked ? tr::lng_channel_banned_status_removed_by