Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
4bce9ded0a
64 changed files with 557 additions and 246 deletions
ScStwLibraries
ScStwLibraries.pri
headers
resources
qml
ScStwStylingQml.qrc
lib/de/itsblue/ScStw/Styling/Components
shared
sources
ScStwStyling
favicon.xcfrelease
test
|
@ -4,6 +4,11 @@ SCSTWLIBRARIES_LIB = 1
|
||||||
ScStwLibraries_QML {
|
ScStwLibraries_QML {
|
||||||
QT += qml quickcontrols2
|
QT += qml quickcontrols2
|
||||||
DEFINES += ScStwLibraries_QML
|
DEFINES += ScStwLibraries_QML
|
||||||
|
|
||||||
|
ScStwLibraries_Styling {
|
||||||
|
DEFINES += ScStwLibraries_Styling
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScStwLibraries_ClientLibs {
|
ScStwLibraries_ClientLibs {
|
||||||
|
@ -14,28 +19,54 @@ INCLUDEPATH += $$PWD/headers $$PWD
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/sources/ScStw.cpp \
|
$$PWD/sources/ScStw.cpp \
|
||||||
|
$$PWD/sources/scstwsettings.cpp \
|
||||||
$$PWD/sources/scstwsoundplayer.cpp \
|
$$PWD/sources/scstwsoundplayer.cpp \
|
||||||
$$PWD/sources/scstwlibraries.cpp \
|
$$PWD/sources/scstwlibraries.cpp \
|
||||||
$$PWD/sources/scstwrace.cpp \
|
$$PWD/sources/scstwrace.cpp \
|
||||||
$$PWD/sources/scstwtimer.cpp
|
$$PWD/sources/scstwtimer.cpp \
|
||||||
|
$$PWD/sources/scstwsetting.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/headers/ScStw.hpp \
|
$$PWD/headers/ScStw.hpp \
|
||||||
$$PWD/headers/ScStwLibraries_global.h \
|
$$PWD/headers/ScStwLibraries_global.h \
|
||||||
$$PWD/headers/scstwlibraries.h \
|
$$PWD/headers/scstwlibraries.h \
|
||||||
$$PWD/headers/scstwrace.h \
|
$$PWD/headers/scstwrace.h \
|
||||||
|
$$PWD/headers/scstwsettings.h \
|
||||||
$$PWD/headers/scstwsoundplayer.h \
|
$$PWD/headers/scstwsoundplayer.h \
|
||||||
$$PWD/headers/scstwtimer.h
|
$$PWD/headers/scstwtimer.h \
|
||||||
|
$$PWD/headers/scstwsetting.h
|
||||||
|
|
||||||
ScStwLibraries_ClientLibs {
|
ScStwLibraries_ClientLibs {
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/sources/scstwclient.cpp
|
$$PWD/sources/client/scstwclient.cpp \
|
||||||
$$PWD/sources/scstwremotemonitorrace.cpp
|
$$PWD/sources/client/scstwremotesettings.cpp \
|
||||||
|
$$PWD/sources/client/scstwremotemonitorrace.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/headers/scstwclient.h \
|
$$PWD/headers/client/scstwclient.h \
|
||||||
$$PWD/headers/scstwremotemonitorrace.h
|
$$PWD/headers/client/scstwremotesettings.h \
|
||||||
|
$$PWD/headers/client/scstwremotemonitorrace.h
|
||||||
|
|
||||||
|
INCLUDEPATH += $$PWD/headers/client
|
||||||
|
}
|
||||||
|
|
||||||
|
ScStwLibraries_QML {
|
||||||
|
ScStwLibraries_Styling {
|
||||||
|
SOURCES += \
|
||||||
|
$$PWD/sources/styling/scstwapptheme.cpp \
|
||||||
|
$$PWD/sources/styling/scstwappthememanager.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
$$PWD/headers/styling/scstwapptheme.h \
|
||||||
|
$$PWD/headers/styling/scstwappthememanager.h
|
||||||
|
|
||||||
|
RESOURCES += \
|
||||||
|
$$PWD/resources/qml/ScStwStylingQml.qrc \
|
||||||
|
$$PWD/resources/shared/ScStwStylingShared.qrc \
|
||||||
|
|
||||||
|
INCLUDEPATH += $$PWD/headers/styling
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
$$PWD/resources/ScStwLibrariesShared.qrc
|
$$PWD/resources/shared/ScStwLibrariesShared.qrc
|
||||||
|
|
|
@ -38,23 +38,9 @@
|
||||||
* git submodule update --init --recursive
|
* git submodule update --init --recursive
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* Add to the list of libraries for the Qt-Secret assembly. For an example you can create Main.Pro in which connect Qt-Secret and your project.pro files as subprojects.
|
|
||||||
*
|
|
||||||
* Main.pro:
|
|
||||||
* \code{.pro}
|
|
||||||
* TEMPLATE = subdirs
|
|
||||||
* CONFIG += ordered
|
|
||||||
*
|
|
||||||
* SUBDIRS += \
|
|
||||||
* ScStwLibraries \
|
|
||||||
* MyProject
|
|
||||||
*
|
|
||||||
* ScStwLibraries.file = shared-libraries/ScStwLibraries/ScStwLibraries.pro
|
|
||||||
* \endcode
|
|
||||||
*
|
|
||||||
* And in your MyProject.pro include the .pri file:
|
* And in your MyProject.pro include the .pri file:
|
||||||
* \code{.pro}
|
* \code{.pro}
|
||||||
* include($$PWD/../shared-libraries/ScStwLibraries/ScStwLibraries.pri)
|
* include($$PWD/shared-libraries/ScStwLibraries/ScStwLibraries.pri)
|
||||||
* \endcode
|
* \endcode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -75,28 +61,11 @@ public:
|
||||||
RaceStateChanged = 9000,
|
RaceStateChanged = 9000,
|
||||||
TimersChanged = 9001,
|
TimersChanged = 9001,
|
||||||
ExtensionsChanged = 9002,
|
ExtensionsChanged = 9002,
|
||||||
NextStartActionChanged = 9003 /*, ProfilesChanged*/
|
NextStartActionChanged = 9003, /*, ProfilesChanged*/
|
||||||
|
SettingChanged = 9004
|
||||||
};
|
};
|
||||||
Q_ENUM(SignalKey)
|
Q_ENUM(SignalKey)
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief The BaseStationSetting enum contains all settings of the base station that can be changed by a client
|
|
||||||
*
|
|
||||||
* \see ScStw::baseStationSettingFromInt()
|
|
||||||
* \see ScStw::baseStationSettingToString()
|
|
||||||
* \see ScStw::baseStationSettingFromString()
|
|
||||||
* \see ScStw::baseStationSettings
|
|
||||||
*/
|
|
||||||
enum BaseStationSetting {
|
|
||||||
InvalidSetting = -1,
|
|
||||||
ReadySoundEnableSetting,
|
|
||||||
ReadySoundDelaySetting,
|
|
||||||
AtYourMarksSoundEnableSetting,
|
|
||||||
AtYourMarksSoundDelaySetting,
|
|
||||||
SoundVolumeSetting
|
|
||||||
};
|
|
||||||
Q_ENUM(BaseStationSetting)
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief The SocketCommand enum contains all commands the base station can handle
|
* \brief The SocketCommand enum contains all commands the base station can handle
|
||||||
*
|
*
|
||||||
|
@ -107,9 +76,9 @@ public:
|
||||||
|
|
||||||
InitializeSessionCommand = 1,
|
InitializeSessionCommand = 1,
|
||||||
|
|
||||||
StartTimersCommand = 1000,
|
StartRaceCommand = 1000,
|
||||||
StopTimersCommand = 1001,
|
StopRaceCommand = 1001,
|
||||||
ResetTimersCommand = 1002,
|
ResetRaceCommand = 1002,
|
||||||
|
|
||||||
GetRaceStateCommand = 2000,
|
GetRaceStateCommand = 2000,
|
||||||
GetNextStartActionCommand = 2005,
|
GetNextStartActionCommand = 2005,
|
||||||
|
@ -171,44 +140,6 @@ public:
|
||||||
*/
|
*/
|
||||||
static const char* SOCKET_MESSAGE_END_KEY;
|
static const char* SOCKET_MESSAGE_END_KEY;
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief baseStationSettings contains a string with reference to all BaseStationSetting values
|
|
||||||
*
|
|
||||||
* \see ScStw::BaseStationSetting
|
|
||||||
* \see ScStw::baseStationSettingToString()
|
|
||||||
* \see ScStw::baseStationSettingFromString()
|
|
||||||
*/
|
|
||||||
static const QMap<QString, ScStw::BaseStationSetting> baseStationSettings;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Function to convert an int to a BaseStationSetting
|
|
||||||
* \param i the int to convert
|
|
||||||
* \return a BaseStationSetting
|
|
||||||
*
|
|
||||||
* \see ScStw::BaseStationSetting
|
|
||||||
*/
|
|
||||||
static BaseStationSetting baseStationSettingfromInt(int i);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Function to convert a QString to a BaseStationSetting
|
|
||||||
* \param s the string to convert
|
|
||||||
* \return a BaseStationSetting
|
|
||||||
*
|
|
||||||
* \see ScStw::BaseStationSetting
|
|
||||||
* \see ScStw::baseStationSettingToString()
|
|
||||||
*/
|
|
||||||
static BaseStationSetting baseStationSettingFromString(QString s);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Function to convert BaseStationSetting to a QString
|
|
||||||
* \param s the BaseStationSetting to convert
|
|
||||||
* \return a QString
|
|
||||||
*
|
|
||||||
* \see ScStw::BaseStationSetting
|
|
||||||
* \see ScStw::baseStationSettingFromString()
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE static QString baseStationSettingToString(BaseStationSetting s);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Function to convert an int to a SignalKey
|
* \brief Function to convert an int to a SignalKey
|
||||||
* \param i the int to convert
|
* \param i the int to convert
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
|
||||||
#include "ScStw.hpp"
|
#include "ScStw.hpp"
|
||||||
|
#include "scstwsettings.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This class is used to connect and talk to the ScStw basestation.
|
* This class is used to connect and talk to the ScStw basestation.
|
||||||
|
@ -59,7 +60,10 @@ public:
|
||||||
*
|
*
|
||||||
* \brief ScStwClient
|
* \brief ScStwClient
|
||||||
*/
|
*/
|
||||||
explicit ScStwClient(QObject *parent = nullptr);
|
explicit ScStwClient(
|
||||||
|
QObject *parent = nullptr,
|
||||||
|
QList<ScStw::SignalKey> signalSubscriptions = {ScStw::ExtensionsChanged}
|
||||||
|
);
|
||||||
|
|
||||||
enum State {DISCONNECTED, CONNECTING, INITIALISING, CONNECTED};
|
enum State {DISCONNECTED, CONNECTING, INITIALISING, CONNECTED};
|
||||||
Q_ENUM(State);
|
Q_ENUM(State);
|
||||||
|
@ -75,6 +79,8 @@ private:
|
||||||
|
|
||||||
QVariantList extensions;
|
QVariantList extensions;
|
||||||
|
|
||||||
|
QList<ScStw::SignalKey> signalSubscriptions;
|
||||||
|
|
||||||
//---general status values---//
|
//---general status values---//
|
||||||
|
|
||||||
// some meta data of the base station
|
// some meta data of the base station
|
||||||
|
@ -139,14 +145,14 @@ public slots:
|
||||||
* \param value the value to write to
|
* \param value the value to write to
|
||||||
* \return the status code returned by the command
|
* \return the status code returned by the command
|
||||||
*/
|
*/
|
||||||
ScStw::StatusCode writeRemoteSetting(ScStw::BaseStationSetting key, QString value);
|
ScStw::StatusCode writeRemoteSetting(ScStwSettings::BaseStationSetting key, QVariant value);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Function to read a setting on the base station
|
* \brief Function to read a setting on the base station
|
||||||
* \param key the key to read from
|
* \param key the key to read from
|
||||||
* \return the value of the key or "false" if the key is not found or an error occured
|
* \return the value of the key or "false" if the key is not found or an error occured
|
||||||
*/
|
*/
|
||||||
QString readRemoteSetting(ScStw::BaseStationSetting key);
|
QVariant readRemoteSetting(ScStwSettings::BaseStationSetting key);
|
||||||
|
|
||||||
/*! Getter fuctions */
|
/*! Getter fuctions */
|
||||||
|
|
||||||
|
@ -199,6 +205,8 @@ public slots:
|
||||||
*/
|
*/
|
||||||
void setIP(QString ipAdress);
|
void setIP(QString ipAdress);
|
||||||
|
|
||||||
|
void addSignalSubscription(ScStw::SignalKey key);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/*!
|
/*!
|
||||||
* \brief called when timeout timer times out
|
* \brief called when timeout timer times out
|
|
@ -1,5 +1,5 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
** ScStw Styling
|
** ScStw Libraries
|
||||||
** Copyright (C) 2020 Itsblue development
|
** Copyright (C) 2020 Itsblue development
|
||||||
**
|
**
|
||||||
** This program is free software: you can redistribute it and/or modify
|
** This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -16,15 +16,38 @@
|
||||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "../headers/scstwstyling.h"
|
#ifndef SCSTWREMOTESETTINGS_H
|
||||||
|
#define SCSTWREMOTESETTINGS_H
|
||||||
|
|
||||||
ScStwStyling::ScStwStyling(QObject *parent) : QObject(parent)
|
#include <QObject>
|
||||||
|
#include "scstwsettings.h"
|
||||||
|
#include "scstwclient.h"
|
||||||
|
#include <QMetaEnum>
|
||||||
|
|
||||||
|
class ScStwRemoteSettings : public ScStwSettings
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ScStwRemoteSettings(ScStwClient * scStwClient, QObject * parent = nullptr);
|
||||||
|
|
||||||
}
|
enum SettingsMode {
|
||||||
|
LOCAL,
|
||||||
|
REMOTE
|
||||||
|
};
|
||||||
|
|
||||||
void ScStwStyling::init(QQmlApplicationEngine *engine) {
|
protected:
|
||||||
qmlRegisterUncreatableType<ScStwAppTheme>("de.itsblue.ScStw.Styling", 2, 0, "ScStwAppTheme", "The ScStwAppTheme has to be managed by a ScStwAppTheme manager and is therefore not creatable");
|
QVariant readSetting(QString key, int keyInt, int keyLevel);
|
||||||
qmlRegisterType<ScStwAppThemeManager>("de.itsblue.ScStw.Styling", 2, 0, "ScStwAppThemeManager");
|
bool writeSetting(QString key, QVariant value, int keyInt,int keyLevel = -1);
|
||||||
engine->addImportPath(":/lib");
|
bool setDefaultSetting(QString key, QVariant defaultVariant, int keyInt,int keyLevel = -1);
|
||||||
}
|
|
||||||
|
private:
|
||||||
|
ScStwClient * scStwClient;
|
||||||
|
|
||||||
|
SettingsMode getMode();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void handleClientStateChange();
|
||||||
|
void handleBaseStationSignal(ScStw::SignalKey key, QVariant data);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SCSTWREMOTESETTINGS_H
|
|
@ -22,10 +22,18 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#ifdef ScStwLibraries_QML
|
#ifdef ScStwLibraries_QML
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
|
|
||||||
|
#ifdef ScStwLibraries_Styling
|
||||||
|
#include "scstwappthememanager.h"
|
||||||
|
#include "scstwapptheme.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#include "scstwtimer.h"
|
#include "scstwtimer.h"
|
||||||
#include "scstwrace.h"
|
#include "scstwrace.h"
|
||||||
|
#include "scstwsettings.h"
|
||||||
#ifdef ScStwLibraries_ClientLibs
|
#ifdef ScStwLibraries_ClientLibs
|
||||||
|
#include "scstwsetting.h"
|
||||||
#include "scstwremotemonitorrace.h"
|
#include "scstwremotemonitorrace.h"
|
||||||
#include "scstwclient.h"
|
#include "scstwclient.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,6 +45,12 @@ class ScStwLibraries : public QObject
|
||||||
public:
|
public:
|
||||||
static void init();
|
static void init();
|
||||||
|
|
||||||
|
#ifdef ScStwLibraries_QML
|
||||||
|
#ifdef ScStwLibraries_Styling
|
||||||
|
static void initStyling(QQmlApplicationEngine *engine);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit ScStwLibraries(QObject *parent = nullptr);
|
explicit ScStwLibraries(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
** ScStw Styling
|
** ScStw Libraries
|
||||||
** Copyright (C) 2020 Itsblue development
|
** Copyright (C) 2020 Itsblue development
|
||||||
**
|
**
|
||||||
** This program is free software: you can redistribute it and/or modify
|
** This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -16,28 +16,40 @@
|
||||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef SCSTWSTYLING_H
|
#ifndef SCSTWQMLSETTING_H
|
||||||
#define SCSTWSTYLING_H
|
#define SCSTWQMLSETTING_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QQmlApplicationEngine>
|
#include <QVariant>
|
||||||
|
|
||||||
#include "scstwapptheme.h"
|
class ScStwSetting : public QObject
|
||||||
#include "scstwappthememanager.h"
|
|
||||||
|
|
||||||
|
|
||||||
class ScStwStyling : public QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QVariant value READ getValue WRITE setValue NOTIFY valueChanged)
|
||||||
|
|
||||||
public:
|
protected:
|
||||||
static void init(QQmlApplicationEngine *engine);
|
explicit ScStwSetting(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
int key;
|
||||||
|
int keyLevel;
|
||||||
|
bool hasToReload;
|
||||||
|
|
||||||
|
virtual bool writeSetting(int, int, QVariant) = 0;
|
||||||
|
virtual QVariant readSetting(int, int) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit ScStwStyling(QObject *parent = nullptr);
|
QVariant valueCache;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
QVariant getValue();
|
||||||
|
void setValue(QVariant value);
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void handleSettingChange(int key, int keyLevel, QVariant value);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void valueChanged();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCSTWSTYLING_H
|
#endif // SCSTWQMLSETTING_H
|
126
ScStwLibraries/headers/scstwsettings.h
Normal file
126
ScStwLibraries/headers/scstwsettings.h
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
/****************************************************************************
|
||||||
|
** ScStw Libraries
|
||||||
|
** 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 SCSTWSETTINGS_H
|
||||||
|
#define SCSTWSETTINGS_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QMetaEnum>
|
||||||
|
#include <QtDebug>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <ScStw.hpp>
|
||||||
|
#include <QDir>
|
||||||
|
#include <scstwsetting.h>
|
||||||
|
|
||||||
|
class ScStwSettings : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ScStwSettings(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
typedef QString(*keyToStringConverter)(int);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief The BaseStationSetting enum contains all settings of the base station that can be changed by a client
|
||||||
|
*
|
||||||
|
* \see ScStw::baseStationSettingFromInt()
|
||||||
|
* \see ScStw::baseStationSettingToString()
|
||||||
|
* \see ScStw::baseStationSettingFromString()
|
||||||
|
* \see ScStw::baseStationSettings
|
||||||
|
*/
|
||||||
|
enum BaseStationSetting {
|
||||||
|
InvalidSetting = -1,
|
||||||
|
ReadySoundEnableSetting,
|
||||||
|
ReadySoundDelaySetting,
|
||||||
|
AtYourMarksSoundEnableSetting,
|
||||||
|
AtYourMarksSoundDelaySetting,
|
||||||
|
SoundVolumeSetting
|
||||||
|
};
|
||||||
|
Q_ENUM(BaseStationSetting)
|
||||||
|
|
||||||
|
enum KeyLevelEnum {
|
||||||
|
KeyLevel = 0
|
||||||
|
};
|
||||||
|
Q_ENUM(KeyLevelEnum)
|
||||||
|
|
||||||
|
virtual QVariant readSetting(BaseStationSetting key);
|
||||||
|
Q_INVOKABLE virtual QVariant readSetting(int key, int keyLevel);
|
||||||
|
virtual bool writeSetting(BaseStationSetting key, QVariant value);
|
||||||
|
Q_INVOKABLE virtual bool writeSetting(int key, int keyLevel, QVariant value);
|
||||||
|
virtual bool setDefaultSetting(BaseStationSetting key, QVariant defaultValue);
|
||||||
|
Q_INVOKABLE virtual bool setDefaultSetting(int key, int keyLevel, QVariant defaultValue);
|
||||||
|
|
||||||
|
Q_INVOKABLE ScStwSetting * getSetting(int key, int keyLevel);
|
||||||
|
|
||||||
|
static BaseStationSetting keyFromInt(int i) {
|
||||||
|
QMetaEnum enumeration = QMetaEnum::fromType<BaseStationSetting>();
|
||||||
|
return static_cast<BaseStationSetting>(enumeration.keyToValue(enumeration.valueToKey(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
static QString keyToString(int key) {
|
||||||
|
return QMetaEnum::fromType<BaseStationSetting>().valueToKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual QVariant readSetting(QString key, int keyInt = -1, int keyLevel = -1);
|
||||||
|
virtual bool writeSetting(QString key, QVariant value, int keyInt = -1,int keyLevel = -1);
|
||||||
|
virtual bool setDefaultSetting(QString key, QVariant defaultValue, int keyInt,int keyLevel = -1);
|
||||||
|
bool registerKeyLevelHandler(int keyLevel, keyToStringConverter);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QFile * settingsFile;
|
||||||
|
QVariantMap settingsCache;
|
||||||
|
|
||||||
|
bool loadSettingsFromFile();
|
||||||
|
|
||||||
|
class ScStwSettingInternal: public ScStwSetting {
|
||||||
|
public:
|
||||||
|
ScStwSettingInternal(int key, int keyLevel, ScStwSettings*scStwSettings, QObject *parent):ScStwSetting(parent) {
|
||||||
|
this->scStwSettings = scStwSettings;
|
||||||
|
connect(this->scStwSettings, &ScStwSettings::settingChanged, this, &ScStwSettingInternal::handleSettingChange);
|
||||||
|
this->key = key;
|
||||||
|
this->keyLevel = keyLevel;
|
||||||
|
this->handleSettingChange(-1, 0, QVariant());
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
ScStwSettings *scStwSettings;
|
||||||
|
|
||||||
|
bool writeSetting(int key, int keyLevel, QVariant value) {
|
||||||
|
return this->scStwSettings->writeSetting(key, keyLevel, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant readSetting(int key, int keyLevel) {
|
||||||
|
return this->scStwSettings->readSetting(key, keyLevel);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
QMap<int, keyToStringConverter> keyToStringConverters;
|
||||||
|
QMap<int, QMap<int, ScStwSettingInternal*>> internalSettingHandlers;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
bool writeSettingsToFile();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void settingChanged(int key, int keyLevel, QVariant value);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SCSTWSETTINGS_H
|
Before (image error) Size: 19 KiB After (image error) Size: 19 KiB |
Before (image error) Size: 9.5 KiB After (image error) Size: 9.5 KiB |
Before (image error) Size: 10 KiB After (image error) Size: 10 KiB |
Before (image error) Size: 15 KiB After (image error) Size: 15 KiB |
|
@ -21,38 +21,6 @@
|
||||||
const char *ScStw::SOCKET_MESSAGE_START_KEY = "<message>";
|
const char *ScStw::SOCKET_MESSAGE_START_KEY = "<message>";
|
||||||
const char *ScStw::SOCKET_MESSAGE_END_KEY = "</message>";
|
const char *ScStw::SOCKET_MESSAGE_END_KEY = "</message>";
|
||||||
|
|
||||||
const QMap<QString, ScStw::BaseStationSetting> ScStw::baseStationSettings = {
|
|
||||||
{"ReadySoundEnable", ScStw::ReadySoundEnableSetting},
|
|
||||||
{"ReadySoundDelay", ScStw::ReadySoundDelaySetting},
|
|
||||||
{"AtYourMarksSoundEnable", ScStw::AtYourMarksSoundEnableSetting},
|
|
||||||
{"AtYourMarksSoundDelay", ScStw::AtYourMarksSoundDelaySetting},
|
|
||||||
{"SoundVolume", ScStw::SoundVolumeSetting}
|
|
||||||
};
|
|
||||||
|
|
||||||
ScStw::BaseStationSetting ScStw::baseStationSettingFromString(QString s) {
|
|
||||||
if(!ScStw::baseStationSettings.contains(s))
|
|
||||||
return ScStw::InvalidSetting;
|
|
||||||
|
|
||||||
return ScStw::baseStationSettings[s];
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ScStw::baseStationSettingToString(ScStw::BaseStationSetting s) {
|
|
||||||
for(QString key: ScStw::baseStationSettings.keys()) {
|
|
||||||
if(ScStw::baseStationSettings[key] == s)
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
return "Invalid";
|
|
||||||
}
|
|
||||||
|
|
||||||
ScStw::BaseStationSetting ScStw::baseStationSettingfromInt(int i) {
|
|
||||||
bool ok;
|
|
||||||
BaseStationSetting s = ScStw::toEnumValue<ScStw::BaseStationSetting>(i, &ok);
|
|
||||||
if(!ok)
|
|
||||||
return InvalidSetting;
|
|
||||||
else
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScStw::SignalKey ScStw::signalKeyFromInt(int i) {
|
ScStw::SignalKey ScStw::signalKeyFromInt(int i) {
|
||||||
bool ok;
|
bool ok;
|
||||||
ScStw::SignalKey k = ScStw::toEnumValue<ScStw::SignalKey>(i, &ok);
|
ScStw::SignalKey k = ScStw::toEnumValue<ScStw::SignalKey>(i, &ok);
|
||||||
|
|
|
@ -16,15 +16,16 @@
|
||||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "../headers/scstwclient.h"
|
#include "scstwclient.h"
|
||||||
|
|
||||||
ScStwClient * pGlobalScStwClient = nullptr;
|
ScStwClient * pGlobalScStwClient = nullptr;
|
||||||
|
|
||||||
ScStwClient::ScStwClient(QObject * parent) : QObject(parent)
|
ScStwClient::ScStwClient(QObject * parent, QList<ScStw::SignalKey> signalSubscriptions) : QObject(parent)
|
||||||
{
|
{
|
||||||
this->state = DISCONNECTED;
|
this->state = DISCONNECTED;
|
||||||
this->nextConnectionId = 1;
|
this->nextConnectionId = 1;
|
||||||
this->extensions = QVariantList({});
|
this->extensions = QVariantList({});
|
||||||
|
this->signalSubscriptions = signalSubscriptions;
|
||||||
|
|
||||||
this->socket = new QTcpSocket(this);
|
this->socket = new QTcpSocket(this);
|
||||||
|
|
||||||
|
@ -72,9 +73,13 @@ bool ScStwClient::init() {
|
||||||
this->setState(INITIALISING);
|
this->setState(INITIALISING);
|
||||||
this->timeoutTimer->stop();
|
this->timeoutTimer->stop();
|
||||||
|
|
||||||
|
QJsonArray signalSubs;
|
||||||
|
foreach (ScStw::SignalKey key, this->signalSubscriptions) {
|
||||||
|
signalSubs.append(key);
|
||||||
|
}
|
||||||
|
|
||||||
// init remote session
|
// init remote session
|
||||||
QJsonArray updateSubs = {ScStw::RaceStateChanged, ScStw::TimersChanged, ScStw::ExtensionsChanged, ScStw::NextStartActionChanged};
|
QJsonObject sessionParams = {{"signalSubscriptions", signalSubs}, {"init", true}, {"usingTerminationKeys", true}};
|
||||||
QJsonObject sessionParams = {{"updateSubs", updateSubs}, {"init", true}, {"usingTerminationKeys", true}};
|
|
||||||
|
|
||||||
QVariantMap initResponse = this->sendCommand(1, sessionParams, 3000, false);
|
QVariantMap initResponse = this->sendCommand(1, sessionParams, 3000, false);
|
||||||
|
|
||||||
|
@ -86,7 +91,7 @@ bool ScStwClient::init() {
|
||||||
this->apiVersion = initResponse["data"].toMap()["apiVersion"].toString();
|
this->apiVersion = initResponse["data"].toMap()["apiVersion"].toString();
|
||||||
qDebug() << "[INFO][CLIENT] base station api version is: " << this->apiVersion;
|
qDebug() << "[INFO][CLIENT] base station api version is: " << this->apiVersion;
|
||||||
int compareResult = ScStw::firmwareCompare(this->API_VERSION, this->apiVersion);
|
int compareResult = ScStw::firmwareCompare(this->API_VERSION, this->apiVersion);
|
||||||
qDebug() << "compare result is: " << compareResult;
|
//qDebug() << "compare result is: " << compareResult;
|
||||||
if( compareResult == -3 ){
|
if( compareResult == -3 ){
|
||||||
// the client version is out of date!!
|
// the client version is out of date!!
|
||||||
this->closeConnection();
|
this->closeConnection();
|
||||||
|
@ -392,19 +397,19 @@ void ScStwClient::handleSignal(QVariantMap data) {
|
||||||
// --- helper functions ---
|
// --- helper functions ---
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
|
||||||
ScStw::StatusCode ScStwClient::writeRemoteSetting(ScStw::BaseStationSetting key, QString value) {
|
ScStw::StatusCode ScStwClient::writeRemoteSetting(ScStwSettings::BaseStationSetting key, QVariant value) {
|
||||||
QJsonArray requestData;
|
QJsonArray requestData;
|
||||||
requestData.append(key);
|
requestData.append(int(key));
|
||||||
requestData.append(value);
|
requestData.append(QJsonValue::fromVariant(value));
|
||||||
return ScStw::StatusCode(this->sendCommand(3000, requestData)["status"].toInt());
|
return ScStw::StatusCode(this->sendCommand(3000, requestData)["status"].toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ScStwClient::readRemoteSetting(ScStw::BaseStationSetting key) {
|
QVariant ScStwClient::readRemoteSetting(ScStwSettings::BaseStationSetting key) {
|
||||||
QVariantMap reply = this->sendCommand(3001, key);
|
QVariantMap reply = this->sendCommand(3001, int(key));
|
||||||
if(reply["status"] != 200){
|
if(reply["status"] != 200){
|
||||||
return "false";
|
return "false";
|
||||||
}
|
}
|
||||||
return reply["data"].toString();
|
return reply["data"];
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScStwClient::setIP(QString newIp){
|
void ScStwClient::setIP(QString newIp){
|
||||||
|
@ -452,3 +457,9 @@ void ScStwClient::setExtensions(QVariantList extensions) {
|
||||||
emit this->extensionsChanged();
|
emit this->extensionsChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ScStwClient::addSignalSubscription(ScStw::SignalKey key) {
|
||||||
|
if(!this->signalSubscriptions.contains(key))
|
||||||
|
this->signalSubscriptions.append(key);
|
||||||
|
}
|
|
@ -16,12 +16,16 @@
|
||||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "../headers/scstwremotemonitorrace.h"
|
#include "scstwremotemonitorrace.h"
|
||||||
|
|
||||||
ScStwRemoteMonitorRace::ScStwRemoteMonitorRace(ScStwClient *monitorClient, QObject *parent) : ScStwRace(parent)
|
ScStwRemoteMonitorRace::ScStwRemoteMonitorRace(ScStwClient *monitorClient, QObject *parent) : ScStwRace(parent)
|
||||||
{
|
{
|
||||||
this->scStwClient = monitorClient;
|
this->scStwClient = monitorClient;
|
||||||
|
|
||||||
|
this->scStwClient->addSignalSubscription(ScStw::RaceStateChanged);
|
||||||
|
this->scStwClient->addSignalSubscription(ScStw::TimersChanged);
|
||||||
|
this->scStwClient->addSignalSubscription(ScStw::NextStartActionChanged);
|
||||||
|
|
||||||
connect(this->scStwClient, &ScStwClient::stateChanged, this, &ScStwRemoteMonitorRace::handleClientStateChanged);
|
connect(this->scStwClient, &ScStwClient::stateChanged, this, &ScStwRemoteMonitorRace::handleClientStateChanged);
|
||||||
connect(this->scStwClient, &ScStwClient::gotSignal, this, &ScStwRemoteMonitorRace::handleBaseStationSignal);
|
connect(this->scStwClient, &ScStwClient::gotSignal, this, &ScStwRemoteMonitorRace::handleBaseStationSignal);
|
||||||
}
|
}
|
71
ScStwLibraries/sources/client/scstwremotesettings.cpp
Normal file
71
ScStwLibraries/sources/client/scstwremotesettings.cpp
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/****************************************************************************
|
||||||
|
** ScStw Libraries
|
||||||
|
** 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/client/scstwremotesettings.h"
|
||||||
|
|
||||||
|
ScStwRemoteSettings::ScStwRemoteSettings(ScStwClient * scStwClient, QObject * parent) : ScStwSettings(parent)
|
||||||
|
{
|
||||||
|
this->scStwClient = scStwClient;
|
||||||
|
this->scStwClient->addSignalSubscription(ScStw::SettingChanged);
|
||||||
|
|
||||||
|
connect(this->scStwClient, &ScStwClient::gotSignal, this, &ScStwRemoteSettings::handleBaseStationSignal);
|
||||||
|
}
|
||||||
|
|
||||||
|
ScStwRemoteSettings::SettingsMode ScStwRemoteSettings::getMode() {
|
||||||
|
if(this->scStwClient->getState() == ScStwClient::CONNECTED)
|
||||||
|
return ScStwRemoteSettings::REMOTE;
|
||||||
|
else
|
||||||
|
return ScStwRemoteSettings::LOCAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ScStwRemoteSettings::readSetting(QString key, int keyInt, int keyLevel) {
|
||||||
|
if(this->getMode() == LOCAL || keyLevel > ScStwSettings::KeyLevel)
|
||||||
|
return ScStwSettings::readSetting(key, keyInt, keyLevel);
|
||||||
|
|
||||||
|
return this->scStwClient->readRemoteSetting(ScStwSettings::BaseStationSetting(keyInt));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScStwRemoteSettings::writeSetting(QString key, QVariant value, int keyInt, int keyLevel) {
|
||||||
|
if(this->getMode() == LOCAL || keyLevel > ScStwSettings::KeyLevel)
|
||||||
|
return ScStwSettings::writeSetting(key, value, keyInt, keyLevel);
|
||||||
|
|
||||||
|
ScStw::StatusCode res = this->scStwClient->writeRemoteSetting(ScStwSettings::BaseStationSetting(keyInt), value);
|
||||||
|
|
||||||
|
return res == ScStw::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScStwRemoteSettings::setDefaultSetting(QString key, QVariant defaultVariant, int keyInt, int keyLevel) {
|
||||||
|
if(this->getMode() == LOCAL || keyLevel > ScStwSettings::KeyLevel)
|
||||||
|
return ScStwSettings::setDefaultSetting(key, defaultVariant, keyInt, keyLevel);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScStwRemoteSettings::handleClientStateChange() {
|
||||||
|
if(this->scStwClient->getState() == ScStwClient::DISCONNECTED)
|
||||||
|
emit this->settingChanged(-1, 0, QVariant());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScStwRemoteSettings::handleBaseStationSignal(ScStw::SignalKey key, QVariant data) {
|
||||||
|
switch (key) {
|
||||||
|
case ScStw::SettingChanged:
|
||||||
|
emit this->settingChanged(data.toMap()["key"].toInt(), ScStwSettings::KeyLevel, data.toMap()["value"]);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,7 +26,7 @@ ScStwLibraries::ScStwLibraries(QObject *parent) : QObject(parent)
|
||||||
void ScStwLibraries::init() {
|
void ScStwLibraries::init() {
|
||||||
#ifdef ScStwLibraries_QML
|
#ifdef ScStwLibraries_QML
|
||||||
qmlRegisterType<ScStw>("de.itsblue.ScStw", 2, 0, "ScStw");
|
qmlRegisterType<ScStw>("de.itsblue.ScStw", 2, 0, "ScStw");
|
||||||
qRegisterMetaType<ScStw::BaseStationSetting>("ScStw::BaseStationSetting");
|
qRegisterMetaType<ScStwSettings::BaseStationSetting>("ScStwSettings::BaseStationSetting");
|
||||||
qRegisterMetaType<ScStw::SocketCommand>("ScStw::SocketCommand");
|
qRegisterMetaType<ScStw::SocketCommand>("ScStw::SocketCommand");
|
||||||
|
|
||||||
qmlRegisterType<ScStwRace>("de.itsblue.ScStw", 2, 0, "ScStwRace");
|
qmlRegisterType<ScStwRace>("de.itsblue.ScStw", 2, 0, "ScStwRace");
|
||||||
|
@ -34,6 +34,19 @@ void ScStwLibraries::init() {
|
||||||
|
|
||||||
#ifdef ScStwLibraries_ClientLibs
|
#ifdef ScStwLibraries_ClientLibs
|
||||||
qmlRegisterType<ScStwClient>("de.itsblue.ScStw", 2, 0, "ScStwClient");
|
qmlRegisterType<ScStwClient>("de.itsblue.ScStw", 2, 0, "ScStwClient");
|
||||||
|
qmlRegisterType<ScStwSettings>("de.itsblue.ScStw", 2, 0, "ScStwSettings");
|
||||||
|
qmlRegisterUncreatableType<ScStwSetting>("de.itsblue.ScStw", 2, 0, "ScStwSetting", "The ScStwSetting is manage by a ScStwSettings instance and therefore not creatable");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef ScStwLibraries_QML
|
||||||
|
#ifdef ScStwLibraries_Styling
|
||||||
|
void ScStwLibraries::initStyling(QQmlApplicationEngine *engine) {
|
||||||
|
qmlRegisterUncreatableType<ScStwAppTheme>("de.itsblue.ScStw.Styling", 2, 0, "ScStwAppTheme", "The ScStwAppTheme has to be managed by a ScStwAppTheme manager and is therefore not creatable");
|
||||||
|
qmlRegisterType<ScStwAppThemeManager>("de.itsblue.ScStw.Styling", 2, 0, "ScStwAppThemeManager");
|
||||||
|
engine->addImportPath(":/lib");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
49
ScStwLibraries/sources/scstwsetting.cpp
Normal file
49
ScStwLibraries/sources/scstwsetting.cpp
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/****************************************************************************
|
||||||
|
** ScStw Libraries
|
||||||
|
** 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 "scstwsetting.h"
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
ScStwSetting::ScStwSetting(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ScStwSetting::getValue() {
|
||||||
|
if(this->hasToReload) {
|
||||||
|
this->valueCache = this->readSetting(this->key, this->keyLevel);
|
||||||
|
this->hasToReload = false;
|
||||||
|
}
|
||||||
|
return this->valueCache;
|
||||||
|
}
|
||||||
|
void ScStwSetting::setValue(QVariant value) {
|
||||||
|
if(value != this->valueCache) {
|
||||||
|
this->writeSetting(this->key, this->keyLevel, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScStwSetting::handleSettingChange(int key, int keyLevel, QVariant value) {
|
||||||
|
if(keyLevel == this->keyLevel && key == this->key) {
|
||||||
|
this->valueCache = value;
|
||||||
|
qDebug() << "value changed!!! key: " << key << " new value " << value;
|
||||||
|
emit this->valueChanged();
|
||||||
|
}
|
||||||
|
else if(key == -1 && this->key != -1 && this->keyLevel != -1 && this->keyLevel == keyLevel) {
|
||||||
|
this->hasToReload = true;
|
||||||
|
emit this->valueChanged();
|
||||||
|
}
|
||||||
|
}
|
140
ScStwLibraries/sources/scstwsettings.cpp
Normal file
140
ScStwLibraries/sources/scstwsettings.cpp
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
/****************************************************************************
|
||||||
|
** ScStw Libraries
|
||||||
|
** 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/scstwsettings.h"
|
||||||
|
|
||||||
|
ScStwSettings::ScStwSettings(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||||
|
QDir dir(path);
|
||||||
|
this->settingsFile = new QFile(path + "/settings.json");
|
||||||
|
if(!this->settingsFile->exists())
|
||||||
|
if(!dir.mkpath(path))
|
||||||
|
qFatal("[FATAL] Couldn't create settings dir %s", qPrintable(path));
|
||||||
|
|
||||||
|
if(!this->settingsFile->open(QFile::ReadWrite))
|
||||||
|
qFatal("[FATAL] Couldn't open settings file %s", qPrintable(path + "/settings.json"));
|
||||||
|
|
||||||
|
if(!this->loadSettingsFromFile() && this->settingsFile->size() != 0)
|
||||||
|
qFatal("[FATAL] Settings file (%s) is of invalid format!", qPrintable(path + "/settings.json"));
|
||||||
|
|
||||||
|
connect(this, &ScStwSettings::settingChanged, this, &ScStwSettings::writeSettingsToFile);
|
||||||
|
|
||||||
|
this->registerKeyLevelHandler(ScStwSettings::KeyLevel, &ScStwSettings::keyToString);
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ScStwSettings::readSetting(BaseStationSetting key) {
|
||||||
|
return this->readSetting(key, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ScStwSettings::readSetting(int key, int keyLevel) {
|
||||||
|
if(this->keyToStringConverters.contains(keyLevel))
|
||||||
|
return this->readSetting(this->keyToStringConverters[keyLevel](key), key, keyLevel);
|
||||||
|
else
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScStwSettings::writeSetting(BaseStationSetting key, QVariant value) {
|
||||||
|
return this->writeSetting(key, 0, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScStwSettings::writeSetting(int key, int keyLevel, QVariant value) {
|
||||||
|
if(this->keyToStringConverters.contains(keyLevel))
|
||||||
|
return this->writeSetting(this->keyToStringConverters[keyLevel](key), value, key, keyLevel);
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScStwSettings::setDefaultSetting(BaseStationSetting key, QVariant defaultValue) {
|
||||||
|
return this->setDefaultSetting(key, 0, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScStwSettings::setDefaultSetting(int key, int keyLevel, QVariant defaultValue) {
|
||||||
|
if(this->keyToStringConverters.contains(keyLevel))
|
||||||
|
return this->setDefaultSetting(this->keyToStringConverters[keyLevel](key), defaultValue, key, keyLevel);
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ScStwSettings::readSetting(QString key, int keyInt, int keyLevel) {
|
||||||
|
Q_UNUSED(keyInt)
|
||||||
|
Q_UNUSED(keyLevel)
|
||||||
|
return this->settingsCache[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScStwSettings::writeSetting(QString key, QVariant value, int keyInt, int keyLevel) {
|
||||||
|
if(!this->settingsCache.contains(key))
|
||||||
|
this->settingsCache.insert(key, value);
|
||||||
|
else if (this->settingsCache[key] == value)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
this->settingsCache[key] = value;
|
||||||
|
|
||||||
|
emit this->settingChanged(keyInt, keyLevel, value);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScStwSettings::setDefaultSetting(QString key, QVariant defaultValue, int keyInt, int keyLevel) {
|
||||||
|
if(!this->settingsCache.contains(key))
|
||||||
|
return this->writeSetting(key, defaultValue, keyInt, keyLevel);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScStwSetting * ScStwSettings::getSetting(int key, int keyLevel) {
|
||||||
|
if(!this->internalSettingHandlers.contains(keyLevel))
|
||||||
|
this->internalSettingHandlers.insert(keyLevel, {});
|
||||||
|
|
||||||
|
if(!this->internalSettingHandlers[keyLevel].contains(key))
|
||||||
|
this->internalSettingHandlers[keyLevel].insert(key, new ScStwSettingInternal(key, keyLevel, this, this));
|
||||||
|
|
||||||
|
return this->internalSettingHandlers[keyLevel][key];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScStwSettings::registerKeyLevelHandler(int keyLevel, keyToStringConverter converterFunction) {
|
||||||
|
if(this->keyToStringConverters.contains(keyLevel))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
this->keyToStringConverters.insert(keyLevel, converterFunction);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* File handling
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool ScStwSettings::writeSettingsToFile() {
|
||||||
|
QJsonDocument doc = QJsonDocument::fromVariant(this->settingsCache);
|
||||||
|
|
||||||
|
// overwrite file
|
||||||
|
this->settingsFile->reset();
|
||||||
|
this->settingsFile->write(doc.toJson(QJsonDocument::Indented));
|
||||||
|
this->settingsFile->flush();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScStwSettings::loadSettingsFromFile() {
|
||||||
|
QJsonDocument doc = QJsonDocument::fromJson(this->settingsFile->readAll());
|
||||||
|
|
||||||
|
if(doc.toVariant().type() != QVariant::Map)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
this->settingsCache = doc.toVariant().toMap();
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -16,7 +16,7 @@
|
||||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "headers/scstwapptheme.h"
|
#include "scstwapptheme.h"
|
||||||
|
|
||||||
ScStwAppTheme::ScStwAppTheme(QString name, QVariantMap colors, QVariantMap icons, QVariantMap fonts, QVariantMap images, QObject *parent) : QObject(parent)
|
ScStwAppTheme::ScStwAppTheme(QString name, QVariantMap colors, QVariantMap icons, QVariantMap fonts, QVariantMap images, QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
|
@ -16,7 +16,7 @@
|
||||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "../headers/scstwappthememanager.h"
|
#include "scstwappthememanager.h"
|
||||||
|
|
||||||
ScStwAppThemeManager::ScStwAppThemeManager(QObject *parent) : QObject(parent)
|
ScStwAppThemeManager::ScStwAppThemeManager(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
1
ScStwStyling/.gitignore
vendored
1
ScStwStyling/.gitignore
vendored
|
@ -1 +0,0 @@
|
||||||
/build/
|
|
|
@ -1,21 +0,0 @@
|
||||||
!isEmpty(SCSTWSTYLING_LIB):error("ScStwLibraries.pri already included")
|
|
||||||
SCSTWSTYLING_LIB = 1
|
|
||||||
|
|
||||||
#DEPENDS
|
|
||||||
CONFIG(release, debug|release): {
|
|
||||||
SCSTWSTYLING_LIB_OUTPUT_DIR="$$PWD/build/release"
|
|
||||||
} else {
|
|
||||||
SCSTWSTYLING_LIB_OUTPUT_DIR="$$PWD/build/debug"
|
|
||||||
}
|
|
||||||
|
|
||||||
unix:LIBS += -L$$SCSTWSTYLING_LIB_OUTPUT_DIR -lScStwStyling
|
|
||||||
|
|
||||||
win32:LIBS += -L$$SCSTWSTYLING_LIB_OUTPUT_DIR -lScStwStyling1
|
|
||||||
|
|
||||||
android {
|
|
||||||
ANDROID_EXTRA_LIBS += $$SCSTWSTYLING_LIB_OUTPUT_DIR/libScStwStyling.so
|
|
||||||
}
|
|
||||||
|
|
||||||
QML_IMPORT_PATH = "$$PWD/resources/qml/lib"
|
|
||||||
INCLUDEPATH += "$$PWD"
|
|
||||||
INCLUDEPATH += "$$PWD"/headers
|
|
|
@ -1,42 +0,0 @@
|
||||||
QT += gui qml
|
|
||||||
|
|
||||||
TEMPLATE = lib
|
|
||||||
DEFINES += SCSTWSTYLING_LIBRARY
|
|
||||||
|
|
||||||
CONFIG += c++11
|
|
||||||
|
|
||||||
# The following define makes your compiler emit warnings if you use
|
|
||||||
# any Qt feature that has been marked deprecated (the exact warnings
|
|
||||||
# depend on your compiler). Please consult the documentation of the
|
|
||||||
# deprecated API in order to know how to port your code away from it.
|
|
||||||
DEFINES += QT_DEPRECATED_WARNINGS
|
|
||||||
|
|
||||||
# You can also make your code fail to compile if it uses deprecated APIs.
|
|
||||||
# In order to do so, uncomment the following line.
|
|
||||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
sources/scstwapptheme.cpp \
|
|
||||||
sources/scstwappthememanager.cpp \
|
|
||||||
sources/scstwstyling.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
|
||||||
headers/scstwapptheme.h \
|
|
||||||
headers/scstwappthememanager.h \
|
|
||||||
headers/scstwstyling.h
|
|
||||||
|
|
||||||
RESOURCES += \
|
|
||||||
resources/qml/ScStwStylingQml.qrc \
|
|
||||||
resources/shared/ScStwStylingShared.qrc \
|
|
||||||
|
|
||||||
#DEPENDS
|
|
||||||
CONFIG(release, debug|release): {
|
|
||||||
DESTDIR="$$PWD/build/release"
|
|
||||||
} else {
|
|
||||||
DESTDIR="$$PWD/build/debug"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Default rules for deployment.
|
|
||||||
target.path = /usr/local/lib
|
|
||||||
!isEmpty(target.path): INSTALLS += target
|
|
BIN
favicon.xcf
BIN
favicon.xcf
Binary file not shown.
|
@ -1,2 +0,0 @@
|
||||||
dpkg-deb --build debian
|
|
||||||
mv debian.deb libScStwSharedLibraries.deb
|
|
|
@ -1,9 +0,0 @@
|
||||||
Package: libScStwSharedLibraries
|
|
||||||
Version: 1.1.0
|
|
||||||
Section: base
|
|
||||||
Priority: optional
|
|
||||||
Architecture: armhf
|
|
||||||
Depends: libqt5raspi-5.12.5 (>=1.0)
|
|
||||||
Maintainer: Dorian Zedler <dorian@itsblue.de>
|
|
||||||
Description: ScStwSharedLibraries
|
|
||||||
This package contains all libraries used in the ScStw Project
|
|
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# reload ld path
|
|
||||||
ldconfig
|
|
|
@ -1 +0,0 @@
|
||||||
libQt-Secret.so.1.2.0
|
|
|
@ -1 +0,0 @@
|
||||||
libQt-Secret.so.1.2.0
|
|
|
@ -1 +0,0 @@
|
||||||
libQt-Secret.so.1.2.0
|
|
Binary file not shown.
|
@ -1 +0,0 @@
|
||||||
libScStwLibraries.so.1.0.0
|
|
|
@ -1 +0,0 @@
|
||||||
libScStwLibraries.so.1.0.0
|
|
|
@ -1 +0,0 @@
|
||||||
libScStwLibraries.so.1.0.0
|
|
Binary file not shown.
|
@ -1 +0,0 @@
|
||||||
libScStwStyling.so.1.0.0
|
|
|
@ -1 +0,0 @@
|
||||||
libScStwStyling.so.1.0.0
|
|
|
@ -1 +0,0 @@
|
||||||
libScStwStyling.so.1.0.0
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
3
test
3
test
|
@ -1,3 +0,0 @@
|
||||||
test for submodule
|
|
||||||
test2
|
|
||||||
test3
|
|
Reference in a new issue