Refactor DeckViewContainer (#5830)

This commit is contained in:
RickyRister 2025-04-15 15:10:24 -07:00 committed by GitHub
parent 181bef0057
commit b4024ee552
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -57,19 +57,13 @@ DeckViewContainer::DeckViewContainer(int _playerId, TabGame *parent)
forceStartGameButton = new QPushButton; forceStartGameButton = new QPushButton;
sideboardLockButton = new ToggleButton; sideboardLockButton = new ToggleButton;
connect(loadLocalButton, SIGNAL(clicked()), this, SLOT(loadLocalDeck())); connect(loadLocalButton, &QPushButton::clicked, this, &DeckViewContainer::loadLocalDeck);
connect(readyStartButton, SIGNAL(clicked()), this, SLOT(readyStart())); connect(loadRemoteButton, &QPushButton::clicked, this, &DeckViewContainer::loadRemoteDeck);
connect(readyStartButton, &QPushButton::clicked, this, &DeckViewContainer::readyStart);
connect(unloadDeckButton, &QPushButton::clicked, this, &DeckViewContainer::unloadDeck); connect(unloadDeckButton, &QPushButton::clicked, this, &DeckViewContainer::unloadDeck);
connect(forceStartGameButton, &QPushButton::clicked, this, &DeckViewContainer::forceStart); connect(forceStartGameButton, &QPushButton::clicked, this, &DeckViewContainer::forceStart);
connect(sideboardLockButton, SIGNAL(clicked()), this, SLOT(sideboardLockButtonClicked())); connect(sideboardLockButton, &QPushButton::clicked, this, &DeckViewContainer::sideboardLockButtonClicked);
connect(sideboardLockButton, SIGNAL(stateChanged()), this, SLOT(updateSideboardLockButtonText())); connect(sideboardLockButton, &ToggleButton::stateChanged, this, &DeckViewContainer::updateSideboardLockButtonText);
if (parentGame->getIsLocalGame()) {
loadRemoteButton->setVisible(false);
loadRemoteButton->setEnabled(false);
} else {
connect(loadRemoteButton, SIGNAL(clicked()), this, SLOT(loadRemoteDeck()));
}
auto *buttonHBox = new QHBoxLayout; auto *buttonHBox = new QHBoxLayout;
buttonHBox->addWidget(loadLocalButton); buttonHBox->addWidget(loadLocalButton);
@ -83,8 +77,8 @@ DeckViewContainer::DeckViewContainer(int _playerId, TabGame *parent)
buttonHBox->addStretch(); buttonHBox->addStretch();
deckView = new DeckView; deckView = new DeckView;
connect(deckView, SIGNAL(newCardAdded(AbstractCardItem *)), this, SIGNAL(newCardAdded(AbstractCardItem *))); connect(deckView, &DeckView::newCardAdded, this, &DeckViewContainer::newCardAdded);
connect(deckView, SIGNAL(sideboardPlanChanged()), this, SLOT(sideboardPlanChanged())); connect(deckView, &DeckView::sideboardPlanChanged, this, &DeckViewContainer::sideboardPlanChanged);
deckViewLayout = new QVBoxLayout; deckViewLayout = new QVBoxLayout;
deckViewLayout->addLayout(buttonHBox); deckViewLayout->addLayout(buttonHBox);
@ -93,7 +87,8 @@ DeckViewContainer::DeckViewContainer(int _playerId, TabGame *parent)
setLayout(deckViewLayout); setLayout(deckViewLayout);
retranslateUi(); retranslateUi();
connect(&SettingsCache::instance().shortcuts(), SIGNAL(shortCutChanged()), this, SLOT(refreshShortcuts())); connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
&DeckViewContainer::refreshShortcuts);
refreshShortcuts(); refreshShortcuts();
connect(&SettingsCache::instance(), &SettingsCache::visualDeckStorageInGameChanged, this, connect(&SettingsCache::instance(), &SettingsCache::visualDeckStorageInGameChanged, this,
@ -268,8 +263,7 @@ void DeckViewContainer::loadDeckFromFile(const QString &filePath)
Command_DeckSelect cmd; Command_DeckSelect cmd;
cmd.set_deck(deckString.toStdString()); cmd.set_deck(deckString.toStdString());
PendingCommand *pend = parentGame->prepareGameCommand(cmd); PendingCommand *pend = parentGame->prepareGameCommand(cmd);
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, connect(pend, &PendingCommand::finished, this, &DeckViewContainer::deckSelectFinished);
SLOT(deckSelectFinished(const Response &)));
parentGame->sendGameCommand(pend, playerId); parentGame->sendGameCommand(pend, playerId);
} }
@ -280,8 +274,7 @@ void DeckViewContainer::loadRemoteDeck()
Command_DeckSelect cmd; Command_DeckSelect cmd;
cmd.set_deck_id(dlg.getDeckId()); cmd.set_deck_id(dlg.getDeckId());
PendingCommand *pend = parentGame->prepareGameCommand(cmd); PendingCommand *pend = parentGame->prepareGameCommand(cmd);
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, connect(pend, &PendingCommand::finished, this, &DeckViewContainer::deckSelectFinished);
SLOT(deckSelectFinished(const Response &)));
parentGame->sendGameCommand(pend, playerId); parentGame->sendGameCommand(pend, playerId);
} }
} }