diff --git a/src/libneochat/models/userlistmodel.cpp b/src/libneochat/models/userlistmodel.cpp index f530e30cb..bbe94cb71 100644 --- a/src/libneochat/models/userlistmodel.cpp +++ b/src/libneochat/models/userlistmodel.cpp @@ -93,6 +93,9 @@ QVariant UserListModel::data(const QModelIndex &index, int role) const return QVariant::fromValue(memberId); } if (role == PowerLevelRole) { + if (m_currentRoom->isCreator(memberId)) { + return std::numeric_limits::max(); + } auto plEvent = m_currentRoom->currentState().get(); if (!plEvent) { return 0; @@ -118,6 +121,9 @@ QVariant UserListModel::data(const QModelIndex &index, int role) const PowerLevel::nameForLevel(PowerLevel::levelForValue(userPl)), userPl); } + if (role == IsCreatorRole) { + return m_currentRoom->isCreator(memberId); + } return {}; } @@ -219,6 +225,7 @@ QHash UserListModel::roleNames() const roles[ObjectRole] = "user"; roles[PowerLevelRole] = "powerLevel"; roles[PowerLevelStringRole] = "powerLevelString"; + roles[IsCreatorRole] = "isCreator"; return roles; } diff --git a/src/libneochat/models/userlistmodel.h b/src/libneochat/models/userlistmodel.h index 39acd22e3..8f893e2fd 100644 --- a/src/libneochat/models/userlistmodel.h +++ b/src/libneochat/models/userlistmodel.h @@ -48,6 +48,7 @@ public: ObjectRole, /**< The QObject for the user. */ PowerLevelRole, /**< The user's power level in the current room. */ PowerLevelStringRole, /**< The name of the user's power level in the current room. */ + IsCreatorRole, /**< Whether this user is considered a creator of the current room. */ }; Q_ENUM(EventRoles) diff --git a/src/libneochat/neochatroom.h b/src/libneochat/neochatroom.h index f2d6f0149..a69e9dfae 100644 --- a/src/libneochat/neochatroom.h +++ b/src/libneochat/neochatroom.h @@ -605,7 +605,7 @@ public: * * For unusual room versions, this information might be wrong. */ - bool roomCreatorHasUltimatePowerLevel() const; + Q_INVOKABLE bool roomCreatorHasUltimatePowerLevel() const; /** * @brief Whether this user is considered a creator of this room. Only applies to post-v12 rooms. diff --git a/src/settings/Permissions.qml b/src/settings/Permissions.qml index 51c7b815a..515679891 100644 --- a/src/settings/Permissions.qml +++ b/src/settings/Permissions.qml @@ -22,6 +22,8 @@ FormCard.FormCardPage { title: i18nc('@title:window', 'Permissions') + readonly property bool loading: permissions.count === 0 && !root.room.roomCreatorHasUltimatePowerLevel() + readonly property PowerLevelModel powerLevelModel: PowerLevelModel { showMute: false } @@ -32,10 +34,11 @@ FormCard.FormCardPage { FormCard.FormHeader { title: i18nc("@title", "Privileged Users") - visible: permissions.count > 0 + visible: !root.loading } FormCard.FormCard { - visible: permissions.count > 0 + visible: !root.loading + Repeater { id: permissions model: KSortFilterProxyModel { @@ -53,6 +56,7 @@ FormCard.FormCardPage { required property string name required property int powerLevel required property string powerLevelString + required property bool isCreator text: name textItem.textFormat: Text.PlainText @@ -62,7 +66,7 @@ FormCard.FormCardPage { QQC2.Label { id: powerLevelLabel text: privilegedUserDelegate.powerLevelString - visible: !root.room.canSendState("m.room.power_levels") || (root.room.memberEffectivePowerLevel(root.room.localMember.id) <= privilegedUserDelegate.powerLevel && privilegedUserDelegate.userId != root.room.localMember.id) + visible: (!root.room.canSendState("m.room.power_levels") || (root.room.memberEffectivePowerLevel(root.room.localMember.id) <= privilegedUserDelegate.powerLevel && privilegedUserDelegate.userId != root.room.localMember.id)) || privilegedUserDelegate.isCreator color: Kirigami.Theme.disabledTextColor } QQC2.ComboBox { @@ -400,7 +404,7 @@ FormCard.FormCardPage { } Item { - visible: permissions.count === 0 + visible: root.loading Layout.fillWidth: true implicitHeight: root.height * 0.9 Kirigami.LoadingPlaceholder {