cleanup + start remembering last folder in QFileDialog

parent 8bc5f2fc
......@@ -29,6 +29,7 @@
#include <KUrlRequesterDialog>
#include <KMessageBox>
#include <klocalizedstring.h>
#include <KRecentDirs>
#include <QDebug>
#include <QFontDatabase>
......@@ -454,7 +455,8 @@ void DocumentChecker::setProperty(QDomElement effect, const QString &name, const
void DocumentChecker::slotSearchClips()
{
QString newpath = QFileDialog::getExistingDirectory(qApp->activeWindow(), i18n("Clips folder"), "kfiledialog:///clipfolder");
QString clipFolder = KRecentDirs::dir(":KdenliveClipFolder");
QString newpath = QFileDialog::getExistingDirectory(qApp->activeWindow(), i18n("Clips folder"), clipFolder);
if (newpath.isEmpty()) return;
int ix = 0;
bool fixed = false;
......
......@@ -36,13 +36,14 @@
#include "project/dialogs/noteswidget.h"
#include <KMessageBox>
#include <QProgressDialog>
#include <KRecentDirs>
#include <klocalizedstring.h>
#include <KIO/CopyJob>
#include <KIO/JobUiDelegate>
#include <KBookmarkManager>
#include <KBookmark>
#include <QProgressDialog>
#include <QCryptographicHash>
#include <QFile>
#include <QDebug>
......@@ -812,12 +813,9 @@ bool KdenliveDoc::saveSceneList(const QString &path, const QString &scene, const
fileName.append('-' + m_documentProperties.value("documentid"));
fileName.append(info.lastModified().toString("-yyyy-MM-dd-hh-mm"));
fileName.append(".kdenlive.png");
QUrl backupFile = m_projectFolder;
backupFile = backupFile.adjusted(QUrl::StripTrailingSlash);
backupFile.setPath(backupFile.path() + '/' + ".backup/");
backupFile = backupFile.adjusted(QUrl::StripTrailingSlash);
backupFile.setPath(backupFile.path() + '/' + fileName);
emit saveTimelinePreview(backupFile.path());
QDir backupFolder(m_projectFolder.toLocalFile());
backupFolder.cd(".backup");
emit saveTimelinePreview(backupFolder.absoluteFilePath(fileName));
}
return true;
}
......@@ -1085,6 +1083,7 @@ bool KdenliveDoc::addClip(QDomElement elem, const QString &clipId, bool createCl
DocClipBase *clip = m_clipManager->getClipById(producerId);
if (clip == NULL) {
QString clipFolder = KRecentDirs::dir(":KdenliveClipFolder");
elem.setAttribute("id", producerId);
QString path = elem.attribute("resource");
QString extension;
......@@ -1111,7 +1110,7 @@ bool KdenliveDoc::addClip(QDomElement elem, const QString &clipId, bool createCl
if (elem.attribute("type").toInt() == SlideShow) {
int res = KMessageBox::questionYesNoCancel(QApplication::activeWindow(), i18n("Clip <b>%1</b><br />is invalid or missing, what do you want to do?", path), i18n("File not found"), KGuiItem(i18n("Search manually")), KGuiItem(i18n("Keep as placeholder")));
if (res == KMessageBox::Yes)
newpath = QFileDialog::getExistingDirectory(QApplication::activeWindow(), i18n("Looking for %1", path), "kfiledialog:///clipfolder");
newpath = QFileDialog::getExistingDirectory(QApplication::activeWindow(), i18n("Looking for %1", path), clipFolder);
else {
// Abort project loading
action = res;
......@@ -1119,7 +1118,7 @@ bool KdenliveDoc::addClip(QDomElement elem, const QString &clipId, bool createCl
} else {
int res = KMessageBox::questionYesNoCancel(QApplication::activeWindow(), i18n("Clip <b>%1</b><br />is invalid or missing, what do you want to do?", path), i18n("File not found"), KGuiItem(i18n("Search manually")), KGuiItem(i18n("Keep as placeholder")));
if (res == KMessageBox::Yes)
newpath = QFileDialog::getOpenFileName(QApplication::activeWindow(), i18n("Looking for %1", path), "kfiledialog:///clipfolder");
newpath = QFileDialog::getOpenFileName(QApplication::activeWindow(), i18n("Looking for %1", path), clipFolder);
else {
// Abort project loading
action = res;
......@@ -1128,7 +1127,7 @@ bool KdenliveDoc::addClip(QDomElement elem, const QString &clipId, bool createCl
}
if (action == KMessageBox::Yes) {
//qDebug() << "// ASKED FOR SRCH CLIP: " << clipId;
m_searchFolder = QFileDialog::getExistingDirectory(QApplication::activeWindow(), QString(), "kfiledialog:///clipfolder");
m_searchFolder = QFileDialog::getExistingDirectory(QApplication::activeWindow(), QString(), clipFolder);
if (!m_searchFolder.isEmpty())
newpath = searchFileRecursively(QDir(m_searchFolder), size, hash);
} else if (action == KMessageBox::Cancel) {
......@@ -1323,7 +1322,13 @@ void KdenliveDoc::slotCreateTextTemplateClip(const QString &group, const QString
{
QString titlesFolder = QDir::cleanPath(projectFolder().path() + QDir::separator() + "titles/");
if (path.isEmpty()) {
path = QFileDialog::getOpenFileUrl(QApplication::activeWindow(), i18n("Enter Template Path"), QUrl("kfiledialog:///clipfolder"), "application/x-kdenlivetitle");
QPointer<QFileDialog> d = new QFileDialog(QApplication::activeWindow(), i18n("Enter Template Path"), titlesFolder);
d->setMimeTypeFilters(QStringList() << "application/x-kdenlivetitle");
d->setFileMode(QFileDialog::ExistingFile);
if (d->exec() == QDialog::Accepted && !d->selectedUrls().isEmpty()) {
path = d->selectedUrls().first();
}
delete d;
}
if (path.isEmpty()) return;
......@@ -1752,10 +1757,8 @@ void KdenliveDoc::backupLastSavedVersion(const QString &path)
void KdenliveDoc::cleanupBackupFiles()
{
QUrl backupFile = m_projectFolder;
backupFile = backupFile.adjusted(QUrl::StripTrailingSlash);
backupFile.setPath(backupFile.path() + '/' + ".backup/");
QDir dir(backupFile.path());
QDir backupFolder(m_projectFolder.toLocalFile());
backupFolder.cd(".backup");
QString projectFile = url().fileName().section('.', 0, -2);
projectFile.append('-' + m_documentProperties.value("documentid"));
projectFile.append("-??");
......@@ -1766,11 +1769,9 @@ void KdenliveDoc::cleanupBackupFiles()
projectFile.append("-??.kdenlive");
QStringList filter;
backupFile = backupFile.adjusted(QUrl::StripTrailingSlash);
backupFile.setPath(backupFile.path() + '/' + projectFile);
filter << projectFile;
dir.setNameFilters(filter);
QFileInfoList resultList = dir.entryInfoList(QDir::Files, QDir::Time);
backupFolder.setNameFilters(filter);
QFileInfoList resultList = backupFolder.entryInfoList(QDir::Files, QDir::Time);
QDateTime d = QDateTime::currentDateTime();
QStringList hourList;
......
......@@ -907,7 +907,7 @@ void DvdWizard::slotAbort()
void DvdWizard::slotSave()
{
QUrl url = QFileDialog::getSaveFileUrl(this, i18n("Save DVD Project"), QUrl("kfiledialog:///projectfolder"), "*.kdvd");
QUrl url = QFileDialog::getSaveFileUrl(this, i18n("Save DVD Project"), QUrl::fromLocalFile(QDir::homePath()), i18n("DVD project (*.kdvd)"));
if (!url.isValid())
return;
......@@ -944,7 +944,7 @@ void DvdWizard::slotSave()
void DvdWizard::slotLoad()
{
const QUrl url = QFileDialog::getOpenFileUrl(this, QString(), QUrl("kfiledialog:///projectfolder"), i18n("DVD project (*.kdvd)"));
const QUrl url = QFileDialog::getOpenFileUrl(this, QString(), QUrl::fromLocalFile(QDir::homePath()), i18n("DVD project (*.kdvd)"));
if (!url.isValid())
return;
QDomDocument doc;
......
......@@ -166,7 +166,7 @@ void DvdWizardVob::slotCheckProfiles()
void DvdWizardVob::slotAddVobList(const QList<QUrl> &list)
{
foreach (const QUrl &url, list) {
slotAddVobFile(QUrl(url), QString(), false);
slotAddVobFile(url, QString(), false);
}
slotCheckVobList();
slotCheckProfiles();
......@@ -174,7 +174,7 @@ void DvdWizardVob::slotAddVobList(const QList<QUrl> &list)
void DvdWizardVob::slotAddVobFile(QUrl url, const QString &chapters, bool checkFormats)
{
if (!url.isValid()) url = QFileDialog::getOpenFileUrl(this, i18n("Add new video file"), QUrl("kfiledialog:///projectfolder"), i18n("MPEG clip (*.mpeg *.mpg *.vob)"));
if (!url.isValid()) url = QFileDialog::getOpenFileUrl(this, i18n("Add new video file"), QUrl::fromLocalFile(QDir::homePath()), i18n("MPEG clip (*.mpeg *.mpg *.vob)"));
if (!url.isValid()) return;
QFile f(url.path());
qint64 fileSize = f.size();
......
......@@ -34,11 +34,12 @@
#include <QFontDatabase>
#include <QFileDialog>
#include <QDebug>
#include <QStandardPaths>
#include <KRecentDirs>
#include <KComboBox>
#include <klocalizedstring.h>
#include <KMessageBox>
#include <QStandardPaths>
CollapsibleEffect::CollapsibleEffect(const QDomElement &effect, const QDomElement &original_effect, const ItemInfo &info, EffectMetaInfo *metaInfo, bool lastEffect, QWidget * parent) :
......@@ -158,9 +159,12 @@ void CollapsibleEffect::slotCreateRegion()
{
QString allExtensions = ProjectList::getExtensions().join(" ");
const QString dialogFilter = allExtensions + ' ' + QLatin1Char('|') + i18n("All Supported Files") + "\n* " + QLatin1Char('|') + i18n("All Files");
QPointer<QFileDialog> d = new QFileDialog(QApplication::activeWindow(), QString(), "kfiledialog:///clipfolder", dialogFilter);
QString clipFolder = KRecentDirs::dir(":KdenliveClipFolder");
if (clipFolder.isEmpty()) clipFolder = QDir::homePath();
QPointer<QFileDialog> d = new QFileDialog(QApplication::activeWindow(), QString(), clipFolder, dialogFilter);
d->setFileMode(QFileDialog::ExistingFile);
if (d->exec() == QDialog::Accepted && !d->selectedUrls().isEmpty()) {
KRecentDirs::add(":KdenliveClipFolder", d->selectedUrls().first().adjusted(QUrl::RemoveFilename).path());
emit createRegion(effectIndex(), d->selectedUrls().first());
}
delete d;
......
......@@ -60,21 +60,17 @@
#include "jogshuttle/jogmanager.h"
#endif
#include <QAction>
#include <KActionCollection>
#include <KActionCategory>
#include <KActionMenu>
#include <KStandardAction>
#include <KShortcutsDialog>
#include <KMessageBox>
#include <QDebug>
#include <KConfigDialog>
#include <KXMLGUIFactory>
#include <KColorSchemeManager>
#include <QStatusBar>
#include <KRecentDirs>
#include <KUrlRequesterDialog>
#include <QTemporaryFile>
#include <QMenu>
#include <ktogglefullscreenaction.h>
#include <KNotifyConfigWidget>
#include <kns3/downloaddialog.h>
......@@ -84,6 +80,10 @@
#include <klocalizedstring.h>
#include <QAction>
#include <QDebug>
#include <QStatusBar>
#include <QTemporaryFile>
#include <QMenu>
#include <QDesktopWidget>
#include <QBitmap>
#include <QUndoGroup>
......@@ -2686,7 +2686,8 @@ void MainWindow::slotTranscodeClip()
{
QString allExtensions = m_projectList->getExtensions().join(" ");
const QString dialogFilter = i18n("All Supported Files") + "(" + allExtensions + ");;" + i18n("All Files") + "(*)";
QStringList urls = QFileDialog::getOpenFileNames(this, i18n("Files to transcode"), "kfiledialog:///projectfolder", dialogFilter);
QString clipFolder = KRecentDirs::dir(":KdenliveClipFolder");
QStringList urls = QFileDialog::getOpenFileNames(this, i18n("Files to transcode"), clipFolder, dialogFilter);
if (urls.isEmpty()) return;
slotTranscode(urls);
}
......
......@@ -29,9 +29,10 @@
#include "timeline/abstractclipitem.h"
#include "twostateaction.h"
#include <QDebug>
#include "klocalizedstring.h"
#include <KRecentDirs>
#include <QDebug>
#include <QMouseEvent>
#include <QMenu>
#include <QToolButton>
......@@ -605,12 +606,16 @@ void Monitor::slotExtractCurrentFrame()
frame = render->extractFrame(render->seekFramePosition(), m_currentClip->fileURL().path());
}
else frame = render->extractFrame(render->seekFramePosition());
QPointer<QFileDialog> fs = new QFileDialog(this, i18n("Save Image"), "");
QString framesFolder = KRecentDirs::dir(":KdenliveFramesFolder");
if (framesFolder.isEmpty()) framesFolder = QDir::homePath();
QPointer<QFileDialog> fs = new QFileDialog(this, i18n("Save Image"), framesFolder);
fs->setMimeTypeFilters(QStringList() << "image/png");
fs->setAcceptMode(QFileDialog::AcceptSave);
if (fs->exec()) {
QStringList path = fs->selectedFiles();
if (!path.isEmpty()) {
KRecentDirs::add(":KdenliveFramesFolder", fs->selectedUrls().first().adjusted(QUrl::RemoveFilename).path());
frame.save(path.first());
}
}
......
......@@ -45,18 +45,20 @@
#include "ui_cutjobdialog_ui.h"
#include "ui_scenecutdialog_ui.h"
#include <QDebug>
#include <klocalizedstring.h>
#include <KMessageBox>
#include <KFileItem>
#include <QDialog>
#include <KRecentDirs>
#include <KColorScheme>
#include <KActionCollection>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <KPassivePopup>
#include <KConfigGroup>
#include <QDebug>
#include <QDialog>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QAction>
#include <QPixmap>
#include <QMenu>
......@@ -65,7 +67,6 @@
#include <QVBoxLayout>
#include <QtConcurrent>
#include <QFileDialog>
#include <KConfigGroup>
#include <QDialogButtonBox>
#include <QPushButton>
......@@ -1655,8 +1656,8 @@ void ProjectList::slotAddClip(const QList <QUrl> &givenList, const QString &grou
l->addWidget(c);
l->addStretch(5);
f->setLayout(l);
QString clipFolder = m_doc->getDocumentProperty("QFileDialogClipFolder");
if (clipFolder.isEmpty()) clipFolder = QDir::homePath();
QString clipFolder = KRecentDirs::dir(":KdenliveClipFolder");
if (clipFolder.isEmpty()) clipFolder = QDir::homePath();
QPointer<QFileDialog> d = new QFileDialog(QApplication::activeWindow(), i18n("Open Clips"), clipFolder, dialogFilter);
//TODO: KF5, how to add a custom widget to file dialog
/*QGridLayout *layout = (QGridLayout*)d->layout();
......@@ -1665,7 +1666,9 @@ void ProjectList::slotAddClip(const QList <QUrl> &givenList, const QString &grou
if (d->exec() == QDialog::Accepted) {
KdenliveSettings::setAutoimagetransparency(c->isChecked());
list = d->selectedUrls();
if (!list.isEmpty()) m_doc->setDocumentProperty("QFileDialogClipFolder", list.first().adjusted(QUrl::RemoveFilename).path());
if (!list.isEmpty()) {
KRecentDirs::add(":KdenliveClipFolder", list.first().adjusted(QUrl::RemoveFilename).path());
}
if (b->isChecked() && list.count() == 1) {
// Check for image sequence
QUrl url = list.at(0);
......
......@@ -5427,8 +5427,8 @@ void CustomTrackView::slotSaveClipMarkers(const QString &id)
cbox->setItemData(i + 1, CommentedTime::markerColor(i), Qt::DecorationRole);
}
cbox->setCurrentIndex(0);
//TODO KF5 how to ass custom cbox to Qfiledialog
QPointer<QFileDialog> fd = new QFileDialog(this, i18n("Save Clip Markers"), "");
//TODO KF5 how to add custom cbox to Qfiledialog
QPointer<QFileDialog> fd = new QFileDialog(this, i18n("Save Clip Markers"), m_document->projectFolder().path());
fd->setMimeTypeFilters(QStringList() << "text/plain");
fd->setFileMode(QFileDialog::AnyFile);
fd->setAcceptMode(QFileDialog::AcceptSave);
......@@ -5475,7 +5475,8 @@ void CustomTrackView::slotLoadClipMarkers(const QString &id)
}
cbox->setCurrentIndex(KdenliveSettings::default_marker_type());
//TODO KF5 how to ass custom cbox to Qfiledialog
QPointer<QFileDialog> fd = new QFileDialog(this, i18n("Load Clip Markers"), "kfiledialog:///projectfolder", "text/plain");
QPointer<QFileDialog> fd = new QFileDialog(this, i18n("Load Clip Markers"), m_document->projectFolder().path());
fd->setMimeTypeFilters(QStringList()<<"text/plain");
fd->setFileMode(QFileDialog::ExistingFile);
if (fd->exec() != QDialog::Accepted) return;
QStringList selection = fd->selectedFiles();
......
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