Commit b2a43a35 authored by Bharadwaj Raju's avatar Bharadwaj Raju 📚 Committed by Nate Graham
Browse files

Implement dropping music files from file manager onto Playlist

BUG: 404712
FIXED-IN: 22.04
parent 12877b62
Pipeline #103634 passed with stage
in 3 minutes and 55 seconds
......@@ -55,6 +55,8 @@
#include <QKeyEvent>
#include <QDebug>
#include <QFileSystemWatcher>
#include <QMimeDatabase>
#include <QMimeType>
#include <memory>
......@@ -238,6 +240,24 @@ void ElisaApplication::setArguments(const DataTypes::EntryDataList &newArguments
}
}
void ElisaApplication::openFiles(const QList<QUrl> &files)
{
auto newArguments = DataTypes::EntryDataList{};
const QMimeDatabase mimeDB;
for (const auto &file : files) {
const QMimeType mime = mimeDB.mimeTypeForUrl(file);
if (mime.inherits(QStringLiteral("audio/x-mpegurl"))) {
d->mMediaPlayListProxyModel->loadPlayList(file);
} else if (mime.name().startsWith(QStringLiteral("audio/"))) {
newArguments.push_back(DataTypes::EntryData{{{DataTypes::ElementTypeRole, ElisaUtils::FileName},
{DataTypes::ResourceRole, file}}, {}, {}});
}
}
setArguments(newArguments);
// so that adding the same file more than once works
setArguments({});
}
void ElisaApplication::activateActionRequested(const QString &actionName, const QVariant &parameter)
{
Q_UNUSED(actionName)
......
......@@ -197,6 +197,8 @@ public Q_SLOTS:
void setArguments(const DataTypes::EntryDataList &newArguments);
void openFiles(const QList<QUrl> &files);
void activateActionRequested(const QString &actionName, const QVariant &parameter);
void activateRequested(const QStringList &arguments, const QString &workingDirectory);
......
......@@ -38,6 +38,15 @@ Kirigami.ApplicationWindow {
}
}
DropArea {
anchors.fill: parent
onDropped: {
if (drop.hasUrls) {
ElisaApplication.openFiles(drop.urls);
}
}
}
// HACK: since elisa's main view hasn't been ported to a page, but page layers are used for mobile settings
// lower the main view and mobile footer's z to be behind the layer when there are layers added (normally it is in front)
property bool layerOnTop: pageStack.layers.depth > 1
......
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