Skip to content

Commit

Permalink
Remember the last visited folder
Browse files Browse the repository at this point in the history
  • Loading branch information
cantabile committed Jan 26, 2016
1 parent 7c42627 commit 034692a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
14 changes: 10 additions & 4 deletions src/wibbly/WibblyWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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] () {
Expand Down
36 changes: 27 additions & 9 deletions src/wobbly/WobblyWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}


Expand Down Expand Up @@ -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);
}
}


Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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());
}
Expand All @@ -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");
}
}


Expand Down

0 comments on commit 034692a

Please sign in to comment.