#include "biddingroundcontrol.h" #include #include #include BiddingRoundControl::BiddingRoundControl(QWidget* parent) : QWidget{parent} { m_layout = new QHBoxLayout(this); m_title = new QLabel("Bidding round control:"); m_status = new QLabel("(No round started yet.)"); m_newRoundButton = new QPushButton("Start new round"); m_restartRoundButton = new QPushButton("Restart last round"); m_stopRoundButton = new QPushButton("Stop round"); m_refreshRoundButton = new QPushButton("Refresh"); m_newRoundButton->setEnabled(false); m_restartRoundButton->setEnabled(false); m_stopRoundButton->setEnabled(false); m_layout->addWidget(m_title); m_layout->addWidget(m_status); m_layout->addWidget(m_newRoundButton); m_layout->addWidget(m_restartRoundButton); m_layout->addWidget(m_stopRoundButton); m_layout->addWidget(m_refreshRoundButton); connect(m_newRoundButton, &QPushButton::clicked, this, &BiddingRoundControl::onStartNewRoundTriggered); connect(m_restartRoundButton, &QPushButton::clicked, this, &BiddingRoundControl::onRestartLastRoundTriggered); connect(m_stopRoundButton, &QPushButton::clicked, this, &BiddingRoundControl::onStopCurrentRoundTriggered); connect(m_refreshRoundButton, &QPushButton::clicked, this, &BiddingRoundControl::onRefreshCurrentRoundTriggered); } void BiddingRoundControl::onRefreshCurrentRoundTriggered() { emit sendGetRequest(GetCurrentBiddingRound); } void BiddingRoundControl::onStartNewRoundTriggered() { emit sendGetRequest(StartNewBiddingRound); } void BiddingRoundControl::onRestartLastRoundTriggered() { emit sendGetRequest(RestartLastBiddingRound); } void BiddingRoundControl::onStopCurrentRoundTriggered() { emit sendGetRequest(StopCurrentBiddingRound); } void BiddingRoundControl::onCurrentBiddingRoundChanged(int roundNumber, bool isActive) { QString text = QString::number(roundNumber); if (isActive) { text.append(" (active)"); m_newRoundButton->setEnabled(false); m_restartRoundButton->setEnabled(false); m_stopRoundButton->setEnabled(true); } else { text.append(" (stopped)"); m_newRoundButton->setEnabled(true); m_restartRoundButton->setEnabled(roundNumber > 0); m_stopRoundButton->setEnabled(false); } m_status->setText(text); }