Implement creating spaces
This commit is contained in:
@@ -533,6 +533,27 @@ void Controller::createRoom(const QString &name, const QString &topic)
|
|||||||
connectSingleShot(this, &Controller::roomAdded, &RoomManager::instance(), &RoomManager::enterRoom, Qt::QueuedConnection);
|
connectSingleShot(this, &Controller::roomAdded, &RoomManager::instance(), &RoomManager::enterRoom, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Controller::createSpace(const QString &name, const QString &topic)
|
||||||
|
{
|
||||||
|
auto createRoomJob = m_connection->createRoom(Connection::UnpublishRoom,
|
||||||
|
{},
|
||||||
|
name,
|
||||||
|
topic,
|
||||||
|
QStringList(),
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
QJsonObject{
|
||||||
|
{"type"_ls, "m.space"_ls},
|
||||||
|
});
|
||||||
|
connect(createRoomJob, &CreateRoomJob::failure, this, [this, createRoomJob] {
|
||||||
|
Q_EMIT errorOccured(i18n("Space creation failed: %1", createRoomJob->errorString()));
|
||||||
|
});
|
||||||
|
connectSingleShot(this, &Controller::roomAdded, &RoomManager::instance(), &RoomManager::enterRoom, Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
|
||||||
bool Controller::isOnline() const
|
bool Controller::isOnline() const
|
||||||
{
|
{
|
||||||
return m_isOnline;
|
return m_isOnline;
|
||||||
|
|||||||
@@ -159,6 +159,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
Q_INVOKABLE void createRoom(const QString &name, const QString &topic);
|
Q_INVOKABLE void createRoom(const QString &name, const QString &topic);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create new space.
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE void createSpace(const QString &name, const QString &topic);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Join a room.
|
* @brief Join a room.
|
||||||
*/
|
*/
|
||||||
|
|||||||
44
src/qml/Dialog/CreateSpaceDialog.qml
Normal file
44
src/qml/Dialog/CreateSpaceDialog.qml
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org>
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Controls 2.15 as QQC2
|
||||||
|
import QtQuick.Layouts 1.15
|
||||||
|
import org.kde.kirigami 2.20 as Kirigami
|
||||||
|
|
||||||
|
import org.kde.neochat 1.0
|
||||||
|
import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm
|
||||||
|
|
||||||
|
Kirigami.OverlaySheet {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
title: i18n("Create a Space")
|
||||||
|
|
||||||
|
Kirigami.Theme.colorSet: Kirigami.Theme.Window
|
||||||
|
|
||||||
|
MobileForm.FormCard {
|
||||||
|
contentItem: ColumnLayout {
|
||||||
|
spacing: 0
|
||||||
|
MobileForm.FormCardHeader {
|
||||||
|
title: i18nc("@title", "Create a Space")
|
||||||
|
}
|
||||||
|
MobileForm.FormTextFieldDelegate {
|
||||||
|
id: nameDelegate
|
||||||
|
label: i18n("Space name")
|
||||||
|
}
|
||||||
|
MobileForm.FormTextFieldDelegate {
|
||||||
|
id: topicDelegate
|
||||||
|
label: i18n("Space topic (optional)")
|
||||||
|
}
|
||||||
|
MobileForm.FormButtonDelegate {
|
||||||
|
text: i18n("Create space")
|
||||||
|
onClicked: {
|
||||||
|
Controller.createSpace(nameDelegate.text, topicDelegate.text)
|
||||||
|
root.close()
|
||||||
|
root.destroy()
|
||||||
|
}
|
||||||
|
enabled: nameDelegate.text.length > 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,18 +24,26 @@ QQC2.ToolBar {
|
|||||||
}
|
}
|
||||||
property Kirigami.Action chatAction: Kirigami.Action {
|
property Kirigami.Action chatAction: Kirigami.Action {
|
||||||
text: i18n("Start a Chat")
|
text: i18n("Start a Chat")
|
||||||
icon.name: "irc-join-channel"
|
icon.name: "list-add-user"
|
||||||
onTriggered: applicationWindow().pushReplaceLayer("qrc:/StartChatPage.qml", {connection: Controller.activeConnection})
|
onTriggered: applicationWindow().pushReplaceLayer("qrc:/StartChatPage.qml", {connection: Controller.activeConnection})
|
||||||
}
|
}
|
||||||
property Kirigami.Action roomAction: Kirigami.Action {
|
property Kirigami.Action roomAction: Kirigami.Action {
|
||||||
text: i18n("Create a Room")
|
text: i18n("Create a Room")
|
||||||
icon.name: "irc-join-channel"
|
icon.name: "system-users"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
let dialog = createRoomDialog.createObject(root.overlay);
|
let dialog = createRoomDialog.createObject(root.overlay);
|
||||||
dialog.open();
|
dialog.open();
|
||||||
}
|
}
|
||||||
shortcut: StandardKey.New
|
shortcut: StandardKey.New
|
||||||
}
|
}
|
||||||
|
property Kirigami.Action spaceAction: Kirigami.Action {
|
||||||
|
text: i18n("Create a Space")
|
||||||
|
icon.name: "list-add"
|
||||||
|
onTriggered: {
|
||||||
|
let dialog = createSpaceDialog.createObject(root.overlay);
|
||||||
|
dialog.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
padding: 0
|
padding: 0
|
||||||
|
|
||||||
@@ -86,6 +94,9 @@ QQC2.ToolBar {
|
|||||||
QQC2.MenuItem {
|
QQC2.MenuItem {
|
||||||
action: roomAction
|
action: roomAction
|
||||||
}
|
}
|
||||||
|
QQC2.MenuItem {
|
||||||
|
action: spaceAction
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component {
|
Component {
|
||||||
@@ -123,6 +134,11 @@ QQC2.ToolBar {
|
|||||||
action: roomAction
|
action: roomAction
|
||||||
onClicked: menuRoot.close()
|
onClicked: menuRoot.close()
|
||||||
}
|
}
|
||||||
|
Kirigami.BasicListItem {
|
||||||
|
implicitHeight: Kirigami.Units.gridUnit * 3
|
||||||
|
action: roomAction
|
||||||
|
onClicked: menuRoot.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -323,6 +323,11 @@ Kirigami.ApplicationWindow {
|
|||||||
CreateRoomDialog {}
|
CreateRoomDialog {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: createSpaceDialog
|
||||||
|
CreateSpaceDialog {}
|
||||||
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: roomWindow
|
id: roomWindow
|
||||||
RoomWindow {}
|
RoomWindow {}
|
||||||
|
|||||||
@@ -76,6 +76,7 @@
|
|||||||
<file alias="GroupChatDrawerHeader.qml">qml/Panel/GroupChatDrawerHeader.qml</file>
|
<file alias="GroupChatDrawerHeader.qml">qml/Panel/GroupChatDrawerHeader.qml</file>
|
||||||
<file alias="UserDetailDialog.qml">qml/Dialog/UserDetailDialog.qml</file>
|
<file alias="UserDetailDialog.qml">qml/Dialog/UserDetailDialog.qml</file>
|
||||||
<file alias="CreateRoomDialog.qml">qml/Dialog/CreateRoomDialog.qml</file>
|
<file alias="CreateRoomDialog.qml">qml/Dialog/CreateRoomDialog.qml</file>
|
||||||
|
<file alias="CreateSpaceDialog.qml">qml/Dialog/CreateSpaceDialog.qml</file>
|
||||||
<file alias="EmojiDialog.qml">qml/Dialog/EmojiDialog.qml</file>
|
<file alias="EmojiDialog.qml">qml/Dialog/EmojiDialog.qml</file>
|
||||||
<file alias="OpenFileDialog.qml">qml/Dialog/OpenFileDialog.qml</file>
|
<file alias="OpenFileDialog.qml">qml/Dialog/OpenFileDialog.qml</file>
|
||||||
<file alias="KeyVerificationDialog.qml">qml/Dialog/KeyVerification/KeyVerificationDialog.qml</file>
|
<file alias="KeyVerificationDialog.qml">qml/Dialog/KeyVerification/KeyVerificationDialog.qml</file>
|
||||||
|
|||||||
Reference in New Issue
Block a user