status-desktop/ui/app/AppLayouts/Chat/popups/PublicChatPopup.qml

116 lines
3.2 KiB
QML
Raw Normal View History

2020-06-17 19:18:31 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import utils 1.0
import shared.controls 1.0
import StatusQ.Core 0.1
import StatusQ.Controls 0.1
import StatusQ.Controls.Validators 0.1
import shared.panels 1.0
import shared.popups 1.0
import "../helpers/channelList.js" as ChannelJSON
import "../panels"
// TODO: replace with StatusModal
2020-05-29 16:27:50 +00:00
ModalPopup {
signal joinPublicChat(string name)
signal suggestedMessageClicked(string channel)
function validate() {
channelName.validate(true)
return channelName.valid
}
function doJoin() {
if (!validate()) {
return
}
popup.joinPublicChat(channelName.text);
popup.close();
}
id: popup
title: qsTr("Join public chat")
2020-05-29 18:38:11 +00:00
onOpened: {
channelName.text = "";
channelName.input.edit.forceActiveFocus(Qt.MouseFocusReason)
2020-05-29 18:38:11 +00:00
}
2022-02-09 09:43:23 +00:00
2020-05-29 16:27:50 +00:00
Row {
id: description
Layout.fillHeight: false
Layout.fillWidth: true
width: parent.width
StyledText {
2020-06-04 14:53:10 +00:00
width: parent.width
2020-05-29 16:27:50 +00:00
font.pixelSize: 15
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-29 16:27:50 +00:00
}
StatusInput {
id: channelName
input.edit.objectName: "joinPublicChannelInput"
2020-05-29 16:27:50 +00:00
anchors.top: description.bottom
anchors.topMargin: Style.current.padding
placeholderText: qsTr("chat-name")
Keys.onEnterPressed: doJoin()
Keys.onReturnPressed: doJoin()
input.icon.name: "channel"
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
}
StatusScrollView {
id: sview
anchors.top: channelName.bottom
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
Layout.fillHeight: true
Layout.fillWidth: true
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
}
SuggestedChannelsPanel {
2020-09-23 19:36:36 +00:00
id: sectionRepeater
width: parent.width
onSuggestedMessageClicked: {
popup.suggestedMessageClicked(channel);
}
}
2020-05-29 16:27:50 +00:00
}
footer: StatusButton {
objectName: "startChatButton"
2020-05-29 16:27:50 +00:00
anchors.bottom: parent.bottom
anchors.right: parent.right
onClicked : doJoin()
text: qsTr("Start chat")
}
}