Improved user perms.
This commit is contained in:
@@ -240,26 +240,28 @@ Drawer {
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
|
||||
MaterialIcon {
|
||||
Layout.preferredWidth: height
|
||||
Layout.fillHeight: true
|
||||
Label {
|
||||
visible: perm != UserType.Member
|
||||
|
||||
enabled: perm != UserType.Member
|
||||
|
||||
icon: {
|
||||
text: {
|
||||
if (perm == UserType.Owner) {
|
||||
return "Owner"
|
||||
}
|
||||
if (perm == UserType.Admin) {
|
||||
return "\ue853"
|
||||
return "Admin"
|
||||
}
|
||||
if (perm == UserType.Moderator) {
|
||||
return "\ue8e8"
|
||||
return "Mod"
|
||||
}
|
||||
if (perm == UserType.Muted) {
|
||||
return "\ue92a"
|
||||
return "Muted"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
color: MPalette.lighter
|
||||
color: perm == UserType.Muted ? MPalette.lighter : MPalette.accent
|
||||
font.pixelSize: 12
|
||||
textFormat: Text.PlainText
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,11 +84,11 @@ QVariant UserListModel::data(const QModelIndex& index, int role) const {
|
||||
auto pl = m_currentRoom->getCurrentState<RoomPowerLevelsEvent>();
|
||||
auto userPl = pl->powerLevelForUser(user->id());
|
||||
|
||||
if (userPl == pl->content().usersDefault) {
|
||||
if (userPl == pl->content().usersDefault) { // Shortcut
|
||||
return UserType::Member;
|
||||
}
|
||||
|
||||
if (userPl < pl->content().usersDefault) {
|
||||
if (userPl < pl->powerLevelForState("m.room.message")) {
|
||||
return UserType::Muted;
|
||||
}
|
||||
|
||||
@@ -105,10 +105,18 @@ QVariant UserListModel::data(const QModelIndex& index, int role) const {
|
||||
}
|
||||
|
||||
if (userPl == highestPl) {
|
||||
return UserType::Owner;
|
||||
}
|
||||
|
||||
if (userPl >= pl->powerLevelForState("m.room.power_levels")) {
|
||||
return UserType::Admin;
|
||||
}
|
||||
|
||||
return UserType::Moderator;
|
||||
if (userPl >= pl->ban() || userPl >= pl->kick() || userPl >= pl->redact()) {
|
||||
return UserType::Moderator;
|
||||
}
|
||||
|
||||
return UserType::Member;
|
||||
}
|
||||
|
||||
return {};
|
||||
|
||||
@@ -17,7 +17,8 @@ class UserType : public QObject {
|
||||
|
||||
public:
|
||||
enum Types {
|
||||
Admin = 1,
|
||||
Owner = 1,
|
||||
Admin,
|
||||
Moderator,
|
||||
Member,
|
||||
Muted,
|
||||
|
||||
Reference in New Issue
Block a user