mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-14 19:18:55 -07:00
Remember last opened directory when loading decks (#5418)
* remember last directory when loading deck * move shared code into new dlg class
This commit is contained in:
parent
9c38c9ed1b
commit
93fab3d78f
7 changed files with 61 additions and 6 deletions
22
cockatrice/src/dialogs/dlg_load_deck.cpp
Normal file
22
cockatrice/src/dialogs/dlg_load_deck.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include "dlg_load_deck.h"
|
||||
|
||||
#include "../deck/deck_loader.h"
|
||||
#include "../settings/cache_settings.h"
|
||||
|
||||
DlgLoadDeck::DlgLoadDeck(QWidget *parent) : QFileDialog(parent, tr("Load Deck"))
|
||||
{
|
||||
QString startingDir = SettingsCache::instance().recents().getLatestDeckDirPath();
|
||||
if (startingDir.isEmpty()) {
|
||||
startingDir = SettingsCache::instance().getDeckPath();
|
||||
}
|
||||
|
||||
setDirectory(startingDir);
|
||||
setNameFilters(DeckLoader::fileNameFilters);
|
||||
|
||||
connect(this, &DlgLoadDeck::accepted, this, &DlgLoadDeck::actAccepted);
|
||||
}
|
||||
|
||||
void DlgLoadDeck::actAccepted()
|
||||
{
|
||||
SettingsCache::instance().recents().setLatestDeckDirPath(directory().absolutePath());
|
||||
}
|
||||
21
cockatrice/src/dialogs/dlg_load_deck.h
Normal file
21
cockatrice/src/dialogs/dlg_load_deck.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
#ifndef DLG_LOAD_DECK_H
|
||||
#define DLG_LOAD_DECK_H
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
/**
|
||||
* The file dialog for "Load Deck" operations.
|
||||
* Handles remembering the most recently used deck loading directory.
|
||||
*/
|
||||
class DlgLoadDeck : public QFileDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
void actAccepted();
|
||||
|
||||
public:
|
||||
explicit DlgLoadDeck(QWidget *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // DLG_LOAD_DECK_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue