Commit ed85bd4a authored by Dmitry Kazakov's avatar Dmitry Kazakov

Ask the user to locate the audio channel file when it is not found

parent 35ad30e3
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <ksqueezedtextlabel.h> #include <ksqueezedtextlabel.h>
#include <kpluginfactory.h> #include <kpluginfactory.h>
#include <KoFileDialog.h>
#include <kis_icon_utils.h> #include <kis_icon_utils.h>
#include <KoDialog.h> #include <KoDialog.h>
#include <KoProgressUpdater.h> #include <KoProgressUpdater.h>
...@@ -190,6 +191,27 @@ void KisImportExportManager::setProgresUpdater(KoProgressUpdater *updater) ...@@ -190,6 +191,27 @@ void KisImportExportManager::setProgresUpdater(KoProgressUpdater *updater)
d->progressUpdater = updater; d->progressUpdater = updater;
} }
QString KisImportExportManager::askForAudioFileName(const QString &defaultDir, QWidget *parent)
{
KoFileDialog dialog(parent, KoFileDialog::ImportFiles, "ImportAudio");
if (!defaultDir.isEmpty()) {
dialog.setDefaultDir(defaultDir);
}
QStringList mimeTypes;
mimeTypes << "audio/mpeg";
mimeTypes << "audio/ogg";
mimeTypes << "audio/vorbis";
mimeTypes << "audio/vnd.wave";
mimeTypes << "audio/flac";
dialog.setMimeTypeFilters(mimeTypes);
dialog.setCaption(i18nc("@titile:window", "Open Audio"));
return dialog.filename();
}
KisImportExportFilter::ConversionStatus KisImportExportManager::convert(KisImportExportManager::Direction direction, const QString &location, const QString& realLocation, const QString &mimeType, bool showWarnings, KisPropertiesConfigurationSP exportConfiguration) KisImportExportFilter::ConversionStatus KisImportExportManager::convert(KisImportExportManager::Direction direction, const QString &location, const QString& realLocation, const QString &mimeType, bool showWarnings, KisPropertiesConfigurationSP exportConfiguration)
{ {
......
...@@ -119,6 +119,8 @@ public: ...@@ -119,6 +119,8 @@ public:
void setProgresUpdater(KoProgressUpdater *updater); void setProgresUpdater(KoProgressUpdater *updater);
static QString askForAudioFileName(const QString &defaultDir, QWidget *parent);
private Q_SLOTS: private Q_SLOTS:
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include "kis_time_range.h" #include "kis_time_range.h"
#include "kis_color_label_selector_widget.h" #include "kis_color_label_selector_widget.h"
#include "kis_slider_spin_box.h" #include "kis_slider_spin_box.h"
#include <KisImportExportManager.h>
#include <KoFileDialog.h> #include <KoFileDialog.h>
#include <QDesktopServices> #include <QDesktopServices>
...@@ -397,8 +398,6 @@ void TimelineFramesView::slotSelectAudioChannelFile() ...@@ -397,8 +398,6 @@ void TimelineFramesView::slotSelectAudioChannelFile()
{ {
if (!m_d->model) return; if (!m_d->model) return;
KoFileDialog dialog(this, KoFileDialog::ImportFiles, "ImportAudio");
QString defaultDir = QDesktopServices::storageLocation(QDesktopServices::MusicLocation); QString defaultDir = QDesktopServices::storageLocation(QDesktopServices::MusicLocation);
const QString currentFile = m_d->model->audioChannelFileName(); const QString currentFile = m_d->model->audioChannelFileName();
...@@ -407,19 +406,7 @@ void TimelineFramesView::slotSelectAudioChannelFile() ...@@ -407,19 +406,7 @@ void TimelineFramesView::slotSelectAudioChannelFile()
defaultDir = baseDir.absolutePath(); defaultDir = baseDir.absolutePath();
} }
dialog.setDefaultDir(defaultDir); const QString result = KisImportExportManager::askForAudioFileName(defaultDir, this);
QStringList mimeTypes;
mimeTypes << "audio/mpeg";
mimeTypes << "audio/ogg";
mimeTypes << "audio/vorbis";
mimeTypes << "audio/vnd.wave";
mimeTypes << "audio/flac";
dialog.setMimeTypeFilters(mimeTypes);
dialog.setCaption(i18nc("@titile:window", "Open Audio"));
const QString result = dialog.filename();
const QFileInfo info(result); const QFileInfo info(result);
if (info.exists()) { if (info.exists()) {
......
...@@ -797,9 +797,9 @@ KisNodeSP KisKraLoader::loadFileLayer(const KoXmlElement& element, KisImageSP im ...@@ -797,9 +797,9 @@ KisNodeSP KisKraLoader::loadFileLayer(const KoXmlElement& element, KisImageSP im
qApp->setOverrideCursor(Qt::ArrowCursor); qApp->setOverrideCursor(Qt::ArrowCursor);
QString msg = i18nc( QString msg = i18nc(
"@info", "@info",
"The file associated to a file layer with the name \"%1\" is not found.<nl/><nl/>" "The file associated to a file layer with the name \"%1\" is not found.\n\n"
"Expected path:<nl/>" "Expected path:\n>"
"%2<nl/><nl/>" "%2\n\n"
"Do you want to locate it manually?", name, fullPath); "Do you want to locate it manually?", name, fullPath);
int result = QMessageBox::warning(0, i18nc("@title:window", "File not found"), msg, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); int result = QMessageBox::warning(0, i18nc("@title:window", "File not found"), msg, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
...@@ -1122,8 +1122,24 @@ void KisKraLoader::loadAudio(const KoXmlElement& elem, KisImageSP image) ...@@ -1122,8 +1122,24 @@ void KisKraLoader::loadAudio(const KoXmlElement& elem, KisImageSP image)
QFileInfo info(fileName); QFileInfo info(fileName);
if (!info.exists()) { if (!info.exists()) {
m_d->errorMessages << i18n("Audio channel file %1 doesn't exist!", fileName); qApp->setOverrideCursor(Qt::ArrowCursor);
} else { QString msg = i18nc(
"@info",
"Audio channel file \"%1\" doesn't exist!\n\n"
"Expected path:\n"
"%2\n\n"
"Do you want to locate it manually?", info.fileName(), info.absoluteFilePath());
int result = QMessageBox::warning(0, i18nc("@title:window", "File not found"), msg, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (result == QMessageBox::Yes) {
info.setFile(KisImportExportManager::askForAudioFileName(info.absolutePath(), 0));
}
qApp->restoreOverrideCursor();
}
if (info.exists()) {
image->animationInterface()->setAudioChannelFileName(info.absoluteFilePath()); image->animationInterface()->setAudioChannelFileName(info.absoluteFilePath());
} }
} }
......
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