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:
@@ -14,9 +14,9 @@ import NeoChat.Dialog 1.0
|
|||||||
Kirigami.OverlaySheet {
|
Kirigami.OverlaySheet {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
required property var author;
|
required property var author
|
||||||
required property string message;
|
required property string message
|
||||||
required property string eventId;
|
required property string eventId
|
||||||
|
|
||||||
signal viewSource()
|
signal viewSource()
|
||||||
signal reply(var author, string message)
|
signal reply(var author, string message)
|
||||||
@@ -29,32 +29,31 @@ Kirigami.OverlaySheet {
|
|||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
spacing: 0
|
spacing: 0
|
||||||
QQC2.Control {
|
RowLayout {
|
||||||
leftPadding: Kirigami.Units.largeSpacing
|
id: headerLayout
|
||||||
rightPadding: Kirigami.Units.largeSpacing
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
implicitHeight: headerLayout.implicitHeight
|
Layout.leftMargin: Kirigami.Units.largeSpacing
|
||||||
contentItem: RowLayout {
|
Layout.rightMargin: Kirigami.Units.largeSpacing
|
||||||
id: headerLayout
|
spacing: Kirigami.Units.largeSpacing
|
||||||
|
Kirigami.Avatar {
|
||||||
|
id: avatar
|
||||||
|
source: author.avatarMediaId ? "image://mxc/" + author.avatarMediaId : ""
|
||||||
|
Layout.preferredWidth: Kirigami.Units.gridUnit * 3
|
||||||
|
Layout.preferredHeight: Kirigami.Units.gridUnit * 3
|
||||||
|
Layout.alignment: Qt.AlignTop
|
||||||
|
}
|
||||||
|
ColumnLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
spacing: Kirigami.Units.largeSpacing
|
Kirigami.Heading {
|
||||||
Kirigami.Avatar {
|
level: 3
|
||||||
source: author.avatarMediaId ? "image://mxc/" + author.avatarMediaId : ""
|
|
||||||
Layout.preferredWidth: Kirigami.Units.iconSizes.large
|
|
||||||
Layout.preferredHeight: Kirigami.Units.iconSizes.large
|
|
||||||
Layout.alignment: Qt.AlignTop
|
|
||||||
}
|
|
||||||
ColumnLayout {
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Kirigami.Heading {
|
text: author.displayName
|
||||||
level: 3
|
wrapMode: Text.WordWrap
|
||||||
Layout.fillWidth: true
|
}
|
||||||
text: author.displayName
|
QQC2.Label {
|
||||||
}
|
text: message
|
||||||
QQC2.Label {
|
Layout.fillWidth: true
|
||||||
text: message
|
wrapMode: Text.WordWrap
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ Kirigami.ScrollablePage {
|
|||||||
if (!identifierField.isJoined) {
|
if (!identifierField.isJoined) {
|
||||||
Controller.joinRoom(connection, identifierField.text);
|
Controller.joinRoom(connection, identifierField.text);
|
||||||
}
|
}
|
||||||
RoomManager.enterRoom(connection.room(identifierField.room));
|
roomManager.enterRoom(connection.room(identifierField.room));
|
||||||
applicationWindow().pageStack.layers.pop();
|
applicationWindow().pageStack.layers.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,7 +112,7 @@ Kirigami.ScrollablePage {
|
|||||||
Controller.joinRoom(connection, roomID)
|
Controller.joinRoom(connection, roomID)
|
||||||
justJoined = true;
|
justJoined = true;
|
||||||
} else {
|
} else {
|
||||||
RoomManager.enterRoom(connection.room(roomID))
|
roomManager.enterRoom(connection.room(roomID))
|
||||||
applicationWindow().pageStack.layers.pop();
|
applicationWindow().pageStack.layers.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import org.kde.kirigami 2.13 as Kirigami
|
|||||||
import org.kde.kitemmodels 1.0
|
import org.kde.kitemmodels 1.0
|
||||||
import org.kde.neochat 1.0
|
import org.kde.neochat 1.0
|
||||||
|
|
||||||
import NeoChat 1.0
|
|
||||||
import NeoChat.Component 1.0
|
import NeoChat.Component 1.0
|
||||||
import NeoChat.Menu 1.0
|
import NeoChat.Menu 1.0
|
||||||
|
|
||||||
@@ -135,7 +134,7 @@ Kirigami.ScrollablePage {
|
|||||||
if (mouse.button == Qt.RightButton) {
|
if (mouse.button == Qt.RightButton) {
|
||||||
roomListContextMenu.createObject(parent, {"room": currentRoom}).popup()
|
roomListContextMenu.createObject(parent, {"room": currentRoom}).popup()
|
||||||
} else {
|
} else {
|
||||||
RoomManager.enterRoom(currentRoom)
|
roomManager.enterRoom(currentRoom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
/**
|
|
||||||
* SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma Singleton
|
|
||||||
|
|
||||||
import QtQuick 2.14
|
|
||||||
import NeoChat.Page 1.0
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Manage opening and close rooms
|
|
||||||
*/
|
|
||||||
Item {
|
|
||||||
id: openRoomAction
|
|
||||||
|
|
||||||
property var currentRoom: null
|
|
||||||
property var pageStack: null
|
|
||||||
|
|
||||||
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 {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
singleton RoomManager 1.0 RoomManager.qml
|
|
||||||
31
qml/main.qml
31
qml/main.qml
@@ -11,7 +11,6 @@ import QtQuick.Layouts 1.14
|
|||||||
import org.kde.kirigami 2.12 as Kirigami
|
import org.kde.kirigami 2.12 as Kirigami
|
||||||
|
|
||||||
import org.kde.neochat 1.0
|
import org.kde.neochat 1.0
|
||||||
import NeoChat 1.0
|
|
||||||
import NeoChat.Component 1.0
|
import NeoChat.Component 1.0
|
||||||
import NeoChat.Panel 1.0
|
import NeoChat.Panel 1.0
|
||||||
import NeoChat.Dialog 1.0
|
import NeoChat.Dialog 1.0
|
||||||
@@ -22,7 +21,35 @@ Kirigami.ApplicationWindow {
|
|||||||
id: root
|
id: root
|
||||||
property var currentRoom: null
|
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 {
|
contextDrawer: RoomDrawer {
|
||||||
id: contextDrawer
|
id: contextDrawer
|
||||||
|
|||||||
2
res.qrc
2
res.qrc
@@ -3,8 +3,6 @@
|
|||||||
<file>assets/img/matrix.svg</file>
|
<file>assets/img/matrix.svg</file>
|
||||||
<file>assets/img/icon.png</file>
|
<file>assets/img/icon.png</file>
|
||||||
<file>qml/main.qml</file>
|
<file>qml/main.qml</file>
|
||||||
<file>imports/NeoChat/qmldir</file>
|
|
||||||
<file>imports/NeoChat/RoomManager.qml</file>
|
|
||||||
<file>imports/NeoChat/Page/qmldir</file>
|
<file>imports/NeoChat/Page/qmldir</file>
|
||||||
<file>imports/NeoChat/Page/LoginPage.qml</file>
|
<file>imports/NeoChat/Page/LoginPage.qml</file>
|
||||||
<file>imports/NeoChat/Page/LoadingPage.qml</file>
|
<file>imports/NeoChat/Page/LoadingPage.qml</file>
|
||||||
|
|||||||
Reference in New Issue
Block a user