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 @@
#include <ksqueezedtextlabel.h>
#include <kpluginfactory.h>
#include <KoFileDialog.h>
#include <kis_icon_utils.h>
#include <KoDialog.h>
#include <KoProgressUpdater.h>
......@@ -190,6 +191,27 @@ void KisImportExportManager::setProgresUpdater(KoProgressUpdater *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)
{
......
......@@ -119,6 +119,8 @@ public:
void setProgresUpdater(KoProgressUpdater *updater);
static QString askForAudioFileName(const QString &defaultDir, QWidget *parent);
private Q_SLOTS:
......
......@@ -55,6 +55,7 @@
#include "kis_time_range.h"
#include "kis_color_label_selector_widget.h"
#include "kis_slider_spin_box.h"
#include <KisImportExportManager.h>
#include <KoFileDialog.h>
#include <QDesktopServices>
......@@ -397,8 +398,6 @@ void TimelineFramesView::slotSelectAudioChannelFile()
{
if (!m_d->model) return;
KoFileDialog dialog(this, KoFileDialog::ImportFiles, "ImportAudio");
QString defaultDir = QDesktopServices::storageLocation(QDesktopServices::MusicLocation);
const QString currentFile = m_d->model->audioChannelFileName();
......@@ -407,19 +406,7 @@ void TimelineFramesView::slotSelectAudioChannelFile()
defaultDir = baseDir.absolutePath();
}
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"));
const QString result = dialog.filename();
const QString result = KisImportExportManager::askForAudioFileName(defaultDir, this);
const QFileInfo info(result);
if (info.exists()) {
......
......@@ -797,9 +797,9 @@ KisNodeSP KisKraLoader::loadFileLayer(const KoXmlElement& element, KisImageSP im
qApp->setOverrideCursor(Qt::ArrowCursor);
QString msg = i18nc(
"@info",
"The file associated to a file layer with the name \"%1\" is not found.<nl/><nl/>"
"Expected path:<nl/>"
"%2<nl/><nl/>"
"The file associated to a file layer with the name \"%1\" is not found.\n\n"
"Expected path:\n>"
"%2\n\n"
"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);
......@@ -1122,8 +1122,24 @@ void KisKraLoader::loadAudio(const KoXmlElement& elem, KisImageSP image)
QFileInfo info(fileName);
if (!info.exists()) {
m_d->errorMessages << i18n("Audio channel file %1 doesn't exist!", fileName);
} else {
qApp->setOverrideCursor(Qt::ArrowCursor);
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());
}
}
......
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