Fix qml warnings in DelegateContextMenu
This commit is contained in:
committed by
Tobias Fella
parent
b80a2f94f4
commit
919fc8b821
@@ -2,16 +2,16 @@
|
|||||||
// SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
|
// SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import QtCore as Core
|
import QtCore as Core
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls as QQC2
|
import QtQuick.Controls as QQC2
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import QtQuick.Dialogs as Dialogs
|
import QtQuick.Dialogs as Dialogs
|
||||||
|
|
||||||
import Qt.labs.qmlmodels
|
|
||||||
import org.kde.kirigami as Kirigami
|
import org.kde.kirigami as Kirigami
|
||||||
import org.kde.kirigamiaddons.components as KirigamiComponents
|
import org.kde.kirigamiaddons.components as KirigamiComponents
|
||||||
import org.kde.kirigamiaddons.formcard as FormCard
|
|
||||||
import org.kde.kirigamiaddons.delegates as Delegates
|
import org.kde.kirigamiaddons.delegates as Delegates
|
||||||
|
|
||||||
import org.kde.neochat
|
import org.kde.neochat
|
||||||
@@ -108,6 +108,8 @@ KirigamiComponents.ConvergentContextMenu {
|
|||||||
model: ["👍", "👎️", "😄", "🎉", "👀", "⋮"]
|
model: ["👍", "👎️", "😄", "🎉", "👀", "⋮"]
|
||||||
delegate: Delegates.RoundedItemDelegate {
|
delegate: Delegates.RoundedItemDelegate {
|
||||||
id: emojiDelegate
|
id: emojiDelegate
|
||||||
|
|
||||||
|
required property string modelData
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredWidth: Kirigami.Units.gridUnit * 2.5
|
Layout.preferredWidth: Kirigami.Units.gridUnit * 2.5
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
@@ -118,12 +120,12 @@ KirigamiComponents.ConvergentContextMenu {
|
|||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
|
||||||
font.family: "emoji"
|
font.family: "emoji"
|
||||||
text: modelData
|
text: emojiDelegate.modelData
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (emojiText.text === "⋮") {
|
if (emojiText.text === "⋮") {
|
||||||
var dialog = emojiDialog.createObject(emojiDelegate);
|
var dialog = emojiDialog.createObject(emojiDelegate) as EmojiDialog;
|
||||||
dialog.showStickers = false;
|
dialog.showStickers = false;
|
||||||
dialog.chosen.connect(emoji => {
|
dialog.chosen.connect(emoji => {
|
||||||
root.room.toggleReaction(root.eventId, emoji);
|
root.room.toggleReaction(root.eventId, emoji);
|
||||||
@@ -136,7 +138,7 @@ KirigamiComponents.ConvergentContextMenu {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentRoom.toggleReaction(eventId, modelData);
|
root.room.toggleReaction(root.eventId, modelData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,7 +146,7 @@ KirigamiComponents.ConvergentContextMenu {
|
|||||||
id: emojiDialog
|
id: emojiDialog
|
||||||
|
|
||||||
EmojiDialog {
|
EmojiDialog {
|
||||||
currentRoom: root.Message.room
|
currentRoom: root.room
|
||||||
showQuickReaction: true
|
showQuickReaction: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,8 +162,8 @@ KirigamiComponents.ConvergentContextMenu {
|
|||||||
text: i18nc("@action:inmenu", "Reply")
|
text: i18nc("@action:inmenu", "Reply")
|
||||||
icon.name: "mail-replied-symbolic"
|
icon.name: "mail-replied-symbolic"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
currentRoom.mainCache.replyId = eventId;
|
root.room.mainCache.replyId = root.eventId;
|
||||||
currentRoom.editCache.editId = "";
|
root.room.editCache.editId = "";
|
||||||
RoomManager.requestFullScreenClose();
|
RoomManager.requestFullScreenClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,10 +173,10 @@ KirigamiComponents.ConvergentContextMenu {
|
|||||||
text: i18nc("@action:inmenu", "Reply in Thread")
|
text: i18nc("@action:inmenu", "Reply in Thread")
|
||||||
icon.name: "dialog-messages"
|
icon.name: "dialog-messages"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
currentRoom.threadCache.replyId = "";
|
root.room.threadCache.replyId = "";
|
||||||
currentRoom.threadCache.threadId = currentRoom.eventIsThreaded(root.eventId) ? currentRoom.rootIdForThread(root.eventId) : root.eventId;
|
root.room.threadCache.threadId = root.room.eventIsThreaded(root.eventId) ? root.room.rootIdForThread(root.eventId) : root.eventId;
|
||||||
currentRoom.mainCache.clearRelations();
|
root.room.mainCache.clearRelations();
|
||||||
currentRoom.editCache.clearRelations();
|
root.room.editCache.clearRelations();
|
||||||
RoomManager.requestFullScreenClose();
|
RoomManager.requestFullScreenClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -184,14 +186,14 @@ KirigamiComponents.ConvergentContextMenu {
|
|||||||
text: i18n("Edit")
|
text: i18n("Edit")
|
||||||
icon.name: "document-edit"
|
icon.name: "document-edit"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
currentRoom.editCache.editId = eventId;
|
root.room.editCache.editId = root.eventId;
|
||||||
currentRoom.mainCache.replyId = "";
|
root.room.mainCache.replyId = "";
|
||||||
currentRoom.mainCache.threadId = "";
|
root.room.mainCache.threadId = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
visible: (author.isLocalMember || currentRoom.canSendState("redact")) && root.messageComponentType !== MessageComponentType.Other
|
visible: (root.author.isLocalMember || root.room.canSendState("redact")) && root.messageComponentType !== MessageComponentType.Other
|
||||||
text: i18nc("@action:button", "Remove…")
|
text: i18nc("@action:button", "Remove…")
|
||||||
icon.name: "edit-delete-remove"
|
icon.name: "edit-delete-remove"
|
||||||
icon.color: "red"
|
icon.color: "red"
|
||||||
@@ -248,7 +250,7 @@ KirigamiComponents.ConvergentContextMenu {
|
|||||||
}
|
}
|
||||||
icon.name: "document-open"
|
icon.name: "document-open"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
currentRoom.openEventMediaExternally(root.eventId);
|
root.room.openEventMediaExternally(root.eventId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,8 +269,8 @@ KirigamiComponents.ConvergentContextMenu {
|
|||||||
}
|
}
|
||||||
icon.name: "document-save"
|
icon.name: "document-save"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
var dialog = saveAsDialog.createObject(QQC2.Overlay.overlay);
|
var dialog = root.saveAsDialog.createObject(QQC2.Overlay.overlay) as Dialogs.FileDialog;
|
||||||
dialog.selectedFile = currentRoom.fileNameToDownload(eventId);
|
dialog.selectedFile = root.room.fileNameToDownload(root.eventId);
|
||||||
dialog.open();
|
dialog.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -288,7 +290,7 @@ KirigamiComponents.ConvergentContextMenu {
|
|||||||
}
|
}
|
||||||
icon.name: "edit-copy"
|
icon.name: "edit-copy"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
currentRoom.copyEventMedia(root.eventId);
|
root.room.copyEventMedia(root.eventId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,14 +312,14 @@ KirigamiComponents.ConvergentContextMenu {
|
|||||||
text: i18nc("@action:inmenu", "Copy Message Link")
|
text: i18nc("@action:inmenu", "Copy Message Link")
|
||||||
icon.name: "link-symbolic"
|
icon.name: "link-symbolic"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
Clipboard.saveText("https://matrix.to/#/" + currentRoom.id + "/" + root.eventId);
|
Clipboard.saveText("https://matrix.to/#/" + root.room.id + "/" + root.eventId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
text: i18nc("@action:button 'Report' as in 'Report this event to the administrators'", "Report…")
|
text: i18nc("@action:button 'Report' as in 'Report this event to the administrators'", "Report…")
|
||||||
icon.name: "dialog-warning-symbolic"
|
icon.name: "dialog-warning-symbolic"
|
||||||
visible: !author.isLocalMember
|
visible: !root.author.isLocalMember
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
let dialog = (root.Kirigami.PageStack.pageStack as Kirigami.PageRow).pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ReasonDialog'), {
|
let dialog = (root.Kirigami.PageStack.pageStack as Kirigami.PageRow).pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ReasonDialog'), {
|
||||||
title: i18nc("@title:dialog", "Report Message"),
|
title: i18nc("@title:dialog", "Report Message"),
|
||||||
@@ -348,9 +350,12 @@ KirigamiComponents.ConvergentContextMenu {
|
|||||||
onOpenUrl: url => RoomManager.resolveResource(url.toString())
|
onOpenUrl: url => RoomManager.resolveResource(url.toString())
|
||||||
}
|
}
|
||||||
delegate: Kirigami.Action {
|
delegate: Kirigami.Action {
|
||||||
text: model.display
|
required property string display
|
||||||
icon.name: model.decoration
|
required property string decoration
|
||||||
onTriggered: webShortcutModel.trigger(model.edit)
|
required property var edit
|
||||||
|
text: display
|
||||||
|
icon.name: decoration
|
||||||
|
onTriggered: webShortcutModel.trigger(edit)
|
||||||
}
|
}
|
||||||
onObjectAdded: (index, object) => webShortcutModelAction.children.push(object)
|
onObjectAdded: (index, object) => webShortcutModelAction.children.push(object)
|
||||||
}
|
}
|
||||||
@@ -378,18 +383,18 @@ KirigamiComponents.ConvergentContextMenu {
|
|||||||
"urls": [filename],
|
"urls": [filename],
|
||||||
"mimeType": [root.mimeType]
|
"mimeType": [root.mimeType]
|
||||||
}
|
}
|
||||||
room: currentRoom
|
room: root.room
|
||||||
eventId: root.eventId
|
eventId: root.eventId
|
||||||
property string filename: Core.StandardPaths.writableLocation(Core.StandardPaths.CacheLocation) + "/" + eventId.replace(":", "_").replace("/", "_").replace("+", "_") + currentRoom.fileNameToDownload(eventId)
|
property string filename: Core.StandardPaths.writableLocation(Core.StandardPaths.CacheLocation) + "/" + eventId.replace(":", "_").replace("/", "_").replace("+", "_") + root.room.fileNameToDownload(eventId)
|
||||||
}
|
}
|
||||||
|
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
readonly property bool pinned: currentRoom.isEventPinned(root.eventId)
|
readonly property bool pinned: root.room.isEventPinned(root.eventId)
|
||||||
|
|
||||||
visible: currentRoom.canSendState("m.room.pinned_events") && root.messageComponentType !== MessageComponentType.Other
|
visible: root.room.canSendState("m.room.pinned_events") && root.messageComponentType !== MessageComponentType.Other
|
||||||
text: pinned ? i18nc("@action:button 'Unpin' as in 'Unpin this message'", "Unpin") : i18nc("@action:button 'Pin' as in 'Pin the message in the room'", "Pin")
|
text: pinned ? i18nc("@action:button 'Unpin' as in 'Unpin this message'", "Unpin") : i18nc("@action:button 'Pin' as in 'Pin the message in the room'", "Pin")
|
||||||
icon.name: pinned ? "window-unpin-symbolic" : "pin-symbolic"
|
icon.name: pinned ? "window-unpin-symbolic" : "pin-symbolic"
|
||||||
onTriggered: pinned ? currentRoom.unpinEvent(root.eventId) : currentRoom.pinEvent(root.eventId)
|
onTriggered: pinned ? root.room.unpinEvent(root.eventId) : root.room.pinEvent(root.eventId)
|
||||||
}
|
}
|
||||||
|
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
@@ -414,7 +419,7 @@ KirigamiComponents.ConvergentContextMenu {
|
|||||||
}
|
}
|
||||||
NeoChatConfig.lastSaveDirectory = currentFolder;
|
NeoChatConfig.lastSaveDirectory = currentFolder;
|
||||||
NeoChatConfig.save();
|
NeoChatConfig.save();
|
||||||
currentRoom.downloadFile(eventId, selectedFile);
|
root.room.downloadFile(root.eventId, selectedFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,7 +450,7 @@ KirigamiComponents.ConvergentContextMenu {
|
|||||||
text: root.plainText
|
text: root.plainText
|
||||||
textFormat: Text.PlainText
|
textFormat: Text.PlainText
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
onLinkActivated: RoomManager.resolveResource(link, "join")
|
onLinkActivated: link => RoomManager.resolveResource(link, "join")
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user