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

Show error message when failing to edit clip with external app

parent fe4ffc18
......@@ -4111,6 +4111,7 @@ void Bin::slotOpenClipExtern()
if (!clip) {
return;
}
QString errorString;
switch (clip->clipType()) {
case ClipType::Text:
case ClipType::TextTemplate:
......@@ -4128,7 +4129,7 @@ void Bin::slotOpenClipExtern()
}
}
if (!KdenliveSettings::defaultimageapp().isEmpty()) {
pCore->openExternalApp(KdenliveSettings::defaultimageapp(), {clip->url()});
errorString = pCore->openExternalApp(KdenliveSettings::defaultimageapp(), {clip->url()});
} else {
KMessageBox::error(QApplication::activeWindow(), i18n("Please set a default application to open image files"));
}
......@@ -4145,7 +4146,7 @@ void Bin::slotOpenClipExtern()
}
}
if (!KdenliveSettings::defaultaudioapp().isEmpty()) {
pCore->openExternalApp(KdenliveSettings::defaultaudioapp(), {clip->url()});
errorString = pCore->openExternalApp(KdenliveSettings::defaultaudioapp(), {clip->url()});
} else {
KMessageBox::error(QApplication::activeWindow(), i18n("Please set a default application to open audio files"));
}
......@@ -4156,6 +4157,9 @@ void Bin::slotOpenClipExtern()
default:
break;
}
if (!errorString.isEmpty()) {
KMessageBox::detailedError(QApplication::activeWindow(), i18n("Cannot open file %1", clip->url()), errorString);
}
}
/*
......
......@@ -261,20 +261,27 @@ void Core::buildLumaThumbs(const QStringList &values)
}
}
QString Core::openExternalApp(const QString &appPath, QStringList args)
QString Core::openExternalApp(QString appPath, QStringList args)
{
QProcess process;
if (QFileInfo(appPath).isRelative()) {
QString updatedPath = QStandardPaths::findExecutable(appPath);
if (updatedPath.isEmpty()) {
return i18n("Cannot open file %1", appPath);
}
appPath = updatedPath;
}
#if defined(Q_OS_MACOS)
args.prepend(QStringLiteral("--args"));
args.prepend(appPath);
args.prepend(QStringLiteral("-a"));
if (!process.startDetached(QStringLiteral("open"), args)) {
return process.errorString();
}
return QString();
process.setProgram("open");
#else
process.setProgram(appPath);
#endif
process.setArguments(args);
qDebug() << "Starting external app" << appPath << "with arguments" << args;
if (!process.startDetached(appPath, args)) {
if (!process.startDetached()) {
return process.errorString();
}
return QString();
......
......@@ -102,7 +102,7 @@ public:
MainWindow *window();
/** @brief Open a file using an external app. */
QString openExternalApp(const QString &appPath, const QStringList args);
QString openExternalApp(QString appPath, const QStringList args);
/** @brief Returns a pointer to the project manager. */
ProjectManager *projectManager();
......
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