diff --git a/imports/NeoChat/Dialog/AcceptInvitationDialog.qml b/imports/NeoChat/Dialog/AcceptInvitationDialog.qml deleted file mode 100644 index 7f9470251..000000000 --- a/imports/NeoChat/Dialog/AcceptInvitationDialog.qml +++ /dev/null @@ -1,55 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2019 Black Hat - * - * SPDX-License-Identifier: GPL-3.0-only - */ -import QtQuick 2.12 -import QtQuick.Controls 2.12 - -Dialog { - property var room - - anchors.centerIn: parent - width: 360 - - id: root - - title: i18n("Invitation Received") - modal: true - - contentItem: Label { - text: i18n("Accept this invitation?") - } - - footer: DialogButtonBox { - Button { - text: i18n("Accept") - flat: true - - onClicked: { - room.acceptInvitation() - close() - } - } - - Button { - text: i18n("Reject") - flat: true - - onClicked: { - room.forget() - close() - } - } - - Button { - text: i18n("Cancel") - flat: true - - onClicked: close() - } - } - - onClosed: destroy() -} - diff --git a/imports/NeoChat/Dialog/qmldir b/imports/NeoChat/Dialog/qmldir index f673702bd..766a8f656 100644 --- a/imports/NeoChat/Dialog/qmldir +++ b/imports/NeoChat/Dialog/qmldir @@ -3,9 +3,7 @@ RoomSettingsDialog 1.0 RoomSettingsDialog.qml UserDetailDialog 1.0 UserDetailDialog.qml LoginDialog 1.0 LoginDialog.qml CreateRoomDialog 1.0 CreateRoomDialog.qml -InviteUserDialog 1.0 InviteUserDialog.qml AcceptInvitationDialog 1.0 AcceptInvitationDialog.qml -FontFamilyDialog 1.0 FontFamilyDialog.qml OpenFileDialog 1.0 OpenFileDialog.qml OpenFolderDialog 1.0 OpenFolderDialog.qml ImageClipboardDialog 1.0 ImageClipboardDialog.qml diff --git a/imports/NeoChat/Page/InvitationPage.qml b/imports/NeoChat/Page/InvitationPage.qml new file mode 100644 index 000000000..a1c4938a6 --- /dev/null +++ b/imports/NeoChat/Page/InvitationPage.qml @@ -0,0 +1,52 @@ +/** + * SPDX-FileCopyrightText: 2019 Black Hat + * SPDX-FileCopyrightText: 2020 Carl Schwan + * + * SPDX-License-Identifier: GPL-3.0-only + */ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import org.kde.kirigami 2.14 as Kirigami +import QtQuick.Layouts 1.12 + +Kirigami.Page { + id: root + property var room + title: i18n("Invitation Received - %1", room.displayName) + + Kirigami.PlaceholderMessage { + anchors.centerIn: parent + text: i18n("Accept this invitation?") + RowLayout { + Button { + flat: true + Layout.alignment : Qt.AlignHCenter + text: i18n("Cancel") + + onClicked: roomManager.getBack(); + } + + Button { + Layout.alignment : Qt.AlignHCenter + text: i18n("Reject") + flat: true + + onClicked: { + room.forget() + roomManager.getBack(); + } + } + + Button { + Layout.alignment : Qt.AlignHCenter + text: i18n("Accept") + + onClicked: { + room.acceptInvitation(); + roomManager.enterRoom(room); + } + } + } + } +} + diff --git a/imports/NeoChat/Page/RoomListPage.qml b/imports/NeoChat/Page/RoomListPage.qml index bb229dcc1..6b3fc1bc5 100644 --- a/imports/NeoChat/Page/RoomListPage.qml +++ b/imports/NeoChat/Page/RoomListPage.qml @@ -86,9 +86,14 @@ Kirigami.ScrollablePage { action: Kirigami.Action { id: enterRoomAction onTriggered: { - var roomItem = roomManager.enterRoom(currentRoom) - roomListItem.KeyNavigation.right = roomItem - roomItem.focus = true; + console.log(RoomType.Invited) + if (category === RoomType.Invited) { + roomManager.openInvitation(currentRoom); + } else { + var roomItem = roomManager.enterRoom(currentRoom) + roomListItem.KeyNavigation.right = roomItem + roomItem.focus = true; + } } } actions: [ @@ -181,7 +186,7 @@ Kirigami.ScrollablePage { if (mouse.button == Qt.RightButton) { roomListContextMenu.createObject(roomLayout, {"room": currentRoom}).popup() } else { - roomManager.enterRoom(currentRoom) + enterRoomAction.trigger(); } } } diff --git a/qml/main.qml b/qml/main.qml index babd9add4..992cb0d00 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -28,6 +28,7 @@ Kirigami.ApplicationWindow { property var currentRoom: null property alias pageStack: root.pageStack + property bool invitationOpen: false readonly property bool hasOpenRoom: currentRoom !== null @@ -44,18 +45,32 @@ Kirigami.ApplicationWindow { } } - function enterRoom(room) { - if (currentRoom != null) { + let item = null; + if (currentRoom != null || invitationOpen) { currentRoom = null; - pageStack.removePage(pageStack.lastItem); + item = pageStack.replace(roomPage, { 'currentRoom': room, }); + } else { + item = pageStack.push(roomPage, { 'currentRoom': room, }); } - var item = pageStack.push(roomPage, { 'currentRoom': room, }); currentRoom = room; Config.openRoom = room.id; Config.save(); return item; } + + function openInvitation(room) { + if (currentRoom != null) { + currentRoom = null; + pageStack.removePage(pageStack.lastItem); + } + invitationOpen = true; + pageStack.push("qrc:/imports/NeoChat/Page/InvitationPage.qml", {"room": room}); + } + + function getBack() { + pageStack.replace(roomPage, { 'currentRoom': currentRoom, }); + } } contextDrawer: RoomDrawer { diff --git a/res.qrc b/res.qrc index 5f3981c3f..0eff6aeff 100644 --- a/res.qrc +++ b/res.qrc @@ -12,6 +12,7 @@ imports/NeoChat/Page/JoinRoomPage.qml imports/NeoChat/Page/InviteUserPage.qml imports/NeoChat/Page/SettingsPage.qml + imports/NeoChat/Page/InvitationPage.qml imports/NeoChat/Component/qmldir imports/NeoChat/Component/ChatTextInput.qml imports/NeoChat/Component/AutoMouseArea.qml @@ -48,7 +49,6 @@ imports/NeoChat/Dialog/UserDetailDialog.qml imports/NeoChat/Menu/Timeline/MessageSourceSheet.qml imports/NeoChat/Dialog/CreateRoomDialog.qml - imports/NeoChat/Dialog/AcceptInvitationDialog.qml imports/NeoChat/Dialog/StartChatDialog.qml imports/NeoChat/Dialog/OpenFileDialog.qml imports/NeoChat/Dialog/OpenFolderDialog.qml