matrixion/resources/qml/dialogs/CreateRoom.qml

158 lines
4.8 KiB
QML
Raw Permalink Normal View History

2022-03-26 00:30:19 +03:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
// SPDX-FileCopyrightText: 2022 Nheko Contributors
//
// 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
title: qsTr("Create Room")
minimumWidth: Math.max(rootLayout.implicitWidth+2*rootLayout.anchors.margins, footer.implicitWidth + Nheko.paddingLarge)
2022-03-26 00:30:19 +03:00
minimumHeight: rootLayout.implicitHeight+footer.implicitHeight+2*rootLayout.anchors.margins
modality: Qt.NonModal
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
onVisibilityChanged: {
newRoomName.forceActiveFocus();
}
2022-03-27 23:32:29 +03:00
Shortcut {
sequence: StandardKey.Cancel
onActivated: createRoomRoot.close()
}
2022-03-26 00:30:19 +03:00
GridLayout {
id: rootLayout
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
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
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
2022-03-27 23:32:29 +03:00
Label {
Layout.preferredWidth: implicitWidth
text: qsTr("#")
color: Nheko.colors.text
}
MatrixTextField {
id: newRoomAlias
focus: true
placeholderText: qsTr("Alias")
}
Label {
Layout.preferredWidth: implicitWidth
property string userName: userInfoGrid.profile.userid
text: userName.substring(userName.indexOf(":"))
color: Nheko.colors.text
}
2022-03-26 00:30:19 +03:00
}
Label {
Layout.preferredWidth: implicitWidth
Layout.alignment: Qt.AlignLeft
text: qsTr("Public")
2022-03-26 00:30:19 +03:00
color: Nheko.colors.text
2022-03-27 23:32:29 +03:00
HoverHandler {
id: privateHover
}
ToolTip.visible: privateHover.hovered
ToolTip.text: qsTr("Public rooms can be joined by anyone, private rooms need explicit invites.")
2022-03-27 23:32:29 +03:00
ToolTip.delay: Nheko.tooltipDelay
2022-03-26 00:30:19 +03:00
}
2022-03-27 23:32:29 +03:00
ToggleButton {
2022-03-26 00:30:19 +03:00
Layout.alignment: Qt.AlignRight
2022-03-27 23:32:29 +03:00
Layout.preferredWidth: implicitWidth
id: isPublic
checked: false
2022-03-26 00:30:19 +03:00
}
Label {
Layout.preferredWidth: implicitWidth
Layout.alignment: Qt.AlignLeft
2022-03-27 23:32:29 +03:00
text: qsTr("Trusted")
2022-03-26 00:30:19 +03:00
color: Nheko.colors.text
2022-03-27 23:32:29 +03:00
HoverHandler {
id: trustedHover
}
ToolTip.visible: trustedHover.hovered
ToolTip.text: qsTr("All invitees are given the same power level as the creator")
ToolTip.delay: Nheko.tooltipDelay
}
ToggleButton {
Layout.alignment: Qt.AlignRight
Layout.preferredWidth: implicitWidth
id: isTrusted
checked: false
enabled: !isPublic.checked
2022-03-26 00:30:19 +03:00
}
2022-03-27 23:32:29 +03:00
Label {
2022-03-26 00:30:19 +03:00
Layout.preferredWidth: implicitWidth
2022-03-27 23:32:29 +03:00
Layout.alignment: Qt.AlignLeft
text: qsTr("Encryption")
color: Nheko.colors.text
HoverHandler {
id: encryptionHover
}
ToolTip.visible: encryptionHover.hovered
ToolTip.text: qsTr("Caution: Encryption cannot be disabled")
ToolTip.delay: Nheko.tooltipDelay
}
ToggleButton {
2022-03-26 00:30:19 +03:00
Layout.alignment: Qt.AlignRight
2022-03-27 23:32:29 +03:00
Layout.preferredWidth: implicitWidth
id: isEncrypted
checked: false
2022-03-26 00:30:19 +03:00
}
Item {Layout.fillHeight: true}
2022-03-26 00:30:19 +03:00
}
footer: DialogButtonBox {
standardButtons: DialogButtonBox.Cancel
Button {
2022-03-27 23:32:29 +03:00
text: qsTr("Create Room")
2022-03-26 00:30:19 +03:00
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
}
onRejected: createRoomRoot.close();
onAccepted: {
var preset = 0;
if (isPublic.checked) {
preset = 1;
}
else {
preset = isTrusted.checked ? 2 : 0;
}
Nheko.createRoom(newRoomName.text, newRoomTopic.text, newRoomAlias.text, isEncrypted.checked, preset)
createRoomRoot.close();
}
2022-03-26 00:30:19 +03:00
}
}