Current Room Messages
Make sure that message delegates are getting the room object directly rather than requiring the assumption that currentRoom is declared somewhere higher up.
This commit is contained in:
@@ -53,7 +53,7 @@ MessageDelegate {
|
||||
PropertyChanges {
|
||||
target: playButton
|
||||
icon.name: "media-playback-start"
|
||||
onClicked: currentRoom.downloadFile(root.eventId)
|
||||
onClicked: root.room.downloadFile(root.eventId)
|
||||
}
|
||||
},
|
||||
State {
|
||||
@@ -67,7 +67,7 @@ MessageDelegate {
|
||||
target: playButton
|
||||
icon.name: "media-playback-stop"
|
||||
onClicked: {
|
||||
currentRoom.cancelFileTransfer(root.eventId)
|
||||
root.room.cancelFileTransfer(root.eventId)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -11,9 +11,12 @@ import org.kde.neochat
|
||||
DelegateChooser {
|
||||
id: root
|
||||
|
||||
/**
|
||||
* @brief The NeoChatRoom the delegate is being displayed in.
|
||||
*/
|
||||
required property NeoChatRoom room
|
||||
|
||||
role: "delegateType"
|
||||
property var room
|
||||
required property NeoChatConnection connection
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.State
|
||||
@@ -23,63 +26,63 @@ DelegateChooser {
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Emote
|
||||
delegate: TextDelegate {
|
||||
connection: root.connection
|
||||
room: root.room
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Message
|
||||
delegate: TextDelegate {
|
||||
connection: root.connection
|
||||
room: root.room
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Notice
|
||||
delegate: TextDelegate {
|
||||
connection: root.connection
|
||||
room: root.room
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Image
|
||||
delegate: ImageDelegate {
|
||||
connection: root.connection
|
||||
room: root.room
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Sticker
|
||||
delegate: ImageDelegate {
|
||||
connection: root.connection
|
||||
room: root.room
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Audio
|
||||
delegate: AudioDelegate {
|
||||
connection: root.connection
|
||||
room: root.room
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Video
|
||||
delegate: VideoDelegate {
|
||||
connection: root.connection
|
||||
room: root.room
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.File
|
||||
delegate: FileDelegate {
|
||||
connection: root.connection
|
||||
room: root.room
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Encrypted
|
||||
delegate: EncryptedDelegate {
|
||||
connection: root.connection
|
||||
room: root.room
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,14 +94,14 @@ DelegateChooser {
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Poll
|
||||
delegate: PollDelegate {
|
||||
connection: root.connection
|
||||
room: root.room
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: DelegateType.Location
|
||||
delegate: LocationDelegate {
|
||||
connection: root.connection
|
||||
room: root.room
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +109,6 @@ DelegateChooser {
|
||||
roleValue: DelegateType.LiveLocation
|
||||
delegate: LiveLocationDelegate {
|
||||
room: root.room
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ MessageDelegate {
|
||||
function saveFileAs() {
|
||||
const dialog = fileDialog.createObject(QQC2.ApplicationWindow.overlay)
|
||||
dialog.open()
|
||||
dialog.currentFile = dialog.folder + "/" + currentRoom.fileNameToDownload(root.eventId)
|
||||
dialog.currentFile = dialog.folder + "/" + root.room.fileNameToDownload(root.eventId)
|
||||
}
|
||||
|
||||
function openSavedFile() {
|
||||
@@ -117,7 +117,7 @@ MessageDelegate {
|
||||
target: downloadButton
|
||||
icon.name: "media-playback-stop"
|
||||
QQC2.ToolTip.text: i18nc("tooltip for a button on a message; stops downloading the message's file", "Stop Download")
|
||||
onClicked: currentRoom.cancelFileTransfer(root.eventId)
|
||||
onClicked: root.room.cancelFileTransfer(root.eventId)
|
||||
}
|
||||
},
|
||||
State {
|
||||
@@ -159,7 +159,7 @@ MessageDelegate {
|
||||
icon.name: "document-open"
|
||||
onClicked: {
|
||||
autoOpenFile = true;
|
||||
currentRoom.downloadTempFile(root.eventId);
|
||||
root.room.downloadTempFile(root.eventId);
|
||||
}
|
||||
|
||||
QQC2.ToolTip.text: i18nc("tooltip for a button on a message; offers ability to open its downloaded file with an appropriate application", "Open File")
|
||||
@@ -188,7 +188,7 @@ MessageDelegate {
|
||||
if (autoOpenFile) {
|
||||
UrlHelper.copyTo(root.progressInfo.localPath, file)
|
||||
} else {
|
||||
currentRoom.download(root.eventId, file);
|
||||
root.room.download(root.eventId, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,7 +198,7 @@ MessageDelegate {
|
||||
id: itinerary
|
||||
model: ItineraryModel {
|
||||
id: itineraryModel
|
||||
connection: root.connection
|
||||
connection: root.room.connection
|
||||
}
|
||||
delegate: DelegateChooser {
|
||||
role: "type"
|
||||
|
||||
@@ -148,7 +148,7 @@ MessageDelegate {
|
||||
openSavedFile()
|
||||
} else {
|
||||
openOnFinished = true
|
||||
ListView.view.currentRoom.downloadFile(root.eventId, StandardPaths.writableLocation(StandardPaths.CacheLocation) + "/" + root.eventId.replace(":", "_").replace("/", "_").replace("+", "_") + ListView.view.currentRoom.fileNameToDownload(root.eventId))
|
||||
root.room.downloadFile(root.eventId, StandardPaths.writableLocation(StandardPaths.CacheLocation) + "/" + root.eventId.replace(":", "_").replace("/", "_").replace("+", "_") + root.room.fileNameToDownload(root.eventId))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,12 +18,11 @@ import org.kde.neochat
|
||||
MessageDelegate {
|
||||
id: root
|
||||
|
||||
property alias room: liveLocationModel.room
|
||||
|
||||
bubbleContent: ColumnLayout {
|
||||
LiveLocationsModel {
|
||||
id: liveLocationModel
|
||||
eventId: root.eventId
|
||||
room: root.room
|
||||
}
|
||||
MapView {
|
||||
id: mapView
|
||||
|
||||
@@ -29,6 +29,11 @@ import org.kde.neochat.config
|
||||
TimelineDelegate {
|
||||
id: root
|
||||
|
||||
/**
|
||||
* @brief The NeoChatRoom the delegate is being displayed in.
|
||||
*/
|
||||
required property NeoChatRoom room
|
||||
|
||||
/**
|
||||
* @brief The index of the delegate in the model.
|
||||
*/
|
||||
@@ -244,8 +249,6 @@ TimelineDelegate {
|
||||
*/
|
||||
readonly property alias hovered: bubble.hovered
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
/**
|
||||
* @brief Open the context menu for the message.
|
||||
*/
|
||||
@@ -326,7 +329,7 @@ TimelineDelegate {
|
||||
|
||||
Component.onCompleted: {
|
||||
if (root.isReply && root.replyDelegateType === DelegateType.Other) {
|
||||
currentRoom.loadReply(root.eventId, root.replyId)
|
||||
root.room.loadReply(root.eventId, root.replyId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,7 +440,7 @@ TimelineDelegate {
|
||||
visible: root.showReactions
|
||||
model: root.reaction
|
||||
|
||||
onReactionClicked: (reaction) => currentRoom.toggleReaction(root.eventId, reaction)
|
||||
onReactionClicked: (reaction) => root.room.toggleReaction(root.eventId, reaction)
|
||||
}
|
||||
AvatarFlow {
|
||||
Layout.alignment: Qt.AlignRight
|
||||
|
||||
@@ -36,7 +36,7 @@ MessageDelegate {
|
||||
delegate: RowLayout {
|
||||
Layout.fillWidth: true
|
||||
CheckBox {
|
||||
checked: root.pollHandler.answers[currentRoom.localUser.id] ? root.pollHandler.answers[currentRoom.localUser.id].includes(modelData["id"]) : false
|
||||
checked: root.pollHandler.answers[root.room.localUser.id] ? root.pollHandler.answers[root.room.localUser.id].includes(modelData["id"]) : false
|
||||
onClicked: root.pollHandler.sendPollAnswer(root.eventId, modelData["id"])
|
||||
enabled: !root.pollHandler.hasEnded
|
||||
}
|
||||
|
||||
@@ -38,9 +38,6 @@ QQC2.ScrollView {
|
||||
QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
|
||||
|
||||
ListView {
|
||||
// So that delegates can access current room properly.
|
||||
readonly property NeoChatRoom currentRoom: root.currentRoom
|
||||
|
||||
clip: true
|
||||
verticalLayoutDirection: ListView.BottomToTop
|
||||
|
||||
@@ -55,7 +52,7 @@ QQC2.ScrollView {
|
||||
alwaysShowAuthor: true
|
||||
alwaysMaxWidth: true
|
||||
cardBackground: false
|
||||
connection: root.connection
|
||||
room: root.currentRoom
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +62,7 @@ QQC2.ScrollView {
|
||||
alwaysShowAuthor: true
|
||||
alwaysMaxWidth: true
|
||||
cardBackground: false
|
||||
connection: root.connection
|
||||
room: root.currentRoom
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,6 @@ Kirigami.Page {
|
||||
chatBarLoader.item.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ Kirigami.ScrollablePage {
|
||||
|
||||
model: searchModel
|
||||
delegate: EventDelegate {
|
||||
connection: root.connection
|
||||
room: root.currentRoom
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ MessageDelegate {
|
||||
RichLabel {
|
||||
id: label
|
||||
Layout.fillWidth: true
|
||||
visible: currentRoom.editCache.editId !== root.eventId
|
||||
visible: root.room.editCache.editId !== root.eventId
|
||||
|
||||
isReply: root.isReply
|
||||
|
||||
@@ -59,17 +59,17 @@ MessageDelegate {
|
||||
Layout.fillWidth: true
|
||||
Layout.minimumHeight: item ? item.minimumHeight : -1
|
||||
Layout.preferredWidth: item ? item.preferredWidth : -1
|
||||
visible: currentRoom.editCache.editId === root.eventId
|
||||
visible: root.room.editCache.editId === root.eventId
|
||||
active: visible
|
||||
sourceComponent: MessageEditComponent {
|
||||
room: currentRoom
|
||||
room: root.room
|
||||
actionsHandler: root.ListView.view.actionsHandler
|
||||
messageId: root.eventId
|
||||
}
|
||||
}
|
||||
LinkPreviewDelegate {
|
||||
Layout.fillWidth: true
|
||||
active: !currentRoom.usesEncryption && currentRoom.urlPreviewEnabled && Config.showLinkPreview && root.showLinkPreview && !root.linkPreview.empty
|
||||
active: !root.room.usesEncryption && root.room.urlPreviewEnabled && Config.showLinkPreview && root.showLinkPreview && !root.linkPreview.empty
|
||||
linkPreviewer: root.linkPreview
|
||||
indicatorEnabled: root.isVisibleInTimeline()
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import org.kde.neochat.config
|
||||
QQC2.ScrollView {
|
||||
id: root
|
||||
required property NeoChatRoom currentRoom
|
||||
required property NeoChatConnection connection
|
||||
onCurrentRoomChanged: {
|
||||
roomChanging = true;
|
||||
roomChangingTimer.restart()
|
||||
@@ -63,8 +62,6 @@ QQC2.ScrollView {
|
||||
|
||||
ListView {
|
||||
id: messageListView
|
||||
// So that delegates can access the current room properly.
|
||||
readonly property NeoChatRoom currentRoom: root.currentRoom
|
||||
// So that delegates can access the actionsHandler properly.
|
||||
readonly property ActionsHandler actionsHandler: root.actionsHandler
|
||||
|
||||
@@ -153,7 +150,6 @@ QQC2.ScrollView {
|
||||
|
||||
delegate: EventDelegate {
|
||||
room: root.currentRoom
|
||||
connection: root.connection
|
||||
}
|
||||
|
||||
KirigamiComponents.FloatingButton {
|
||||
|
||||
@@ -358,7 +358,7 @@ MessageDelegate {
|
||||
playSavedFile()
|
||||
} else {
|
||||
playOnFinished = true
|
||||
ListView.view.currentRoom.downloadFile(root.eventId, Platform.StandardPaths.writableLocation(Platform.StandardPaths.CacheLocation) + "/" + root.eventId.replace(":", "_").replace("/", "_").replace("+", "_") + ListView.view.currentRoom.fileNameToDownload(root.eventId))
|
||||
root.room.downloadFile(root.eventId, Platform.StandardPaths.writableLocation(Platform.StandardPaths.CacheLocation) + "/" + root.eventId.replace(":", "_").replace("/", "_").replace("+", "_") + root.room.fileNameToDownload(root.eventId))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user