mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 06:22:15 -07:00
Change start local game button to disconnect when connected.
Took 9 minutes
This commit is contained in:
parent
8861a4281b
commit
62d3ddbd9a
3 changed files with 16 additions and 11 deletions
|
|
@ -180,11 +180,8 @@ QGroupBox *HomeWidget::createButtons()
|
|||
connectButton = new HomeStyledButton(tr("Connect/Play"), gradientColors);
|
||||
boxLayout->addWidget(connectButton, 1);
|
||||
|
||||
localGameButton = new HomeStyledButton(tr("Start Local Game"), gradientColors);
|
||||
boxLayout->addWidget(localGameButton);
|
||||
if (auto mainWindow = qobject_cast<MainWindow *>(tabSupervisor->parent())) {
|
||||
connect(localGameButton, &QPushButton::clicked, mainWindow, &MainWindow::actSinglePlayer);
|
||||
}
|
||||
localGameOrDisconnectButton = new HomeStyledButton(tr("Start Local Game"), gradientColors);
|
||||
boxLayout->addWidget(localGameOrDisconnectButton);
|
||||
|
||||
auto visualDeckEditorButton = new HomeStyledButton(tr("Create New Deck"), gradientColors);
|
||||
connect(visualDeckEditorButton, &QPushButton::clicked, tabSupervisor,
|
||||
|
|
@ -218,6 +215,7 @@ QGroupBox *HomeWidget::createButtons()
|
|||
void HomeWidget::updateConnectionStatus(const ClientStatus status)
|
||||
{
|
||||
disconnect(connectButton, &QPushButton::clicked, nullptr, nullptr);
|
||||
disconnect(localGameOrDisconnectButton, &QPushButton::clicked, nullptr, nullptr);
|
||||
switch (status) {
|
||||
case StatusDisconnected:
|
||||
connectButton->setText(tr("Connect"));
|
||||
|
|
@ -225,14 +223,17 @@ void HomeWidget::updateConnectionStatus(const ClientStatus status)
|
|||
connect(connectButton, &QPushButton::clicked, qobject_cast<MainWindow *>(tabSupervisor->parentWidget()),
|
||||
&MainWindow::actConnect);
|
||||
|
||||
localGameButton->setEnabled(true);
|
||||
localGameButton->setVisible(true);
|
||||
localGameOrDisconnectButton->setText(tr("Start Local Game"));
|
||||
localGameOrDisconnectButton->setEnabled(true);
|
||||
if (auto mainWindow = qobject_cast<MainWindow *>(tabSupervisor->parent())) {
|
||||
connect(localGameOrDisconnectButton, &QPushButton::clicked, mainWindow, &MainWindow::actSinglePlayer);
|
||||
}
|
||||
break;
|
||||
case StatusConnecting:
|
||||
connectButton->setText(tr("Connecting..."));
|
||||
connectButton->setEnabled(false);
|
||||
|
||||
localGameButton->setEnabled(false);
|
||||
localGameOrDisconnectButton->setEnabled(false);
|
||||
break;
|
||||
case StatusLoggedIn:
|
||||
connectButton->setText(tr("Play"));
|
||||
|
|
@ -240,7 +241,11 @@ void HomeWidget::updateConnectionStatus(const ClientStatus status)
|
|||
connect(connectButton, &QPushButton::clicked, tabSupervisor,
|
||||
&TabSupervisor::switchToFirstAvailableNetworkTab);
|
||||
|
||||
localGameButton->setVisible(false);
|
||||
localGameOrDisconnectButton->setEnabled(true);
|
||||
localGameOrDisconnectButton->setText(tr("Disconnect"));
|
||||
if (auto mainWindow = qobject_cast<MainWindow *>(tabSupervisor->parent())) {
|
||||
connect(localGameOrDisconnectButton, &QPushButton::clicked, mainWindow, &MainWindow::actDisconnect);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ private:
|
|||
QPixmap overlay;
|
||||
QPair<QColor, QColor> gradientColors;
|
||||
HomeStyledButton *connectButton;
|
||||
HomeStyledButton *localGameButton;
|
||||
HomeStyledButton *localGameOrDisconnectButton;
|
||||
};
|
||||
|
||||
#endif // HOME_WIDGET_H
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ public slots:
|
|||
void actCheckServerUpdates();
|
||||
void actCheckClientUpdates();
|
||||
void actConnect();
|
||||
void actDisconnect();
|
||||
void actSinglePlayer();
|
||||
void actExit();
|
||||
private slots:
|
||||
|
|
@ -80,7 +81,6 @@ private slots:
|
|||
void localGameEnded();
|
||||
void pixmapCacheSizeChanged(int newSizeInMBs);
|
||||
void notifyUserAboutUpdate();
|
||||
void actDisconnect();
|
||||
void actWatchReplay();
|
||||
void actFullScreen(bool checked);
|
||||
void actRegister();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue