Add power level to the user details dialog

The only way to check a user's power level is to haul yourself over to
the member list, which is cumbersome but also hard to parse - especially
if a room has lots of members.

This adds the user's power level to the existing details dialog. For
example, this makes it easier to identify someone as a moderator if they
sent a message in the room.
This commit is contained in:
Joshua Goins
2025-02-03 20:32:36 -05:00
parent 8d33fe6221
commit 4d1c82a623
3 changed files with 21 additions and 0 deletions

View File

@@ -116,6 +116,16 @@ Kirigami.Dialog {
}
}
Kirigami.Chip {
visible: root.room
text: root.room ? QmlUtils.nameForLevel(root.room.memberEffectivePowerLevel(root.user.id)) : ""
closable: false
checkable: false
Layout.leftMargin: Kirigami.Units.largeSpacing
Layout.bottomMargin: Kirigami.Units.largeSpacing
}
Kirigami.Separator {
Layout.fillWidth: true
}

View File

@@ -48,6 +48,11 @@ QQuickItem *QmlUtils::focusedWindowItem()
}
}
QString QmlUtils::nameForLevel(const PowerLevel::Level level)
{
return PowerLevel::nameForLevel(level);
}
bool Utils::isEmoji(const QString &text)
{
#ifdef HAVE_ICU

View File

@@ -12,6 +12,8 @@
#include <Quotient/user.h>
#include "enums/powerlevel.h"
using namespace Qt::StringLiterals;
class QmlUtils : public QObject
@@ -38,6 +40,10 @@ public:
Q_INVOKABLE QString escapeString(const QString &string);
Q_INVOKABLE QColor getUserColor(qreal hueF);
Q_INVOKABLE QQuickItem *focusedWindowItem();
/**
* @brief Invokable version of PowerLevel::nameForLevel.
*/
Q_INVOKABLE QString nameForLevel(PowerLevel::Level level);
private:
QmlUtils() = default;