diff --git a/cockatrice/src/interface/deck_loader/deck_loader.cpp b/cockatrice/src/interface/deck_loader/deck_loader.cpp index 305cd34d9..3481e245b 100644 --- a/cockatrice/src/interface/deck_loader/deck_loader.cpp +++ b/cockatrice/src/interface/deck_loader/deck_loader.cpp @@ -91,6 +91,22 @@ void DeckLoader::loadFromFileAsync(const QString &fileName, DeckFileFormat::Form }); } +bool DeckLoader::reload() +{ + QString lastFileName = loadedDeck.lastLoadInfo.fileName; + if (lastFileName.isEmpty()) { + return false; + } + std::optional deck = loadFromFile(lastFileName, loadedDeck.lastLoadInfo.fileFormat, false); + + if (!deck) { + return false; + } + + loadedDeck = *deck; + return true; +} + std::optional DeckLoader::loadFromRemote(const QString &nativeString, int remoteDeckId) { DeckList deckList; diff --git a/cockatrice/src/interface/deck_loader/deck_loader.h b/cockatrice/src/interface/deck_loader/deck_loader.h index 1780e2706..2530b7f5d 100644 --- a/cockatrice/src/interface/deck_loader/deck_loader.h +++ b/cockatrice/src/interface/deck_loader/deck_loader.h @@ -62,6 +62,13 @@ public: */ void loadFromFileAsync(const QString &fileName, DeckFileFormat::Format fmt, bool userRequest); + /** + * @brief Loads the file that the lastLoadInfo currently points to into this instance. + * No-ops if the lastLoadInfo is missing the required info or the load fails. + * @return Whether the loaded succeeded. + */ + bool reload(); + /** * @brief Loads a deck from a local file. * @param fileName The file to load