summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-05-07 02:30:16 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2022-05-07 02:30:16 +0200
commitdb1bcd7b5aec3c3c814083b6d98020508f98ed13 (patch)
tree56e28e3cfbc6763a1f26f8debd4bfe33b8e3b34e
parentMerge branch 'TheDrawingCoder-Gamer-master' (diff)
downloadnheko-db1bcd7b5aec3c3c814083b6d98020508f98ed13.tar.xz
Show powerlevels in memberlist
-rw-r--r--resources/icons/ui/person.svg1
-rw-r--r--resources/icons/ui/ribbon.svg1
-rw-r--r--resources/icons/ui/ribbon_star.svg1
-rw-r--r--resources/qml/dialogs/RoomMembers.qml35
-rw-r--r--resources/res.qrc9
-rw-r--r--src/MemberList.cpp1
-rw-r--r--src/timeline/Permissions.cpp25
-rw-r--r--src/timeline/Permissions.h4
8 files changed, 74 insertions, 3 deletions
diff --git a/resources/icons/ui/person.svg b/resources/icons/ui/person.svg
new file mode 100644

index 00000000..a9eb62ad --- /dev/null +++ b/resources/icons/ui/person.svg
@@ -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> diff --git a/resources/icons/ui/ribbon.svg b/resources/icons/ui/ribbon.svg new file mode 100644
index 00000000..5026f571 --- /dev/null +++ b/resources/icons/ui/ribbon.svg
@@ -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> diff --git a/resources/icons/ui/ribbon_star.svg b/resources/icons/ui/ribbon_star.svg new file mode 100644
index 00000000..3b6603bc --- /dev/null +++ b/resources/icons/ui/ribbon_star.svg
@@ -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> diff --git a/resources/qml/dialogs/RoomMembers.qml b/resources/qml/dialogs/RoomMembers.qml
index 8a12e5bc..608a5acf 100644 --- a/resources/qml/dialogs/RoomMembers.qml +++ b/resources/qml/dialogs/RoomMembers.qml
@@ -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 diff --git a/resources/res.qrc b/resources/res.qrc
index 3ce63f42..35b06704 100644 --- a/resources/res.qrc +++ b/resources/res.qrc
@@ -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> diff --git a/src/MemberList.cpp b/src/MemberList.cpp
index fcd9d624..ff1b1a79 100644 --- a/src/MemberList.cpp +++ b/src/MemberList.cpp
@@ -59,6 +59,7 @@ MemberListBackend::roleNames() const {DisplayName, "displayName"}, {AvatarUrl, "avatarUrl"}, {Trustlevel, "trustlevel"}, + {Powerlevel, "powerlevel"}, }; } diff --git a/src/timeline/Permissions.cpp b/src/timeline/Permissions.cpp
index 917495a2..01d38599 100644 --- a/src/timeline/Permissions.cpp +++ b/src/timeline/Permissions.cpp
@@ -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() { diff --git a/src/timeline/Permissions.h b/src/timeline/Permissions.h
index c0b47b37..1285f01d 100644 --- a/src/timeline/Permissions.h +++ b/src/timeline/Permissions.h
@@ -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();