Commit ee9a39fb authored by Dorian Zedler's avatar Dorian Zedler

added basic controls

parent 62037105
......@@ -57,7 +57,7 @@ bool BaseConn::init() {
this->setState("connected");
// init remote session
QJsonArray updateSubs = {"onTimersChanged"};
QJsonArray updateSubs = {"onTimersChanged", "onRaceStateChanged"};
QJsonObject sessionParams = {{"updateSubs", updateSubs}, {"init", true}};
if(this->sendCommand(1, sessionParams)["status"] != 200) {
......@@ -344,6 +344,13 @@ void BaseConn::setState(QString newState){
void BaseConn::handleUpdate(QVariantMap data) {
int header = data["header"].toInt();
switch (header) {
case 9000:
{
// the remote race state changed
this->remoteRaceState = data["data"].toInt();
this->raceStateChanged();
break;
}
case 9001:
{
// the remote timers have changed
......@@ -351,6 +358,7 @@ void BaseConn::handleUpdate(QVariantMap data) {
break;
}
}
}
......@@ -446,3 +454,8 @@ QVariant BaseConn::getTimerTextList()
{
return this->timerTextList;
}
int BaseConn::getRaceState()
{
return this->remoteRaceState;
}
......@@ -19,6 +19,7 @@ class BaseConn : public QObject
Q_PROPERTY(QString ipAddress READ getIP WRITE setIP)
Q_PROPERTY(QString state READ getState NOTIFY stateChanged)
Q_PROPERTY(QVariant timers READ getTimerTextList NOTIFY timerTextChanged)
Q_PROPERTY(int raceState READ getRaceState NOTIFY raceStateChanged)
public:
explicit BaseConn(QObject *parent = nullptr);
......@@ -45,7 +46,7 @@ public:
QVariant remoteTimers;
QVariant timerTextList;
int remoteRaceState;
private:
QDateTime *date;
......@@ -82,6 +83,7 @@ signals:
// for qml
void timerTextChanged();
void raceStateChanged();
public slots:
......@@ -117,6 +119,7 @@ public slots:
QString getState() const;
QVariant getTimerTextList();
int getRaceState();
private slots:
void readyRead();
......
......@@ -24,6 +24,11 @@ int main(int argc, char *argv[])
engine.rootContext()->setContextProperty("XscreenHeight", size.height());
engine.rootContext()->setContextProperty("XscreenWidth", size.width());
if(argc > 0 && QString(argv[0]) == "-noControls")
engine.rootContext()->setContextProperty("showControls", false);
else
engine.rootContext()->setContextProperty("showControls", true);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment