New: restore last used CSV export data folder

This commit is contained in:
LoudSnorer 2024-08-07 19:44:34 -04:00
parent 2ad41e3c7b
commit 4043761486
3 changed files with 12 additions and 7 deletions

View File

@ -160,6 +160,7 @@ const QString STR_PREF_ReimportBackup = "ReimportBackup";
const QString STR_PREF_LastCPAPPath = "LastCPAPPath";
const QString STR_PREF_LastJournalPath = "LastJouralPath";
const QString STR_PREF_LastOximetryPath = "LastOximetryPath";
const QString STR_PREF_LastExportCsvPath = "LastExportCsvPath";
const QString STR_MACH_ResMed = "ResMed";
const QString STR_MACH_PRS1 = "PRS1";

View File

@ -7,7 +7,7 @@
* License. See the file COPYING in the main directory of the source code
* for more details. */
#define TEST_MACROS_ENABLED
#define TEST_MACROS_ENABLEDoff
#include <test_macros.h>
#include <QHostInfo>
@ -2274,20 +2274,21 @@ void MainWindow::on_actionChange_Data_Folder_triggered()
RestartApplication(false, "-d");
}
QString /*MainWindow::*/profilePath(QString folderProfileName ) {
QString MainWindow::profilePath(QString folderProfileName ) {
QString folderName;
if (p_profile->contains(folderProfileName)) {
folderName = (*p_profile)[STR_PREF_LastOximetryPath].toString();
folderName = (*p_profile)[folderProfileName].toString();
QFileInfo fi(folderName);
if (fi.exists() && fi.isDir()) return folderName;
if (fi.exists() && fi.isDir()) {
return folderName;
}
}
QStringList paths = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
if (paths.size()>1) folderName = paths[0];
return folderName;
}
void /*MainWindow::*/saveProfilePath(QString folderProfileName , QString pathName) {
DEBUGFC Q(pathName);
void MainWindow::saveProfilePath(QString folderProfileName , QString pathName) {
(*p_profile)[folderProfileName] = pathName;
}
@ -2299,7 +2300,6 @@ void MainWindow::importNonCPAP(MachineLoader &loader)
QFileDialog w;
if (folder.exists() ) {
DEBUGFC Q(folder);
w.setDirectory(folder);
}
w.setFileMode(QFileDialog::ExistingFiles);
@ -2667,6 +2667,7 @@ void MainWindow::on_actionImport_Journal_triggered()
void MainWindow::on_actionExport_Journal_triggered()
{
QString folder;
folder = profilePath(STR_PREF_LastJournalPath);
if (p_profile->contains(STR_PREF_LastJournalPath)) {
folder = (*p_profile)[STR_PREF_LastJournalPath].toString();
}

View File

@ -181,6 +181,9 @@ class MainWindow : public QMainWindow
void RestartApplication(bool force_login = false, QString cmdline = QString());
QString profilePath(QString folderProfileName );
void saveProfilePath(QString folderProfileName , QString pathName);
protected:
void closeEvent(QCloseEvent *) override;
void keyPressEvent(QKeyEvent *event) override;