Added an "Event" tab with a BiddingRoundControl class in it. No connections of signals and slots yet.
This commit is contained in:
57
UIs/BeetRoundWidgets/widgets/biddingroundcontrol.cpp
Normal file
57
UIs/BeetRoundWidgets/widgets/biddingroundcontrol.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
#include "biddingroundcontrol.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
|
||||
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::triggerStartNewRound);
|
||||
connect(m_restartRoundButton, &QPushButton::clicked, this,
|
||||
&BiddingRoundControl::triggerRestartLastRound);
|
||||
connect(m_stopRoundButton, &QPushButton::clicked, this,
|
||||
&BiddingRoundControl::triggerStopCurrentRound);
|
||||
connect(m_refreshRoundButton, &QPushButton::clicked, this,
|
||||
&BiddingRoundControl::onRefreshCurrentRoundTriggered);
|
||||
}
|
||||
|
||||
void BiddingRoundControl::onRefreshCurrentRoundTriggered() {
|
||||
emit sendGetRequest(GetCurrentBiddingRound);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
41
UIs/BeetRoundWidgets/widgets/biddingroundcontrol.h
Normal file
41
UIs/BeetRoundWidgets/widgets/biddingroundcontrol.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef BIDDINGROUNDCONTROL_H
|
||||
#define BIDDINGROUNDCONTROL_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "model/metadata.h"
|
||||
|
||||
class QPushButton;
|
||||
class QLabel;
|
||||
class QHBoxLayout;
|
||||
class BiddingRoundControl : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BiddingRoundControl(QWidget* parent = nullptr);
|
||||
|
||||
signals:
|
||||
void sendGetRequest(GetRequestTypes type);
|
||||
|
||||
void triggerStartNewRound();
|
||||
void triggerRestartLastRound();
|
||||
void triggerStopCurrentRound();
|
||||
// void refreshCurrentRound();
|
||||
|
||||
public slots:
|
||||
/// button slots
|
||||
void onRefreshCurrentRoundTriggered();
|
||||
|
||||
/// event slots
|
||||
void onCurrentBiddingRoundChanged(int roundNumber, bool isActive);
|
||||
|
||||
private:
|
||||
QHBoxLayout* m_layout = nullptr;
|
||||
QLabel* m_title = nullptr;
|
||||
QLabel* m_status = nullptr;
|
||||
|
||||
QPushButton* m_newRoundButton = nullptr;
|
||||
QPushButton* m_restartRoundButton = nullptr;
|
||||
QPushButton* m_stopRoundButton = nullptr;
|
||||
QPushButton* m_refreshRoundButton = nullptr;
|
||||
};
|
||||
|
||||
#endif // BIDDINGROUNDCONTROL_H
|
||||
Reference in New Issue
Block a user