diff --git a/cockatrice/src/client/tabs/abstract_tab_deck_editor.cpp b/cockatrice/src/client/tabs/abstract_tab_deck_editor.cpp index 4dcc57ea6..085638934 100644 --- a/cockatrice/src/client/tabs/abstract_tab_deck_editor.cpp +++ b/cockatrice/src/client/tabs/abstract_tab_deck_editor.cpp @@ -128,6 +128,19 @@ void AbstractTabDeckEditor::actSwapCard(CardInfoPtr info, QString zoneName) deckDockWidget->deckModel->findCard(info->getName(), zoneName, providerId, collectorNumber)); } +/** + * Opens the deck in this tab. + * @param deck The deck. Takes ownership of the object + */ +void AbstractTabDeckEditor::openDeck(DeckLoader *deck) +{ + setDeck(deck); + + if (!deck->getLastFileName().isEmpty()) { + SettingsCache::instance().recents().updateRecentlyOpenedDeckPaths(deck->getLastFileName()); + } +} + /** * Sets the currently active deck for this tab * @param _deck The deck. Takes ownership of the object @@ -290,13 +303,12 @@ void AbstractTabDeckEditor::openDeckFromFile(const QString &fileName, DeckOpenLo auto *l = new DeckLoader; if (l->loadFromFile(fileName, fmt, true)) { - SettingsCache::instance().recents().updateRecentlyOpenedDeckPaths(fileName); if (deckOpenLocation == NEW_TAB) { emit openDeckEditor(l); l->deleteLater(); } else { deckMenu->setSaveStatus(false); - setDeck(l); + openDeck(l); } } else { l->deleteLater(); diff --git a/cockatrice/src/client/tabs/abstract_tab_deck_editor.h b/cockatrice/src/client/tabs/abstract_tab_deck_editor.h index 94fbe9bde..bc7b31917 100644 --- a/cockatrice/src/client/tabs/abstract_tab_deck_editor.h +++ b/cockatrice/src/client/tabs/abstract_tab_deck_editor.h @@ -54,7 +54,7 @@ public: virtual void retranslateUi() override = 0; // Deck Management - virtual void setDeck(DeckLoader *_deckLoader); + void openDeck(DeckLoader *deck); DeckLoader *getDeckList() const; void setModified(bool _windowModified); @@ -117,6 +117,7 @@ protected slots: virtual void dockFloatingTriggered() = 0; private: + virtual void setDeck(DeckLoader *_deck); void editDeckInClipboard(bool annotated); protected: diff --git a/cockatrice/src/client/tabs/tab_deck_storage.cpp b/cockatrice/src/client/tabs/tab_deck_storage.cpp index 5fa25be4f..f696f607c 100644 --- a/cockatrice/src/client/tabs/tab_deck_storage.cpp +++ b/cockatrice/src/client/tabs/tab_deck_storage.cpp @@ -246,8 +246,6 @@ void TabDeckStorage::actOpenLocalDeck() if (!deckLoader.loadFromFile(filePath, DeckLoader::CockatriceFormat, true)) continue; - SettingsCache::instance().recents().updateRecentlyOpenedDeckPaths(filePath); - emit openDeckEditor(&deckLoader); } } diff --git a/cockatrice/src/client/tabs/tab_supervisor.cpp b/cockatrice/src/client/tabs/tab_supervisor.cpp index 5b89ab257..e2fb234d7 100644 --- a/cockatrice/src/client/tabs/tab_supervisor.cpp +++ b/cockatrice/src/client/tabs/tab_supervisor.cpp @@ -772,7 +772,7 @@ TabDeckEditor *TabSupervisor::addDeckEditorTab(const DeckLoader *deckToOpen) { auto *tab = new TabDeckEditor(this); if (deckToOpen) - tab->setDeck(new DeckLoader(*deckToOpen)); + tab->openDeck(new DeckLoader(*deckToOpen)); connect(tab, &AbstractTabDeckEditor::deckEditorClosing, this, &TabSupervisor::deckEditorClosed); connect(tab, &AbstractTabDeckEditor::openDeckEditor, this, &TabSupervisor::addDeckEditorTab); myAddTab(tab);