mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 16:32:16 -07:00
remember last directory when loading deck
This commit is contained in:
parent
38e99f2e87
commit
eea65a61d4
4 changed files with 31 additions and 2 deletions
|
|
@ -928,11 +928,19 @@ void TabDeckEditor::actLoadDeck()
|
||||||
}
|
}
|
||||||
|
|
||||||
QFileDialog dialog(this, tr("Load deck"));
|
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);
|
dialog.setNameFilters(DeckLoader::fileNameFilters);
|
||||||
if (!dialog.exec())
|
if (!dialog.exec())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
SettingsCache::instance().recents().setLatestDeckDirPath(dialog.directory().absolutePath());
|
||||||
|
|
||||||
QString fileName = dialog.selectedFiles().at(0);
|
QString fileName = dialog.selectedFiles().at(0);
|
||||||
openDeckFromFile(fileName, deckOpenLocation);
|
openDeckFromFile(fileName, deckOpenLocation);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -289,11 +289,19 @@ void TabGame::refreshShortcuts()
|
||||||
void DeckViewContainer::loadLocalDeck()
|
void DeckViewContainer::loadLocalDeck()
|
||||||
{
|
{
|
||||||
QFileDialog dialog(this, tr("Load deck"));
|
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);
|
dialog.setNameFilters(DeckLoader::fileNameFilters);
|
||||||
if (!dialog.exec())
|
if (!dialog.exec())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
SettingsCache::instance().recents().setLatestDeckDirPath(dialog.directory().absolutePath());
|
||||||
|
|
||||||
loadDeckFromFile(dialog.selectedFiles().at(0));
|
loadDeckFromFile(dialog.selectedFiles().at(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,4 +29,14 @@ void RecentsSettings::updateRecentlyOpenedDeckPaths(const QString &deckPath)
|
||||||
|
|
||||||
setValue(deckPaths, "deckpaths", "deckbuilder");
|
setValue(deckPaths, "deckpaths", "deckbuilder");
|
||||||
emit recentlyOpenedDeckPathsChanged();
|
emit recentlyOpenedDeckPathsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString RecentsSettings::getLatestDeckDirPath()
|
||||||
|
{
|
||||||
|
return getValue("latestDeckDir", "dirs").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RecentsSettings::setLatestDeckDirPath(const QString &dirPath)
|
||||||
|
{
|
||||||
|
setValue(dirPath, "latestDeckDir", "dirs");
|
||||||
}
|
}
|
||||||
|
|
@ -16,6 +16,9 @@ public:
|
||||||
void clearRecentlyOpenedDeckPaths();
|
void clearRecentlyOpenedDeckPaths();
|
||||||
void updateRecentlyOpenedDeckPaths(const QString &deckPath);
|
void updateRecentlyOpenedDeckPaths(const QString &deckPath);
|
||||||
|
|
||||||
|
QString getLatestDeckDirPath();
|
||||||
|
void setLatestDeckDirPath(const QString &dirPath);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void recentlyOpenedDeckPathsChanged();
|
void recentlyOpenedDeckPathsChanged();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue