matrixion/resources/qml/dialogs/CreateRoom.qml

178 lines
4.9 KiB
QML
Raw Normal View History

// SPDX-FileCopyrightText: Nheko Contributors
2022-03-26 00:30:19 +03:00
//
// SPDX-License-Identifier: GPL-3.0-or-later
import ".."
import QtQuick 2.15
import QtQuick.Window 2.13
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.3
import im.nheko 1.0
ApplicationWindow {
id: createRoomRoot
2022-09-05 03:00:20 +03:00
property bool space: false
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
2023-10-31 05:11:03 +03:00
minimumHeight: rootLayout.implicitHeight + footer.implicitHeight + 2 * rootLayout.anchors.margins
minimumWidth: Math.max(rootLayout.implicitWidth + 2 * rootLayout.anchors.margins, footer.implicitWidth + Nheko.paddingLarge)
modality: Qt.NonModal
title: space ? qsTr("New community") : qsTr("New Room")
footer: DialogButtonBox {
standardButtons: DialogButtonBox.Cancel
onAccepted: {
var preset = 0;
if (isPublic.checked) {
preset = 1;
} else {
preset = isTrusted.checked ? 2 : 0;
}
Nheko.createRoom(space, newRoomName.text, newRoomTopic.text, newRoomAlias.text, isEncrypted.checked, preset);
createRoomRoot.close();
}
onRejected: createRoomRoot.close()
Button {
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
text: qsTr("Create Room")
}
}
onVisibilityChanged: {
newRoomName.forceActiveFocus();
}
2022-03-27 23:32:29 +03:00
Shortcut {
sequence: StandardKey.Cancel
2023-10-31 05:11:03 +03:00
2022-03-27 23:32:29 +03:00
onActivated: createRoomRoot.close()
}
2022-03-26 00:30:19 +03:00
GridLayout {
id: rootLayout
2023-10-31 05:11:03 +03:00
2022-03-26 00:30:19 +03:00
anchors.fill: parent
anchors.margins: Nheko.paddingLarge
2022-03-26 00:30:19 +03:00
columns: 2
rowSpacing: Nheko.paddingMedium
2022-03-26 00:30:19 +03:00
MatrixTextField {
id: newRoomName
2023-10-31 05:11:03 +03:00
2022-03-26 00:30:19 +03:00
Layout.columnSpan: 2
Layout.fillWidth: true
focus: true
label: qsTr("Name")
placeholderText: qsTr("No name")
2022-03-26 00:30:19 +03:00
}
MatrixTextField {
id: newRoomTopic
2023-10-31 05:11:03 +03:00
2022-03-26 00:30:19 +03:00
Layout.columnSpan: 2
Layout.fillWidth: true
focus: true
label: qsTr("Topic")
placeholderText: qsTr("No topic")
2022-03-26 00:30:19 +03:00
}
Item {
Layout.preferredHeight: newRoomName.height / 2
}
2022-03-27 23:32:29 +03:00
RowLayout {
2022-03-26 00:30:19 +03:00
Layout.columnSpan: 2
Layout.fillWidth: true
2023-10-31 05:11:03 +03:00
2022-03-27 23:32:29 +03:00
Label {
Layout.preferredWidth: implicitWidth
color: palette.text
2023-10-31 05:11:03 +03:00
text: "#"
2022-03-27 23:32:29 +03:00
}
MatrixTextField {
id: newRoomAlias
2023-10-31 05:11:03 +03:00
2022-03-27 23:32:29 +03:00
focus: true
placeholderText: qsTr("Alias")
}
Label {
property string userName: userInfoGrid.profile.userid
2023-10-31 05:11:03 +03:00
Layout.preferredWidth: implicitWidth
color: palette.text
2023-10-31 05:11:03 +03:00
text: userName.substring(userName.indexOf(":"))
2022-03-27 23:32:29 +03:00
}
2022-03-26 00:30:19 +03:00
}
Label {
Layout.alignment: Qt.AlignLeft
2023-10-31 05:11:03 +03:00
Layout.preferredWidth: implicitWidth
ToolTip.delay: Nheko.tooltipDelay
ToolTip.text: qsTr("Public rooms can be joined by anyone; private rooms need explicit invites.")
ToolTip.visible: privateHover.hovered
color: palette.text
2023-10-31 05:11:03 +03:00
text: qsTr("Public")
2022-03-27 23:32:29 +03:00
HoverHandler {
id: privateHover
2023-10-31 05:11:03 +03:00
2022-03-27 23:32:29 +03:00
}
2022-03-26 00:30:19 +03:00
}
2022-03-27 23:32:29 +03:00
ToggleButton {
2023-10-31 05:11:03 +03:00
id: isPublic
2022-03-26 00:30:19 +03:00
Layout.alignment: Qt.AlignRight
2022-03-27 23:32:29 +03:00
Layout.preferredWidth: implicitWidth
checked: false
2022-03-26 00:30:19 +03:00
}
Label {
Layout.alignment: Qt.AlignLeft
2023-10-31 05:11:03 +03:00
Layout.preferredWidth: implicitWidth
ToolTip.delay: Nheko.tooltipDelay
ToolTip.text: qsTr("All invitees are given the same power level as the creator")
ToolTip.visible: trustedHover.hovered
color: palette.text
2023-10-31 05:11:03 +03:00
text: qsTr("Trusted")
visible: !space
2022-03-27 23:32:29 +03:00
HoverHandler {
id: trustedHover
2023-10-31 05:11:03 +03:00
2022-03-27 23:32:29 +03:00
}
}
ToggleButton {
2023-10-31 05:11:03 +03:00
id: isTrusted
2022-03-27 23:32:29 +03:00
Layout.alignment: Qt.AlignRight
Layout.preferredWidth: implicitWidth
checked: false
enabled: !isPublic.checked
2023-10-31 05:11:03 +03:00
visible: !space
2022-03-26 00:30:19 +03:00
}
2022-03-27 23:32:29 +03:00
Label {
Layout.alignment: Qt.AlignLeft
2023-10-31 05:11:03 +03:00
Layout.preferredWidth: implicitWidth
ToolTip.delay: Nheko.tooltipDelay
ToolTip.text: qsTr("Caution: Encryption cannot be disabled")
ToolTip.visible: encryptionHover.hovered
color: palette.text
2023-10-31 05:11:03 +03:00
text: qsTr("Encryption")
visible: !space
2022-03-27 23:32:29 +03:00
HoverHandler {
id: encryptionHover
2023-10-31 05:11:03 +03:00
2022-03-27 23:32:29 +03:00
}
}
ToggleButton {
2023-10-31 05:11:03 +03:00
id: isEncrypted
2022-03-26 00:30:19 +03:00
Layout.alignment: Qt.AlignRight
2022-03-27 23:32:29 +03:00
Layout.preferredWidth: implicitWidth
checked: false
2023-10-31 05:11:03 +03:00
visible: !space
2022-03-26 00:30:19 +03:00
}
2023-10-31 05:11:03 +03:00
Item {
Layout.fillHeight: true
}
2022-03-26 00:30:19 +03:00
}
}