Skip to content

Commit

Permalink
Smarter strategy for selecting initial import/export/open/save direct…
Browse files Browse the repository at this point in the history
…ories for #360
  • Loading branch information
markummitchell-tu committed Nov 29, 2019
1 parent fc5bc2a commit a35cc8a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/main/MainDirectoryPersist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include "MainDirectoryPersist.h"
#include <QFileInfo>

// QDir::current() gives "working directory" consistent with setting in qtcreator
bool MainDirectoryPersist::m_setExportSave = false;
bool MainDirectoryPersist::m_setImportOpen = false;
QDir MainDirectoryPersist::m_directoryExportSave = QDir::current();
QDir MainDirectoryPersist::m_directoryImportOpen = QDir::current();

Expand All @@ -27,10 +28,28 @@ QDir MainDirectoryPersist::getDirectoryImportOpen() const

void MainDirectoryPersist::setDirectoryExportSaveFromFilename(const QString &fileName)
{
m_setExportSave = true;
m_directoryExportSave = QFileInfo(fileName).dir();

if (!m_setImportOpen) {

// Use the export directory for import since no better alternative is available
m_setImportOpen = true;
m_directoryImportOpen = m_directoryExportSave;

}
}

void MainDirectoryPersist::setDirectoryImportOpenFromFilename(const QString &fileName)
{
m_setImportOpen = true;
m_directoryImportOpen = QFileInfo(fileName).dir();

if (!m_setExportSave) {

// Use the import directory for export since no better alternative is available
m_setExportSave = true;
m_directoryExportSave = m_directoryImportOpen;

}
}
2 changes: 2 additions & 0 deletions src/main/MainDirectoryPersist.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class MainDirectoryPersist
private:

// The directories are static so all instances of this class share the same values
static bool m_setExportSave;
static bool m_setImportOpen;
static QDir m_directoryExportSave;
static QDir m_directoryImportOpen;

Expand Down

0 comments on commit a35cc8a

Please sign in to comment.