Verified Commit 9f7c40f2 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

wallpapers/image: fix drag and drop in config dialog

Use url data type directly, no need to convert url to string.
parent b7685338
Pipeline #184886 passed with stage
in 6 minutes and 18 seconds
......@@ -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);
}
});
}
......
......@@ -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<QFileDialog *>(sender());
if (dialog) {
addSlidePath(dialog->directoryUrl().toLocalFile());
addSlidePath(dialog->directoryUrl());
}
}
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment