diff --git a/cockatrice/src/client/tabs/tab_deck_editor.cpp b/cockatrice/src/client/tabs/tab_deck_editor.cpp index a10dc91f3..90f658f69 100644 --- a/cockatrice/src/client/tabs/tab_deck_editor.cpp +++ b/cockatrice/src/client/tabs/tab_deck_editor.cpp @@ -928,11 +928,19 @@ void TabDeckEditor::actLoadDeck() } QFileDialog dialog(this, tr("Load deck")); - dialog.setDirectory(SettingsCache::instance().getDeckPath()); + + QString startingDir = SettingsCache::instance().recents().getLatestDeckDirPath(); + if (startingDir.isEmpty()) { + startingDir = SettingsCache::instance().getDeckPath(); + } + + dialog.setDirectory(startingDir); dialog.setNameFilters(DeckLoader::fileNameFilters); if (!dialog.exec()) return; + SettingsCache::instance().recents().setLatestDeckDirPath(dialog.directory().absolutePath()); + QString fileName = dialog.selectedFiles().at(0); openDeckFromFile(fileName, deckOpenLocation); } diff --git a/cockatrice/src/client/tabs/tab_game.cpp b/cockatrice/src/client/tabs/tab_game.cpp index 7eead5aa0..67a3937e2 100644 --- a/cockatrice/src/client/tabs/tab_game.cpp +++ b/cockatrice/src/client/tabs/tab_game.cpp @@ -289,11 +289,19 @@ void TabGame::refreshShortcuts() void DeckViewContainer::loadLocalDeck() { QFileDialog dialog(this, tr("Load deck")); - dialog.setDirectory(SettingsCache::instance().getDeckPath()); + + QString startingDir = SettingsCache::instance().recents().getLatestDeckDirPath(); + if (startingDir.isEmpty()) { + startingDir = SettingsCache::instance().getDeckPath(); + } + + dialog.setDirectory(startingDir); dialog.setNameFilters(DeckLoader::fileNameFilters); if (!dialog.exec()) return; + SettingsCache::instance().recents().setLatestDeckDirPath(dialog.directory().absolutePath()); + loadDeckFromFile(dialog.selectedFiles().at(0)); } diff --git a/cockatrice/src/settings/recents_settings.cpp b/cockatrice/src/settings/recents_settings.cpp index da3c5313e..5bbec3c8c 100644 --- a/cockatrice/src/settings/recents_settings.cpp +++ b/cockatrice/src/settings/recents_settings.cpp @@ -29,4 +29,14 @@ void RecentsSettings::updateRecentlyOpenedDeckPaths(const QString &deckPath) setValue(deckPaths, "deckpaths", "deckbuilder"); emit recentlyOpenedDeckPathsChanged(); +} + +QString RecentsSettings::getLatestDeckDirPath() +{ + return getValue("latestDeckDir", "dirs").toString(); +} + +void RecentsSettings::setLatestDeckDirPath(const QString &dirPath) +{ + setValue(dirPath, "latestDeckDir", "dirs"); } \ No newline at end of file diff --git a/cockatrice/src/settings/recents_settings.h b/cockatrice/src/settings/recents_settings.h index c240b100d..6e91cd2f0 100644 --- a/cockatrice/src/settings/recents_settings.h +++ b/cockatrice/src/settings/recents_settings.h @@ -16,6 +16,9 @@ public: void clearRecentlyOpenedDeckPaths(); void updateRecentlyOpenedDeckPaths(const QString &deckPath); + QString getLatestDeckDirPath(); + void setLatestDeckDirPath(const QString &dirPath); + signals: void recentlyOpenedDeckPathsChanged(); };