adapted to latest libraries

This commit is contained in:
Dorian Zedler 2021-01-05 20:47:17 +01:00
parent 9a69b356f5
commit d651e5b04b
Signed by: dorian
GPG key ID: 989DE36109AFA354
8 changed files with 45 additions and 158 deletions

View file

@ -18,8 +18,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \ SOURCES += \
sources/main.cpp \ sources/main.cpp
sources/scstwmonitorbackend.cpp
RESOURCES += \ RESOURCES += \
resources/qml/qml.qrc \ resources/qml/qml.qrc \
@ -43,7 +42,6 @@ else: unix:!android: target.path = /usr/share/ScStwMonitor
!isEmpty(target.path): INSTALLS += target !isEmpty(target.path): INSTALLS += target
HEADERS += \ HEADERS += \
headers/scstwmonitorbackend.h
DISTFILES += \ DISTFILES += \
android/AndroidManifest.xml \ android/AndroidManifest.xml \

View file

@ -1,55 +0,0 @@
/****************************************************************************
** ScStw Monitor
** Copyright (C) 2020 Itsblue development
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef SCSTWMONITORBACKEND_H
#define SCSTWMONITORBACKEND_H
#include <QObject>
#include <scstwclient.h>
#include <scstwremotemonitorrace.h>
class ScStwMonitorBackend : public QObject
{
Q_OBJECT
Q_PROPERTY(ScStwRace* race READ getRace NOTIFY raceChanged)
Q_PROPERTY(ScStwClient *scStwClient READ getScStwClient NOTIFY scStwClientChanged)
public:
explicit ScStwMonitorBackend(QObject *parent = nullptr);
private:
ScStwClient * scStwClient;
QTimer *autoConnectRetryTimer; // timer to frequently trigger a connection attempt to the base station
QTimer * timerTextRefreshTimer;
ScStwRemoteMonitorRace * remoteRace;
public slots:
// functions for qml
Q_INVOKABLE ScStwRace *getRace();
Q_INVOKABLE ScStwClient *getScStwClient();
private slots:
void refreshTimerText();
void doConnectionAttempt();
signals:
void raceChanged();
void scStwClientChanged();
};
#endif // SCSTWMONITORBACKEND_H

Binary file not shown.

View file

@ -3,7 +3,7 @@ Version: 1.1
Section: base Section: base
Priority: optional Priority: optional
Architecture: armhf Architecture: armhf
Depends: libScStwSharedLibraries (>=1.1.0), xinit (>= 1.4.0-1), x11-xserver-utils (>= 7.7+8+rpi1) Depends: libScStwSharedLibraries (>=1.1.0), xinit (>= 1.4.0-1), x11-xserver-utils (>= 7.7+8)
Maintainer: Dorian Zedler <dorian@itsblue.de> Maintainer: Dorian Zedler <dorian@itsblue.de>
Description: ScStwMonitor Description: ScStwMonitor
This is the ScStwMonitor Application, used with the ScStw project This is the ScStwMonitor Application, used with the ScStw project

View file

@ -24,7 +24,6 @@ import Qt.labs.settings 1.0
import QtQuick.Layouts 1.0 import QtQuick.Layouts 1.0
import de.itsblue.ScStw 2.0 import de.itsblue.ScStw 2.0
import de.itsblue.ScStwMonitor 2.0
import de.itsblue.ScStw.Styling 2.0 import de.itsblue.ScStw.Styling 2.0
import de.itsblue.ScStw.Styling.Components 1.0 import de.itsblue.ScStw.Styling.Components 1.0
@ -49,9 +48,29 @@ Window {
return app.width > app.height return app.width > app.height
} }
ScStwMonitorBackend { ScStwClient {
id: backend id: scStwClient
scStwClient.ipAddress: appSettings.baseStationIp ipAddress: appSettings.baseStationIp
}
Timer {
running: scStwClient.state !== ScStwClient.Connected
interval: 10
onTriggered: scStwClient.connectToHost()
}
ScStwRemoteRace {
id: scStwRemoteRace
autoRefreshTimerText: true
scStwClient: scStwClient
onStateChanged: {
if(scStwRemoteRace.state !== ScStwRace.IDLE) {
settingsDialog.close()
profilesDialog.close()
}
}
} }
ScStwAppThemeManager { ScStwAppThemeManager {
@ -89,7 +108,7 @@ Window {
anchors.fill: parent anchors.fill: parent
sourceComponent: backend.scStwClient.state === ScStwClient.CONNECTED ? displayComp:loadingComp sourceComponent: scStwClient.state === ScStwClient.CONNECTED ? displayComp:loadingComp
} }
Component { Component {
@ -100,7 +119,7 @@ Window {
Rectangle { Rectangle {
id: topBanner id: topBanner
width: parent.width width: parent.width
height: !showControls && showBanners ? backend.race.state === ScStwRace.IDLE ? parent.height * 0.1:parent.height * 0.05 : 0 height: !showControls && showBanners ? scStwRemoteRace.state === ScStwRace.IDLE ? parent.height * 0.1:parent.height * 0.05 : 0
color: "black" color: "black"
Text { Text {
@ -156,12 +175,12 @@ Window {
TimerColumn { TimerColumn {
anchors.fill: parent anchors.fill: parent
timers: removeDisabledTimers(backend.race.timers) timers: removeDisabledTimers(scStwRemoteRace.timers)
colors: appTheme.theme.colors colors: appTheme.theme.colors
fontName: appTheme.theme.fonts.timers fontName: appTheme.theme.fonts.timers
opacity: !showControls || [ScStwRace.IDLE,ScStwRace.STARTING].indexOf(backend.race.state) < 0 ? 1:0 opacity: !showControls || [ScStwRace.IDLE,ScStwRace.STARTING].indexOf(scStwRemoteRace.state) < 0 ? 1:0
function removeDisabledTimers(timers) { function removeDisabledTimers(timers) {
var ret = [] var ret = []
@ -199,7 +218,7 @@ Window {
"please wait...", "please wait...",
"running\ntap anywhere to stop", "running\ntap anywhere to stop",
"tap anywhere to reset" "tap anywhere to reset"
][backend.race.state] ][scStwRemoteRace.state]
anchors.fill: parent anchors.fill: parent
@ -210,9 +229,9 @@ Window {
font.pixelSize: height * 0.3 font.pixelSize: height * 0.3
color: backend.race.state === ScStwRace.STARTING ? appTheme.theme.colors.warning:appTheme.theme.colors.text color: scStwRemoteRace.state === ScStwRace.STARTING ? appTheme.theme.colors.warning:appTheme.theme.colors.text
text: implicitText === "NEXT_START_ACTION" ? ["", "at your \nmarks", "ready", "starting..."][backend.race.nextStartActionDetails[ScStwRace.NextStartAction]+1]:implicitText text: implicitText === "NEXT_START_ACTION" ? ["", "at your \nmarks", "ready", "starting..."][scStwRemoteRace.nextStartActionDetails[ScStwRace.NextStartAction]+1]:implicitText
Behavior on text { Behavior on text {
FadeAnimation { FadeAnimation {
@ -233,9 +252,9 @@ Window {
height: app.landscape() ? app.height * 0.1:app.width * 0.1 height: app.landscape() ? app.height * 0.1:app.width * 0.1
opacity: backend.race.nextStartActionDetails[ScStwRace.NextStartAction] < 3 && backend.race.state === ScStwRace.STARTING ? 1:0 opacity: scStwRemoteRace.nextStartActionDetails[ScStwRace.NextStartAction] < 3 && scStwRemoteRace.state === ScStwRace.STARTING ? 1:0
value: backend.race.nextStartActionDetails[ScStwRace.NextStartActionDelayProgress] value: scStwRemoteRace.nextStartActionDetails[ScStwRace.NextStartActionDelayProgress]
background: Rectangle { background: Rectangle {
@ -273,25 +292,25 @@ Window {
enabled: visible enabled: visible
onClicked: { onClicked: {
switch (backend.race.state) { switch (scStwRemoteRace.state) {
case ScStwRace.IDLE: case ScStwRace.IDLE:
// IDLE // IDLE
backend.race.start() scStwRemoteRace.start()
break; break;
case ScStwRace.STARTING: case ScStwRace.STARTING:
// STARTING // STARTING
backend.race.cancel() scStwRemoteRace.cancel()
break; break;
case ScStwRace.WAITING: case ScStwRace.WAITING:
// WAITING // WAITING
break; break;
case ScStwRace.RUNNING: case ScStwRace.RUNNING:
// RUNNING // RUNNING
backend.race.stop() scStwRemoteRace.stop()
break; break;
case ScStwRace.STOPPED: case ScStwRace.STOPPED:
// STOPPED // STOPPED
backend.race.reset() scStwRemoteRace.reset()
break; break;
} }
@ -310,7 +329,7 @@ Window {
height: app.landscape() ? app.height * 0.1:app.width * 0.12 height: app.landscape() ? app.height * 0.1:app.width * 0.12
spacing: 0 spacing: 0
opacity: backend.race.state === ScStwRace.IDLE ? 1:0 opacity: scStwRemoteRace.state === ScStwRace.IDLE ? 1:0
visible: opacity > 0 visible: opacity > 0
Behavior on opacity { Behavior on opacity {
@ -399,7 +418,7 @@ Window {
states: [ states: [
State { State {
when: [ScStwRace.IDLE,ScStwRace.STARTING].indexOf(backend.race.state) >= 0 when: [ScStwRace.IDLE,ScStwRace.STARTING].indexOf(scStwRemoteRace.state) >= 0
name: "big" name: "big"
PropertyChanges { PropertyChanges {
target: clickHintLabel target: clickHintLabel
@ -417,7 +436,7 @@ Window {
} }
}, },
State { State {
when: [ScStwRace.IDLE,ScStwRace.STARTING].indexOf(backend.race.state) < 0 when: [ScStwRace.IDLE,ScStwRace.STARTING].indexOf(scStwRemoteRace.state) < 0
name: "small" name: "small"
PropertyChanges { PropertyChanges {
@ -452,7 +471,7 @@ Window {
Rectangle { Rectangle {
id: bottomBanner id: bottomBanner
width: parent.width width: parent.width
height: !showControls && showBanners ? backend.race.state === ScStwRace.IDLE ? parent.height * 0.1:parent.height * 0.05 : 0 height: !showControls && showBanners ? scStwRemoteRace.state === ScStwRace.IDLE ? parent.height * 0.1:parent.height * 0.05 : 0
color: "black" color: "black"
@ -519,7 +538,7 @@ Window {
visible: !textFieldEnableMa.containsMouse visible: !textFieldEnableMa.containsMouse
opacity: backend.scStwClient.state === ScStwClient.CONNECTED ? 0:1 opacity: scStwClient.state === ScStwClient.CONNECTED ? 0:1
text: appSettings.baseStationIp text: appSettings.baseStationIp

@ -1 +1 @@
Subproject commit ae9e6398ac233217ac89ef009fd84d8ce19f4159 Subproject commit 39850455da76100e5f8e7a396b105da2cffb5ceb

View file

@ -25,7 +25,6 @@
#include <scstwlibraries.h> #include <scstwlibraries.h>
#include "headers/scstwmonitorbackend.h"
#if defined(Q_OS_IOS) #if defined(Q_OS_IOS)
#include "sleepprevent.h" #include "sleepprevent.h"
#endif #endif
@ -39,8 +38,6 @@ int main(int argc, char *argv[])
app.setOrganizationName("itsblue"); app.setOrganizationName("itsblue");
app.setOrganizationDomain("itsblue.de"); app.setOrganizationDomain("itsblue.de");
qmlRegisterType<ScStwMonitorBackend>("de.itsblue.ScStwMonitor", 2, 0, "ScStwMonitorBackend");
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
ScStwLibraries::init(); ScStwLibraries::init();

View file

@ -1,72 +0,0 @@
/****************************************************************************
** ScStw Monitor
** Copyright (C) 2020 Itsblue development
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "../headers/scstwmonitorbackend.h"
ScStwMonitorBackend::ScStwMonitorBackend(QObject *parent) : QObject(parent)
{
this->scStwClient = new ScStwClient();
this->remoteRace = new ScStwRemoteMonitorRace(this->scStwClient, this);
// init refresh timers
this->autoConnectRetryTimer = new QTimer(this);
this->autoConnectRetryTimer->setInterval(1000);
this->autoConnectRetryTimer->setSingleShot(true);
connect(this->autoConnectRetryTimer, &QTimer::timeout, this, &ScStwMonitorBackend::doConnectionAttempt);
this->autoConnectRetryTimer->start();
this->timerTextRefreshTimer = new QTimer(this);
this->timerTextRefreshTimer->setInterval(1);
this->timerTextRefreshTimer->setSingleShot(true);
this->timerTextRefreshTimer->connect(this->timerTextRefreshTimer, &QTimer::timeout, this, &ScStwMonitorBackend::refreshTimerText);
this->refreshTimerText();
}
void ScStwMonitorBackend::refreshTimerText() {
// --- refresh timer text ---
if(this->getRace()->getState() == ScStwRace::RUNNING) {
emit this->getRace()->timersChanged();
}
// --- refresh next start action delay progress ---
if(this->getRace()->getState() == ScStwRace::STARTING) {
emit this->getRace()->nextStartActionDetailsChanged();
}
this->timerTextRefreshTimer->start();
}
void ScStwMonitorBackend::doConnectionAttempt()
{
if(this->scStwClient->getState() == ScStwClient::DISCONNECTED) {
qDebug() << "+--- trying to connect";
this->scStwClient->connectToHost();
}
this->autoConnectRetryTimer->start();
}
ScStwRace* ScStwMonitorBackend::getRace() {
return this->remoteRace;
}
ScStwClient* ScStwMonitorBackend::getScStwClient() {
return this->scStwClient;
}