Added time duration and countdown duration to game tab
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
@@ -22,7 +23,7 @@ static QMap<QString,QString> parseGamResponse(const QString &response,
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
for (const QString &entry : tokens.mid(2)) {
|
for (const QString &entry : tokens.mid(2)) {
|
||||||
if (entry.size() < 5) continue; // need at least 4-char code + 1-char name
|
if (entry.size() < 5) continue;
|
||||||
const QString code = entry.left(4);
|
const QString code = entry.left(4);
|
||||||
QString name = entry.mid(4);
|
QString name = entry.mid(4);
|
||||||
name.replace("_S", " ");
|
name.replace("_S", " ");
|
||||||
@@ -59,7 +60,7 @@ GamesPanel::GamesPanel(QWidget *parent) : QWidget(parent)
|
|||||||
leftLayout->addWidget(m_availableList, 1);
|
leftLayout->addWidget(m_availableList, 1);
|
||||||
leftLayout->addWidget(m_addBtn);
|
leftLayout->addWidget(m_addBtn);
|
||||||
|
|
||||||
// ---- Right pane: Installed games + Start/Stop ----
|
// ---- Right pane: Installed games + Start/Stop + time/countdown inputs ----
|
||||||
auto *rightWidget = new QWidget(splitter);
|
auto *rightWidget = new QWidget(splitter);
|
||||||
auto *rightLayout = new QVBoxLayout(rightWidget);
|
auto *rightLayout = new QVBoxLayout(rightWidget);
|
||||||
rightLayout->setContentsMargins(4, 4, 4, 4);
|
rightLayout->setContentsMargins(4, 4, 4, 4);
|
||||||
@@ -70,6 +71,25 @@ GamesPanel::GamesPanel(QWidget *parent) : QWidget(parent)
|
|||||||
m_installedList = new QListWidget(rightWidget);
|
m_installedList = new QListWidget(rightWidget);
|
||||||
m_installedList->addItem("Connect to load installed games...");
|
m_installedList->addItem("Connect to load installed games...");
|
||||||
|
|
||||||
|
// Parameter inputs row
|
||||||
|
auto *paramRow = new QHBoxLayout();
|
||||||
|
auto *timeLabel = new QLabel("Time:", rightWidget);
|
||||||
|
m_timeEdit = new QLineEdit(rightWidget);
|
||||||
|
m_timeEdit->setPlaceholderText("seconds");
|
||||||
|
m_timeEdit->setFixedWidth(72);
|
||||||
|
m_timeEdit->setToolTip("Optional: game duration in seconds (adds ,t<value>)");
|
||||||
|
auto *countLabel = new QLabel("Countdown:", rightWidget);
|
||||||
|
m_countdownEdit = new QLineEdit(rightWidget);
|
||||||
|
m_countdownEdit->setPlaceholderText("seconds");
|
||||||
|
m_countdownEdit->setFixedWidth(72);
|
||||||
|
m_countdownEdit->setToolTip("Optional: countdown duration in seconds (adds ,c<value>)");
|
||||||
|
paramRow->addWidget(timeLabel);
|
||||||
|
paramRow->addWidget(m_timeEdit);
|
||||||
|
paramRow->addSpacing(8);
|
||||||
|
paramRow->addWidget(countLabel);
|
||||||
|
paramRow->addWidget(m_countdownEdit);
|
||||||
|
paramRow->addStretch(1);
|
||||||
|
|
||||||
// Start / Stop button row
|
// Start / Stop button row
|
||||||
auto *btnRow = new QHBoxLayout();
|
auto *btnRow = new QHBoxLayout();
|
||||||
m_startBtn = new QPushButton("▶ Start Game", rightWidget);
|
m_startBtn = new QPushButton("▶ Start Game", rightWidget);
|
||||||
@@ -90,6 +110,7 @@ GamesPanel::GamesPanel(QWidget *parent) : QWidget(parent)
|
|||||||
|
|
||||||
rightLayout->addWidget(instLabel);
|
rightLayout->addWidget(instLabel);
|
||||||
rightLayout->addWidget(m_installedList, 1);
|
rightLayout->addWidget(m_installedList, 1);
|
||||||
|
rightLayout->addLayout(paramRow);
|
||||||
rightLayout->addLayout(btnRow);
|
rightLayout->addLayout(btnRow);
|
||||||
|
|
||||||
splitter->addWidget(leftWidget);
|
splitter->addWidget(leftWidget);
|
||||||
@@ -154,7 +175,7 @@ void GamesPanel::rebuildAvailable()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Add selected available game to installed list
|
// Add selected available game
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
void GamesPanel::onAddClicked()
|
void GamesPanel::onAddClicked()
|
||||||
{
|
{
|
||||||
@@ -166,7 +187,11 @@ void GamesPanel::onAddClicked()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Start selected installed game: GST <code> ,p
|
// Start selected installed game:
|
||||||
|
// GST <code> ,p (no params)
|
||||||
|
// GST <code> ,p,t<time> (time only)
|
||||||
|
// GST <code> ,p,c<countdown> (countdown only)
|
||||||
|
// GST <code> ,p,t<time>,c<countdown> (both)
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
void GamesPanel::onStartClicked()
|
void GamesPanel::onStartClicked()
|
||||||
{
|
{
|
||||||
@@ -174,5 +199,14 @@ void GamesPanel::onStartClicked()
|
|||||||
if (!item) return;
|
if (!item) return;
|
||||||
const QString name = item->text();
|
const QString name = item->text();
|
||||||
if (!m_installedGames.contains(name)) return;
|
if (!m_installedGames.contains(name)) return;
|
||||||
emit commandRequested(QString("GST %1 ,p").arg(m_installedGames[name]));
|
|
||||||
|
const QString code = m_installedGames[name];
|
||||||
|
const QString timeVal = m_timeEdit->text().trimmed();
|
||||||
|
const QString countVal = m_countdownEdit->text().trimmed();
|
||||||
|
|
||||||
|
QString params = ",p";
|
||||||
|
if (!timeVal.isEmpty()) params += QString(",t%1").arg(timeVal);
|
||||||
|
if (!countVal.isEmpty()) params += QString(",c%1").arg(countVal);
|
||||||
|
|
||||||
|
emit commandRequested(QString("GST %1 %2").arg(code, params));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
class QLineEdit;
|
||||||
class QListWidget;
|
class QListWidget;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
|
||||||
@@ -31,6 +32,8 @@ private:
|
|||||||
|
|
||||||
// Right pane
|
// Right pane
|
||||||
QListWidget *m_installedList = nullptr;
|
QListWidget *m_installedList = nullptr;
|
||||||
|
QLineEdit *m_timeEdit = nullptr;
|
||||||
|
QLineEdit *m_countdownEdit = nullptr;
|
||||||
QPushButton *m_startBtn = nullptr;
|
QPushButton *m_startBtn = nullptr;
|
||||||
QPushButton *m_stopBtn = nullptr;
|
QPushButton *m_stopBtn = nullptr;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user