From d3c6bcd43c96363d3b8b98893b3273043138d2e4 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Thu, 28 Apr 2022 20:30:22 -0400 Subject: [PATCH] Allow creating spaces --- resources/qml/RoomList.qml | 2 +- resources/qml/dialogs/CreateRoom.qml | 22 ++++++++++++++++++++-- src/ui/NhekoGlobalObject.cpp | 7 ++++++- src/ui/NhekoGlobalObject.h | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/resources/qml/RoomList.qml b/resources/qml/RoomList.qml index 078baede..980d06e3 100644 --- a/resources/qml/RoomList.qml +++ b/resources/qml/RoomList.qml @@ -661,7 +661,7 @@ Page { } Platform.MenuItem { - text: qsTr("Create a new room") + text: qsTr("Create a new room or space") onTriggered: { var createRoom = createRoomComponent.createObject(timelineRoot); createRoom.show(); diff --git a/resources/qml/dialogs/CreateRoom.qml b/resources/qml/dialogs/CreateRoom.qml index 5d224885..c617dc82 100644 --- a/resources/qml/dialogs/CreateRoom.qml +++ b/resources/qml/dialogs/CreateRoom.qml @@ -85,7 +85,7 @@ ApplicationWindow { id: privateHover } ToolTip.visible: privateHover.hovered - ToolTip.text: qsTr("Public rooms can be joined by anyone, private rooms need explicit invites.") + ToolTip.text: qsTr("Public rooms can be joined by anyone; private rooms need explicit invites.") ToolTip.delay: Nheko.tooltipDelay } ToggleButton { @@ -94,6 +94,24 @@ ApplicationWindow { id: isPublic checked: false } + Label { + Layout.preferredWidth: implicitWidth + Layout.alignment: Qt.AlignLeft + text: qsTr("Space") + color: Nheko.colors.text + HoverHandler { + id: spaceHover + } + ToolTip.visible: spaceHover.hovered + ToolTip.text: qsTr("Make this a space for organizing other rooms and spaces.") + ToolTip.delay: Nheko.tooltipDelay + } + ToggleButton { + Layout.alignment: Qt.AlignRight + Layout.preferredWidth: implicitWidth + id: isSpace + checked: false + } Label { Layout.preferredWidth: implicitWidth Layout.alignment: Qt.AlignLeft @@ -150,7 +168,7 @@ ApplicationWindow { else { preset = isTrusted.checked ? 2 : 0; } - Nheko.createRoom(newRoomName.text, newRoomTopic.text, newRoomAlias.text, isEncrypted.checked, preset) + Nheko.createRoom(newRoomName.text, newRoomTopic.text, newRoomAlias.text, isEncrypted.checked, isSpace.checked, preset) createRoomRoot.close(); } } diff --git a/src/ui/NhekoGlobalObject.cpp b/src/ui/NhekoGlobalObject.cpp index 2e1aadf0..9ffbb666 100644 --- a/src/ui/NhekoGlobalObject.cpp +++ b/src/ui/NhekoGlobalObject.cpp @@ -128,7 +128,7 @@ Nheko::logout() const } void -Nheko::createRoom(QString name, QString topic, QString aliasLocalpart, bool isEncrypted, int preset) +Nheko::createRoom(QString name, QString topic, QString aliasLocalpart, bool isEncrypted, bool isSpace, int preset) { mtx::requests::CreateRoom req; @@ -155,5 +155,10 @@ Nheko::createRoom(QString name, QString topic, QString aliasLocalpart, bool isEn req.initial_state.emplace_back(std::move(enc)); } + if (isSpace) { + req.creation_content = mtx::events::state::Create{}; + req.creation_content->type = "m.space"; + } + emit ChatPage::instance()->createRoom(req); } diff --git a/src/ui/NhekoGlobalObject.h b/src/ui/NhekoGlobalObject.h index cfcf31fb..9e1cbd7e 100644 --- a/src/ui/NhekoGlobalObject.h +++ b/src/ui/NhekoGlobalObject.h @@ -53,7 +53,7 @@ public: Q_INVOKABLE void showUserSettingsPage() const; Q_INVOKABLE void logout() const; Q_INVOKABLE void - createRoom(QString name, QString topic, QString aliasLocalpart, bool isEncrypted, int preset); + createRoom(QString name, QString topic, QString aliasLocalpart, bool isEncrypted, bool isSpace, int preset); public slots: void updateUserProfile();