Add option to accept invitation
This commit is contained in:
@@ -1,55 +0,0 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019 Black Hat <bhat@encom.eu.org>
|
||||
*
|
||||
* 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()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
52
imports/NeoChat/Page/InvitationPage.qml
Normal file
52
imports/NeoChat/Page/InvitationPage.qml
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019 Black Hat <bhat@encom.eu.org>
|
||||
* SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
23
qml/main.qml
23
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 {
|
||||
|
||||
2
res.qrc
2
res.qrc
@@ -12,6 +12,7 @@
|
||||
<file>imports/NeoChat/Page/JoinRoomPage.qml</file>
|
||||
<file>imports/NeoChat/Page/InviteUserPage.qml</file>
|
||||
<file>imports/NeoChat/Page/SettingsPage.qml</file>
|
||||
<file>imports/NeoChat/Page/InvitationPage.qml</file>
|
||||
<file>imports/NeoChat/Component/qmldir</file>
|
||||
<file>imports/NeoChat/Component/ChatTextInput.qml</file>
|
||||
<file>imports/NeoChat/Component/AutoMouseArea.qml</file>
|
||||
@@ -48,7 +49,6 @@
|
||||
<file>imports/NeoChat/Dialog/UserDetailDialog.qml</file>
|
||||
<file>imports/NeoChat/Menu/Timeline/MessageSourceSheet.qml</file>
|
||||
<file>imports/NeoChat/Dialog/CreateRoomDialog.qml</file>
|
||||
<file>imports/NeoChat/Dialog/AcceptInvitationDialog.qml</file>
|
||||
<file>imports/NeoChat/Dialog/StartChatDialog.qml</file>
|
||||
<file>imports/NeoChat/Dialog/OpenFileDialog.qml</file>
|
||||
<file>imports/NeoChat/Dialog/OpenFolderDialog.qml</file>
|
||||
|
||||
Reference in New Issue
Block a user