diff --git a/TODO.md b/TODO.md index 76795c14..039c9522 100644 --- a/TODO.md +++ b/TODO.md @@ -1,15 +1,12 @@ # TODO -- fix reply bar height - don't trust PowerLevelsEvent, may be old +- fix button layout +- improve power levels event text + +- fix reply bar height - joining new DM, not loading past events? -- HLabeledItem disabled opacity -- cancel setPowerLevel future on Cancel button click -- enter to trigger apply button -- destroy setPowerLevel future on Component.onDestruction -- warn about setting level of someone to 100 -- gray out if no permission to change -- improve event text +- fix HLabeledItem disabled opacity - save and restore status in accounts.json - mark accounts as offline when closing mirage diff --git a/src/gui/Base/PowerLevelControl.qml b/src/gui/Base/PowerLevelControl.qml index eaccbae3..f8b9f95f 100644 --- a/src/gui/Base/PowerLevelControl.qml +++ b/src/gui/Base/PowerLevelControl.qml @@ -11,9 +11,8 @@ AutoDirectionLayout { readonly property alias changed: field.changed - readonly property int level: - Math.min(maximumLevel, parseInt(field.text || "0", 10)) - + readonly property int uncappedLevel: parseInt(field.text || "0", 10) + readonly property int level: Math.min(maximumLevel, uncappedLevel) readonly property alias fieldFocused: field.activeFocus readonly property bool fieldOverMaximum: @@ -35,7 +34,7 @@ AutoDirectionLayout { horizontalAlignment: Qt.AlignHCenter validator: IntValidator { top: root.maximumLevel } inputMethodHints: Qt.ImhFormattedNumbersOnly - maximumLength: root.level < 0 ? 16 : String(root.maximumLevel).length + maximumLength: root.level < 0 ? 16 : 3 defaultText: String(root.defaultLevel) error: root.fieldOverMaximum @@ -59,7 +58,7 @@ AutoDirectionLayout { height: parent.height icon.name: "user-power-default" toolTip.text: qsTr("Limited") - checked: root.level < 50 + checked: root.uncappedLevel < 50 uncheckable: false onClicked: field.text = 0 } @@ -68,7 +67,7 @@ AutoDirectionLayout { height: parent.height icon.name: "user-power-50" toolTip.text: qsTr("Moderator") - checked: root.level >= 50 && root.level < 100 + checked: root.uncappedLevel >= 50 && root.uncappedLevel < 100 uncheckable: false onClicked: field.text = 50 } @@ -77,7 +76,7 @@ AutoDirectionLayout { height: parent.height icon.name: "user-power-100" toolTip.text: qsTr("Admin") - checked: root.level >= 100 + checked: root.uncappedLevel >= 100 uncheckable: false onClicked: field.text = 100 } diff --git a/src/gui/Pages/Chat/RoomPane/MemberView/MemberProfile.qml b/src/gui/Pages/Chat/RoomPane/MemberView/MemberProfile.qml index 4bce1a59..bca71389 100644 --- a/src/gui/Pages/Chat/RoomPane/MemberView/MemberProfile.qml +++ b/src/gui/Pages/Chat/RoomPane/MemberView/MemberProfile.qml @@ -169,6 +169,35 @@ HListView { label.text: qsTr("Power level:") label.horizontalAlignment: Qt.AlignHCenter + errorLabel.horizontalAlignment: Qt.AlignHCenter + errorLabel.text: + ! item.changed ? + "" : + + item.fieldOverMaximum && root.userId === member.id ? + qsTr("Can't set your own level higher") : + + item.fieldOverMaximum ? + qsTr("Can't set level higher than your own") : + + item.uncappedLevel === root.ownPowerLevel ? + qsTr("You won't be able to demote this user") : + + item.uncappedLevel < + root.ownPowerLevel && root.userId === member.id ? + qsTr("You won't be able to regain power") : + + "" + + errorLabel.color: + item.uncappedLevel === root.ownPowerLevel || + ( + item.uncappedLevel < + root.ownPowerLevel && root.userId === member.id + ) ? + theme.colors.warningText : + theme.colors.errorText + Layout.preferredWidth: parent.width PowerLevelControl {