Fix sharing
This commit is contained in:
@@ -31,6 +31,7 @@ Dependencies:
|
||||
- 'on': ['Linux', 'FreeBSD']
|
||||
'require':
|
||||
'frameworks/kdbusaddons': '@latest-kf6'
|
||||
'frameworks/purpose': '@latest-kf6'
|
||||
|
||||
- 'on': ['Linux']
|
||||
'require':
|
||||
|
||||
@@ -293,7 +293,6 @@ qt_add_qml_module(neochat URI org.kde.neochat NO_PLUGIN
|
||||
qml/RoomInformation.qml
|
||||
qml/RoomMedia.qml
|
||||
qml/ChooseRoomDialog.qml
|
||||
qml/ShareAction.qml
|
||||
qml/SpaceHomePage.qml
|
||||
qml/SpaceHierarchyDelegate.qml
|
||||
qml/RemoveChildDialog.qml
|
||||
@@ -332,6 +331,16 @@ qt_add_qml_module(neochat URI org.kde.neochat NO_PLUGIN
|
||||
qml/glowdot.png
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
qt_target_qml_sources(neochat QML_FILES qml/ShareAction.qml)
|
||||
else()
|
||||
set_source_files_properties(qml/ShareActionStub.qml PROPERTIES
|
||||
QT_RESOURCE_ALIAS qml/ShareAction.qml
|
||||
)
|
||||
qt_target_qml_sources(neochat QML_FILES qml/ShareActionStub.qml)
|
||||
endif()
|
||||
|
||||
|
||||
configure_file(config-neochat.h.in ${CMAKE_CURRENT_BINARY_DIR}/config-neochat.h)
|
||||
|
||||
if(WIN32)
|
||||
|
||||
@@ -243,3 +243,8 @@ Comment[x-test]=xxThere is a new invitation to a roomxx
|
||||
Comment[zh_CN]=有新的聊天室邀请
|
||||
Comment[zh_TW]=有新的加入聊天室邀請
|
||||
Action=Popup
|
||||
|
||||
[Event/Share]
|
||||
Name=Share
|
||||
Comment=The result of sharing a piece of content
|
||||
Action=Popup
|
||||
|
||||
@@ -89,20 +89,12 @@ DelegateContextMenu {
|
||||
ShareAction {
|
||||
id: shareAction
|
||||
inputData: {
|
||||
'urls': [],
|
||||
'mimeType': [root.mimeType]
|
||||
"urls": [filename],
|
||||
"mimeType": [root.mimeType]
|
||||
}
|
||||
room: currentRoom
|
||||
eventId: root.eventId
|
||||
property string filename: StandardPaths.writableLocation(StandardPaths.CacheLocation) + "/" + eventId.replace(":", "_").replace("/", "_").replace("+", "_") + currentRoom.fileNameToDownload(eventId)
|
||||
|
||||
doBeforeSharing: () => {
|
||||
currentRoom.downloadFile(eventId, filename);
|
||||
}
|
||||
Component.onCompleted: {
|
||||
shareAction.inputData = {
|
||||
urls: [filename],
|
||||
mimeType: [root.mimeType]
|
||||
};
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -3,12 +3,16 @@
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.purpose as Purpose
|
||||
|
||||
import org.kde.neochat
|
||||
|
||||
/**
|
||||
* Action that allows an user to share data with other apps and service
|
||||
* 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
|
||||
* adapte itself for each platform and adopt the native component.
|
||||
* adapt itself for each platform and adopt the native component.
|
||||
*
|
||||
* TODO add Android support
|
||||
*/
|
||||
@@ -19,7 +23,6 @@ Kirigami.Action {
|
||||
text: i18n("Share")
|
||||
tooltip: i18n("Share the selected media")
|
||||
|
||||
property var doBeforeSharing: () => {}
|
||||
visible: false
|
||||
|
||||
/**
|
||||
@@ -34,19 +37,15 @@ Kirigami.Action {
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
property var inputData: ({})
|
||||
property var inputData
|
||||
|
||||
required property string eventId
|
||||
required property NeoChatRoom room
|
||||
|
||||
property Instantiator _instantiator: Instantiator {
|
||||
Component.onCompleted: {
|
||||
const purposeModel = Qt.createQmlObject('import org.kde.purpose as Purpose;
|
||||
Purpose.PurposeAlternativesModel {
|
||||
pluginType: "Export"
|
||||
}', root._instantiator);
|
||||
purposeModel.inputData = Qt.binding(function () {
|
||||
return root.inputData;
|
||||
});
|
||||
_instantiator.model = purposeModel;
|
||||
root.visible = true;
|
||||
model: Purpose.PurposeAlternativesModel {
|
||||
pluginType: "Export"
|
||||
inputData: root.inputData
|
||||
}
|
||||
|
||||
delegate: Kirigami.Action {
|
||||
@@ -54,12 +53,21 @@ Purpose.PurposeAlternativesModel {
|
||||
text: model.display
|
||||
icon.name: model.iconName
|
||||
onTriggered: {
|
||||
doBeforeSharing();
|
||||
root.room.download(root.eventId, root.inputData.urls[0]);
|
||||
root.room.fileTransferCompleted.connect(share);
|
||||
}
|
||||
function share(id) {
|
||||
if (id != root.eventId) {
|
||||
return;
|
||||
}
|
||||
applicationWindow().pageStack.pushDialogLayer('qrc:/org/kde/neochat/qml/ShareDialog.qml', {
|
||||
title: root.tooltip,
|
||||
title: root.text,
|
||||
index: index,
|
||||
model: root._instantiator.model
|
||||
}, {
|
||||
title: i18nc("@title", "Share")
|
||||
});
|
||||
root.room.fileTransferCompleted.disconnect(share);
|
||||
}
|
||||
}
|
||||
onObjectAdded: (index, object) => {
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.kde.kirigami as Kirigami
|
||||
|
||||
Kirigami.Action {
|
||||
property var inputData: ({})
|
||||
property var doBeforeSharing: () => {}
|
||||
property var room
|
||||
property string eventId
|
||||
visible: false
|
||||
}
|
||||
@@ -8,9 +8,12 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls as QQC2
|
||||
|
||||
import org.kde.purpose as Purpose
|
||||
import org.kde.notification
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.notification
|
||||
|
||||
import org.kde.neochat
|
||||
|
||||
Kirigami.Page {
|
||||
id: root
|
||||
@@ -30,29 +33,31 @@ Kirigami.Page {
|
||||
|
||||
Notification {
|
||||
id: sharingFailed
|
||||
eventId: "sharingFailed"
|
||||
eventId: "Share"
|
||||
text: i18n("Sharing failed")
|
||||
urgency: Notification.NormalUrgency
|
||||
}
|
||||
|
||||
Notification {
|
||||
id: sharingSuccess
|
||||
eventId: "sharingSuccess"
|
||||
eventId: "Share"
|
||||
flags: Notification.Persistent
|
||||
}
|
||||
|
||||
Component.onCompleted: jobView.start()
|
||||
Component.onCompleted: {
|
||||
jobView.start();
|
||||
}
|
||||
|
||||
contentItem: Purpose.JobView {
|
||||
Purpose.JobView {
|
||||
id: jobView
|
||||
|
||||
anchors.fill: parent
|
||||
onStateChanged: {
|
||||
if (state === Purpose.PurposeJobController.Finished) {
|
||||
if (jobView.job.output.url !== "") {
|
||||
// Show share url
|
||||
// TODO no needed anymore in purpose > 5.90
|
||||
sharingSuccess.text = i18n("Shared url for image is <a href='%1'>%1</a>", jobView.output.url);
|
||||
if (jobView.job?.output?.url?.length > 0) {
|
||||
sharingSuccess.text = i18n("Shared url for image is <a href='%1'>%1</a>", jobView.job.output.url);
|
||||
sharingSuccess.sendEvent();
|
||||
Clipboard.saveText(jobView.output.url);
|
||||
Clipboard.saveText(jobView.job.output.url);
|
||||
}
|
||||
root.closeDialog();
|
||||
} else if (state === Purpose.PurposeJobController.Error) {
|
||||
|
||||
Reference in New Issue
Block a user