From 1070ea664fc53717a4d8ece10ddd76efa2e744eb Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Sat, 15 Oct 2016 13:00:26 -0700 Subject: [PATCH] Remember last folder used to open a project. --- common/lc_application.cpp | 2 -- common/lc_basewindow.h | 1 - common/lc_mainwindow.cpp | 6 +++++ qt/lc_qpreferencesdialog.cpp | 10 -------- qt/lc_qpreferencesdialog.h | 1 - qt/lc_qpreferencesdialog.ui | 44 ++++++++---------------------------- 6 files changed, 15 insertions(+), 49 deletions(-) diff --git a/common/lc_application.cpp b/common/lc_application.cpp index bbcff188..dd676412 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -455,7 +455,6 @@ void lcApplication::ShowPreferencesDialog() Options.Preferences = mPreferences; Options.DefaultAuthor = lcGetProfileString(LC_PROFILE_DEFAULT_AUTHOR_NAME); - Options.ProjectsPath = lcGetProfileString(LC_PROFILE_PROJECTS_PATH); Options.LibraryPath = lcGetProfileString(LC_PROFILE_PARTS_LIBRARY); Options.POVRayPath = lcGetProfileString(LC_PROFILE_POVRAY_PATH); Options.LGEOPath = lcGetProfileString(LC_PROFILE_POVRAY_LGEO_PATH); @@ -485,7 +484,6 @@ void lcApplication::ShowPreferencesDialog() mPreferences.SaveDefaults(); lcSetProfileString(LC_PROFILE_DEFAULT_AUTHOR_NAME, Options.DefaultAuthor); - lcSetProfileString(LC_PROFILE_PROJECTS_PATH, Options.ProjectsPath); lcSetProfileString(LC_PROFILE_PARTS_LIBRARY, Options.LibraryPath); lcSetProfileString(LC_PROFILE_POVRAY_PATH, Options.POVRayPath); lcSetProfileString(LC_PROFILE_POVRAY_LGEO_PATH, Options.LGEOPath); diff --git a/common/lc_basewindow.h b/common/lc_basewindow.h index d2611024..76d7a4c3 100644 --- a/common/lc_basewindow.h +++ b/common/lc_basewindow.h @@ -49,7 +49,6 @@ struct lcPreferencesDialogOptions lcPreferences Preferences; QString DefaultAuthor; - QString ProjectsPath; QString LibraryPath; QString POVRayPath; QString LGEOPath; diff --git a/common/lc_mainwindow.cpp b/common/lc_mainwindow.cpp index 7679b1cc..414f8d8e 100644 --- a/common/lc_mainwindow.cpp +++ b/common/lc_mainwindow.cpp @@ -1847,6 +1847,8 @@ bool lcMainWindow::OpenProject(const QString& FileName) if (LoadFileName.isEmpty()) return false; + + lcSetProfileString(LC_PROFILE_PROJECTS_PATH, QFileInfo(LoadFileName).absolutePath()); } Project* NewProject = new Project(); @@ -1878,6 +1880,8 @@ void lcMainWindow::MergeProject() if (LoadFileName.isEmpty()) return; + lcSetProfileString(LC_PROFILE_PROJECTS_PATH, QFileInfo(LoadFileName).absolutePath()); + Project* NewProject = new Project(); if (NewProject->Load(LoadFileName)) @@ -1920,6 +1924,8 @@ bool lcMainWindow::SaveProject(const QString& FileName) if (SaveFileName.isEmpty()) return false; + + lcSetProfileString(LC_PROFILE_PROJECTS_PATH, QFileInfo(SaveFileName).absolutePath()); } if (QFileInfo(SaveFileName).suffix().toLower() == QLatin1String("lcd")) diff --git a/qt/lc_qpreferencesdialog.cpp b/qt/lc_qpreferencesdialog.cpp index 2c87730c..dfcae579 100644 --- a/qt/lc_qpreferencesdialog.cpp +++ b/qt/lc_qpreferencesdialog.cpp @@ -26,7 +26,6 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget *parent, void *data) : options = (lcPreferencesDialogOptions*)data; ui->authorName->setText(options->DefaultAuthor); - ui->projectsFolder->setText(options->ProjectsPath); ui->partsLibrary->setText(options->LibraryPath); ui->povrayExecutable->setText(options->POVRayPath); ui->lgeoPath->setText(options->LGEOPath); @@ -89,7 +88,6 @@ void lcQPreferencesDialog::accept() } options->DefaultAuthor = ui->authorName->text(); - options->ProjectsPath = ui->projectsFolder->text(); options->LibraryPath = ui->partsLibrary->text(); options->POVRayPath = ui->povrayExecutable->text(); options->LGEOPath = ui->lgeoPath->text(); @@ -119,14 +117,6 @@ void lcQPreferencesDialog::accept() QDialog::accept(); } -void lcQPreferencesDialog::on_projectsFolderBrowse_clicked() -{ - QString result = QFileDialog::getExistingDirectory(this, tr("Open Projects Folder"), ui->projectsFolder->text()); - - if (!result.isEmpty()) - ui->projectsFolder->setText(QDir::toNativeSeparators(result)); -} - void lcQPreferencesDialog::on_partsLibraryBrowse_clicked() { QString result = QFileDialog::getExistingDirectory(this, tr("Open Parts Library Folder"), ui->partsLibrary->text()); diff --git a/qt/lc_qpreferencesdialog.h b/qt/lc_qpreferencesdialog.h index 4a1114bb..1d001958 100644 --- a/qt/lc_qpreferencesdialog.h +++ b/qt/lc_qpreferencesdialog.h @@ -27,7 +27,6 @@ public: public slots: void accept(); - void on_projectsFolderBrowse_clicked(); void on_partsLibraryBrowse_clicked(); void on_povrayExecutableBrowse_clicked(); void on_lgeoPathBrowse_clicked(); diff --git a/qt/lc_qpreferencesdialog.ui b/qt/lc_qpreferencesdialog.ui index 9a5f89d0..6c63a93c 100644 --- a/qt/lc_qpreferencesdialog.ui +++ b/qt/lc_qpreferencesdialog.ui @@ -40,31 +40,7 @@ - - - - Default projects folder: - - - projectsFolder - - - - - - - - - - - - ... - - - - - - + Custom parts library: @@ -74,7 +50,7 @@ - + @@ -88,7 +64,7 @@ - + POV-Ray Executable: @@ -98,7 +74,7 @@ - + @@ -112,7 +88,7 @@ - + LGEO Path: @@ -122,7 +98,7 @@ - + @@ -136,7 +112,7 @@ - + Check for updates: @@ -146,7 +122,7 @@ - + @@ -165,7 +141,7 @@ - + Fixed direction keys @@ -855,8 +831,6 @@ tabWidget buttonBox authorName - projectsFolder - projectsFolderBrowse partsLibrary partsLibraryBrowse povrayExecutable