PowerLevelControl: add error and warning texts

This commit is contained in:
miruka 2020-07-13 19:21:50 -04:00
parent 757679a6e0
commit 7277b5d198
3 changed files with 40 additions and 15 deletions

13
TODO.md
View File

@ -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

View File

@ -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
}

View File

@ -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 {