mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 16:44:48 -07:00
Add setting for which deck editor tab to open deck in (#5895)
* Create new setting * Update settings dlg * implement functionality * Make setting into an enum
This commit is contained in:
parent
24e27d3c31
commit
57c6f2716f
10 changed files with 70 additions and 5 deletions
|
|
@ -590,7 +590,7 @@ void TabSupervisor::actTabDeckStorage(bool checked)
|
|||
void TabSupervisor::openTabDeckStorage()
|
||||
{
|
||||
tabDeckStorage = new TabDeckStorage(this, client, userInfo);
|
||||
connect(tabDeckStorage, &TabDeckStorage::openDeckEditor, this, &TabSupervisor::addDeckEditorTab);
|
||||
connect(tabDeckStorage, &TabDeckStorage::openDeckEditor, this, &TabSupervisor::openDeckInNewTab);
|
||||
myAddTab(tabDeckStorage, aTabDeckStorage);
|
||||
connect(tabDeckStorage, &Tab::closed, this, [this] {
|
||||
tabDeckStorage = nullptr;
|
||||
|
|
@ -691,7 +691,7 @@ void TabSupervisor::gameJoined(const Event_GameJoined &event)
|
|||
auto *tab = new TabGame(this, QList<AbstractClient *>() << client, event, roomGameTypes);
|
||||
connect(tab, &TabGame::gameClosing, this, &TabSupervisor::gameLeft);
|
||||
connect(tab, &TabGame::openMessageDialog, this, &TabSupervisor::addMessageTab);
|
||||
connect(tab, &TabGame::openDeckEditor, this, &TabSupervisor::addDeckEditorTab);
|
||||
connect(tab, &TabGame::openDeckEditor, this, &TabSupervisor::openDeckInNewTab);
|
||||
myAddTab(tab);
|
||||
gameTabs.insert(event.game_info().game_id(), tab);
|
||||
setCurrentWidget(tab);
|
||||
|
|
@ -701,7 +701,7 @@ void TabSupervisor::localGameJoined(const Event_GameJoined &event)
|
|||
{
|
||||
auto *tab = new TabGame(this, localClients, event, QMap<int, QString>());
|
||||
connect(tab, &TabGame::gameClosing, this, &TabSupervisor::gameLeft);
|
||||
connect(tab, &TabGame::openDeckEditor, this, &TabSupervisor::addDeckEditorTab);
|
||||
connect(tab, &TabGame::openDeckEditor, this, &TabSupervisor::openDeckInNewTab);
|
||||
myAddTab(tab);
|
||||
gameTabs.insert(event.game_info().game_id(), tab);
|
||||
setCurrentWidget(tab);
|
||||
|
|
@ -807,6 +807,29 @@ void TabSupervisor::talkLeft(TabMessage *tab)
|
|||
removeTab(indexOf(tab));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new deck editor tab and loads the deck into it.
|
||||
* Creates either a classic or visual deck editor tab depending on settings
|
||||
* @param deckToOpen The deck to open in the tab. Creates a copy of the DeckLoader instance.
|
||||
*/
|
||||
void TabSupervisor::openDeckInNewTab(const DeckLoader *deckToOpen)
|
||||
{
|
||||
int type = SettingsCache::instance().getDefaultDeckEditorType();
|
||||
switch (type) {
|
||||
case ClassicDeckEditor:
|
||||
addDeckEditorTab(deckToOpen);
|
||||
break;
|
||||
case VisualDeckEditor:
|
||||
addVisualDeckEditorTab(deckToOpen);
|
||||
break;
|
||||
default:
|
||||
qCWarning(TabSupervisorLog) << "Unknown DeckEditorType [" << type
|
||||
<< "]; opening ClassicDeckEditor as fallback";
|
||||
addDeckEditorTab(deckToOpen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new deck editor tab
|
||||
* @param deckToOpen The deck to open in the tab. Creates a copy of the DeckLoader instance.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue