2022-05-26 15:46:02 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.4
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
import QtGraphicalEffects 1.14
|
2020-12-11 20:29:46 +00:00
|
|
|
import QtQuick.Dialogs 1.3
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.popups 1.0
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
2021-08-17 10:49:13 +00:00
|
|
|
import StatusQ.Controls.Validators 0.1
|
2021-07-16 10:11:03 +00:00
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
import "../../controls/community"
|
|
|
|
|
2022-02-09 09:43:23 +00:00
|
|
|
StatusModal {
|
2022-05-26 15:46:02 +00:00
|
|
|
id: root
|
2020-12-17 13:24:33 +00:00
|
|
|
|
2021-10-22 20:49:47 +00:00
|
|
|
property var store
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
width: 640
|
2022-06-10 10:08:31 +00:00
|
|
|
padding: 16
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
header.title: qsTr("Create New Community")
|
2021-07-16 10:11:03 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
rightButtons: [
|
|
|
|
StatusButton {
|
|
|
|
text: qsTr("Next")
|
|
|
|
enabled: generalView.canGoNext
|
|
|
|
visible: generalView.visible
|
2021-07-16 10:11:03 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
onClicked: stackLayout.currentIndex = stackLayout.currentIndex + 1
|
|
|
|
},
|
|
|
|
StatusButton {
|
|
|
|
text: qsTr("Create Community")
|
|
|
|
enabled: introMessageInput.valid && outroMessageInput.valid
|
|
|
|
visible: introMessageInput.visible
|
2021-09-14 06:01:43 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
onClicked: d.createCommunity()
|
|
|
|
}
|
|
|
|
]
|
2021-07-16 10:11:03 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
leftButtons: [
|
|
|
|
StatusRoundButton {
|
|
|
|
id: btnBack
|
|
|
|
icon.name: "arrow-right"
|
|
|
|
icon.width: 20
|
|
|
|
icon.height: 16
|
|
|
|
rotation: 180
|
|
|
|
visible: stackLayout.currentIndex !== 0
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
onClicked: stackLayout.currentIndex = 0
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
2022-05-26 15:46:02 +00:00
|
|
|
]
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
StackLayout {
|
|
|
|
id: stackLayout
|
2021-07-16 10:11:03 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
anchors.fill: parent
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2022-06-03 07:16:54 +00:00
|
|
|
implicitHeight: 720
|
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
Flickable {
|
|
|
|
id: generalView
|
2021-07-16 10:11:03 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
readonly property bool canGoNext: nameInput.valid && descriptionTextInput.valid
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
clip: true
|
|
|
|
contentHeight: generalViewLayout.height
|
|
|
|
interactive: contentHeight > height
|
|
|
|
flickableDirection: Flickable.VerticalFlick
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: generalViewLayout
|
|
|
|
width: generalView.width
|
|
|
|
spacing: 12
|
2021-07-16 10:11:03 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
CommunityNameInput {
|
|
|
|
id: nameInput
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Component.onCompleted: nameInput.input.forceActiveFocus(
|
|
|
|
Qt.MouseFocusReason)
|
2022-05-18 12:21:03 +00:00
|
|
|
}
|
2021-07-16 10:11:03 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
CommunityDescriptionInput {
|
|
|
|
id: descriptionTextInput
|
|
|
|
Layout.fillWidth: true
|
2021-07-16 10:11:03 +00:00
|
|
|
}
|
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
CommunityLogoPicker {
|
|
|
|
id: logoPicker
|
|
|
|
Layout.fillWidth: true
|
2021-03-01 19:43:50 +00:00
|
|
|
}
|
2021-02-10 20:37:17 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
CommunityColorPicker {
|
|
|
|
id: colorPicker
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
StatusModalDivider {
|
|
|
|
Layout.fillWidth: true
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
CommunityOptions {
|
|
|
|
id: options
|
|
|
|
|
|
|
|
archiveSupportOptionVisible: root.store.isCommunityHistoryArchiveSupportEnabled
|
|
|
|
archiveSupportEnabled: archiveSupportOptionVisible
|
2022-04-08 10:46:38 +00:00
|
|
|
}
|
2022-05-10 16:13:36 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
Item {
|
|
|
|
Layout.fillHeight: true
|
2022-05-10 16:13:36 +00:00
|
|
|
}
|
|
|
|
}
|
2021-02-10 20:37:17 +00:00
|
|
|
}
|
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: introOutroMessageView
|
2020-12-11 20:38:10 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
spacing: 12
|
2021-07-16 10:11:03 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
CommunityIntroMessageInput {
|
|
|
|
id: introMessageInput
|
2020-12-17 13:24:33 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
input.maximumHeight: 0
|
|
|
|
}
|
|
|
|
|
|
|
|
CommunityOutroMessageInput {
|
|
|
|
id: outroMessageInput
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2021-05-24 03:09:49 +00:00
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
2022-05-26 15:46:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
function createCommunity() {
|
2022-06-02 17:48:10 +00:00
|
|
|
const error = store.createCommunity({
|
|
|
|
name: Utils.filterXSS(nameInput.input.text),
|
|
|
|
description: Utils.filterXSS(descriptionTextInput.input.text),
|
|
|
|
introMessage: Utils.filterXSS(introMessageInput.input.text),
|
|
|
|
outroMessage: Utils.filterXSS(outroMessageInput.input.text),
|
|
|
|
color: colorPicker.color.toString().toUpperCase(),
|
|
|
|
image: {
|
|
|
|
src: logoPicker.source,
|
|
|
|
AX: logoPicker.cropRect.x,
|
|
|
|
AY: logoPicker.cropRect.y,
|
|
|
|
BX: logoPicker.cropRect.x + logoPicker.cropRect.width,
|
|
|
|
BY: logoPicker.cropRect.y + logoPicker.cropRect.height,
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
historyArchiveSupportEnabled: options.archiveSupportEnabled,
|
|
|
|
checkedMembership: options.requestToJoinEnabled ? Constants.communityChatOnRequestAccess : Constants.communityChatPublicAccess,
|
|
|
|
pinMessagesAllowedForMembers: options.pinMessagesEnabled
|
|
|
|
}
|
|
|
|
})
|
2022-05-26 15:46:02 +00:00
|
|
|
if (error) {
|
|
|
|
errorDialog.text = error.error
|
|
|
|
errorDialog.open()
|
|
|
|
}
|
|
|
|
root.close()
|
|
|
|
}
|
|
|
|
}
|
2021-07-16 10:11:03 +00:00
|
|
|
|
|
|
|
MessageDialog {
|
2022-05-26 15:46:02 +00:00
|
|
|
id: errorDialog
|
|
|
|
|
|
|
|
title: qsTr("Error creating the community")
|
2021-07-16 10:11:03 +00:00
|
|
|
icon: StandardIcon.Critical
|
|
|
|
standardButtons: StandardButton.Ok
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|