Commit ce7d3d14 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Use Windows compatible methods when dropping a folder in bin.

Related to #287
parent 7da3201e
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "projectitemmodel.h" #include "projectitemmodel.h"
#include "titler/titledocument.h" #include "titler/titledocument.h"
#include "dialogs/clipcreationdialog.h"
#include "utils/devices.hpp" #include "utils/devices.hpp"
#include "xml/xml.hpp" #include "xml/xml.hpp"
#include <KMessageBox> #include <KMessageBox>
...@@ -229,34 +230,21 @@ const QString ClipCreator::createClipsFromList(const QList<QUrl> &list, bool che ...@@ -229,34 +230,21 @@ const QString ClipCreator::createClipsFromList(const QList<QUrl> &list, bool che
if (!QFile::exists(file.toLocalFile())) { if (!QFile::exists(file.toLocalFile())) {
continue; continue;
} }
QFileInfo info(file.toLocalFile());
QMimeType mType = db.mimeTypeForUrl(file); QMimeType mType = db.mimeTypeForUrl(file);
if (mType.inherits(QLatin1String("inode/directory"))) { if (info.isDir()) {
// user dropped a folder, import its files // user dropped a folder, import its files
QDir dir(file.path()); QDir dir(file.toLocalFile());
QString folderId; QString folderId;
Fun local_undo = []() { return true; }; Fun local_undo = []() { return true; };
Fun local_redo = []() { return true; }; Fun local_redo = []() { return true; };
QStringList result = dir.entryList(QDir::Files);
QStringList subfolders = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); QStringList subfolders = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
dir.setNameFilters(ClipCreationDialog::getExtensions());
QStringList result = dir.entryList(QDir::Files);
QList<QUrl> folderFiles; QList<QUrl> folderFiles;
for (const QString &path : result) { for (const QString &path : result) {
QUrl url = QUrl::fromLocalFile(dir.absoluteFilePath(path)); QUrl url = QUrl::fromLocalFile(dir.absoluteFilePath(path));
// Check file is of a supported type folderFiles.append(url);
mType = db.mimeTypeForUrl(url);
QString mimeAliases = mType.name();
bool isValid = mimeAliases.contains(QLatin1String("video/"));
if (!isValid) {
isValid = mimeAliases.contains(QLatin1String("audio/"));
}
if (!isValid) {
isValid = mimeAliases.contains(QLatin1String("image/"));
}
if (!isValid && (mType.inherits(QLatin1String("video/mlt-playlist")) || mType.inherits(QLatin1String("application/x-kdenlivetitle")))) {
isValid = true;
}
if (isValid) {
folderFiles.append(url);
}
} }
if (folderFiles.isEmpty()) { if (folderFiles.isEmpty()) {
QList<QUrl> sublist; QList<QUrl> sublist;
......
Markdown is supported
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