From 034692ab74ab4ec324912b4c88b9d7032c2b6643 Mon Sep 17 00:00:00 2001 From: cantabile Date: Tue, 26 Jan 2016 18:25:02 +0200 Subject: [PATCH] Remember the last visited folder --- src/wibbly/WibblyWindow.cpp | 14 ++++++++++---- src/wobbly/WobblyWindow.cpp | 36 +++++++++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/wibbly/WibblyWindow.cpp b/src/wibbly/WibblyWindow.cpp index eb543ca..e5cebe8 100644 --- a/src/wibbly/WibblyWindow.cpp +++ b/src/wibbly/WibblyWindow.cpp @@ -490,9 +490,11 @@ void WibblyWindow::createMainWindow() { connect(main_destination_edit, &QLineEdit::editingFinished, destinationChanged); connect(main_choose_button, &QPushButton::clicked, [this, destinationChanged] () { - QString path = QFileDialog::getSaveFileName(this, QStringLiteral("Choose destination"), QString(), QStringLiteral("Wobbly projects (*.json);;All files (*)"), nullptr, QFileDialog::DontUseNativeDialog); + QString path = QFileDialog::getSaveFileName(this, QStringLiteral("Choose destination"), settings.value("user_interface/last_dir").toString(), QStringLiteral("Wobbly projects (*.json);;All files (*)"), nullptr, QFileDialog::DontUseNativeDialog); if (!path.isEmpty()) { + settings.setValue("user_interface/last_dir", QFileInfo(path).absolutePath()); + main_destination_edit->setText(path); destinationChanged(); } @@ -515,13 +517,17 @@ void WibblyWindow::createMainWindow() { }); connect(main_add_jobs_button, &QPushButton::clicked, [this] () { - QStringList paths = QFileDialog::getOpenFileNames(this, QStringLiteral("Open video file"), QString(), QString(), nullptr, QFileDialog::DontUseNativeDialog); + QStringList paths = QFileDialog::getOpenFileNames(this, QStringLiteral("Open video file"), settings.value("user_interface/last_dir").toString(), QString(), nullptr, QFileDialog::DontUseNativeDialog); paths.sort(); - for (int i = 0; i < paths.size(); i++) - if (!paths[i].isNull()) + for (int i = 0; i < paths.size(); i++) { + if (!paths[i].isNull()) { + settings.setValue("user_interface/last_dir", QFileInfo(paths[i]).absolutePath()); + realOpenVideo(paths[i]); + } + } }); connect(main_remove_jobs_button, &QPushButton::clicked, [this] () { diff --git a/src/wobbly/WobblyWindow.cpp b/src/wobbly/WobblyWindow.cpp index 701b87f..45339d8 100644 --- a/src/wobbly/WobblyWindow.cpp +++ b/src/wobbly/WobblyWindow.cpp @@ -3087,10 +3087,13 @@ void WobblyWindow::realOpenProject(const QString &path) { void WobblyWindow::openProject() { - QString path = QFileDialog::getOpenFileName(this, QStringLiteral("Open Wobbly project"), QString(), QStringLiteral("Wobbly projects (*.json);;All files (*)"), nullptr, QFileDialog::DontUseNativeDialog); + QString path = QFileDialog::getOpenFileName(this, QStringLiteral("Open Wobbly project"), settings.value("user_interface/last_dir").toString(), QStringLiteral("Wobbly projects (*.json);;All files (*)"), nullptr, QFileDialog::DontUseNativeDialog); + + if (!path.isNull()) { + settings.setValue("user_interface/last_dir", QFileInfo(path).absolutePath()); - if (!path.isNull()) realOpenProject(path); + } } @@ -3160,10 +3163,13 @@ void WobblyWindow::realOpenVideo(const QString &path) { void WobblyWindow::openVideo() { - QString path = QFileDialog::getOpenFileName(this, QStringLiteral("Open video file"), QString(), QString(), nullptr, QFileDialog::DontUseNativeDialog); + QString path = QFileDialog::getOpenFileName(this, QStringLiteral("Open video file"), settings.value("user_interface/last_dir").toString(), QString(), nullptr, QFileDialog::DontUseNativeDialog); + + if (!path.isNull()) { + settings.setValue("user_interface/last_dir", QFileInfo(path).absolutePath()); - if (!path.isNull()) realOpenVideo(path); + } } @@ -3212,10 +3218,13 @@ void WobblyWindow::saveProjectAs() { if (!project) throw WobblyException("Can't save the project because none has been loaded."); - QString path = QFileDialog::getSaveFileName(this, QStringLiteral("Save Wobbly project"), QString(), QStringLiteral("Wobbly projects (*.json);;All files (*)"), nullptr, QFileDialog::DontUseNativeDialog); + QString path = QFileDialog::getSaveFileName(this, QStringLiteral("Save Wobbly project"), settings.value("user_interface/last_dir").toString(), QStringLiteral("Wobbly projects (*.json);;All files (*)"), nullptr, QFileDialog::DontUseNativeDialog); + + if (!path.isNull()) { + settings.setValue("user_interface/last_dir", QFileInfo(path).absolutePath()); - if (!path.isNull()) realSaveProject(path); + } } catch (WobblyException &e) { errorPopup(e.what()); } @@ -3270,8 +3279,11 @@ void WobblyWindow::saveScriptAs() { QString path = QFileDialog::getSaveFileName(this, QStringLiteral("Save script"), dir, QStringLiteral("VapourSynth scripts (*.py *.vpy);;All files (*)"), nullptr, QFileDialog::DontUseNativeDialog); - if (!path.isNull()) + if (!path.isNull()) { + settings.setValue("user_interface/last_dir", QFileInfo(path).absolutePath()); + realSaveScript(path); + } } catch (WobblyException &e) { errorPopup(e.what()); } @@ -3323,8 +3335,11 @@ void WobblyWindow::saveTimecodesAs() { QString path = QFileDialog::getSaveFileName(this, QStringLiteral("Save timecodes"), dir, QStringLiteral("Timecodes v1 files (*.txt);;All files (*)"), nullptr, QFileDialog::DontUseNativeDialog); - if (!path.isNull()) + if (!path.isNull()) { + settings.setValue("user_interface/last_dir", QFileInfo(path).absolutePath()); + realSaveTimecodes(path); + } } catch (WobblyException &e) { errorPopup(e.what()); } @@ -3343,8 +3358,11 @@ void WobblyWindow::saveScreenshot() { path = QFileDialog::getSaveFileName(this, QStringLiteral("Save screenshot"), path, QStringLiteral("PNG images (*.png);;All files (*)"), nullptr, QFileDialog::DontUseNativeDialog); - if (!path.isNull()) + if (!path.isNull()) { + settings.setValue("user_interface/last_dir", QFileInfo(path).absolutePath()); + frame_label->pixmap()->save(path, "png"); + } }