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

View file

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