diff --git a/plugins/findthisdevice/findthisdevicehelper.cpp b/plugins/findthisdevice/findthisdevicehelper.cpp index 7ab74ba28..4eca7e426 100644 --- a/plugins/findthisdevice/findthisdevicehelper.cpp +++ b/plugins/findthisdevice/findthisdevicehelper.cpp @@ -17,6 +17,7 @@ #endif #include +#include #include QString FindThisDeviceHelper::defaultSound() @@ -48,3 +49,8 @@ QString FindThisDeviceHelper::defaultSound() } return soundURL.toLocalFile(); } + +bool FindThisDeviceHelper::pathExists(const QString &path) +{ + return QFileInfo::exists(path); +} diff --git a/plugins/findthisdevice/findthisdevicehelper.h b/plugins/findthisdevice/findthisdevicehelper.h index c2e1bdb8e..14be8188f 100644 --- a/plugins/findthisdevice/findthisdevicehelper.h +++ b/plugins/findthisdevice/findthisdevicehelper.h @@ -17,4 +17,5 @@ class FindThisDeviceHelper : public QObject public: static Q_INVOKABLE QString defaultSound(); + bool pathExists(const QString &path); }; diff --git a/plugins/findthisdevice/kdeconnect_findthisdevice_config.qml b/plugins/findthisdevice/kdeconnect_findthisdevice_config.qml index dfea4685d..6b8cfa4c5 100644 --- a/plugins/findthisdevice/kdeconnect_findthisdevice_config.qml +++ b/plugins/findthisdevice/kdeconnect_findthisdevice_config.qml @@ -52,9 +52,25 @@ Kirigami.ScrollablePage { QQC2.Button { text: i18nc("@action:button", "Choose file") display: QQC2.Button.IconOnly - icon.name: "document-open" + icon.name: "document-open-symbolic" onClicked: fileDialog.open() } + + QQC2.Button { + text: i18nc("@action:button", "Play") + display: QQC2.Button.IconOnly + icon.name: playMusic.playing ? "media-playback-stop-symbolic" : "media-playback-start-symbolic" + enabled: FindThisDevice.FindThisDeviceHelper.pathExists(path.text) + onClicked: { + playMusic.source = path.text; + playMusic.playing ? playMusic.stop() : playMusic.play(); + } + + MediaPlayer { + id: playMusic + audioOutput: AudioOutput {} + } + } } } }