2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2022-07-12 08:27:35 +00:00
|
|
|
import QtQml.Models 2.14
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.controls 1.0
|
2022-07-12 08:27:35 +00:00
|
|
|
import shared.panels 1.0
|
|
|
|
import utils 1.0
|
2021-10-20 08:34:05 +00:00
|
|
|
|
2022-07-12 08:27:35 +00:00
|
|
|
import StatusQ.Components 0.1
|
2021-10-20 08:34:05 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2022-07-12 08:27:35 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
2022-07-08 14:06:09 +00:00
|
|
|
import StatusQ.Popups.Dialog 0.1
|
2021-10-20 08:34:05 +00:00
|
|
|
|
2022-07-08 14:06:09 +00:00
|
|
|
StatusDialog {
|
|
|
|
id: root
|
2022-09-01 07:53:22 +00:00
|
|
|
objectName: "groupChatEdit_main"
|
2020-06-15 12:51:04 +00:00
|
|
|
|
2022-07-12 08:27:35 +00:00
|
|
|
property string activeGroupImageData
|
|
|
|
property string activeGroupColor
|
|
|
|
property string activeGroupName
|
|
|
|
|
|
|
|
signal updateGroupChatDetails(string groupName, string groupColor, string groupImage)
|
2021-10-22 20:49:47 +00:00
|
|
|
|
2022-07-12 08:27:35 +00:00
|
|
|
title: qsTr("Edit group name and image")
|
|
|
|
width: 480
|
|
|
|
height: 610
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
readonly property int nameCharLimit: 24
|
|
|
|
}
|
2022-07-08 14:06:09 +00:00
|
|
|
|
2020-06-15 12:51:04 +00:00
|
|
|
onOpened: {
|
2022-09-27 21:26:26 +00:00
|
|
|
groupName.input.edit.forceActiveFocus()
|
2022-07-12 08:27:35 +00:00
|
|
|
groupName.text = root.activeGroupName.substring(0, d.nameCharLimit)
|
2020-06-15 12:51:04 +00:00
|
|
|
|
2022-07-12 08:27:35 +00:00
|
|
|
colorSelectionGrid.selectedColor = activeGroupColor
|
2020-06-15 12:51:04 +00:00
|
|
|
|
2022-07-12 08:27:35 +00:00
|
|
|
for (let i = 0; i < colorSelectionGrid.model.length; i++) {
|
|
|
|
if(colorSelectionGrid.model[i] === root.activeGroupColor.toUpperCase())
|
|
|
|
colorSelectionGrid.selectedColorIndex = i
|
|
|
|
}
|
2022-07-08 14:06:09 +00:00
|
|
|
|
2022-08-11 10:58:09 +00:00
|
|
|
imageEditor.dataImage = activeGroupImageData
|
2022-07-12 08:27:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
2022-07-08 14:06:09 +00:00
|
|
|
anchors.fill: parent
|
2022-07-12 08:27:35 +00:00
|
|
|
spacing: 20
|
|
|
|
|
|
|
|
StatusInput {
|
|
|
|
id: groupName
|
2022-09-01 07:53:22 +00:00
|
|
|
input.edit.objectName: "groupChatEdit_name"
|
2022-07-12 08:27:35 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
label: qsTr("Name the group")
|
|
|
|
charLimit: d.nameCharLimit
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: imgText
|
|
|
|
text: qsTr("Group image")
|
|
|
|
leftPadding: groupName.leftPadding - root.padding
|
|
|
|
font.pixelSize: 15
|
|
|
|
}
|
|
|
|
|
|
|
|
EditCroppedImagePanel {
|
|
|
|
id: imageEditor
|
2022-09-01 07:53:22 +00:00
|
|
|
objectName: "groupChatEdit_image"
|
2022-07-12 08:27:35 +00:00
|
|
|
Layout.preferredWidth: 128
|
|
|
|
Layout.preferredHeight: Layout.preferredWidth / aspectRatio
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
|
|
|
imageFileDialogTitle: qsTr("Choose an image as logo")
|
|
|
|
title: qsTr("Edit group name and image")
|
|
|
|
acceptButtonText: qsTr("Use as an icon for this group chat")
|
|
|
|
|
|
|
|
backgroundComponent:
|
|
|
|
StatusLetterIdenticon {
|
|
|
|
id: letter
|
|
|
|
color: colorSelectionGrid.selectedColor
|
|
|
|
name: root.activeGroupName
|
|
|
|
height: 100
|
|
|
|
width: 100
|
|
|
|
letterSize: 64
|
|
|
|
|
|
|
|
StatusRoundButton {
|
|
|
|
id: addButton
|
|
|
|
|
|
|
|
icon.name: "add"
|
|
|
|
type: StatusRoundButton.Type.Secondary
|
|
|
|
|
|
|
|
transform: [
|
|
|
|
Translate {
|
|
|
|
x: -addButton.width/2 - 5
|
|
|
|
y: -addButton.height/2 + 5
|
|
|
|
},
|
|
|
|
Rotation { angle: -addRotationTransform.angle },
|
|
|
|
Rotation {
|
|
|
|
id: addRotationTransform
|
|
|
|
angle: 135
|
|
|
|
origin.x: letter.radius
|
|
|
|
},
|
|
|
|
Translate {
|
|
|
|
x: letter.width - 2 * letter.radius
|
|
|
|
y: letter.radius
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
onClicked: imageEditor.chooseImageToCrop()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: colorText
|
|
|
|
text: qsTr("Standard colours")
|
|
|
|
leftPadding: groupName.leftPadding - root.padding
|
|
|
|
font.pixelSize: 15
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusColorSelectorGrid {
|
|
|
|
id: colorSelectionGrid
|
2022-09-01 07:53:22 +00:00
|
|
|
objectName: "groupChatEdit_color"
|
2022-07-12 08:27:35 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
diameter: 40
|
|
|
|
selectorDiameter: 16
|
|
|
|
columns: 6
|
|
|
|
selectedColorIndex: -1
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: spacerItem
|
|
|
|
height: 10
|
|
|
|
}
|
|
|
|
}
|
2022-07-08 14:06:09 +00:00
|
|
|
|
2022-07-12 08:27:35 +00:00
|
|
|
footer: StatusDialogFooter {
|
|
|
|
rightButtons: ObjectModel {
|
|
|
|
StatusButton {
|
|
|
|
id: saveBtn
|
2022-09-01 07:53:22 +00:00
|
|
|
objectName: "groupChatEdit_save"
|
2022-07-12 08:27:35 +00:00
|
|
|
text: qsTr("Save changes")
|
|
|
|
enabled: groupName.text.trim().length > 0 &&
|
2022-08-11 10:58:09 +00:00
|
|
|
((groupName.text != root.activeGroupName) ||
|
|
|
|
(root.activeGroupColor != colorSelectionGrid.selectedColor) ||
|
|
|
|
(String(imageEditor.source).length > 0))
|
2022-07-12 08:27:35 +00:00
|
|
|
onClicked : {
|
2022-08-11 10:58:09 +00:00
|
|
|
updateGroupChatDetails(groupName.text, colorSelectionGrid.selectedColor,
|
|
|
|
Utils.getImageAndCropInfoJson(imageEditor.source, imageEditor.cropRect))
|
2022-07-12 08:27:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-08 14:06:09 +00:00
|
|
|
}
|
2020-06-15 12:51:04 +00:00
|
|
|
}
|