diff --git a/wallpapers/image/imagepackage/contents/ui/config.qml b/wallpapers/image/imagepackage/contents/ui/config.qml index 3bc654d8c..e056a41fc 100644 --- a/wallpapers/image/imagepackage/contents/ui/config.qml +++ b/wallpapers/image/imagepackage/contents/ui/config.qml @@ -169,18 +169,15 @@ ColumnLayout { onEntered: { if (drag.hasUrls) { - event.accept(); + drag.accept(); } } onDropped: { drop.urls.forEach(function (url) { - if (url.indexOf("file://") === 0) { - var path = url.substr(7); // 7 is length of "file://" - if (configDialog.currentWallpaper === "org.kde.image") { - imageWallpaper.addUsersWallpaper(path); - } else { - imageWallpaper.addSlidePath(path); - } + if (configDialog.currentWallpaper === "org.kde.image") { + imageWallpaper.addUsersWallpaper(url); + } else { + imageWallpaper.addSlidePath(url); } }); } diff --git a/wallpapers/image/plugin/imagebackend.cpp b/wallpapers/image/plugin/imagebackend.cpp index c029f248e..db9b23c4b 100644 --- a/wallpapers/image/plugin/imagebackend.cpp +++ b/wallpapers/image/plugin/imagebackend.cpp @@ -321,16 +321,16 @@ void ImageBackend::showAddSlidePathsDialog() dialog->show(); } -void ImageBackend::addSlidePath(const QString &_path) +void ImageBackend::addSlidePath(const QUrl &url) { - if (_path.isEmpty()) { + if (url.isEmpty()) { return; } - QString path = _path; + QString path = url.toLocalFile(); // If path is a file, use its parent folder. - const QFileInfo info(QUrl(path).toLocalFile()); + const QFileInfo info(path); if (info.isFile()) { path = info.dir().absolutePath(); @@ -367,7 +367,7 @@ void ImageBackend::addDirFromSelectionDialog() { QFileDialog *dialog = qobject_cast(sender()); if (dialog) { - addSlidePath(dialog->directoryUrl().toLocalFile()); + addSlidePath(dialog->directoryUrl()); } } diff --git a/wallpapers/image/plugin/imagebackend.h b/wallpapers/image/plugin/imagebackend.h index 880586fba..6aefb30c0 100644 --- a/wallpapers/image/plugin/imagebackend.h +++ b/wallpapers/image/plugin/imagebackend.h @@ -82,7 +82,7 @@ public: QUrl modelImage() const; // this is for QML use - Q_INVOKABLE void addSlidePath(const QString &path); + Q_INVOKABLE void addSlidePath(const QUrl &url); Q_INVOKABLE void removeSlidePath(const QString &path); Q_INVOKABLE void openFolder(const QString &path); Q_INVOKABLE void openModelImage() const;