Fix MessageDelegateContextMenu not being displayed

It turnout that using an QML Singleton was a bad idea, instead create a
qml object in the main component and refer to it in the rest of the
codebase.

This commit also simplify a bit the qml structure of the Menu and fix
some visual bugs.
This commit is contained in:
Carl Schwan
2020-11-16 10:00:18 +01:00
parent 523adace21
commit 6db8354727
7 changed files with 57 additions and 75 deletions

View File

@@ -11,7 +11,6 @@ import QtQuick.Layouts 1.14
import org.kde.kirigami 2.12 as Kirigami
import org.kde.neochat 1.0
import NeoChat 1.0
import NeoChat.Component 1.0
import NeoChat.Panel 1.0
import NeoChat.Dialog 1.0
@@ -22,7 +21,35 @@ Kirigami.ApplicationWindow {
id: root
property var currentRoom: null
Component.onCompleted: RoomManager.pageStack = root.pageStack
/**
* Manage opening and close rooms
*/
Item {
id: roomManager
property var currentRoom: null
property alias pageStack: root.pageStack
readonly property bool hasOpenRoom: currentRoom != null
signal leaveRoom(string room);
signal openRoom(string room);
function enterRoom(room) {
if (currentRoom != null) {
currentRoom = null;
pageStack.removePage(pageStack.lastItem);
}
pageStack.push(roomPage, { 'currentRoom': room, });
currentRoom = room;
}
Component {
id: roomPage
RoomPage {}
}
}
contextDrawer: RoomDrawer {
id: contextDrawer