Commit 5ea2b338 authored by Boudewijn Rempt's avatar Boudewijn Rempt Committed by Scott Petrovic

Refactor the filename requester and filedialog

The messing with relative paths to the default folder meant that
the user never could be sure which path we were going to save to.

Rendering to GIF still fails, though, but I need more brain to
figure out why.

CCBUG:372572,372537
parent 71036a95
......@@ -956,10 +956,10 @@ bool KisMainWindow::saveDocument(KisDocument *document, bool saveas)
KoFileDialog dialog(this, KoFileDialog::SaveFile, "SaveDocument");
dialog.setCaption(i18n("untitled"));
if (d->isExporting && !d->lastExportUrl.isEmpty()) {
dialog.setDefaultDir(d->lastExportUrl.toLocalFile(), true);
dialog.setDefaultDir(d->lastExportUrl.toLocalFile());
}
else {
dialog.setDefaultDir(suggestedURL.toLocalFile(), true);
dialog.setDefaultDir(suggestedURL.toLocalFile());
}
// Default to all supported file types if user is exporting, otherwise use Krita default
dialog.setMimeTypeFilters(mimeFilter, QString(_native_format));
......
......@@ -20,6 +20,7 @@
#include "ui_wdg_file_name_requester.h"
#include <QDesktopServices>
#include <QDebug>
#include "KoIcon.h"
......@@ -47,15 +48,8 @@ void KisFileNameRequester::setStartDir(const QString &path)
void KisFileNameRequester::setFileName(const QString &path)
{
QString realPath = path;
if (!m_basePath.isEmpty()) {
QDir d(m_basePath);
realPath = d.relativeFilePath(path);
}
m_ui->txtFileName->setText(realPath);
emit fileSelected(realPath);
m_ui->txtFileName->setText(path);
emit fileSelected(path);
}
QString KisFileNameRequester::fileName() const
......@@ -91,7 +85,12 @@ void KisFileNameRequester::slotSelectFile()
{
dialog.setCaption(i18n("Select a directory to load..."));
}
dialog.setDefaultDir(m_basePath.isEmpty() ? QDesktopServices::storageLocation(QDesktopServices::PicturesLocation) : m_basePath);
if (m_basePath.isEmpty()) {
dialog.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
}
else {
dialog.setDefaultDir(m_basePath);
}
Q_ASSERT(!m_mime_filter_list.isEmpty());
dialog.setMimeTypeFilters(m_mime_filter_list, m_mime_default_filter);
......
......@@ -83,12 +83,10 @@ void KoFileDialog::setCaption(const QString &caption)
d->caption = caption;
}
void KoFileDialog::setDefaultDir(const QString &defaultDir, bool override)
void KoFileDialog::setDefaultDir(const QString &defaultDir)
{
if (override || d->defaultDirectory.isEmpty() || !QFile(d->defaultDirectory).exists()) {
QFileInfo f(defaultDir);
d->defaultDirectory = f.absoluteFilePath();
}
QFileInfo f(defaultDir);
d->defaultDirectory = f.absoluteFilePath();
}
void KoFileDialog::setOverrideDir(const QString &overrideDir)
......
......@@ -70,7 +70,7 @@ public:
*
* @param defaultDir a path to a file or directory
*/
void setDefaultDir(const QString &defaultDir, bool override = false);
void setDefaultDir(const QString &defaultDir);
/**
* @brief setOverrideDir override both the default dir and the saved dir found by dialogName
......
......@@ -378,7 +378,9 @@ QString DlgAnimationRenderer::findFFMpeg()
proposedPaths << customPath;
proposedPaths << customPath + QDir::separator() + "ffmpeg";
proposedPaths << "ffmpeg";
proposedPaths << QDir::homePath() + "/bin/ffmpeg";
proposedPaths << "/usr/bin/ffmpeg";
proposedPaths << "/usr/local/bin/ffmpeg";
proposedPaths << KoResourcePaths::getApplicationRoot() +
QDir::separator() + "bin" + QDir::separator() + "ffmpeg";
......
......@@ -273,7 +273,7 @@ KisImageBuilder_Result VideoSaver::encode(const QString &filename, KisProperties
KisImageBuilder_Result result =
m_runner->runFFMpeg(args, i18n("Fetching palette..."),
framesDir.filePath("log_palettegen.log"),
framesDir.filePath("log_generate_palette_gif.log"),
clipRange.duration() + clipRange.start());
if (result) {
......@@ -292,7 +292,7 @@ KisImageBuilder_Result VideoSaver::encode(const QString &filename, KisProperties
KisImageBuilder_Result result =
m_runner->runFFMpeg(args, i18n("Encoding frames..."),
framesDir.filePath("log_paletteuse.log"),
framesDir.filePath("log_encode_gif.log"),
clipRange.duration() + clipRange.start());
if (result) {
......
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