2022-09-09 22:09:37 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
|
|
|
import shared.panels 1.0
|
|
|
|
|
2023-06-30 12:34:42 +00:00
|
|
|
import AppLayouts.Communities.controls 1.0
|
|
|
|
|
2022-09-09 22:09:37 +00:00
|
|
|
|
|
|
|
StatusDropdown {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property int mode: PermissionsDropdown.Mode.Add
|
|
|
|
property int initialPermissionType: PermissionTypes.Type.None
|
|
|
|
|
2023-01-20 11:22:04 +00:00
|
|
|
property bool enableAdminPermission: true
|
2023-01-20 11:04:12 +00:00
|
|
|
|
2022-09-09 22:09:37 +00:00
|
|
|
enum Mode {
|
|
|
|
Add, Update
|
|
|
|
}
|
|
|
|
|
2023-02-11 19:03:57 +00:00
|
|
|
signal done(int permissionType)
|
2022-09-09 22:09:37 +00:00
|
|
|
|
|
|
|
width: d.width
|
|
|
|
padding: d.padding
|
|
|
|
|
|
|
|
// force keeping within the bounds of the enclosing window
|
|
|
|
margins: 0
|
|
|
|
|
|
|
|
onAboutToShow: {
|
|
|
|
group.checkState = Qt.Unchecked
|
|
|
|
d.initialPermissionTypeChanged()
|
|
|
|
}
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
// internals
|
|
|
|
readonly property int initialPermissionType: root.initialPermissionType
|
|
|
|
|
|
|
|
// values from design
|
|
|
|
readonly property int padding: 8
|
|
|
|
readonly property int width: 289
|
|
|
|
readonly property int sectionHeight: 34
|
|
|
|
readonly property int sectionFontSize: 12
|
|
|
|
readonly property int extraMarginForText: 8
|
|
|
|
|
|
|
|
readonly property int separatorTopMargin: 4
|
|
|
|
readonly property int separatorBottomMargin: 12
|
|
|
|
|
|
|
|
readonly property int descriptionFontSize: 13
|
|
|
|
readonly property int descriptionLineHeight: 18
|
|
|
|
|
|
|
|
readonly property int buttonTopMargin: 32
|
|
|
|
|
2023-02-11 19:03:57 +00:00
|
|
|
component CustomSeparator: Item {
|
|
|
|
property alias text: baseText.text
|
2022-09-09 22:09:37 +00:00
|
|
|
|
|
|
|
StatusBaseText {
|
2023-02-11 19:03:57 +00:00
|
|
|
id: baseText
|
|
|
|
|
2022-09-09 22:09:37 +00:00
|
|
|
anchors.margins: d.extraMarginForText
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2023-02-11 19:03:57 +00:00
|
|
|
|
2022-09-09 22:09:37 +00:00
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
font.pixelSize: d.sectionFontSize
|
|
|
|
elide: Text.ElideRight
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-11 19:03:57 +00:00
|
|
|
component CustomPermissionListItem: PermissionListItem {
|
|
|
|
required property int permissionType
|
|
|
|
required property string description
|
2022-09-09 22:09:37 +00:00
|
|
|
|
2023-02-11 19:03:57 +00:00
|
|
|
title: PermissionTypes.getName(permissionType)
|
|
|
|
description: PermissionTypes.getDescription(permissionType)
|
|
|
|
asset.name: PermissionTypes.getIcon(permissionType)
|
2022-09-09 22:09:37 +00:00
|
|
|
checked: d.initialPermissionType === permissionType
|
2023-02-11 19:03:57 +00:00
|
|
|
|
2022-09-09 22:09:37 +00:00
|
|
|
buttonGroup: group
|
2023-02-11 19:03:57 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-09 22:09:37 +00:00
|
|
|
|
2023-02-11 19:03:57 +00:00
|
|
|
ButtonGroup {
|
|
|
|
id: group
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: ColumnLayout {
|
|
|
|
spacing: 0
|
2023-01-20 11:04:12 +00:00
|
|
|
|
2023-02-11 19:03:57 +00:00
|
|
|
CustomSeparator {
|
2022-09-09 22:09:37 +00:00
|
|
|
Layout.fillWidth: true
|
2023-02-11 19:03:57 +00:00
|
|
|
Layout.preferredHeight: d.sectionHeight
|
|
|
|
|
|
|
|
text: qsTr("Community")
|
2022-09-09 22:09:37 +00:00
|
|
|
}
|
|
|
|
|
2023-02-11 19:03:57 +00:00
|
|
|
CustomPermissionListItem {
|
|
|
|
permissionType: PermissionTypes.Type.Admin
|
|
|
|
enabled: root.enableAdminPermission
|
2022-09-09 22:09:37 +00:00
|
|
|
|
2023-02-11 19:03:57 +00:00
|
|
|
Layout.fillWidth: true
|
2023-08-31 05:31:43 +00:00
|
|
|
objectName: "becomeAdmin"
|
2023-02-11 19:03:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CustomPermissionListItem {
|
|
|
|
permissionType: PermissionTypes.Type.Member
|
2022-09-09 22:09:37 +00:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2023-08-31 05:31:43 +00:00
|
|
|
objectName: "becomeMember"
|
2022-09-09 22:09:37 +00:00
|
|
|
}
|
|
|
|
|
2023-02-11 19:03:57 +00:00
|
|
|
CustomSeparator {
|
2022-09-09 22:09:37 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: d.sectionHeight
|
|
|
|
|
2023-02-11 19:03:57 +00:00
|
|
|
text: qsTr("Channels")
|
2022-09-09 22:09:37 +00:00
|
|
|
}
|
|
|
|
|
2023-02-11 19:03:57 +00:00
|
|
|
CustomPermissionListItem {
|
|
|
|
permissionType: PermissionTypes.Type.ViewAndPost
|
2022-09-09 22:09:37 +00:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2023-08-31 05:31:43 +00:00
|
|
|
objectName: "viewAndPost"
|
2022-09-09 22:09:37 +00:00
|
|
|
}
|
|
|
|
|
2023-02-11 19:03:57 +00:00
|
|
|
CustomPermissionListItem {
|
|
|
|
permissionType: PermissionTypes.Type.Read
|
2022-09-09 22:09:37 +00:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2023-08-31 05:31:43 +00:00
|
|
|
objectName: "viewOnly"
|
2022-09-09 22:09:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Separator {
|
|
|
|
visible: !!group.checkedButton
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.topMargin: d.separatorTopMargin
|
|
|
|
Layout.bottomMargin: d.separatorBottomMargin
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: d.extraMarginForText
|
|
|
|
|
|
|
|
visible: !!group.checkedButton
|
|
|
|
text: group.checkedButton ? group.checkedButton.item.description : ""
|
|
|
|
|
|
|
|
textFormat: Text.StyledText
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
font.pixelSize: d.descriptionFontSize
|
|
|
|
lineHeight: d.descriptionLineHeight
|
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.topMargin: d.buttonTopMargin
|
|
|
|
|
|
|
|
text: root.mode === PermissionsDropdown.Mode.Add ? qsTr("Add") : qsTr("Update")
|
|
|
|
enabled: !!group.checkedButton
|
|
|
|
|
2023-02-11 19:03:57 +00:00
|
|
|
onClicked: root.done(group.checkedButton.item.permissionType)
|
2022-09-09 22:09:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|