mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 00:42:14 -07:00
move shared code into new dlg class
This commit is contained in:
parent
eea65a61d4
commit
902bafac55
5 changed files with 48 additions and 22 deletions
|
|
@ -56,6 +56,7 @@ set(cockatrice_SOURCES
|
||||||
src/dialogs/dlg_tip_of_the_day.cpp
|
src/dialogs/dlg_tip_of_the_day.cpp
|
||||||
src/dialogs/dlg_update.cpp
|
src/dialogs/dlg_update.cpp
|
||||||
src/dialogs/dlg_view_log.cpp
|
src/dialogs/dlg_view_log.cpp
|
||||||
|
src/dialogs/dlg_load_deck.cpp
|
||||||
src/game/filters/filter_string.cpp
|
src/game/filters/filter_string.cpp
|
||||||
src/game/filters/filter_builder.cpp
|
src/game/filters/filter_builder.cpp
|
||||||
src/game/filters/filter_tree.cpp
|
src/game/filters/filter_tree.cpp
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
#include "../../client/ui/widgets/cards/card_info_frame_widget.h"
|
#include "../../client/ui/widgets/cards/card_info_frame_widget.h"
|
||||||
#include "../../deck/deck_list_model.h"
|
#include "../../deck/deck_list_model.h"
|
||||||
#include "../../deck/deck_stats_interface.h"
|
#include "../../deck/deck_stats_interface.h"
|
||||||
|
#include "../../dialogs/dlg_load_deck.h"
|
||||||
#include "../../dialogs/dlg_load_deck_from_clipboard.h"
|
#include "../../dialogs/dlg_load_deck_from_clipboard.h"
|
||||||
#include "../../game/cards/card_database_manager.h"
|
#include "../../game/cards/card_database_manager.h"
|
||||||
#include "../../game/cards/card_database_model.h"
|
#include "../../game/cards/card_database_model.h"
|
||||||
|
|
@ -927,20 +928,10 @@ void TabDeckEditor::actLoadDeck()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFileDialog dialog(this, tr("Load deck"));
|
DlgLoadDeck dialog(this);
|
||||||
|
|
||||||
QString startingDir = SettingsCache::instance().recents().getLatestDeckDirPath();
|
|
||||||
if (startingDir.isEmpty()) {
|
|
||||||
startingDir = SettingsCache::instance().getDeckPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog.setDirectory(startingDir);
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "../../deck/deck_loader.h"
|
#include "../../deck/deck_loader.h"
|
||||||
#include "../../deck/deck_view.h"
|
#include "../../deck/deck_view.h"
|
||||||
#include "../../dialogs/dlg_create_game.h"
|
#include "../../dialogs/dlg_create_game.h"
|
||||||
|
#include "../../dialogs/dlg_load_deck.h"
|
||||||
#include "../../dialogs/dlg_load_remote_deck.h"
|
#include "../../dialogs/dlg_load_remote_deck.h"
|
||||||
#include "../../dialogs/dlg_manage_sets.h"
|
#include "../../dialogs/dlg_manage_sets.h"
|
||||||
#include "../../game/board/arrow_item.h"
|
#include "../../game/board/arrow_item.h"
|
||||||
|
|
@ -288,20 +289,10 @@ void TabGame::refreshShortcuts()
|
||||||
|
|
||||||
void DeckViewContainer::loadLocalDeck()
|
void DeckViewContainer::loadLocalDeck()
|
||||||
{
|
{
|
||||||
QFileDialog dialog(this, tr("Load deck"));
|
DlgLoadDeck dialog(this);
|
||||||
|
|
||||||
QString startingDir = SettingsCache::instance().recents().getLatestDeckDirPath();
|
|
||||||
if (startingDir.isEmpty()) {
|
|
||||||
startingDir = SettingsCache::instance().getDeckPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog.setDirectory(startingDir);
|
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
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