Fix admin ranks in admin list
This commit is contained in:
		
							parent
							
								
									89fdd00284
								
							
						
					
					
						commit
						fe4dddea36
					
				
					 3 changed files with 41 additions and 6 deletions
				
			
		| 
						 | 
					@ -172,7 +172,7 @@ void PeerListRowWithLink::rightActionPaint(
 | 
				
			||||||
		int outerWidth,
 | 
							int outerWidth,
 | 
				
			||||||
		bool selected,
 | 
							bool selected,
 | 
				
			||||||
		bool actionSelected) {
 | 
							bool actionSelected) {
 | 
				
			||||||
	if (!_action.isEmpty() && (_actionPlaceholder.isEmpty() || selected)) {
 | 
						if (!_action.isEmpty() && ((_actionPlaceholder.isEmpty() && _adminRank.isEmpty()) || selected)) {
 | 
				
			||||||
		p.setFont(actionSelected ? st::linkOverFont : st::linkFont);
 | 
							p.setFont(actionSelected ? st::linkOverFont : st::linkFont);
 | 
				
			||||||
		p.setPen(actionSelected ? st::defaultLinkButton.overColor : st::defaultLinkButton.color);
 | 
							p.setPen(actionSelected ? st::defaultLinkButton.overColor : st::defaultLinkButton.color);
 | 
				
			||||||
		p.drawTextLeft(x, y, outerWidth, _action, _actionWidth);
 | 
							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(
 | 
					PeerListGlobalSearchController::PeerListGlobalSearchController(
 | 
				
			||||||
	not_null<Main::Session*> session)
 | 
						not_null<Main::Session*> session)
 | 
				
			||||||
: _session(session)
 | 
					: _session(session)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,6 +47,15 @@ public:
 | 
				
			||||||
	void lazyInitialize(const style::PeerListItem &st) override;
 | 
						void lazyInitialize(const style::PeerListItem &st) override;
 | 
				
			||||||
	bool hasAction() 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:
 | 
					private:
 | 
				
			||||||
	void refreshActionLink();
 | 
						void refreshActionLink();
 | 
				
			||||||
	QSize rightActionSize() const override;
 | 
						QSize rightActionSize() const override;
 | 
				
			||||||
| 
						 | 
					@ -66,6 +75,8 @@ private:
 | 
				
			||||||
	int _actionWidth = 0;
 | 
						int _actionWidth = 0;
 | 
				
			||||||
	int _actionPlaceholderWidth = 0;
 | 
						int _actionPlaceholderWidth = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						QString _adminRank;
 | 
				
			||||||
 | 
						bool _isCreator = false;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PeerListGlobalSearchController : public PeerListSearchController {
 | 
					class PeerListGlobalSearchController : public PeerListSearchController {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1917,7 +1917,7 @@ std::unique_ptr<PeerListRow> ParticipantsBoxController::createRow(
 | 
				
			||||||
		if (_additional.canEditAdmin(user) && !_additional.isCreator(user)) {
 | 
							if (_additional.canEditAdmin(user) && !_additional.isCreator(user)) {
 | 
				
			||||||
			row->setActionLink(tr::lng_profile_kick(tr::now));
 | 
								row->setActionLink(tr::lng_profile_kick(tr::now));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		row->setActionPlaceholder(channel
 | 
							row->setAdminRank(channel
 | 
				
			||||||
			? channel->adminRank(user)
 | 
								? channel->adminRank(user)
 | 
				
			||||||
			: (chat && _additional.isCreator(user))
 | 
								: (chat && _additional.isCreator(user))
 | 
				
			||||||
				? tr::lng_owner_badge(tr::now)
 | 
									? tr::lng_owner_badge(tr::now)
 | 
				
			||||||
| 
						 | 
					@ -1976,9 +1976,8 @@ void ParticipantsBoxController::recomputeTypeFor(
 | 
				
			||||||
void ParticipantsBoxController::refreshCustomStatus(
 | 
					void ParticipantsBoxController::refreshCustomStatus(
 | 
				
			||||||
		not_null<PeerListRow*> row) const {
 | 
							not_null<PeerListRow*> row) const {
 | 
				
			||||||
	const auto participant = row->peer();
 | 
						const auto participant = row->peer();
 | 
				
			||||||
	// const auto user = participant->asUser();
 | 
						/* const auto user = participant->asUser();
 | 
				
			||||||
	if (_role == Role::Admins) {
 | 
						if (_role == Role::Admins) {
 | 
				
			||||||
		/*
 | 
					 | 
				
			||||||
		Assert(user != nullptr);
 | 
							Assert(user != nullptr);
 | 
				
			||||||
		if (const auto by = _additional.adminPromotedBy(user)) {
 | 
							if (const auto by = _additional.adminPromotedBy(user)) {
 | 
				
			||||||
			row->setCustomStatus(tr::lng_channel_admin_status_promoted_by(
 | 
								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));
 | 
										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);
 | 
							const auto by = _additional.restrictedBy(participant);
 | 
				
			||||||
		row->setCustomStatus((_role == Role::Kicked
 | 
							row->setCustomStatus((_role == Role::Kicked
 | 
				
			||||||
			? tr::lng_channel_banned_status_removed_by
 | 
								? tr::lng_channel_banned_status_removed_by
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue