2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.controls 1.0
|
2021-10-19 11:54:54 +00:00
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
import StatusQ.Core 0.1
|
2021-10-19 11:54:54 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2022-07-28 17:31:22 +00:00
|
|
|
import StatusQ.Controls.Validators 0.1
|
2021-10-19 11:54:54 +00:00
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.popups 1.0
|
2021-10-01 15:58:36 +00:00
|
|
|
import "../helpers/channelList.js" as ChannelJSON
|
|
|
|
import "../panels"
|
2020-05-27 20:11:56 +00:00
|
|
|
|
2021-10-14 11:33:34 +00:00
|
|
|
// TODO: replace with StatusModal
|
2020-05-29 16:27:50 +00:00
|
|
|
ModalPopup {
|
2021-10-22 20:49:47 +00:00
|
|
|
signal joinPublicChat(string name)
|
|
|
|
signal suggestedMessageClicked(string channel)
|
2020-11-06 19:46:21 +00:00
|
|
|
function validate() {
|
2022-07-28 17:31:22 +00:00
|
|
|
channelName.validate(true)
|
|
|
|
return channelName.valid
|
2020-11-06 19:46:21 +00:00
|
|
|
}
|
|
|
|
|
2020-06-15 16:24:21 +00:00
|
|
|
function doJoin() {
|
2020-11-06 19:46:21 +00:00
|
|
|
if (!validate()) {
|
|
|
|
return
|
|
|
|
}
|
2021-10-22 20:49:47 +00:00
|
|
|
popup.joinPublicChat(channelName.text);
|
2020-06-15 16:24:21 +00:00
|
|
|
popup.close();
|
|
|
|
}
|
|
|
|
|
2020-05-27 20:11:56 +00:00
|
|
|
id: popup
|
2022-04-04 11:26:30 +00:00
|
|
|
title: qsTr("Join public chat")
|
2020-06-09 10:01:19 +00:00
|
|
|
|
2020-05-29 18:38:11 +00:00
|
|
|
onOpened: {
|
|
|
|
channelName.text = "";
|
2022-07-28 17:31:22 +00:00
|
|
|
channelName.input.edit.forceActiveFocus(Qt.MouseFocusReason)
|
2020-05-29 18:38:11 +00:00
|
|
|
}
|
2022-02-09 09:43:23 +00:00
|
|
|
|
2022-09-27 08:51:53 +00:00
|
|
|
contentWrapper.anchors.bottomMargin: 0
|
|
|
|
|
2020-05-29 16:27:50 +00:00
|
|
|
Row {
|
|
|
|
id: description
|
|
|
|
Layout.fillHeight: false
|
|
|
|
Layout.fillWidth: true
|
|
|
|
width: parent.width
|
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-06-04 14:53:10 +00:00
|
|
|
width: parent.width
|
2020-05-29 16:27:50 +00:00
|
|
|
font.pixelSize: 15
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("A public chat is where you get to hang out with others, make friends and talk about subjects of your interest.")
|
2020-05-29 16:27:50 +00:00
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
verticalAlignment: Text.AlignTop
|
2020-05-27 20:11:56 +00:00
|
|
|
}
|
2020-05-29 16:27:50 +00:00
|
|
|
}
|
2020-05-27 20:11:56 +00:00
|
|
|
|
2022-07-28 17:31:22 +00:00
|
|
|
StatusInput {
|
2020-06-15 16:24:21 +00:00
|
|
|
id: channelName
|
2022-07-28 17:31:22 +00:00
|
|
|
input.edit.objectName: "joinPublicChannelInput"
|
2020-05-29 16:27:50 +00:00
|
|
|
anchors.top: description.bottom
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.topMargin: Style.current.padding
|
2022-04-04 11:26:30 +00:00
|
|
|
placeholderText: qsTr("chat-name")
|
2022-11-14 17:15:02 +00:00
|
|
|
charLimit: 24
|
2020-06-15 16:24:21 +00:00
|
|
|
Keys.onEnterPressed: doJoin()
|
|
|
|
Keys.onReturnPressed: doJoin()
|
2022-08-11 11:55:08 +00:00
|
|
|
input.asset.name: "channel"
|
2022-07-28 17:31:22 +00:00
|
|
|
validators: [StatusMinLengthValidator {
|
|
|
|
minLength: 1
|
|
|
|
errorMessage: qsTr("You need to enter a channel name")
|
|
|
|
},
|
|
|
|
StatusValidator {
|
|
|
|
name: "validChannelNameValidator"
|
|
|
|
validate: function (t) { return Utils.isValidChannelName(t) }
|
|
|
|
errorMessage: qsTr("The channel name can only contain lowercase letters, numbers and dashes")
|
|
|
|
}]
|
|
|
|
validationMode: StatusInput.ValidationMode.OnlyWhenDirty
|
2020-05-29 16:27:50 +00:00
|
|
|
}
|
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
StatusScrollView {
|
2020-09-23 13:51:49 +00:00
|
|
|
id: sview
|
|
|
|
|
2020-06-15 16:24:21 +00:00
|
|
|
anchors.top: channelName.bottom
|
2020-09-23 13:51:49 +00:00
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
|
2020-09-23 16:49:08 +00:00
|
|
|
contentHeight: {
|
|
|
|
var totalHeight = 0
|
|
|
|
for (let i = 0; i < sectionRepeater.count; i++) {
|
|
|
|
totalHeight += sectionRepeater.itemAt(i).height + Style.current.padding
|
|
|
|
}
|
|
|
|
return totalHeight + Style.current.padding
|
|
|
|
}
|
2020-05-27 20:11:56 +00:00
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
SuggestedChannelsPanel {
|
2020-09-23 19:36:36 +00:00
|
|
|
id: sectionRepeater
|
2022-08-03 14:04:01 +00:00
|
|
|
width: sview.width
|
2021-10-01 15:58:36 +00:00
|
|
|
onSuggestedMessageClicked: {
|
2021-10-22 20:49:47 +00:00
|
|
|
popup.suggestedMessageClicked(channel);
|
2021-10-01 15:58:36 +00:00
|
|
|
}
|
2020-05-27 20:11:56 +00:00
|
|
|
}
|
2020-05-29 16:27:50 +00:00
|
|
|
}
|
2020-05-27 20:11:56 +00:00
|
|
|
|
2020-10-03 11:14:23 +00:00
|
|
|
footer: StatusButton {
|
2022-07-20 12:14:50 +00:00
|
|
|
objectName: "startChatButton"
|
2020-05-29 16:27:50 +00:00
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: parent.right
|
2020-10-03 11:14:23 +00:00
|
|
|
onClicked : doJoin()
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Start chat")
|
2020-06-15 16:24:21 +00:00
|
|
|
}
|
2020-05-27 20:11:56 +00:00
|
|
|
}
|