Library migration #36
9 changed files with 46 additions and 73 deletions
|
@ -55,7 +55,7 @@ private slots:
|
|||
void refreshMode();
|
||||
void reloadRaceSettings();
|
||||
void reloadBaseStationIpAdress();
|
||||
void handleSettingChange(int keyInt, int keyLevel);
|
||||
void handleSettingChange(int keyInt, int keyLevel, QVariant value);
|
||||
|
||||
signals:
|
||||
void modeChanged();
|
||||
|
|
|
@ -11,7 +11,6 @@ class ScStwAppSettings : public ScStwRemoteSettings
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit ScStwAppSettings(ScStwClient * scStwClient, QObject *parent = nullptr);
|
||||
~ScStwAppSettings();
|
||||
|
||||
enum AppInternalSetting {
|
||||
InvalidSetting = -1,
|
||||
|
@ -27,12 +26,14 @@ public:
|
|||
|
||||
using ScStwSettings::readSetting;
|
||||
Q_INVOKABLE QVariant readSetting(AppInternalSetting key);
|
||||
Q_INVOKABLE QVariant readSetting(int key, int level);
|
||||
using ScStwSettings::writeSetting;
|
||||
Q_INVOKABLE bool writeSetting(AppInternalSetting key, QVariant value);
|
||||
Q_INVOKABLE bool writeSetting(int key, QVariant value, int level);
|
||||
using ScStwSettings::setDefaultSetting;
|
||||
Q_INVOKABLE void setDefaultSetting(AppInternalSetting key, QVariant defaultVariant);
|
||||
Q_INVOKABLE bool setDefaultSetting(AppInternalSetting key, QVariant defaultValue);
|
||||
|
||||
static QString keyToString(int key) {
|
||||
return QMetaEnum::fromType<AppInternalSetting>().valueToKey(key);
|
||||
}
|
||||
|
||||
signals:
|
||||
|
||||
|
|
|
@ -220,25 +220,21 @@ Column {
|
|||
|
||||
SmoothSliderDelegate {
|
||||
id: baseStationVolumeDel
|
||||
|
||||
property ScStwSetting setting: speedBackend.settings.getSetting(ScStwSettings.SoundVolumeSetting, ScStwSettings.KeyLevel)
|
||||
|
||||
text: qsTr("volume")
|
||||
|
||||
width: parent.width
|
||||
height: parentObj.delegateHeight
|
||||
|
||||
sliderValue: 0
|
||||
sliderValue: setting.value
|
||||
|
||||
onSliderFinished: {
|
||||
enabled = false
|
||||
speedBackend.settings.writeSetting(ScStwSettings.SoundVolumeSetting, sliderValue, ScStwSettings.KeyLevel)
|
||||
setting.value = sliderValue
|
||||
enabled = true
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
var val = speedBackend.settings.readSetting(ScStwSettings.SoundVolumeSetting, ScStwSettings.KeyLevel)
|
||||
if(val !== "false"){
|
||||
sliderValue = parseFloat(val)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,26 +34,27 @@ Column {
|
|||
SmoothSwitchDelegate {
|
||||
id: ready_del
|
||||
|
||||
property bool busy: false
|
||||
property ScStwSetting setting: speedBackend.settings.getSetting(ScStwSettings.ReadySoundEnableSetting, ScStwSettings.KeyLevel)
|
||||
|
||||
width: parent.width
|
||||
height: parentObj.delegateHeight
|
||||
|
||||
enabled: !busy
|
||||
|
||||
text: qsTr("say 'ready'")
|
||||
|
||||
checked: parent.loadSetting(ScStwSettings.ReadySoundEnableSetting, ready_del)
|
||||
checked: setting.value
|
||||
|
||||
onCheckedChanged: {
|
||||
parent.updateSetting(ScStwSettings.ReadySoundEnableSetting, checked, ready_del)
|
||||
enabled = false
|
||||
setting.value = checked
|
||||
enabled = true
|
||||
}
|
||||
|
||||
text: qsTr("say 'ready'")
|
||||
}
|
||||
|
||||
InputDelegate {
|
||||
id: ready_delay_del
|
||||
|
||||
property bool busy: false
|
||||
property ScStwSetting setting: speedBackend.settings.getSetting(ScStwSettings.ReadySoundDelaySetting, ScStwSettings.KeyLevel)
|
||||
|
||||
width: parent.width
|
||||
height: parentObj.delegateHeight
|
||||
|
@ -64,29 +65,32 @@ Column {
|
|||
inputHint: qsTr("time")
|
||||
inputMethodHints: Qt.ImhFormattedNumbersOnly
|
||||
|
||||
inputText: control.loadSetting(ScStwSettings.ReadySoundDelaySetting, ready_delay_del)
|
||||
inputText: setting.value
|
||||
|
||||
onInputFinished: {
|
||||
control.updateSetting(ScStwSettings.ReadySoundDelaySetting, inputText, ready_delay_del)
|
||||
console.log("input finished")
|
||||
busy = true
|
||||
setting.value = inputText
|
||||
busy = false
|
||||
}
|
||||
}
|
||||
|
||||
SmoothSwitchDelegate {
|
||||
id: at_marks_del
|
||||
|
||||
property bool busy: false
|
||||
property ScStwSetting setting: speedBackend.settings.getSetting(ScStwSettings.AtYourMarksSoundEnableSetting, ScStwSettings.KeyLevel)
|
||||
|
||||
width: parent.width
|
||||
height: parentObj.delegateHeight
|
||||
|
||||
enabled: !busy
|
||||
|
||||
text: qsTr("say 'at your marks'")
|
||||
|
||||
checked: control.loadSetting(ScStwSettings.AtYourMarksSoundEnableSetting , ready_del)
|
||||
checked: setting.value
|
||||
|
||||
onCheckedChanged: {
|
||||
parent.updateSetting(ScStwSettings.AtYourMarksSoundEnableSetting, at_marks_del.checked, at_marks_del)
|
||||
enabled = false
|
||||
setting.value = checked
|
||||
enabled = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,6 +98,7 @@ Column {
|
|||
id: at_marks_delay_del
|
||||
|
||||
property bool busy: false
|
||||
property ScStwSetting setting: speedBackend.settings.getSetting(ScStwSettings.AtYourMarksSoundDelaySetting, ScStwSettings.KeyLevel)
|
||||
|
||||
width: parent.width
|
||||
height: parentObj.delegateHeight
|
||||
|
@ -104,10 +109,12 @@ Column {
|
|||
|
||||
enabled: !busy && at_marks_del.checked
|
||||
|
||||
inputText: control.loadSetting(ScStwSettings.AtYourMarksSoundDelaySetting, at_marks_delay_del)
|
||||
inputText: setting.value
|
||||
|
||||
onInputFinished: {
|
||||
control.updateSetting(ScStwSettings.AtYourMarksSoundDelaySetting, inputText, at_marks_delay_del)
|
||||
busy = true
|
||||
setting.setValue(inputText)
|
||||
busy = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ Column {
|
|||
width: parent.width
|
||||
height: parentObj.delegateHeight
|
||||
|
||||
checked: appThemeSetting.value === "Dark"
|
||||
checked: appTheme.setting === "Dark"
|
||||
|
||||
onCheckedChanged: {
|
||||
appThemeSetting.value = checked ? "Dark":"Light"
|
||||
|
|
|
@ -101,23 +101,13 @@ Window {
|
|||
|
||||
ScStwAppThemeManager {
|
||||
id: appTheme
|
||||
property ScStwSetting setting: speedBackend.settings.getSetting(ScStwAppSettings.AppThemeSetting, ScStwAppSettings.KeyLevel)
|
||||
|
||||
Component.onCompleted: {
|
||||
appTheme.setTheme(speedBackend.settings.readSetting(ScStwAppSettings.AppThemeSetting))
|
||||
}
|
||||
}
|
||||
|
||||
ScStwSetting {
|
||||
id: appThemeSetting
|
||||
scStwSettings: speedBackend.settings
|
||||
key: ScStwAppSettings.AppThemeSetting
|
||||
keyLevel: ScStwAppSettings.KeyLevel
|
||||
|
||||
onValueChanged: {
|
||||
appTheme.setTheme(appThemeSetting.value)
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------
|
||||
Timer text an upper line
|
||||
------------------------*/
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit ad3f8318c709653863058fc234469bd0ff006042
|
||||
Subproject commit f336e953eb86f1a47f6376a6e94c30f82982e606
|
|
@ -209,14 +209,14 @@ void ScStwAppBackend::reloadBaseStationIpAdress() {
|
|||
this->scStwClient->setIP(this->appSettings->readSetting(ScStwAppSettings::BaseStationIpSetting).toString());
|
||||
}
|
||||
|
||||
void ScStwAppBackend::handleSettingChange(int keyInt, int keyLevel) {
|
||||
void ScStwAppBackend::handleSettingChange(int keyInt, int keyLevel, QVariant value) {
|
||||
Q_UNUSED(value)
|
||||
|
||||
if(keyInt == -1) {
|
||||
emit this->settingsChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "setting changed: " << keyInt;
|
||||
|
||||
switch (keyLevel) {
|
||||
case 0: {
|
||||
// BaseStationSetting!!
|
||||
|
@ -227,8 +227,6 @@ void ScStwAppBackend::handleSettingChange(int keyInt, int keyLevel) {
|
|||
default:
|
||||
if(this->mode == LOCAL)
|
||||
this->reloadRaceSettings();
|
||||
else
|
||||
emit this->settingsChanged();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
@ -248,6 +246,4 @@ void ScStwAppBackend::handleSettingChange(int keyInt, int keyLevel) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
emit this->settingsChanged();
|
||||
}
|
||||
|
|
|
@ -22,35 +22,18 @@ ScStwAppSettings * pGlobalAppSettings = nullptr;
|
|||
ScStwAppSettings::ScStwAppSettings(ScStwClient * client, QObject* parent)
|
||||
:ScStwRemoteSettings(client, parent)
|
||||
{
|
||||
this->registerKeyLevelHandler(ScStwAppSettings::KeyLevel, &ScStwAppSettings::keyToString);
|
||||
}
|
||||
|
||||
QVariant ScStwAppSettings::readSetting(AppInternalSetting key) {
|
||||
return ScStwSettings::readSetting(QMetaEnum::fromType<AppInternalSetting>().valueToKey(int(key)), int(key), 1);
|
||||
}
|
||||
|
||||
QVariant ScStwAppSettings::readSetting(int key, int keyLevel) {
|
||||
if(keyLevel == ScStwAppSettings::KeyLevel)
|
||||
return this->readSetting(ScStwAppSettings::AppInternalSetting(key));
|
||||
else
|
||||
return ScStwSettings::readSetting(key, keyLevel);
|
||||
return this->readSetting(key, 1);
|
||||
}
|
||||
|
||||
bool ScStwAppSettings::writeSetting(AppInternalSetting key, QVariant value) {
|
||||
return ScStwSettings::writeSetting(QMetaEnum::fromType<AppInternalSetting>().valueToKey(int(key)), value, int(key), 1);
|
||||
return this->writeSetting(key, 1, value);
|
||||
}
|
||||
|
||||
bool ScStwAppSettings::writeSetting(int key, QVariant value, int keyLevel) {
|
||||
if(keyLevel == ScStwAppSettings::KeyLevel)
|
||||
return this->writeSetting(ScStwAppSettings::AppInternalSetting(key), value);
|
||||
else
|
||||
return ScStwSettings::writeSetting(key, value, keyLevel);
|
||||
}
|
||||
|
||||
void ScStwAppSettings::setDefaultSetting(AppInternalSetting key, QVariant defaultVariant) {
|
||||
ScStwSettings::setDefaultSetting(QMetaEnum::fromType<AppInternalSetting>().valueToKey(int(key)), defaultVariant, int(key), 1);
|
||||
}
|
||||
|
||||
ScStwAppSettings::~ScStwAppSettings()
|
||||
{
|
||||
bool ScStwAppSettings::setDefaultSetting(AppInternalSetting key, QVariant defaultValue) {
|
||||
return this->setDefaultSetting(key, 1, defaultValue);
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue