2022-05-26 15:46:02 +00:00
|
|
|
import QtQuick 2.14
|
2022-08-18 14:25:06 +00:00
|
|
|
import QtQuick.Controls 2.14
|
2022-05-26 15:46:02 +00:00
|
|
|
import QtQuick.Layouts 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
|
2022-07-05 10:12:27 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
2021-07-16 10:11:03 +00:00
|
|
|
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-06-21 08:57:09 +00:00
|
|
|
import "../../Chat/controls/community"
|
2022-05-26 15:46:02 +00:00
|
|
|
|
2022-06-16 09:41:21 +00:00
|
|
|
import "../controls"
|
|
|
|
import "../panels"
|
|
|
|
|
|
|
|
StatusStackModal {
|
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
|
2022-08-18 14:25:06 +00:00
|
|
|
property bool isDiscordImport // creating new or importing from discord?
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2022-08-18 14:25:06 +00:00
|
|
|
stackTitle: isDiscordImport ? qsTr("Import a community from Discord into Status") :
|
|
|
|
qsTr("Create New Community")
|
2022-06-28 10:55:33 +00:00
|
|
|
width: 640
|
|
|
|
|
|
|
|
nextButton: StatusButton {
|
2022-07-18 20:56:33 +00:00
|
|
|
objectName: "createCommunityNextBtn"
|
2022-08-18 15:29:55 +00:00
|
|
|
font.weight: Font.Medium
|
|
|
|
text: typeof currentItem.nextButtonText !== "undefined" ? currentItem.nextButtonText : qsTr("Next")
|
|
|
|
enabled: typeof(currentItem.canGoNext) == "undefined" || currentItem.canGoNext
|
|
|
|
onClicked: {
|
|
|
|
let nextAction = currentItem.nextAction
|
|
|
|
if (typeof(nextAction) == "function") {
|
|
|
|
return nextAction()
|
|
|
|
}
|
|
|
|
root.currentIndex++
|
|
|
|
}
|
2022-06-28 10:55:33 +00:00
|
|
|
}
|
2021-07-16 10:11:03 +00:00
|
|
|
|
2022-06-16 09:41:21 +00:00
|
|
|
finishButton: StatusButton {
|
2022-07-18 20:56:33 +00:00
|
|
|
objectName: "createCommunityFinalBtn"
|
2022-08-18 15:29:55 +00:00
|
|
|
font.weight: Font.Medium
|
|
|
|
text: root.isDiscordImport ? qsTr("Start Discord import") : qsTr("Create Community")
|
|
|
|
enabled: typeof(currentItem.canGoNext) == "undefined" || currentItem.canGoNext
|
|
|
|
onClicked: {
|
|
|
|
let nextAction = currentItem.nextAction
|
|
|
|
if (typeof (nextAction) == "function") {
|
|
|
|
return nextAction()
|
|
|
|
}
|
|
|
|
if (!root.isDiscordImport)
|
|
|
|
d.createCommunity()
|
|
|
|
}
|
2022-06-16 09:41:21 +00:00
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2022-08-03 00:07:27 +00:00
|
|
|
onAboutToShow: nameInput.input.edit.forceActiveFocus()
|
|
|
|
|
2022-06-16 09:41:21 +00:00
|
|
|
stackItems: [
|
2022-07-13 12:29:38 +00:00
|
|
|
StatusScrollView {
|
2022-05-26 15:46:02 +00:00
|
|
|
id: generalView
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2022-08-18 15:29:55 +00:00
|
|
|
readonly property bool canGoNext: nameInput.valid && descriptionTextInput.valid
|
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: generalViewLayout
|
2022-07-14 11:03:36 +00:00
|
|
|
width: generalView.availableWidth
|
2022-08-03 00:07:27 +00:00
|
|
|
spacing: 16
|
2021-07-16 10:11:03 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
CommunityNameInput {
|
|
|
|
id: nameInput
|
2022-07-18 20:56:33 +00:00
|
|
|
input.edit.objectName: "createCommunityNameInput"
|
2022-05-26 15:46:02 +00:00
|
|
|
Layout.fillWidth: true
|
2022-08-03 00:07:27 +00:00
|
|
|
input.tabNavItem: descriptionTextInput.input.edit
|
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
|
2022-07-18 20:56:33 +00:00
|
|
|
input.edit.objectName: "createCommunityDescriptionInput"
|
2022-05-26 15:46:02 +00:00
|
|
|
Layout.fillWidth: true
|
2022-08-03 00:07:27 +00:00
|
|
|
input.tabNavItem: nameInput.input.edit
|
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-08-17 12:44:53 +00:00
|
|
|
CommunityBannerPicker {
|
|
|
|
id: bannerPicker
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
CommunityColorPicker {
|
|
|
|
id: colorPicker
|
2022-06-16 09:41:21 +00:00
|
|
|
onPick: root.replace(colorPanel)
|
2022-05-26 15:46:02 +00:00
|
|
|
Layout.fillWidth: true
|
2022-06-16 09:41:21 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: colorPanel
|
|
|
|
|
|
|
|
CommunityColorPanel {
|
|
|
|
Component.onCompleted: color = colorPicker.color
|
|
|
|
onAccepted: {
|
|
|
|
colorPicker.color = color;
|
|
|
|
root.replace(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-05-26 15:46:02 +00:00
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2022-06-09 14:59:54 +00:00
|
|
|
CommunityTagsPicker {
|
|
|
|
id: communityTagsPicker
|
|
|
|
tags: root.store.communityTags
|
2022-06-16 09:41:21 +00:00
|
|
|
onPick: root.replace(tagsPanel)
|
2022-06-09 14:59:54 +00:00
|
|
|
Layout.fillWidth: true
|
2022-06-16 09:41:21 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: tagsPanel
|
|
|
|
|
|
|
|
CommunityTagsPanel {
|
|
|
|
Component.onCompleted: {
|
|
|
|
tags = communityTagsPicker.tags;
|
|
|
|
selectedTags = communityTagsPicker.selectedTags;
|
|
|
|
}
|
|
|
|
onAccepted: {
|
|
|
|
communityTagsPicker.selectedTags = selectedTags;
|
|
|
|
root.replace(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-06-09 14:59:54 +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
|
|
|
}
|
|
|
|
}
|
2022-06-16 09:41:21 +00:00
|
|
|
},
|
2022-08-18 15:29:55 +00:00
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: introOutroMessageView
|
2022-07-29 08:00:37 +00:00
|
|
|
spacing: 11
|
2022-08-18 15:29:55 +00:00
|
|
|
readonly property bool canGoNext: introMessageInput.valid && outroMessageInput.valid
|
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
CommunityIntroMessageInput {
|
|
|
|
id: introMessageInput
|
2022-07-18 20:56:33 +00:00
|
|
|
input.edit.objectName: "createCommunityIntroMessageInput"
|
2022-08-18 15:29:55 +00:00
|
|
|
input.tabNavItem: outroMessageInput.input.edit
|
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-07-29 08:00:37 +00:00
|
|
|
minimumHeight: height
|
|
|
|
maximumHeight: (height - Style.current.xlPadding)
|
2022-05-26 15:46:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CommunityOutroMessageInput {
|
|
|
|
id: outroMessageInput
|
2022-07-18 20:56:33 +00:00
|
|
|
input.edit.objectName: "createCommunityOutroMessageInput"
|
2022-08-18 15:29:55 +00:00
|
|
|
input.tabNavItem: introMessageInput.input.edit
|
2022-05-26 15:46:02 +00:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2021-05-24 03:09:49 +00:00
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
2022-06-16 09:41:21 +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({
|
2022-07-05 10:12:27 +00:00
|
|
|
name: StatusQUtils.Utils.filterXSS(nameInput.input.text),
|
|
|
|
description: StatusQUtils.Utils.filterXSS(descriptionTextInput.input.text),
|
|
|
|
introMessage: StatusQUtils.Utils.filterXSS(introMessageInput.input.text),
|
|
|
|
outroMessage: StatusQUtils.Utils.filterXSS(outroMessageInput.input.text),
|
2022-06-02 17:48:10 +00:00
|
|
|
color: colorPicker.color.toString().toUpperCase(),
|
2022-06-09 14:59:54 +00:00
|
|
|
tags: communityTagsPicker.selectedTags,
|
2022-06-02 17:48:10 +00:00
|
|
|
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-08-17 12:44:53 +00:00
|
|
|
},
|
|
|
|
bannerJsonStr: JSON.stringify({imagePath: String(bannerPicker.source).replace("file://", ""), cropRect: bannerPicker.cropRect})
|
2022-06-02 17:48:10 +00:00
|
|
|
})
|
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
|
|
|
}
|