mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Paint admin stars with different color in profile.
This commit is contained in:
parent
0d38106ed0
commit
d08dbb835f
5 changed files with 35 additions and 17 deletions
|
@ -468,7 +468,10 @@ overviewPhotoSelectOverlay: #40ace333; // shared photos / videos / links fill fo
|
|||
profileStatusFgOver: #7c99b2; // group members list in group profile user last seen text with mouse over
|
||||
profileVerifiedCheckBg: windowBgActive; // profile verified check icon background
|
||||
profileVerifiedCheckFg: windowFgActive; // profile verified check icon tick
|
||||
profileAdminStartFg: windowBgActive; // group members list admin star icon
|
||||
profileAdminStartFg: windowBgActive; // group members list creator star icon
|
||||
profileAdminStarFgOver: profileAdminStartFg; // group members list creator star icon with mouse over
|
||||
profileOtherAdminStarFg: windowSubTextFg; // group members list admin star icon
|
||||
profileOtherAdminStarFgOver: profileStatusFgOver; // group members list admin star icon with mouse over
|
||||
|
||||
// settings
|
||||
notificationsBoxMonitorFg: windowFg; // custom notifications settings box monitor color
|
||||
|
|
|
@ -132,7 +132,10 @@ profileMemberPhotoPosition: point(12px, 6px);
|
|||
profileMemberNamePosition: point(68px, 11px);
|
||||
profileMemberNameFg: windowBoldFg;
|
||||
profileMemberStatusPosition: point(68px, 31px);
|
||||
profileMemberAdminIcon: icon {{ "profile_admin_star", profileAdminStartFg, point(4px, 3px) }};
|
||||
profileMemberCreatorIcon: icon {{ "profile_admin_star", profileAdminStartFg, point(4px, 3px) }};
|
||||
profileMemberCreatorIconOver: icon {{ "profile_admin_star", profileAdminStarFgOver, point(4px, 3px) }};
|
||||
profileMemberAdminIcon: icon {{ "profile_admin_star", profileOtherAdminStarFg, point(4px, 3px) }};
|
||||
profileMemberAdminIconOver: icon {{ "profile_admin_star", profileOtherAdminStarFgOver, point(4px, 3px) }};
|
||||
profileLimitReachedLabel: FlatLabel(defaultFlatLabel) {
|
||||
width: 180px;
|
||||
margin: margins(profileMemberPaddingLeft, 9px, profileMemberPaddingLeft, 6px);
|
||||
|
|
|
@ -209,7 +209,7 @@ Ui::PopupMenu *GroupMembersWidget::fillPeerMenu(PeerData *selectedPeer) {
|
|||
for_const (auto item, items()) {
|
||||
if (item->peer == selectedPeer) {
|
||||
auto canRemoveAdmin = [item, chat, channel] {
|
||||
if (item->hasAdminStar && !item->peer->isSelf()) {
|
||||
if ((item->adminState == Item::AdminState::Admin) && !item->peer->isSelf()) {
|
||||
if (chat) {
|
||||
// Adding of admins from context menu of chat participants
|
||||
// is not supported, so the removing is also disabled.
|
||||
|
@ -222,7 +222,7 @@ Ui::PopupMenu *GroupMembersWidget::fillPeerMenu(PeerData *selectedPeer) {
|
|||
};
|
||||
if (channel) {
|
||||
if (channel->canEditAdmin(user)) {
|
||||
auto label = lang(item->hasAdminStar ? lng_context_edit_permissions : lng_context_promote_admin);
|
||||
auto label = lang((item->adminState != Item::AdminState::None) ? lng_context_edit_permissions : lng_context_promote_admin);
|
||||
result->addAction(label, base::lambda_guarded(this, [this, user] {
|
||||
editAdmin(user);
|
||||
}));
|
||||
|
@ -250,7 +250,7 @@ void GroupMembersWidget::updateItemStatusText(Item *item) {
|
|||
auto user = member->user();
|
||||
if (member->statusText.isEmpty() || (member->onlineTextTill <= _now)) {
|
||||
if (user->botInfo) {
|
||||
auto seesAllMessages = (user->botInfo->readsAllHistory || member->hasAdminStar);
|
||||
auto seesAllMessages = (user->botInfo->readsAllHistory || (member->adminState != Item::AdminState::None));
|
||||
member->statusText = lang(seesAllMessages ? lng_status_bot_reads_all : lng_status_bot_not_reads_all);
|
||||
member->onlineTextTill = _now + 86400;
|
||||
} else {
|
||||
|
@ -390,15 +390,17 @@ void GroupMembersWidget::fillChatMembers(ChatData *chat) {
|
|||
}
|
||||
|
||||
void GroupMembersWidget::setItemFlags(Item *item, ChatData *chat) {
|
||||
using AdminState = Item::AdminState;
|
||||
auto user = getMember(item)->user();
|
||||
auto isCreator = (peerFromUser(chat->creator) == item->peer->id);
|
||||
auto isAdmin = chat->admins.contains(user);
|
||||
item->hasAdminStar = isCreator || isAdmin;
|
||||
auto adminState = isCreator ? AdminState::Creator : isAdmin ? AdminState::Admin : AdminState::None;
|
||||
item->adminState = adminState;
|
||||
if (item->peer->id == AuthSession::CurrentUserPeerId()) {
|
||||
item->hasRemoveLink = false;
|
||||
} else if (chat->amCreator() || (chat->amAdmin() && !item->hasAdminStar)) {
|
||||
} else if (chat->amCreator() || (chat->amAdmin() && (adminState == AdminState::None))) {
|
||||
item->hasRemoveLink = true;
|
||||
} else if (chat->invitedByMe.contains(user) && !item->hasAdminStar) {
|
||||
} else if (chat->invitedByMe.contains(user) && (adminState == AdminState::None)) {
|
||||
item->hasRemoveLink = true;
|
||||
} else {
|
||||
item->hasRemoveLink = false;
|
||||
|
@ -462,14 +464,16 @@ bool GroupMembersWidget::addUsersToEnd(ChannelData *megagroup) {
|
|||
}
|
||||
|
||||
void GroupMembersWidget::setItemFlags(Item *item, ChannelData *megagroup) {
|
||||
auto amCreatorOrAdmin = item->peer->isSelf() && (megagroup->hasAdminRights() || megagroup->amCreator());
|
||||
using AdminState = Item::AdminState;
|
||||
auto amCreator = item->peer->isSelf() && megagroup->amCreator();
|
||||
auto amAdmin = item->peer->isSelf() && megagroup->hasAdminRights();
|
||||
auto adminIt = megagroup->mgInfo->lastAdmins.constFind(getMember(item)->user());
|
||||
auto isAdmin = (adminIt != megagroup->mgInfo->lastAdmins.cend());
|
||||
auto isCreator = megagroup->mgInfo->creator == item->peer;
|
||||
auto adminCanEdit = isAdmin && adminIt->canEdit;
|
||||
auto hasAdminStar = amCreatorOrAdmin || isAdmin || isCreator;
|
||||
if (item->hasAdminStar != hasAdminStar) {
|
||||
item->hasAdminStar = hasAdminStar;
|
||||
auto adminState = (amCreator || isCreator) ? AdminState::Creator : (amAdmin || isAdmin) ? AdminState::Admin : AdminState::None;
|
||||
if (item->adminState != adminState) {
|
||||
item->adminState = adminState;
|
||||
auto user = item->peer->asUser();
|
||||
t_assert(user != nullptr);
|
||||
if (user->botInfo) {
|
||||
|
@ -480,7 +484,7 @@ void GroupMembersWidget::setItemFlags(Item *item, ChannelData *megagroup) {
|
|||
}
|
||||
if (item->peer->isSelf()) {
|
||||
item->hasRemoveLink = false;
|
||||
} else if (megagroup->amCreator() || (megagroup->canBanMembers() && (!item->hasAdminStar || adminCanEdit))) {
|
||||
} else if (megagroup->amCreator() || megagroup->canBanMembers() && ((adminState == AdminState::None) || adminCanEdit)) {
|
||||
item->hasRemoveLink = true;
|
||||
} else {
|
||||
item->hasRemoveLink = false;
|
||||
|
|
|
@ -111,10 +111,13 @@ void PeerListWidget::paintItem(Painter &p, int x, int y, Item *item, bool select
|
|||
p.drawTextLeft(nameLeft + nameWidth - _removeWidth, nameTop, width(), _removeText, _removeWidth);
|
||||
nameWidth -= _removeWidth + skip;
|
||||
}
|
||||
if (item->hasAdminStar) {
|
||||
if (item->adminState != Item::AdminState::None) {
|
||||
nameWidth -= st::profileMemberAdminIcon.width();
|
||||
int iconLeft = nameLeft + qMin(nameWidth, item->name.maxWidth());
|
||||
st::profileMemberAdminIcon.paint(p, QPoint(iconLeft, nameTop), width());
|
||||
auto iconLeft = nameLeft + qMin(nameWidth, item->name.maxWidth());
|
||||
auto &icon = (item->adminState == Item::AdminState::Creator)
|
||||
? (selected ? st::profileMemberCreatorIconOver : st::profileMemberCreatorIcon)
|
||||
: (selected ? st::profileMemberAdminIconOver : st::profileMemberAdminIcon);
|
||||
icon.paint(p, QPoint(iconLeft, nameTop), width());
|
||||
}
|
||||
p.setPen(st::profileMemberNameFg);
|
||||
item->name.drawLeftElided(p, nameLeft, nameTop, nameWidth, width());
|
||||
|
|
|
@ -48,7 +48,12 @@ public:
|
|||
Text name;
|
||||
QString statusText;
|
||||
bool statusHasOnlineColor = false;
|
||||
bool hasAdminStar = false;
|
||||
enum class AdminState {
|
||||
None,
|
||||
Admin,
|
||||
Creator,
|
||||
};
|
||||
AdminState adminState = AdminState::None;
|
||||
bool hasRemoveLink = false;
|
||||
std::unique_ptr<Ui::RippleAnimation> ripple;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue