Cleanup connection handling in QML
Consistently pass connection objects to files that need them instead of randomly using Controller.activeConnection in some of them
This commit is contained in:
committed by
Carl Schwan
parent
6439fa48f9
commit
5e80715898
@@ -46,6 +46,8 @@ QQC2.Control {
|
||||
*/
|
||||
property alias textField: textField
|
||||
|
||||
property NeoChatConnection connection
|
||||
|
||||
/**
|
||||
* @brief The list of actions in the ChatBar.
|
||||
*
|
||||
@@ -414,6 +416,7 @@ QQC2.Control {
|
||||
y: -height - 5
|
||||
z: 1
|
||||
chatDocumentHandler: documentHandler
|
||||
connection: root.connection
|
||||
Behavior on height {
|
||||
NumberAnimation {
|
||||
property: "height"
|
||||
|
||||
@@ -36,6 +36,8 @@ ColumnLayout {
|
||||
*/
|
||||
required property NeoChatRoom currentRoom
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
/**
|
||||
* @brief A message has been sent from the chat bar.
|
||||
*/
|
||||
@@ -62,6 +64,8 @@ ColumnLayout {
|
||||
ChatBar {
|
||||
id: chatBar
|
||||
|
||||
connection: root.connection
|
||||
|
||||
visible: root.currentRoom.canSendEvent("m.room.message")
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
@@ -17,11 +17,13 @@ QQC2.Popup {
|
||||
id: root
|
||||
width: parent.width
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
visible: completions.count > 0
|
||||
|
||||
RoomListModel {
|
||||
id: roomListModel
|
||||
connection: Controller.activeConnection
|
||||
connection: root.connection
|
||||
}
|
||||
|
||||
property var chatDocumentHandler
|
||||
|
||||
@@ -14,6 +14,7 @@ ColumnLayout {
|
||||
id: root
|
||||
|
||||
required property NeoChatRoom room
|
||||
required property NeoChatConnection connection
|
||||
|
||||
FormCard.FormHeader {
|
||||
title: i18nc("@title", "Choose Room")
|
||||
@@ -26,7 +27,7 @@ ColumnLayout {
|
||||
valueRole: "roomId"
|
||||
model: RoomListModel {
|
||||
id: roomListModel
|
||||
connection: Controller.activeConnection
|
||||
connection: root.connection
|
||||
}
|
||||
currentIndex: -1
|
||||
Component.onCompleted: currentIndex = roomListModel.rowForRoom(root.room)
|
||||
|
||||
@@ -12,13 +12,17 @@ import org.kde.kitemmodels 1.0
|
||||
import org.kde.neochat 1.0
|
||||
|
||||
ColumnLayout {
|
||||
id: root
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
FormCard.FormHeader {
|
||||
title: i18n("Server Capabilities")
|
||||
}
|
||||
FormCard.FormCard {
|
||||
FormCard.FormTextDelegate {
|
||||
text: i18n("Can change password")
|
||||
description: Controller.activeConnection.canChangePassword
|
||||
description: root.connection.canChangePassword
|
||||
}
|
||||
}
|
||||
FormCard.FormHeader {
|
||||
@@ -26,7 +30,7 @@ ColumnLayout {
|
||||
}
|
||||
FormCard.FormCard {
|
||||
FormCard.FormTextDelegate {
|
||||
text: Controller.activeConnection.defaultRoomVersion
|
||||
text: root.connection.defaultRoomVersion
|
||||
}
|
||||
}
|
||||
FormCard.FormHeader {
|
||||
|
||||
@@ -14,6 +14,8 @@ import './RoomList' as RoomList
|
||||
QQC2.Dialog {
|
||||
id: root
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
parent: applicationWindow().overlay
|
||||
width: Math.min(700, parent.width)
|
||||
height: 400
|
||||
@@ -84,13 +86,15 @@ QQC2.Dialog {
|
||||
filterText: searchField.text
|
||||
sourceModel: RoomListModel {
|
||||
id: roomListModel
|
||||
connection: Controller.activeConnection
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
delegate: RoomList.RoomDelegate {
|
||||
filterText: searchField.text
|
||||
|
||||
connection: root.connection
|
||||
|
||||
onClicked: {
|
||||
RoomManager.enterRoom(currentRoom);
|
||||
root.close()
|
||||
|
||||
@@ -10,8 +10,10 @@ import org.kde.neochat 1.0
|
||||
|
||||
DelegateChooser {
|
||||
id: root
|
||||
|
||||
role: "delegateType"
|
||||
property var room
|
||||
required property NeoChatConnection connection
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.State
|
||||
@@ -20,22 +22,30 @@ DelegateChooser {
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Emote
|
||||
delegate: MessageDelegate {}
|
||||
delegate: MessageDelegate {
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Message
|
||||
delegate: MessageDelegate {}
|
||||
delegate: MessageDelegate {
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Notice
|
||||
delegate: MessageDelegate {}
|
||||
delegate: MessageDelegate {
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Image
|
||||
delegate: ImageDelegate {}
|
||||
delegate: ImageDelegate {
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
@@ -45,22 +55,30 @@ DelegateChooser {
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Audio
|
||||
delegate: AudioDelegate {}
|
||||
delegate: AudioDelegate {
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Video
|
||||
delegate: VideoDelegate {}
|
||||
delegate: VideoDelegate {
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.File
|
||||
delegate: FileDelegate {}
|
||||
delegate: FileDelegate {
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Encrypted
|
||||
delegate: EncryptedDelegate {}
|
||||
delegate: EncryptedDelegate {
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
@@ -70,17 +88,22 @@ DelegateChooser {
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Poll
|
||||
delegate: PollDelegate {}
|
||||
delegate: PollDelegate {
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Location
|
||||
delegate: LocationDelegate {}
|
||||
delegate: LocationDelegate {
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.LiveLocation
|
||||
delegate: LiveLocationDelegate {
|
||||
room: root.room
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ QQC2.TextArea {
|
||||
id: root
|
||||
|
||||
property NeoChatRoom room
|
||||
required property NeoChatConnection connection
|
||||
onRoomChanged: room.chatBoxEditIdChanged.connect(updateEditText)
|
||||
|
||||
property string messageId
|
||||
@@ -101,6 +102,7 @@ QQC2.TextArea {
|
||||
height: implicitHeight
|
||||
y: -height - 5
|
||||
z: 10
|
||||
connection: root.connection
|
||||
chatDocumentHandler: documentHandler
|
||||
Behavior on height {
|
||||
NumberAnimation {
|
||||
|
||||
@@ -243,6 +243,8 @@ ColumnLayout {
|
||||
*/
|
||||
readonly property alias hovered: bubble.hovered
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
/**
|
||||
* @brief Open the context menu for the message.
|
||||
*/
|
||||
@@ -612,6 +614,7 @@ ColumnLayout {
|
||||
file: file,
|
||||
progressInfo: root.progressInfo,
|
||||
plainText: root.plainText,
|
||||
connection: root.connection,
|
||||
});
|
||||
contextMenu.open();
|
||||
}
|
||||
@@ -626,6 +629,7 @@ ColumnLayout {
|
||||
eventType: root.delegateType,
|
||||
plainText: root.plainText,
|
||||
htmlText: root.display,
|
||||
connection: root.connection,
|
||||
});
|
||||
contextMenu.open();
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ QQC2.ScrollView {
|
||||
|
||||
delegate: EventDelegate {
|
||||
room: root.currentRoom
|
||||
connection: root.connection
|
||||
}
|
||||
|
||||
QQC2.RoundButton {
|
||||
|
||||
@@ -10,6 +10,10 @@ import QtQuick.Layouts 1.10
|
||||
import org.kde.neochat 1.0
|
||||
|
||||
Labs.MenuBar {
|
||||
id: root
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
Labs.Menu {
|
||||
title: i18nc("menu", "NeoChat")
|
||||
|
||||
@@ -23,7 +27,7 @@ Labs.MenuBar {
|
||||
|
||||
shortcut: StandardKey.Preferences
|
||||
onTriggered: pageStack.pushDialogLayer("qrc:/SettingsPage.qml", {
|
||||
connection: Controller.activeConnection
|
||||
connection: root.connection
|
||||
}, {
|
||||
title: i18n("Configure")
|
||||
})
|
||||
@@ -41,7 +45,7 @@ Labs.MenuBar {
|
||||
Labs.MenuItem {
|
||||
text: i18nc("menu", "New Private Chat…")
|
||||
enabled: pageStack.layers.currentItem.title !== i18n("Start a Chat") && AccountRegistry.accountCount > 0
|
||||
onTriggered: pushReplaceLayer("qrc:/StartChatPage.qml", {connection: Controller.activeConnection})
|
||||
onTriggered: pushReplaceLayer("qrc:/StartChatPage.qml", {connection: root.connection})
|
||||
}
|
||||
Labs.MenuItem {
|
||||
text: i18nc("menu", "New Group…")
|
||||
@@ -55,10 +59,10 @@ Labs.MenuBar {
|
||||
Labs.MenuItem {
|
||||
text: i18nc("menu", "Browse Chats…")
|
||||
onTriggered: {
|
||||
let dialog = pageStack.pushDialogLayer("qrc:/JoinRoomPage.qml", {connection: Controller.activeConnection}, {title: i18nc("@title", "Explore Rooms")})
|
||||
let dialog = pageStack.pushDialogLayer("qrc:/JoinRoomPage.qml", {connection: root.connection}, {title: i18nc("@title", "Explore Rooms")})
|
||||
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
||||
if (isJoined) {
|
||||
RoomManager.enterRoom(Controller.activeConnection.room(roomId))
|
||||
RoomManager.enterRoom(root.connection.room(roomId))
|
||||
} else {
|
||||
Controller.joinRoom(roomId)
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ Loader {
|
||||
required property string plainText
|
||||
property string htmlText: undefined
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
property list<Kirigami.Action> nestedActions
|
||||
|
||||
property list<Kirigami.Action> actions: [
|
||||
@@ -31,7 +33,7 @@ Loader {
|
||||
currentRoom.chatBoxEditId = eventId;
|
||||
currentRoom.chatBoxReplyId = "";
|
||||
}
|
||||
visible: author.id === Controller.activeConnection.localUserId && (root.eventType === DelegateType.Emote || root.eventType === DelegateType.Message)
|
||||
visible: author.id === root.connection.localUserId && (root.eventType === DelegateType.Emote || root.eventType === DelegateType.Message)
|
||||
},
|
||||
Kirigami.Action {
|
||||
text: i18n("Reply")
|
||||
@@ -45,12 +47,14 @@ Loader {
|
||||
text: i18nc("@action:inmenu As in 'Forward this message'", "Forward")
|
||||
icon.name: "mail-forward-symbolic"
|
||||
onTriggered: {
|
||||
let page = applicationWindow().pageStack.pushDialogLayer("qrc:/ChooseRoomDialog.qml", {}, {
|
||||
let page = applicationWindow().pageStack.pushDialogLayer("qrc:/ChooseRoomDialog.qml", {
|
||||
connection: root.connection
|
||||
}, {
|
||||
title: i18nc("@title", "Forward Message"),
|
||||
width: Kirigami.Units.gridUnit * 25
|
||||
})
|
||||
page.chosen.connect(function(targetRoomId) {
|
||||
Controller.activeConnection.room(targetRoomId).postHtmlMessage(root.plainText, root.htmlText ? root.htmlText : root.plainText)
|
||||
root.connection.room(targetRoomId).postHtmlMessage(root.plainText, root.htmlText ? root.htmlText : root.plainText)
|
||||
page.closeDialog()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ Kirigami.ScrollablePage {
|
||||
|
||||
signal chosen(string roomId)
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
header: Kirigami.SearchField {
|
||||
onTextChanged: sortModel.filterText = text
|
||||
}
|
||||
@@ -25,7 +27,7 @@ Kirigami.ScrollablePage {
|
||||
model: SortFilterRoomListModel {
|
||||
id: sortModel
|
||||
sourceModel: RoomListModel {
|
||||
connection: Controller.activeConnection
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
delegate: RoomDelegate {
|
||||
@@ -34,6 +36,7 @@ Kirigami.ScrollablePage {
|
||||
onClicked: {
|
||||
root.chosen(roomDelegate.currentRoom.id)
|
||||
}
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ FormCard.FormCardPage {
|
||||
id: root
|
||||
|
||||
property NeoChatRoom room
|
||||
required property NeoChatConnection connection
|
||||
|
||||
title: i18n("Developer Tools")
|
||||
|
||||
@@ -37,7 +38,10 @@ FormCard.FormCardPage {
|
||||
|
||||
RoomData {
|
||||
room: root.room
|
||||
connection: root.connection
|
||||
}
|
||||
ServerData {
|
||||
connection: root.connection
|
||||
}
|
||||
ServerData {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,7 +225,6 @@ Kirigami.ScrollablePage {
|
||||
publicRoomListModel.next();
|
||||
}
|
||||
delegate: ExplorerDelegate {
|
||||
connection: root.connection
|
||||
onRoomSelected: (roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
||||
root.roomSelected(roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined);
|
||||
root.closeDialog();
|
||||
|
||||
@@ -12,13 +12,16 @@ import '../Dialog' as Dialog
|
||||
|
||||
QQC2.Menu {
|
||||
id: root
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
margins: Kirigami.Units.smallSpacing
|
||||
|
||||
QQC2.MenuItem {
|
||||
text: i18n("Edit this account")
|
||||
icon.name: "document-edit"
|
||||
onTriggered: pageStack.pushDialogLayer("qrc:/AccountEditorPage.qml", {
|
||||
connection: Controller.activeConnection
|
||||
connection: root.connection
|
||||
}, {
|
||||
title: i18n("Account editor")
|
||||
});
|
||||
@@ -28,7 +31,7 @@ QQC2.Menu {
|
||||
icon.name: "notifications"
|
||||
onTriggered: pageStack.pushDialogLayer("qrc:/SettingsPage.qml", {
|
||||
defaultPage: "notifications",
|
||||
connection: Controller.activeConnection,
|
||||
connection: root.connection,
|
||||
}, {
|
||||
title: i18n("Configure")
|
||||
});
|
||||
@@ -38,7 +41,7 @@ QQC2.Menu {
|
||||
icon.name: "computer-symbolic"
|
||||
onTriggered: pageStack.pushDialogLayer("qrc:/SettingsPage.qml", {
|
||||
defaultPage: "devices",
|
||||
connection: Controller.activeConnection,
|
||||
connection: root.connection,
|
||||
}, {
|
||||
title: i18n("Configure")
|
||||
})
|
||||
@@ -52,7 +55,7 @@ QQC2.Menu {
|
||||
Component {
|
||||
id: confirmLogoutDialogComponent
|
||||
Dialog.ConfirmLogout {
|
||||
connection: Controller.activeConnection
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,10 @@ import org.kde.neochat 1.0
|
||||
*/
|
||||
Loader {
|
||||
id: root
|
||||
|
||||
property NeoChatRoom room
|
||||
required property NeoChatConnection connection
|
||||
|
||||
signal closed()
|
||||
|
||||
Component {
|
||||
@@ -116,7 +119,7 @@ Loader {
|
||||
QQC2.MenuItem {
|
||||
text: i18n("Room Settings")
|
||||
icon.name: "configure"
|
||||
onTriggered: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room}, { title: i18n("Room Settings") })
|
||||
onTriggered: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room, connection: connection}, { title: i18n("Room Settings") })
|
||||
}
|
||||
|
||||
QQC2.MenuSeparator {}
|
||||
@@ -183,7 +186,7 @@ Loader {
|
||||
QQC2.ToolButton {
|
||||
icon.name: 'settings-configure'
|
||||
onClicked: {
|
||||
QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room}, { title: i18n("Room Settings") })
|
||||
QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room, connection: root.connection}, { title: i18n("Room Settings") })
|
||||
drawer.close()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ RowLayout {
|
||||
text: i18n("Explore rooms")
|
||||
icon.name: "compass"
|
||||
onTriggered: {
|
||||
let dialog = pageStack.pushDialogLayer("qrc:/JoinRoomPage.qml", {connection: Controller.activeConnection}, {title: i18nc("@title", "Explore Rooms")})
|
||||
let dialog = pageStack.pushDialogLayer("qrc:/JoinRoomPage.qml", {connection: root.connection}, {title: i18nc("@title", "Explore Rooms")})
|
||||
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
||||
if (isJoined) {
|
||||
RoomManager.enterRoom(Controller.activeConnection.room(roomId))
|
||||
RoomManager.enterRoom(root.connection.room(roomId))
|
||||
} else {
|
||||
Controller.joinRoom(roomId)
|
||||
}
|
||||
@@ -33,7 +33,7 @@ RowLayout {
|
||||
property Kirigami.Action chatAction: Kirigami.Action {
|
||||
text: i18n("Start a Chat")
|
||||
icon.name: "list-add-user"
|
||||
onTriggered: pageStack.pushDialogLayer("qrc:/StartChatPage.qml", {connection: Controller.activeConnection}, {title: i18nc("@title", "Start a Chat")})
|
||||
onTriggered: pageStack.pushDialogLayer("qrc:/StartChatPage.qml", {connection: root.connection}, {title: i18nc("@title", "Start a Chat")})
|
||||
}
|
||||
property Kirigami.Action roomAction: Kirigami.Action {
|
||||
text: i18n("Create a Room")
|
||||
|
||||
@@ -102,6 +102,8 @@ Kirigami.Page {
|
||||
id: spaceDrawer
|
||||
Layout.preferredWidth: spaceDrawer.enabled ? Kirigami.Units.gridUnit * 3 : 0
|
||||
Layout.fillHeight: true
|
||||
|
||||
connection: root.connection
|
||||
}
|
||||
|
||||
Kirigami.Separator {
|
||||
@@ -161,14 +163,14 @@ Kirigami.Page {
|
||||
text: sortFilterRoomListModel.filterText.length > 0 ? i18n("Search in room directory") : i18n("Explore rooms")
|
||||
onTriggered: {
|
||||
let dialog = pageStack.layers.push("qrc:/JoinRoomPage.qml", {
|
||||
connection: Controller.activeConnection,
|
||||
connection: root.connection,
|
||||
keyword: sortFilterRoomListModel.filterText
|
||||
}, {
|
||||
title: i18nc("@title", "Explore Rooms")
|
||||
})
|
||||
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
||||
if (isJoined) {
|
||||
RoomManager.enterRoom(Controller.activeConnection.room(roomId))
|
||||
RoomManager.enterRoom(root.connection.room(roomId))
|
||||
} else {
|
||||
Controller.joinRoom(roomId)
|
||||
}
|
||||
@@ -265,6 +267,8 @@ Kirigami.Page {
|
||||
RoomList.RoomDelegate {
|
||||
filterText: sortFilterRoomListModel.filterText
|
||||
|
||||
connection: root.connection
|
||||
|
||||
height: visible ? implicitHeight : 0
|
||||
|
||||
visible: categoryVisible || filterText.length > 0 || Config.mergeRoomList
|
||||
@@ -282,6 +286,7 @@ Kirigami.Page {
|
||||
footer: UserInfo {
|
||||
width: parent.width
|
||||
visible: !root.collapsed
|
||||
connection: root.connection
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
|
||||
@@ -22,6 +22,7 @@ Delegates.RoundedItemDelegate {
|
||||
required property int notificationCount
|
||||
required property int highlightCount
|
||||
required property NeoChatRoom currentRoom
|
||||
required property NeoChatConnection connection
|
||||
required property bool categoryVisible
|
||||
required property string filterText
|
||||
required property string avatar
|
||||
@@ -138,6 +139,7 @@ Delegates.RoundedItemDelegate {
|
||||
const component = Qt.createComponent(Qt.resolvedUrl("./ContextMenu.qml"))
|
||||
const menu = component.createObject(root, {
|
||||
room: root.currentRoom,
|
||||
connection: root.connection,
|
||||
});
|
||||
if (!Kirigami.Settings.isMobile && !Config.compactRoomList) {
|
||||
configButton.visible = true;
|
||||
|
||||
@@ -17,6 +17,8 @@ QQC2.Control {
|
||||
readonly property real pinnedWidth: Kirigami.Units.gridUnit * 6
|
||||
property bool drawerEnabled: true
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
leftPadding: 0
|
||||
rightPadding: 0
|
||||
topPadding: 0
|
||||
@@ -73,12 +75,12 @@ QQC2.Control {
|
||||
Repeater {
|
||||
model: SortFilterSpaceListModel {
|
||||
sourceModel: RoomListModel {
|
||||
connection: Controller.activeConnection
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
onCountChanged: {
|
||||
root.enabled = count > 0
|
||||
if (!Controller.activeConnection.room(root.selectedSpaceId)) {
|
||||
if (!root.connection.room(root.selectedSpaceId)) {
|
||||
root.selectedSpaceId = ""
|
||||
}
|
||||
}
|
||||
@@ -111,7 +113,8 @@ QQC2.Control {
|
||||
|
||||
function createContextMenu(room) {
|
||||
let context = spaceListContextMenu.createObject(root, {
|
||||
room: room
|
||||
room: room,
|
||||
connection: root.connection
|
||||
});
|
||||
context.open()
|
||||
}
|
||||
|
||||
@@ -16,7 +16,10 @@ import org.kde.neochat 1.0
|
||||
*/
|
||||
Loader {
|
||||
id: root
|
||||
|
||||
property NeoChatRoom room
|
||||
required property NeoChatConnection connection
|
||||
|
||||
signal closed()
|
||||
|
||||
Component {
|
||||
@@ -41,7 +44,7 @@ Loader {
|
||||
QQC2.MenuItem {
|
||||
text: i18nc("'Space' is a matrix space", "Space Settings")
|
||||
icon.name: 'settings-configure'
|
||||
onTriggered: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room}, { title: i18n("Space Settings") })
|
||||
onTriggered: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room, connection: connection}, { title: i18n("Space Settings") })
|
||||
}
|
||||
|
||||
QQC2.MenuSeparator {}
|
||||
@@ -99,7 +102,7 @@ Loader {
|
||||
|
||||
QQC2.ToolButton {
|
||||
icon.name: 'settings-configure'
|
||||
onClicked: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room}, { title: i18n("Space Settings") })
|
||||
onClicked: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room, connection: root.connection}, { title: i18n("Space Settings") })
|
||||
}
|
||||
}
|
||||
Kirigami.BasicListItem {
|
||||
|
||||
@@ -15,6 +15,8 @@ QQC2.ToolBar {
|
||||
|
||||
padding: 0
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
property var addAccount
|
||||
|
||||
contentItem: ColumnLayout {
|
||||
@@ -126,7 +128,7 @@ QQC2.ToolBar {
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
Controller.activeConnection = userDelegate.connection
|
||||
root.connection = userDelegate.connection
|
||||
if (switchUserButton.checked) {
|
||||
switchUserButton.checked = false
|
||||
}
|
||||
@@ -164,7 +166,7 @@ QQC2.ToolBar {
|
||||
accountMenu.open();
|
||||
} else {
|
||||
pageStack.pushDialogLayer(Qt.resolvedUrl('qrc:/AccountEditorPage.qml'), {
|
||||
connection: Controller.activeConnection
|
||||
connection: root.connection
|
||||
}, {
|
||||
title: i18n("Account editor")
|
||||
});
|
||||
@@ -175,10 +177,10 @@ QQC2.ToolBar {
|
||||
text: i18n("Edit this account")
|
||||
|
||||
contentItem: KirigamiComponents.Avatar {
|
||||
readonly property string mediaId: Controller.activeConnection.localUser.avatarMediaId
|
||||
readonly property string mediaId: root.connection.localUser.avatarMediaId
|
||||
|
||||
source: mediaId ? ("image://mxc/" + mediaId) : ""
|
||||
name: Controller.activeConnection.localUser.displayName ?? Controller.activeConnection.localUser.id
|
||||
name: root.connection.localUser.displayName ?? root.connection.localUser.id
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,13 +189,13 @@ QQC2.ToolBar {
|
||||
spacing: 0
|
||||
QQC2.Label {
|
||||
id: displayNameLabel
|
||||
text: Controller.activeConnection.localUser.displayName
|
||||
text: root.connection.localUser.displayName
|
||||
textFormat: Text.PlainText
|
||||
elide: Text.ElideRight
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
QQC2.Label {
|
||||
text: (Controller.activeConnection.label.length > 0 ? (Controller.activeConnection.label + " ") : "") + Controller.activeConnection.localUser.id
|
||||
text: (root.connection.label.length > 0 ? (root.connection.label + " ") : "") + root.connection.localUser.id
|
||||
font.pointSize: displayNameLabel.font.pointSize * 0.8
|
||||
opacity: 0.7
|
||||
textFormat: Text.PlainText
|
||||
@@ -232,7 +234,7 @@ QQC2.ToolBar {
|
||||
}
|
||||
QQC2.ToolButton {
|
||||
icon.name: "settings-configure"
|
||||
onClicked: pageStack.pushDialogLayer("qrc:/SettingsPage.qml", {connection: Controller.activeConnection}, { title: i18n("Configure") })
|
||||
onClicked: pageStack.pushDialogLayer("qrc:/SettingsPage.qml", {connection: root.connection}, { title: i18n("Configure") })
|
||||
text: i18n("Open Settings")
|
||||
display: QQC2.AbstractButton.IconOnly
|
||||
Layout.minimumWidth: Layout.preferredWidth
|
||||
@@ -249,6 +251,7 @@ QQC2.ToolBar {
|
||||
AccountMenu {
|
||||
id: accountMenu
|
||||
y: -height
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ Kirigami.Page {
|
||||
|
||||
/// Not readonly because of the separate window view.
|
||||
property NeoChatRoom currentRoom: RoomManager.currentRoom
|
||||
|
||||
required property NeoChatConnection connection
|
||||
property bool loading: !root.currentRoom || (root.currentRoom.timelineSize === 0 && !root.currentRoom.allHistoryLoaded)
|
||||
|
||||
/// Disable cancel shortcut. Used by the separate window since it provides its own cancel implementation.
|
||||
@@ -109,6 +111,7 @@ Kirigami.Page {
|
||||
id: chatBox
|
||||
width: parent.width
|
||||
currentRoom: root.currentRoom
|
||||
connection: root.connection
|
||||
onMessageSent: {
|
||||
if (!timelineViewLoader.item.atYEnd) {
|
||||
timelineViewLoader.item.goToLastMessage();
|
||||
@@ -153,7 +156,7 @@ Kirigami.Page {
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: Controller.activeConnection
|
||||
target: root.connection
|
||||
function onJoinedRoom(room, invited) {
|
||||
if(root.currentRoom.id === invited.id) {
|
||||
RoomManager.enterRoom(room);
|
||||
|
||||
@@ -13,6 +13,8 @@ Kirigami.ApplicationWindow {
|
||||
id: root
|
||||
|
||||
required property NeoChatRoom currentRoom
|
||||
required property NeoChatConnection connection
|
||||
|
||||
minimumWidth: Kirigami.Units.gridUnit * 10
|
||||
minimumHeight: Kirigami.Units.gridUnit * 15
|
||||
|
||||
@@ -24,6 +26,7 @@ Kirigami.ApplicationWindow {
|
||||
visible: true
|
||||
currentRoom: root.currentRoom
|
||||
disableCancelShortcut: true
|
||||
connection: root.connection
|
||||
}
|
||||
|
||||
onCurrentRoomChanged: if (!currentRoom) {
|
||||
|
||||
@@ -13,6 +13,7 @@ Kirigami.ScrollablePage {
|
||||
id: root
|
||||
|
||||
property NeoChatRoom currentRoom
|
||||
required property NeoChatConnection connection
|
||||
|
||||
title: i18nc("@action:title", "Search Messages")
|
||||
|
||||
@@ -20,7 +21,7 @@ Kirigami.ScrollablePage {
|
||||
|
||||
SearchModel {
|
||||
id: searchModel
|
||||
connection: Controller.activeConnection
|
||||
connection: root.connection
|
||||
searchText: searchField.text
|
||||
room: root.currentRoom
|
||||
}
|
||||
@@ -71,6 +72,8 @@ Kirigami.ScrollablePage {
|
||||
}
|
||||
|
||||
model: searchModel
|
||||
delegate: EventDelegate {}
|
||||
delegate: EventDelegate {
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ import org.kde.neochat 1.0
|
||||
|
||||
Kirigami.OverlayDrawer {
|
||||
id: root
|
||||
|
||||
readonly property NeoChatRoom room: RoomManager.currentRoom
|
||||
required property NeoChatConnection connection
|
||||
|
||||
width: actualWidth
|
||||
|
||||
@@ -98,7 +100,7 @@ Kirigami.OverlayDrawer {
|
||||
text: i18n("Room settings")
|
||||
display: QQC2.AbstractButton.IconOnly
|
||||
|
||||
onClicked: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room}, { title: i18n("Room Settings") })
|
||||
onClicked: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room, connection: root.connection}, { title: i18n("Room Settings") })
|
||||
|
||||
QQC2.ToolTip.text: text
|
||||
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
||||
@@ -118,6 +120,7 @@ Kirigami.OverlayDrawer {
|
||||
id: roomInformation
|
||||
RoomInformation {
|
||||
room: root.room
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +128,7 @@ Kirigami.OverlayDrawer {
|
||||
id: roomMedia
|
||||
RoomMedia {
|
||||
currentRoom: root.room
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ Kirigami.Page {
|
||||
* @brief The current room that user is viewing.
|
||||
*/
|
||||
readonly property NeoChatRoom room: RoomManager.currentRoom
|
||||
required property NeoChatConnection connection
|
||||
|
||||
title: drawerItemLoader.item ? drawerItemLoader.item.title : ""
|
||||
|
||||
@@ -43,7 +44,7 @@ Kirigami.Page {
|
||||
displayHint: Kirigami.DisplayHint.IconOnly
|
||||
text: i18n("Settings")
|
||||
icon.name: "settings-configure"
|
||||
onTriggered: applicationWindow().pageStack.pushDialogLayer('qrc:/Categories.qml', {room: root.room}, { title: i18n("Room Settings") })
|
||||
onTriggered: applicationWindow().pageStack.pushDialogLayer('qrc:/Categories.qml', {room: root.room, connection: root.connection}, { title: i18n("Room Settings") })
|
||||
}
|
||||
]
|
||||
|
||||
@@ -58,6 +59,7 @@ Kirigami.Page {
|
||||
id: roomInformation
|
||||
RoomInformation {
|
||||
room: root.room
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +67,7 @@ Kirigami.Page {
|
||||
id: roomMedia
|
||||
RoomMedia {
|
||||
currentRoom: root.room
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ QQC2.ScrollView {
|
||||
*/
|
||||
required property NeoChatRoom room
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
/**
|
||||
* @brief The title that should be displayed for this component if available.
|
||||
*/
|
||||
@@ -77,7 +79,7 @@ QQC2.ScrollView {
|
||||
Layout.fillWidth: true
|
||||
|
||||
onClicked: {
|
||||
applicationWindow().pageStack.pushDialogLayer("qrc:/DevtoolsPage.qml", {room: root.room}, {title: i18n("Developer Tools")})
|
||||
applicationWindow().pageStack.pushDialogLayer("qrc:/DevtoolsPage.qml", {room: root.room, connection: root.connection}, {title: i18n("Developer Tools")})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +93,8 @@ QQC2.ScrollView {
|
||||
|
||||
onClicked: {
|
||||
pageStack.pushDialogLayer("qrc:/SearchPage.qml", {
|
||||
currentRoom: root.room
|
||||
currentRoom: root.room,
|
||||
connection: root.connection
|
||||
}, {
|
||||
title: i18nc("@action:title", "Search")
|
||||
})
|
||||
|
||||
@@ -33,6 +33,8 @@ QQC2.ScrollView {
|
||||
*/
|
||||
required property NeoChatRoom currentRoom
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
// HACK: Hide unnecessary horizontal scrollbar (https://bugreports.qt.io/browse/QTBUG-83890)
|
||||
QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
|
||||
|
||||
@@ -54,6 +56,7 @@ QQC2.ScrollView {
|
||||
alwaysShowAuthor: true
|
||||
alwaysMaxWidth: true
|
||||
cardBackground: false
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +66,7 @@ QQC2.ScrollView {
|
||||
alwaysShowAuthor: true
|
||||
alwaysMaxWidth: true
|
||||
cardBackground: false
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@ import org.kde.neochat 1.0
|
||||
|
||||
KirigamiSettings.CategorizedSettings {
|
||||
id: root
|
||||
|
||||
property NeoChatRoom room
|
||||
required property NeoChatConnection connection
|
||||
|
||||
objectName: "settingsPage"
|
||||
actions: [
|
||||
@@ -21,7 +23,8 @@ KirigamiSettings.CategorizedSettings {
|
||||
page: Qt.resolvedUrl("General.qml")
|
||||
initialProperties: {
|
||||
return {
|
||||
room: root.room
|
||||
room: root.room,
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -17,6 +17,7 @@ FormCard.FormCardPage {
|
||||
id: root
|
||||
|
||||
property NeoChatRoom room
|
||||
required property NeoChatConnection connection
|
||||
|
||||
title: i18n("General")
|
||||
|
||||
@@ -287,7 +288,7 @@ FormCard.FormCardPage {
|
||||
actions: Kirigami.Action {
|
||||
text: i18n("See older messages…")
|
||||
onTriggered: {
|
||||
RoomManager.enterRoom(Controller.activeConnection.room(room.predecessorId));
|
||||
RoomManager.enterRoom(root.connection.room(room.predecessorId));
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
@@ -301,7 +302,7 @@ FormCard.FormCardPage {
|
||||
actions: Kirigami.Action {
|
||||
text: i18n("See new room…")
|
||||
onTriggered: {
|
||||
RoomManager.enterRoom(Controller.activeConnection.room(room.successorId));
|
||||
RoomManager.enterRoom(root.connection.room(room.successorId));
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ FormCard.FormCardPage {
|
||||
|
||||
FormCard.AbstractFormDelegate {
|
||||
Layout.fillWidth: true
|
||||
visible: Controller.activeConnection && devicesModel.count === 0 // We can assume 0 means loading since there is at least one device
|
||||
visible: root.connection && devicesModel.count === 0 // We can assume 0 means loading since there is at least one device
|
||||
contentItem: Kirigami.LoadingPlaceholder { }
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ FormCard.FormCardPage {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
text: i18n("Please login to view the signed-in devices for your account.")
|
||||
type: Kirigami.MessageType.Information
|
||||
visible: !Controller.activeConnection
|
||||
visible: !root.connection
|
||||
}
|
||||
|
||||
property Kirigami.OverlaySheet passwordSheet: Kirigami.OverlaySheet {
|
||||
|
||||
@@ -19,6 +19,7 @@ FormCard.FormCard {
|
||||
}
|
||||
|
||||
property var emoticonType
|
||||
required property NeoChatConnection connection
|
||||
|
||||
Flow {
|
||||
id: stickerFlow
|
||||
@@ -28,7 +29,7 @@ FormCard.FormCard {
|
||||
id: emoticonFilterModel
|
||||
sourceModel: AccountEmoticonModel {
|
||||
id: stickerModel
|
||||
connection: Controller.activeConnection
|
||||
connection: root.connection
|
||||
}
|
||||
showStickers: root.emoticonType === EmoticonFormCard.Stickers
|
||||
showEmojis: root.emoticonType === EmoticonFormCard.Emojis
|
||||
|
||||
@@ -11,6 +11,8 @@ import org.kde.neochat 1.0
|
||||
FormCard.FormCardPage {
|
||||
id: root
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
title: i18nc("@title", "Stickers & Emojis")
|
||||
|
||||
FormCard.FormHeader {
|
||||
@@ -18,6 +20,7 @@ FormCard.FormCardPage {
|
||||
}
|
||||
EmoticonFormCard {
|
||||
emoticonType: EmoticonFormCard.Emojis
|
||||
connection: root.connection
|
||||
}
|
||||
|
||||
FormCard.FormHeader {
|
||||
@@ -25,6 +28,7 @@ FormCard.FormCardPage {
|
||||
}
|
||||
EmoticonFormCard {
|
||||
emoticonType: EmoticonFormCard.Stickers
|
||||
connection: root.connection
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,6 +44,11 @@ KirigamiSettings.CategorizedSettings {
|
||||
text: i18n("Stickers & Emojis")
|
||||
icon.name: "preferences-desktop-emoticons"
|
||||
page: Qt.resolvedUrl("EmoticonsPage.qml")
|
||||
initialProperties: {
|
||||
return {
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
KirigamiSettings.SettingAction {
|
||||
|
||||
@@ -22,6 +22,8 @@ Kirigami.ApplicationWindow {
|
||||
|
||||
property RoomPage roomPage
|
||||
|
||||
property NeoChatConnection connection: Controller.activeConnection
|
||||
|
||||
minimumWidth: Kirigami.Units.gridUnit * 20
|
||||
minimumHeight: Kirigami.Units.gridUnit * 15
|
||||
|
||||
@@ -47,7 +49,9 @@ Kirigami.ApplicationWindow {
|
||||
|
||||
Loader {
|
||||
active: Kirigami.Settings.hasPlatformMenuBar && !Kirigami.Settings.isMobile
|
||||
source: Qt.resolvedUrl("qrc:/GlobalMenu.qml")
|
||||
sourceComponent: GlobalMenu {
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
// This timer allows to batch update the window size change to reduce
|
||||
@@ -76,14 +80,16 @@ Kirigami.ApplicationWindow {
|
||||
Loader {
|
||||
id: quickView
|
||||
active: !Kirigami.Settings.isMobile
|
||||
sourceComponent: QuickSwitcher { }
|
||||
sourceComponent: QuickSwitcher {
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: RoomManager
|
||||
|
||||
function onPushRoom(room, event) {
|
||||
root.roomPage = pageStack.push("qrc:/RoomPage.qml");
|
||||
root.roomPage = pageStack.push("qrc:/RoomPage.qml", {connection: root.connection});
|
||||
root.roomPage.forceActiveFocus();
|
||||
if (event.length > 0) {
|
||||
roomPage.goToEvent(event);
|
||||
@@ -107,7 +113,7 @@ Kirigami.ApplicationWindow {
|
||||
}
|
||||
|
||||
function onOpenRoomInNewWindow(room) {
|
||||
const secondaryWindow = roomWindow.createObject(undefined, {currentRoom: room});
|
||||
const secondaryWindow = roomWindow.createObject(undefined, {currentRoom: room, connection: root.connection});
|
||||
secondaryWindow.width = root.width - pageStack.get(0).width;
|
||||
secondaryWindow.show();
|
||||
}
|
||||
@@ -128,7 +134,9 @@ Kirigami.ApplicationWindow {
|
||||
}
|
||||
|
||||
function openRoomDrawer() {
|
||||
pageStack.push("qrc:/RoomDrawerPage.qml")
|
||||
pageStack.push("qrc:/RoomDrawerPage.qml", {
|
||||
connection: root.connection
|
||||
})
|
||||
}
|
||||
|
||||
contextDrawer: RoomDrawer {
|
||||
@@ -138,6 +146,8 @@ Kirigami.ApplicationWindow {
|
||||
// It is used to ensure that user choice is remembered when changing pages and expanding and contracting the window width
|
||||
property bool drawerUserState: Config.autoRoomInfoDrawer
|
||||
|
||||
connection: root.connection
|
||||
|
||||
// Connect to the onClicked function of the RoomDrawer handle button
|
||||
Connections {
|
||||
target: contextDrawer.handle.children[0]
|
||||
@@ -190,7 +200,7 @@ Kirigami.ApplicationWindow {
|
||||
RoomList.Page {
|
||||
id: roomList
|
||||
|
||||
connection: Controller.activeConnection
|
||||
connection: root.connection
|
||||
|
||||
Shortcut {
|
||||
sequences: ["Ctrl+PgUp", "Ctrl+Backtab", "Alt+Up"]
|
||||
@@ -280,10 +290,10 @@ Kirigami.ApplicationWindow {
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: Controller.activeConnection
|
||||
target: root.connection
|
||||
|
||||
function onDirectChatAvailable(directChat) {
|
||||
RoomManager.enterRoom(Controller.activeConnection.room(directChat.id));
|
||||
RoomManager.enterRoom(root.connection.room(directChat.id));
|
||||
}
|
||||
function onNewKeyVerificationSession(session) {
|
||||
applicationWindow().pageStack.pushDialogLayer(keyVerificationDialogComponent, {
|
||||
@@ -321,14 +331,14 @@ Kirigami.ApplicationWindow {
|
||||
id: createRoomDialog
|
||||
|
||||
CreateRoomDialog {
|
||||
connection: Controller.activeConnection
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: createSpaceDialog
|
||||
CreateSpaceDialog {
|
||||
connection: Controller.activeConnection
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,7 +392,7 @@ Kirigami.ApplicationWindow {
|
||||
Shortcut {
|
||||
sequence: "Ctrl+Shift+,"
|
||||
onActivated: {
|
||||
pageStack.pushDialogLayer("qrc:/SettingsPage.qml", {connection: Controller.activeConnection}, { title: i18n("Configure") })
|
||||
pageStack.pushDialogLayer("qrc:/SettingsPage.qml", {connection: root.connection}, { title: i18n("Configure") })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user