smsapp: Clarify that source/file is a URL

Not using a URL type for URL data may lead to confusion.
This commit is contained in:
ivan tkachenko 2024-06-05 14:27:54 +06:00 committed by Simon Redman
parent 0ed648b4ba
commit 11ef11c0c3
2 changed files with 14 additions and 14 deletions

View file

@ -13,7 +13,7 @@ import QtMultimedia
Kirigami.Page { Kirigami.Page {
id: root id: root
property string filePath property url fileUrl
property string mimeType property string mimeType
actions: [ actions: [
@ -21,7 +21,7 @@ Kirigami.Page {
text: i18nd("kdeconnect-sms", "Open with default") text: i18nd("kdeconnect-sms", "Open with default")
icon.name: "window-new" icon.name: "window-new"
onTriggered: { onTriggered: {
Qt.openUrlExternally(root.filePath); Qt.openUrlExternally(root.fileUrl);
} }
} }
] ]
@ -40,7 +40,7 @@ Kirigami.Page {
Image { Image {
id: image id: image
source: parent.visible ? root.filePath : "" source: parent.visible ? root.fileUrl : ""
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: sourceSize.width width: sourceSize.width
@ -51,7 +51,7 @@ Kirigami.Page {
MediaPlayer { MediaPlayer {
id: mediaPlayer id: mediaPlayer
source: root.filePath source: root.fileUrl
onPositionChanged: { onPositionChanged: {
if (mediaPlayer.position > 1000 && mediaPlayer.duration - mediaPlayer.position < 1000) { if (mediaPlayer.position > 1000 && mediaPlayer.duration - mediaPlayer.position < 1000) {

View file

@ -15,7 +15,7 @@ Item {
property int partID property int partID
property string mimeType property string mimeType
property string uniqueIdentifier property string uniqueIdentifier
property string sourcePath: "" property url source
readonly property int elementWidth: 100 readonly property int elementWidth: 100
readonly property int elementHeight: 100 readonly property int elementHeight: 100
@ -27,7 +27,7 @@ Item {
id: attachmentViewer id: attachmentViewer
AttachmentViewer { AttachmentViewer {
filePath: root.sourcePath fileUrl: root.source
mimeType: root.mimeType mimeType: root.mimeType
title: uniqueIdentifier title: uniqueIdentifier
} }
@ -46,7 +46,7 @@ Item {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
if (root.sourcePath == "") { if (root.source.toString() === "") {
conversationModel.requestAttachmentPath(root.partID, root.uniqueIdentifier) conversationModel.requestAttachmentPath(root.partID, root.uniqueIdentifier)
} else { } else {
openMedia(); openMedia();
@ -59,7 +59,7 @@ Item {
visible: root.mimeType.match("video") visible: root.mimeType.match("video")
anchors.centerIn: parent anchors.centerIn: parent
onClicked: { onClicked: {
if (root.sourcePath == "") { if (root.source.toString() === "") {
conversationModel.requestAttachmentPath(root.partID, root.uniqueIdentifier) conversationModel.requestAttachmentPath(root.partID, root.uniqueIdentifier)
} else { } else {
openMedia(); openMedia();
@ -77,7 +77,7 @@ Item {
MediaPlayer { MediaPlayer {
id: audioPlayer id: audioPlayer
source: root.sourcePath source: root.source
onPlaybackStateChanged: { onPlaybackStateChanged: {
if (playbackState === MediaPlayer.PlayingState) { if (playbackState === MediaPlayer.PlayingState) {
@ -93,12 +93,12 @@ Item {
spacing: Kirigami.Units.largeSpacing spacing: Kirigami.Units.largeSpacing
Button { Button {
id : audioPlayButton id: audioPlayButton
icon.name: "media-playback-start" icon.name: "media-playback-start"
Layout.alignment: Qt.AlignCenter Layout.alignment: Qt.AlignCenter
onClicked: { onClicked: {
if (root.sourcePath != "") { if (root.source.toString() !== "") {
if (icon.name === "media-playback-start") { if (icon.name === "media-playback-start") {
audioPlayer.play() audioPlayer.play()
} else { } else {
@ -119,11 +119,11 @@ Item {
Connections { Connections {
target: conversationModel target: conversationModel
function onFilePathReceived(filePath, fileName) { function onFilePathReceived(filePath, fileName) {
if (root.uniqueIdentifier === fileName && root.sourcePath == "") { if (root.uniqueIdentifier === fileName && root.source.toString() === "") {
root.sourcePath = "file://" + filePath root.source = "file://" + filePath
if (root.mimeType.match("audio")) { if (root.mimeType.match("audio")) {
audioPlayer.source = root.sourcePath audioPlayer.source = root.source
audioPlayer.play() audioPlayer.play()
} else if (root.mimeType.match("image") || root.mimeType.match("video")) { } else if (root.mimeType.match("image") || root.mimeType.match("video")) {
openMedia(); openMedia();