Show powerlevels in memberlist

This commit is contained in:
Nicolas Werner 2022-05-07 02:30:16 +02:00
parent cd07a76cd6
commit db1bcd7b5a
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
8 changed files with 74 additions and 3 deletions

View file

@ -0,0 +1 @@
<svg width="32" height="32" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M17.754 14a2.249 2.249 0 0 1 2.25 2.249v.575c0 .894-.32 1.76-.902 2.438-1.57 1.834-3.957 2.739-7.102 2.739-3.146 0-5.532-.905-7.098-2.74a3.75 3.75 0 0 1-.898-2.435v-.577a2.249 2.249 0 0 1 2.249-2.25h11.501Zm0 1.5H6.253a.749.749 0 0 0-.75.749v.577c0 .536.192 1.054.54 1.461 1.253 1.468 3.219 2.214 5.957 2.214s4.706-.746 5.962-2.214a2.25 2.25 0 0 0 .541-1.463v-.575a.749.749 0 0 0-.749-.75ZM12 2.004a5 5 0 1 1 0 10 5 5 0 0 1 0-10Zm0 1.5a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7Z" fill="#212121"/></svg>

After

Width:  |  Height:  |  Size: 601 B

View file

@ -0,0 +1 @@
<svg width="32" height="32" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 2a7 7 0 0 1 5 11.898v7.352a.75.75 0 0 1-1.093.668l-.09-.055L12 19.176l-3.816 2.687a.75.75 0 0 1-1.175-.508L7 21.25l-.002-7.352A7 7 0 0 1 12 2Zm3.5 17.805v-4.741A6.969 6.969 0 0 1 12 16c-1.275 0-2.47-.34-3.5-.936v4.74l3.067-2.159a.75.75 0 0 1 .763-.06l.1.06 3.07 2.16v-4.741 4.741ZM12 3.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11Z" fill="#212121"/></svg>

After

Width:  |  Height:  |  Size: 459 B

View file

@ -0,0 +1 @@
<svg width="32" height="32" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="m12.229 5.642.912 1.853 2.044.295c.21.03.293.288.142.435l-1.479 1.44.35 2.036a.255.255 0 0 1-.37.269L12 11.008l-1.827.962a.255.255 0 0 1-.37-.269l.35-2.035-1.48-1.44a.255.255 0 0 1 .142-.436l2.044-.295.912-1.853a.255.255 0 0 1 .458 0Z" fill="#212121"/><path d="M19 9a7 7 0 1 0-12 4.898v7.352l.008.105a.75.75 0 0 0 1.175.508l3.816-2.687 3.819 2.688.089.054a.75.75 0 0 0 1.092-.668l.002-7.352A6.977 6.977 0 0 0 19 9Zm-3.5 6.064v4.741l-3.07-2.16-.1-.06a.75.75 0 0 0-.763.06l-3.066 2.16v-4.741A6.969 6.969 0 0 0 12 16c1.275 0 2.47-.34 3.5-.936ZM6.5 9a5.5 5.5 0 1 1 11 0 5.5 5.5 0 0 1-11 0Z" fill="#212121"/></svg>

After

Width:  |  Height:  |  Size: 714 B

View file

