Commit 833791ad authored by Bharadwaj Raju's avatar Bharadwaj Raju Committed by Nate Graham
Browse files

Inform the user when opening files fails

Currently, if a user drops an incompatible file onto Elisa, or calls it with
a nonexistent file, Elisa just silently drops it. With this change, Elisa will
show a passive notification informing the user when this happens.
parent 07c34311
Pipeline #228092 passed with stage
in 9 minutes
......@@ -221,12 +221,12 @@ void ElisaApplication::setupActions(const QString &actionName)
#endif
}
void ElisaApplication::openFiles(const QList<QUrl> &files)
bool ElisaApplication::openFiles(const QList<QUrl> &files)
{
openFiles(files, QDir::currentPath());
return openFiles(files, QDir::currentPath());
}
void ElisaApplication::openFiles(const QList<QUrl> &files, const QString &workingDirectory)
bool ElisaApplication::openFiles(const QList<QUrl> &files, const QString &workingDirectory)
{
auto audioFiles = DataTypes::EntryDataList{};
const QMimeDatabase mimeDB;
......@@ -245,6 +245,7 @@ void ElisaApplication::openFiles(const QList<QUrl> &files, const QString &workin
ElisaUtils::PlayListEnqueueMode::AppendPlayList,
ElisaUtils::PlayListEnqueueTriggerPlay::TriggerPlay);
}
return (audioFiles.count() == files.count());
}
void ElisaApplication::activateActionRequested(const QString &actionName, const QVariant &parameter)
......
......@@ -187,8 +187,8 @@ public Q_SLOTS:
void configureElisa();
void openFiles(const QList<QUrl> &files);
void openFiles(const QList<QUrl> &files, const QString &workingDirectory);
bool openFiles(const QList<QUrl> &files);
bool openFiles(const QList<QUrl> &files, const QString &workingDirectory);
void activateActionRequested(const QString &actionName, const QVariant &parameter);
......
......@@ -499,10 +499,12 @@ Module {
Method { name: "configureElisa" }
Method {
name: "openFiles"
type: "bool"
Parameter { name: "files"; type: "QList<QUrl>" }
}
Method {
name: "openFiles"
type: "bool"
Parameter { name: "files"; type: "QList<QUrl>" }
Parameter { name: "workingDirectory"; type: "string" }
}
......
......@@ -50,7 +50,9 @@ Kirigami.ApplicationWindow {
anchors.fill: parent
onDropped: {
if (drop.hasUrls) {
ElisaApplication.openFiles(drop.urls);
if (!ElisaApplication.openFiles(drop.urls)) {
showPassiveNotification(i18nc("@info:status", "Could not load some files. Elisa can only open audio and playlist files."), 7000, "", function() {})
}
}
}
}
......@@ -471,7 +473,9 @@ Kirigami.ApplicationWindow {
mprisloader.active = true
ElisaApplication.openFiles(elisaStartupArguments)
if (!ElisaApplication.openFiles(elisaStartupArguments)) {
showPassiveNotification(i18nc("@info:status", "Could not load some files. Elisa can only open audio and playlist files."), 7000, "", function() {})
}
// use global drawer on mobile
if (Kirigami.Settings.isMobile) {
......
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