Files
neochat/src/app/qml/ShareAction.qml
Joshua Goins 8bef9713fd Hide Purpose's own "Copy to Clipboard" function
This was added recently to Purpose, and it's not too useful for us.
We already have a bunch of better, more integrated ways to copy
events to the clipboard.
2025-08-29 10:02:50 -04:00

84 lines
2.6 KiB
QML

// SPDX-FileCopyrightText: 2021 Carl Schwan <carl@carlschwan.eu>
// SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
pragma ComponentBehavior: Bound
import QtQuick
import org.kde.kirigami as Kirigami
import org.kde.purpose as Purpose
import org.kde.neochat
/**
* Action that allows a user to share data with other apps and services
* installed on their computer. The goal of this high level API is to
* adapt itself for each platform and adopt the native component.
*
* TODO add Android support
*/
Kirigami.Action {
id: root
icon.name: "emblem-shared-symbolic"
text: i18nc("@action:button", "Share")
tooltip: i18nc("@info:tooltip", "Share the selected media")
/**
* This property holds the input data for purpose.
*
* @code{.qml}
* Purpose.ShareAction {
* inputData: {
* 'urls': ['file://home/notroot/Pictures/mypicture.png'],
* 'mimeType': ['image/png']
* }
* }
* @endcode
*/
property var inputData
required property string eventId
required property NeoChatRoom room
property Instantiator _instantiator: Instantiator {
model: Purpose.PurposeAlternativesModel {
pluginType: "Export"
inputData: root.inputData
// We already have many better ways to copy events to the clipboard
disabledPlugins: ["clipboardplugin"]
}
delegate: Kirigami.Action {
required property int index
required property string display
required property string iconName
text: display
icon.name: iconName
onTriggered: {
root.room.download(root.eventId, root.inputData.urls[0]);
root.room.fileTransferCompleted.connect(share);
}
function share(id: string): void {
if (id != root.eventId) {
return;
}
pageStack.pushDialogLayer(Qt.createComponent("org.kde.neochat", "ShareDialog"), {
title: root.text,
index: index,
model: root._instantiator.model
}, {
title: i18nc("@title", "Share")
});
root.room.fileTransferCompleted.disconnect(share);
}
}
onObjectAdded: (index, object) => {
object.index = index;
root.children.push(object);
}
onObjectRemoved: (index, object) => root.children = Array.from(root.children).filter(obj => obj.pluginId !== object.pluginId)
}
}