@ -168,6 +168,41 @@ ApplicationWindow {
Layout.fillWidth: true
}
Image {
property bool isAdmin: room.permissions.changeLevel(MtxEvent.PowerLevels) <= model.powerlevel
property bool isModerator: room.permissions.redactLevel() <= model.powerlevel
//property bool isDefault: room.permissions.defaultLevel() <= model.powerlevel
property string sourceUrl: {
if (isAdmin)
return "image://colorimage/:/icons/icons/ui/ribbon_star.svg?";
else if (isModerator)
return "image://colorimage/:/icons/icons/ui/ribbon.svg?";
else
return "image://colorimage/:/icons/icons/ui/person.svg?";
}
width: 16
height: 16
sourceSize.height: height * Screen.devicePixelRatio
sourceSize.width: width * Screen.devicePixelRatio
source: sourceUrl + (ma.hovered ? Nheko.colors.highlight : Nheko.colors.buttonText)
ToolTip.visible: ma.hovered
ToolTip.text: {
if (isAdmin)
return qsTr("Administrator: %1").arg(model.powerlevel);
else if (isModerator)
return qsTr("Moderator: %1").arg(model.powerlevel);
else
return qsTr("User: %1").arg(model.powerlevel);
}
HoverHandler {
id: ma
}
}
EncryptionIndicator {
id: encryptInd

View file

@ -17,12 +17,15 @@
<file>icons/ui/end-call.svg</file>
<file>icons/ui/expanded.svg</file>
<file>icons/ui/image-failed.svg</file>
<file>icons/ui/image.svg</file>
<file>icons/ui/lowprio.svg</file>
<file>icons/ui/microphone-mute.svg</file>
<file>icons/ui/microphone-unmute.svg</file>
<file>icons/ui/music.svg</file>
<file>icons/ui/options.svg</file>
<file>icons/ui/pause-symbol.svg</file>
<file>icons/ui/people.svg</file>
<file>icons/ui/person.svg</file>
<file>icons/ui/picture-in-picture.svg</file>
<file>icons/ui/pin-off.svg</file>
<file>icons/ui/pin.svg</file>
@ -31,6 +34,8 @@
<file>icons/ui/power-off.svg</file>
<file>icons/ui/refresh.svg</file>
<file>icons/ui/reply.svg</file>
<file>icons/ui/ribbon.svg</file>
<file>icons/ui/ribbon_star.svg</file>
<file>icons/ui/round-remove-button.svg</file>
<file>icons/ui/screen-share.svg</file>
<file>icons/ui/search.svg</file>
@ -42,14 +47,12 @@
<file>icons/ui/sticky-note-solid.svg</file>
<file>icons/ui/tag.svg</file>
<file>icons/ui/user-friends-solid.svg</file>
<file>icons/ui/video-file.svg</file>
<file>icons/ui/video.svg</file>
<file>icons/ui/volume-off-indicator.svg</file>
<file>icons/ui/volume-up.svg</file>
<file>icons/ui/world.svg</file>
<file>icons/ui/music.svg</file>
<file>icons/ui/image.svg</file>
<file>icons/ui/zip.svg</file>
<file>icons/ui/video-file.svg</file>
<file>icons/emoji-categories/activity.svg</file>
<file>icons/emoji-categories/flags.svg</file>
<file>icons/emoji-categories/foods.svg</file>

View file

@ -59,6 +59,7 @@ MemberListBackend::roleNames() const
{DisplayName, "displayName"},
{AvatarUrl, "avatarUrl"},
{Trustlevel, "trustlevel"},
{Powerlevel, "powerlevel"},
};
}

View file

@ -63,6 +63,31 @@ Permissions::canSend(int eventType)
qml_mtx_events::fromRoomEventType(static_cast<qml_mtx_events::EventType>(eventType))));
}
int
Permissions::defaultLevel()
{
return pl.users_default;
}
int
Permissions::redactLevel()
{
return pl.redact;
}
int
Permissions::changeLevel(int eventType)
{
return
pl.state_level(to_string(
qml_mtx_events::fromRoomEventType(static_cast<qml_mtx_events::EventType>(eventType))));
}
int
Permissions::sendLevel(int eventType)
{
return
pl.event_level(to_string(
qml_mtx_events::fromRoomEventType(static_cast<qml_mtx_events::EventType>(eventType))));
}
bool
Permissions::canPingRoom()
{

View file

@ -25,6 +25,10 @@ public:
Q_INVOKABLE bool canRedact();
Q_INVOKABLE bool canChange(int eventType);
Q_INVOKABLE bool canSend(int eventType);
Q_INVOKABLE int defaultLevel();
Q_INVOKABLE int redactLevel();
Q_INVOKABLE int changeLevel(int eventType);
Q_INVOKABLE int sendLevel(int eventType);
Q_INVOKABLE bool canPingRoom();