Add power level display to member profile
This commit is contained in:
parent
e3b6f3eb54
commit
fe831e7865
3
TODO.md
3
TODO.md
|
@ -17,8 +17,7 @@
|
|||
## Refactoring
|
||||
|
||||
- General change/upload avatar component for account and room settings
|
||||
- Reorder QML object declarations,
|
||||
conform to https://doc-snapshots.qt.io/qt5-dev/qml-codingconventions.html
|
||||
- Refactor EventList.qml
|
||||
|
||||
## Issues
|
||||
|
||||
|
|
74
src/gui/Base/PowerLevelControl.qml
Normal file
74
src/gui/Base/PowerLevelControl.qml
Normal file
|
@ -0,0 +1,74 @@
|
|||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
|
||||
AutoDirectionLayout {
|
||||
id: control
|
||||
|
||||
property alias defaultLevel: field.defaultText
|
||||
|
||||
readonly property int level: Math.min(100, parseInt(field.text || "0", 10))
|
||||
|
||||
function reset() { field.reset() }
|
||||
|
||||
|
||||
rowSpacing: theme.spacing
|
||||
|
||||
HSpacer {}
|
||||
|
||||
HTextField {
|
||||
id: field
|
||||
|
||||
radius: 0
|
||||
horizontalAlignment: Qt.AlignHCenter
|
||||
validator: IntValidator { top: 100 }
|
||||
inputMethodHints: Qt.ImhFormattedNumbersOnly
|
||||
maximumLength: control.level < 0 ? 16 : 3
|
||||
|
||||
onActiveFocusChanged:
|
||||
if (! activeFocus && parseInt(text || "0", 10) > 100)
|
||||
text = 100
|
||||
|
||||
Layout.minimumWidth:
|
||||
mainUI.fontMetrics.boundingRect("-999").width +
|
||||
leftPadding +
|
||||
rightPadding
|
||||
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
}
|
||||
|
||||
Row {
|
||||
Layout.preferredHeight: field.height
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
|
||||
HButton {
|
||||
height: parent.height
|
||||
icon.name: "user-power-default"
|
||||
toolTip.text: qsTr("Default")
|
||||
checked: control.level >= 0 && control.level < 50
|
||||
uncheckable: false
|
||||
onClicked: field.text = 0
|
||||
}
|
||||
|
||||
HButton {
|
||||
height: parent.height
|
||||
icon.name: "user-power-50"
|
||||
toolTip.text: qsTr("Moderator")
|
||||
checked: control.level >= 50 && control.level < 100
|
||||
uncheckable: false
|
||||
onClicked: field.text = 50
|
||||
}
|
||||
|
||||
HButton {
|
||||
height: parent.height
|
||||
icon.name: "user-power-100"
|
||||
toolTip.text: qsTr("Admin")
|
||||
checked: control.level >= 100
|
||||
uncheckable: false
|
||||
onClicked: field.text = 100
|
||||
}
|
||||
}
|
||||
|
||||
HSpacer {}
|
||||
}
|
|
@ -150,54 +150,29 @@ HListView {
|
|||
color: theme.colors.halfDimText
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.bottomMargin: theme.spacing
|
||||
}
|
||||
|
||||
// TODO
|
||||
// HColumnLayout {
|
||||
// spacing: theme.spacing / 2
|
||||
HColumnLayout {
|
||||
spacing: theme.spacing / 2
|
||||
|
||||
// HLabel {
|
||||
// text: qsTr("Power level:")
|
||||
// wrapMode: HLabel.Wrap
|
||||
// horizontalAlignment: Qt.AlignHCenter
|
||||
Layout.preferredWidth: parent.width
|
||||
Layout.bottomMargin: theme.spacing
|
||||
|
||||
// Layout.fillWidth: true
|
||||
// }
|
||||
HLabel {
|
||||
text: qsTr("Power level:")
|
||||
wrapMode: HLabel.Wrap
|
||||
horizontalAlignment: Qt.AlignHCenter
|
||||
|
||||
// HRowLayout {
|
||||
// spacing: theme.spacing
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
// HSpacer {}
|
||||
PowerLevelControl {
|
||||
defaultLevel: member.power_level
|
||||
rowSpacing: parent.spacing
|
||||
|
||||
// Row {
|
||||
// HButton {
|
||||
// text: qsTr("Default")
|
||||
// checked: levelBox.value >= 0 && levelBox.value < 50
|
||||
// onClicked: levelBox.value = 0
|
||||
// }
|
||||
// HButton {
|
||||
// text: qsTr("Moderator")
|
||||
// checked: levelBox.value >= 50 && levelBox.value < 100
|
||||
// onClicked: levelBox.value = 50
|
||||
// }
|
||||
// HButton {
|
||||
// text: qsTr("Admin")
|
||||
// checked: levelBox.value === 100
|
||||
// onClicked: levelBox.value = 100
|
||||
// }
|
||||
// }
|
||||
|
||||
// HSpinBox {
|
||||
// id: levelBox
|
||||
// from: -999
|
||||
// to: 100
|
||||
// defaultValue: member.power_level
|
||||
// }
|
||||
|
||||
// HSpacer {}
|
||||
// }
|
||||
// }
|
||||
Layout.preferredWidth: parent.width
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: loadDevices()
|
||||
|
|
3
src/icons/thin/user-power-default.svg
Normal file
3
src/icons/thin/user-power-default.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m20.822 18.096c-3.439-.794-6.641-1.49-5.09-4.418 4.719-8.912 1.251-13.678-3.732-13.678-5.082 0-8.465 4.949-3.732 13.678 1.598 2.945-1.725 3.641-5.09 4.418-2.979.688-3.178 2.143-3.178 4.663l.005 1.241h1.995c0-3.134-.125-3.55 1.838-4.003 2.851-.657 5.543-1.278 6.525-3.456.359-.795.592-2.103-.338-3.815-2.058-3.799-2.578-7.089-1.423-9.026 1.354-2.275 5.426-2.264 6.767-.034 1.15 1.911.639 5.219-1.403 9.076-.91 1.719-.671 3.023-.31 3.814.99 2.167 3.707 2.794 6.584 3.458 1.879.436 1.76.882 1.76 3.986h1.995l.005-1.241c0-2.52-.199-3.975-3.178-4.663z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 654 B |
Loading…
Reference in New Issue
Block a user