mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 14:32:15 -07:00
[HomeTab] Add a button to start a local game.
Took 21 minutes
This commit is contained in:
parent
754dd904d2
commit
8861a4281b
4 changed files with 27 additions and 13 deletions
|
|
@ -40,9 +40,9 @@ HomeWidget::HomeWidget(QWidget *parent, TabSupervisor *_tabSupervisor)
|
||||||
|
|
||||||
initializeBackgroundFromSource();
|
initializeBackgroundFromSource();
|
||||||
|
|
||||||
updateConnectButton(tabSupervisor->getClient()->getStatus());
|
updateConnectionStatus(tabSupervisor->getClient()->getStatus());
|
||||||
|
|
||||||
connect(tabSupervisor->getClient(), &RemoteClient::statusChanged, this, &HomeWidget::updateConnectButton);
|
connect(tabSupervisor->getClient(), &RemoteClient::statusChanged, this, &HomeWidget::updateConnectionStatus);
|
||||||
connect(&SettingsCache::instance(), &SettingsCache::homeTabBackgroundSourceChanged, this,
|
connect(&SettingsCache::instance(), &SettingsCache::homeTabBackgroundSourceChanged, this,
|
||||||
&HomeWidget::initializeBackgroundFromSource);
|
&HomeWidget::initializeBackgroundFromSource);
|
||||||
connect(&SettingsCache::instance(), &SettingsCache::homeTabBackgroundShuffleFrequencyChanged, this,
|
connect(&SettingsCache::instance(), &SettingsCache::homeTabBackgroundShuffleFrequencyChanged, this,
|
||||||
|
|
@ -177,9 +177,15 @@ QGroupBox *HomeWidget::createButtons()
|
||||||
boxLayout->addWidget(logoLabel);
|
boxLayout->addWidget(logoLabel);
|
||||||
boxLayout->addSpacing(25);
|
boxLayout->addSpacing(25);
|
||||||
|
|
||||||
connectButton = new HomeStyledButton("Connect/Play", gradientColors);
|
connectButton = new HomeStyledButton(tr("Connect/Play"), gradientColors);
|
||||||
boxLayout->addWidget(connectButton, 1);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
auto visualDeckEditorButton = new HomeStyledButton(tr("Create New Deck"), gradientColors);
|
auto visualDeckEditorButton = new HomeStyledButton(tr("Create New Deck"), gradientColors);
|
||||||
connect(visualDeckEditorButton, &QPushButton::clicked, tabSupervisor,
|
connect(visualDeckEditorButton, &QPushButton::clicked, tabSupervisor,
|
||||||
[this] { tabSupervisor->openDeckInNewTab(nullptr); });
|
[this] { tabSupervisor->openDeckInNewTab(nullptr); });
|
||||||
|
|
@ -209,25 +215,32 @@ QGroupBox *HomeWidget::createButtons()
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HomeWidget::updateConnectButton(const ClientStatus status)
|
void HomeWidget::updateConnectionStatus(const ClientStatus status)
|
||||||
{
|
{
|
||||||
disconnect(connectButton, &QPushButton::clicked, nullptr, nullptr);
|
disconnect(connectButton, &QPushButton::clicked, nullptr, nullptr);
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case StatusConnecting:
|
|
||||||
connectButton->setText(tr("Connecting..."));
|
|
||||||
connectButton->setEnabled(false);
|
|
||||||
break;
|
|
||||||
case StatusDisconnected:
|
case StatusDisconnected:
|
||||||
connectButton->setText(tr("Connect"));
|
connectButton->setText(tr("Connect"));
|
||||||
connectButton->setEnabled(true);
|
connectButton->setEnabled(true);
|
||||||
connect(connectButton, &QPushButton::clicked, qobject_cast<MainWindow *>(tabSupervisor->parentWidget()),
|
connect(connectButton, &QPushButton::clicked, qobject_cast<MainWindow *>(tabSupervisor->parentWidget()),
|
||||||
&MainWindow::actConnect);
|
&MainWindow::actConnect);
|
||||||
|
|
||||||
|
localGameButton->setEnabled(true);
|
||||||
|
localGameButton->setVisible(true);
|
||||||
|
break;
|
||||||
|
case StatusConnecting:
|
||||||
|
connectButton->setText(tr("Connecting..."));
|
||||||
|
connectButton->setEnabled(false);
|
||||||
|
|
||||||
|
localGameButton->setEnabled(false);
|
||||||
break;
|
break;
|
||||||
case StatusLoggedIn:
|
case StatusLoggedIn:
|
||||||
connectButton->setText(tr("Play"));
|
connectButton->setText(tr("Play"));
|
||||||
connectButton->setEnabled(true);
|
connectButton->setEnabled(true);
|
||||||
connect(connectButton, &QPushButton::clicked, tabSupervisor,
|
connect(connectButton, &QPushButton::clicked, tabSupervisor,
|
||||||
&TabSupervisor::switchToFirstAvailableNetworkTab);
|
&TabSupervisor::switchToFirstAvailableNetworkTab);
|
||||||
|
|
||||||
|
localGameButton->setVisible(false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public slots:
|
||||||
void updateBackgroundProperties();
|
void updateBackgroundProperties();
|
||||||
void updateButtonsToBackgroundColor();
|
void updateButtonsToBackgroundColor();
|
||||||
QGroupBox *createButtons();
|
QGroupBox *createButtons();
|
||||||
void updateConnectButton(const ClientStatus status);
|
void updateConnectionStatus(const ClientStatus status);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QGridLayout *layout;
|
QGridLayout *layout;
|
||||||
|
|
@ -38,6 +38,7 @@ private:
|
||||||
QPixmap overlay;
|
QPixmap overlay;
|
||||||
QPair<QColor, QColor> gradientColors;
|
QPair<QColor, QColor> gradientColors;
|
||||||
HomeStyledButton *connectButton;
|
HomeStyledButton *connectButton;
|
||||||
|
HomeStyledButton *localGameButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HOME_WIDGET_H
|
#endif // HOME_WIDGET_H
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ public slots:
|
||||||
void actCheckServerUpdates();
|
void actCheckServerUpdates();
|
||||||
void actCheckClientUpdates();
|
void actCheckClientUpdates();
|
||||||
void actConnect();
|
void actConnect();
|
||||||
|
void actSinglePlayer();
|
||||||
void actExit();
|
void actExit();
|
||||||
private slots:
|
private slots:
|
||||||
void updateTabMenu(const QList<QMenu *> &newMenuList);
|
void updateTabMenu(const QList<QMenu *> &newMenuList);
|
||||||
|
|
@ -80,7 +81,6 @@ private slots:
|
||||||
void pixmapCacheSizeChanged(int newSizeInMBs);
|
void pixmapCacheSizeChanged(int newSizeInMBs);
|
||||||
void notifyUserAboutUpdate();
|
void notifyUserAboutUpdate();
|
||||||
void actDisconnect();
|
void actDisconnect();
|
||||||
void actSinglePlayer();
|
|
||||||
void actWatchReplay();
|
void actWatchReplay();
|
||||||
void actFullScreen(bool checked);
|
void actFullScreen(bool checked);
|
||||||
void actRegister();
|
void actRegister();
|
||||||
|
|
|
||||||
|
|
@ -104,9 +104,9 @@ void CloseButton::paintEvent(QPaintEvent * /*event*/)
|
||||||
}
|
}
|
||||||
|
|
||||||
TabSupervisor::TabSupervisor(AbstractClient *_client, QMenu *tabsMenu, QWidget *parent)
|
TabSupervisor::TabSupervisor(AbstractClient *_client, QMenu *tabsMenu, QWidget *parent)
|
||||||
: QTabWidget(parent), userInfo(nullptr), client(_client), tabsMenu(tabsMenu), tabVisualDeckStorage(nullptr),
|
: QTabWidget(parent), userInfo(nullptr), client(_client), tabsMenu(tabsMenu), tabHome(nullptr),
|
||||||
tabServer(nullptr), tabAccount(nullptr), tabDeckStorage(nullptr), tabReplays(nullptr), tabAdmin(nullptr),
|
tabVisualDeckStorage(nullptr), tabServer(nullptr), tabAccount(nullptr), tabDeckStorage(nullptr),
|
||||||
tabLog(nullptr), isLocalGame(false)
|
tabReplays(nullptr), tabAdmin(nullptr), tabLog(nullptr), isLocalGame(false)
|
||||||
{
|
{
|
||||||
setElideMode(Qt::ElideRight);
|
setElideMode(Qt::ElideRight);
|
||||||
setMovable(true);
|
setMovable(true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue