Simplify function call in RoomPage
Instead of passing every argument in the right order, pass the entire model/event object to the context menu functions. This is less copy pasta of code and the order of the args is now less likely to break in the future. Signed-off-by: Carl Schwan <carl@carlschwan.eu>
This commit is contained in:
@@ -377,11 +377,11 @@ Kirigami.ScrollablePage {
|
|||||||
Layout.leftMargin: Config.showAvatarInTimeline ? Kirigami.Units.largeSpacing : 0
|
Layout.leftMargin: Config.showAvatarInTimeline ? Kirigami.Units.largeSpacing : 0
|
||||||
TapHandler {
|
TapHandler {
|
||||||
acceptedButtons: Qt.RightButton
|
acceptedButtons: Qt.RightButton
|
||||||
onTapped: openMessageContext(author, model.message, eventId, toolTip, eventType, model.formattedBody, parent.selectedText)
|
onTapped: openMessageContext(model, parent.selectedText)
|
||||||
}
|
}
|
||||||
TapHandler {
|
TapHandler {
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
onLongPressed: openMessageContext(author, model.message, eventId, toolTip, eventType, model.formattedBody, parent.selectedText)
|
onLongPressed: openMessageContext(model, parent.selectedText)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -403,11 +403,11 @@ Kirigami.ScrollablePage {
|
|||||||
Layout.leftMargin: Config.showAvatarInTimeline ? Kirigami.Units.largeSpacing : 0
|
Layout.leftMargin: Config.showAvatarInTimeline ? Kirigami.Units.largeSpacing : 0
|
||||||
TapHandler {
|
TapHandler {
|
||||||
acceptedButtons: Qt.RightButton
|
acceptedButtons: Qt.RightButton
|
||||||
onTapped: openMessageContext(author, model.message, eventId, toolTip, eventType, model.formattedBody, parent.selectedText)
|
onTapped: openMessageContext(model, parent.selectedText)
|
||||||
}
|
}
|
||||||
TapHandler {
|
TapHandler {
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
onLongPressed: openMessageContext(author, model.message, eventId, toolTip, eventType, model.formattedBody, parent.selectedText)
|
onLongPressed: openMessageContext(model, parent.selectedText)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -446,13 +446,19 @@ Kirigami.ScrollablePage {
|
|||||||
Layout.maximumHeight: Kirigami.Units.gridUnit * 20
|
Layout.maximumHeight: Kirigami.Units.gridUnit * 20
|
||||||
TapHandler {
|
TapHandler {
|
||||||
acceptedButtons: Qt.RightButton
|
acceptedButtons: Qt.RightButton
|
||||||
onTapped: openFileContext(author, model.display, eventId, toolTip, progressInfo, parent)
|
onTapped: openFileContext(model, parent)
|
||||||
}
|
}
|
||||||
TapHandler {
|
TapHandler {
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
onLongPressed: openFileContext(author, model.display, eventId, toolTip, progressInfo, parent)
|
onLongPressed: openFileContext(model, parent)
|
||||||
onTapped: {
|
onTapped: {
|
||||||
fullScreenImage.createObject(parent, {"filename": eventId, "localPath": currentRoom.urlToDownload(eventId), "blurhash": model.content.info["xyz.amorgan.blurhash"], "imageWidth": content.info.w, "imageHeight": content.info.h}).showFullScreen()
|
fullScreenImage.createObject(parent, {
|
||||||
|
filename: eventId,
|
||||||
|
localPath: currentRoom.urlToDownload(eventId),
|
||||||
|
blurhash: model.content.info["xyz.amorgan.blurhash"],
|
||||||
|
imageWidth: content.info.w,
|
||||||
|
imageHeight: content.info.h
|
||||||
|
}).showFullScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -491,11 +497,11 @@ Kirigami.ScrollablePage {
|
|||||||
Layout.maximumWidth: audioContainer.bubbleMaxWidth
|
Layout.maximumWidth: audioContainer.bubbleMaxWidth
|
||||||
TapHandler {
|
TapHandler {
|
||||||
acceptedButtons: Qt.RightButton
|
acceptedButtons: Qt.RightButton
|
||||||
onTapped: openFileContext(author, model.display, eventId, toolTip, progressInfo, parent)
|
onTapped: openFileContext(model, parent)
|
||||||
}
|
}
|
||||||
TapHandler {
|
TapHandler {
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
onLongPressed: openFileContext(author, model.display, eventId, toolTip, progressInfo, parent)
|
onLongPressed: openFileContext(model, parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -519,11 +525,11 @@ Kirigami.ScrollablePage {
|
|||||||
|
|
||||||
TapHandler {
|
TapHandler {
|
||||||
acceptedButtons: Qt.RightButton
|
acceptedButtons: Qt.RightButton
|
||||||
onTapped: openFileContext(author, model.display, eventId, toolTip, progressInfo, parent)
|
onTapped: openFileContext(model, parent)
|
||||||
}
|
}
|
||||||
TapHandler {
|
TapHandler {
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
onLongPressed: openFileContext(author, model.display, eventId, toolTip, progressInfo, parent)
|
onLongPressed: openFileContext(model, parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -542,11 +548,11 @@ Kirigami.ScrollablePage {
|
|||||||
Layout.maximumWidth: fileContainer.bubbleMaxWidth
|
Layout.maximumWidth: fileContainer.bubbleMaxWidth
|
||||||
TapHandler {
|
TapHandler {
|
||||||
acceptedButtons: Qt.RightButton
|
acceptedButtons: Qt.RightButton
|
||||||
onTapped: openFileContext(author, model.display, eventId, toolTip, progressInfo, parent)
|
onTapped: openFileContext(model, parent)
|
||||||
}
|
}
|
||||||
TapHandler {
|
TapHandler {
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
onLongPressed: openFileContext(author, model.display, eventId, toolTip, progressInfo, parent)
|
onLongPressed: openFileContext(model, parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -886,28 +892,28 @@ Kirigami.ScrollablePage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Open message context dialog for file and videos
|
/// Open message context dialog for file and videos
|
||||||
function openFileContext(author, message, eventId, source, progressInfo, file) {
|
function openFileContext(event, file) {
|
||||||
const contextMenu = fileDelegateContextMenu.createObject(page, {
|
const contextMenu = fileDelegateContextMenu.createObject(page, {
|
||||||
author: author,
|
author: event.author,
|
||||||
message: message,
|
message: event.message,
|
||||||
eventId: eventId,
|
eventId: event.eventId,
|
||||||
source: source,
|
source: event.toolTip,
|
||||||
file: file,
|
file: file,
|
||||||
progressInfo: progressInfo,
|
progressInfo: event.progressInfo,
|
||||||
});
|
});
|
||||||
contextMenu.open();
|
contextMenu.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Open context menu for normal message
|
/// Open context menu for normal message
|
||||||
function openMessageContext(author, message, eventId, source, eventType, formattedBody, selectedText) {
|
function openMessageContext(event, selectedText) {
|
||||||
const contextMenu = messageDelegateContextMenu.createObject(page, {
|
const contextMenu = messageDelegateContextMenu.createObject(page, {
|
||||||
selectedText: selectedText,
|
selectedText: selectedText,
|
||||||
author: author,
|
author: event.author,
|
||||||
message: message,
|
message: event.message,
|
||||||
eventId: eventId,
|
eventId: event.eventId,
|
||||||
formattedBody: formattedBody,
|
formattedBody: event.formattedBody,
|
||||||
source: source,
|
source: event.toolTip,
|
||||||
eventType: eventType
|
eventType: event.eventType
|
||||||
});
|
});
|
||||||
contextMenu.open();
|
contextMenu.open();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user