diff --git a/resources/qml/RoomList.qml b/resources/qml/RoomList.qml
index 702d77e5..078baede 100644
--- a/resources/qml/RoomList.qml
+++ b/resources/qml/RoomList.qml
@@ -26,6 +26,20 @@ Page {
}
+ Component {
+ id: createRoomComponent
+
+ CreateRoom {
+ }
+ }
+
+ Component {
+ id: createDirectComponent
+
+ CreateDirect {
+ }
+ }
+
ListView {
id: roomlist
@@ -648,7 +662,20 @@ Page {
Platform.MenuItem {
text: qsTr("Create a new room")
- onTriggered: Nheko.openCreateRoomDialog()
+ onTriggered: {
+ var createRoom = createRoomComponent.createObject(timelineRoot);
+ createRoom.show();
+ timelineRoot.destroyOnClose(createRoom);
+ }
+ }
+
+ Platform.MenuItem {
+ text: qsTr("Start a direct chat")
+ onTriggered: {
+ var createDirect = createDirectComponent.createObject(timelineRoot);
+ createDirect.show();
+ timelineRoot.destroyOnClose(createDirect);
+ }
}
}
diff --git a/resources/qml/dialogs/CreateDirect.qml b/resources/qml/dialogs/CreateDirect.qml
new file mode 100644
index 00000000..85768cad
--- /dev/null
+++ b/resources/qml/dialogs/CreateDirect.qml
@@ -0,0 +1,116 @@
+// 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 QtQml.Models 2.15
+import im.nheko 1.0
+
+ApplicationWindow {
+ id: createDirectRoot
+ title: qsTr("Create Direct Chat")
+ property var profile
+ property bool otherUserHasE2ee: profile? profile.deviceList.rowCount() > 0 : true
+ minimumHeight: layout.implicitHeight + footer.implicitHeight + Nheko.paddingLarge*2
+ minimumWidth: Math.max(footer.implicitWidth, layout.implicitWidth)
+ modality: Qt.NonModal
+ flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
+
+ onVisibilityChanged: {
+ userID.forceActiveFocus();
+ }
+
+ Shortcut {
+ sequence: StandardKey.Cancel
+ onActivated: createDirectRoot.close()
+ }
+
+ ColumnLayout {
+ id: layout
+ anchors.fill: parent
+ anchors.margins: Nheko.paddingLarge
+ spacing: userID.height/4
+
+ GridLayout {
+ Layout.fillWidth: true
+ rows: 2
+ columns: 2
+ rowSpacing: Nheko.paddingSmall
+ columnSpacing: Nheko.paddingMedium
+
+ Avatar {
+ Layout.rowSpan: 2
+ Layout.preferredWidth: Nheko.avatarSize
+ Layout.preferredHeight: Nheko.avatarSize
+ Layout.alignment: Qt.AlignLeft
+ userid: profile? profile.userid : ""
+ url: profile? profile.avatarUrl.replace("mxc://", "image://MxcImage/") : null
+ displayName: profile? profile.displayName : ""
+ enabled: false
+ }
+ Label {
+ Layout.fillWidth: true
+ text: profile? profile.displayName : ""
+ color: TimelineManager.userColor(userID.text, Nheko.colors.window)
+ font.pointSize: fontMetrics.font.pointSize
+ }
+
+ Label {
+ Layout.fillWidth: true
+ text: userID.text
+ color: Nheko.colors.buttonText
+ font.pointSize: fontMetrics.font.pointSize * 0.9
+ }
+ }
+
+ MatrixTextField {
+ id: userID
+ property bool isValidMxid: text.match("@.+?:.{3,}")
+ Layout.fillWidth: true
+ focus: true
+ label: qsTr("User to invite")
+ placeholderText: qsTr("@user:server.tld")
+ onTextChanged: {
+ if(isValidMxid) {
+ profile = TimelineManager.getGlobalUserProfile(text);
+ } else
+ profile = null;
+ }
+ }
+
+ RowLayout {
+ Layout.fillWidth: true
+ Label {
+ Layout.fillWidth: true
+ Layout.alignment: Qt.AlignLeft
+ text: qsTr("Encryption")
+ color: Nheko.colors.text
+ }
+ ToggleButton {
+ Layout.alignment: Qt.AlignRight
+ id: encryption
+ checked: otherUserHasE2ee
+ }
+ }
+
+ Item {Layout.fillHeight: true}
+ }
+ footer: DialogButtonBox {
+ standardButtons: DialogButtonBox.Cancel
+ Button {
+ text: "Start Direct Chat"
+ DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
+ enabled: userID.isValidMxid
+ }
+ onRejected: createDirectRoot.close();
+ onAccepted: {
+ profile.startChat(encryption.checked)
+ createDirectRoot.close()
+ }
+ }
+}
diff --git a/resources/qml/dialogs/CreateRoom.qml b/resources/qml/dialogs/CreateRoom.qml
new file mode 100644
index 00000000..5d224885
--- /dev/null
+++ b/resources/qml/dialogs/CreateRoom.qml
@@ -0,0 +1,157 @@
+// 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)
+ minimumHeight: rootLayout.implicitHeight+footer.implicitHeight+2*rootLayout.anchors.margins
+ modality: Qt.NonModal
+ flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
+
+ onVisibilityChanged: {
+ newRoomName.forceActiveFocus();
+ }
+
+ Shortcut {
+ sequence: StandardKey.Cancel
+ onActivated: createRoomRoot.close()
+ }
+ GridLayout {
+ id: rootLayout
+ anchors.fill: parent
+ anchors.margins: Nheko.paddingLarge
+ columns: 2
+ rowSpacing: Nheko.paddingMedium
+
+ MatrixTextField {
+ id: newRoomName
+ Layout.columnSpan: 2
+ Layout.fillWidth: true
+
+ focus: true
+ label: qsTr("Name")
+ placeholderText: qsTr("No name")
+ }
+ MatrixTextField {
+ id: newRoomTopic
+ Layout.columnSpan: 2
+ Layout.fillWidth: true
+
+ focus: true
+ label: qsTr("Topic")
+ placeholderText: qsTr("No topic")
+ }
+
+ Item {
+ Layout.preferredHeight: newRoomName.height / 2
+ }
+
+ RowLayout {
+ Layout.columnSpan: 2
+ Layout.fillWidth: true
+ 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
+ }
+ }
+ Label {
+ Layout.preferredWidth: implicitWidth
+ Layout.alignment: Qt.AlignLeft
+ text: qsTr("Public")
+ color: Nheko.colors.text
+ HoverHandler {
+ id: privateHover
+ }
+ ToolTip.visible: privateHover.hovered
+ ToolTip.text: qsTr("Public rooms can be joined by anyone, private rooms need explicit invites.")
+ ToolTip.delay: Nheko.tooltipDelay
+ }
+ ToggleButton {
+ Layout.alignment: Qt.AlignRight
+ Layout.preferredWidth: implicitWidth
+ id: isPublic
+ checked: false
+ }
+ Label {
+ Layout.preferredWidth: implicitWidth
+ Layout.alignment: Qt.AlignLeft
+ text: qsTr("Trusted")
+ color: Nheko.colors.text
+ 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
+ }
+ Label {
+ Layout.preferredWidth: implicitWidth
+ 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 {
+ Layout.alignment: Qt.AlignRight
+ Layout.preferredWidth: implicitWidth
+ id: isEncrypted
+ checked: false
+ }
+
+ Item {Layout.fillHeight: true}
+ }
+ footer: DialogButtonBox {
+ standardButtons: DialogButtonBox.Cancel
+ Button {
+ text: qsTr("Create Room")
+ 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();
+ }
+ }
+}
diff --git a/resources/res.qrc b/resources/res.qrc
index 3b762d20..3ce63f42 100644
--- a/resources/res.qrc
+++ b/resources/res.qrc
@@ -143,6 +143,8 @@
<file>qml/device-verification/NewVerificationRequest.qml</file>
<file>qml/device-verification/Success.qml</file>
<file>qml/device-verification/Waiting.qml</file>
+ <file>qml/dialogs/CreateDirect.qml</file>
+ <file>qml/dialogs/CreateRoom.qml</file>
<file>qml/dialogs/ImageOverlay.qml</file>
<file>qml/dialogs/ImagePackEditorDialog.qml</file>
<file>qml/dialogs/ImagePackSettingsDialog.qml</file>
|