54 lines
1.8 KiB
C++
54 lines
1.8 KiB
C++
|
#include "../../headers/client/scstwremotesettings.h"
|
||
|
|
||
|
ScStwRemoteSettings::ScStwRemoteSettings(ScStwClient * scStwClient, QObject * parent) : ScStwSettings(parent)
|
||
|
{
|
||
|
this->scStwClient = scStwClient;
|
||
|
|
||
|
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 > 0)
|
||
|
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 > 0)
|
||
|
return ScStwSettings::writeSetting(key, value, keyInt, keyLevel);
|
||
|
|
||
|
this->scStwClient->writeRemoteSetting(ScStwSettings::BaseStationSetting(keyInt), value);
|
||
|
emit this->settingChanged(keyInt, keyLevel);
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
void ScStwRemoteSettings::setDefaultSetting(QString key, QVariant defaultVariant, int keyInt, int keyLevel) {
|
||
|
if(this->getMode() == LOCAL || keyLevel > 0)
|
||
|
return ScStwSettings::setDefaultSetting(key, defaultVariant, keyInt, keyLevel);
|
||
|
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
void ScStwRemoteSettings::handleClientStateChange() {
|
||
|
if(this->scStwClient->getState() == ScStwClient::DISCONNECTED)
|
||
|
emit this->settingChanged(-1, 0);
|
||
|
}
|
||
|
|
||
|
void ScStwRemoteSettings::handleBaseStationSignal(ScStw::SignalKey key, QVariant data) {
|
||
|
switch (key) {
|
||
|
case ScStw::SettingChanged:
|
||
|
emit this->settingChanged(data.toMap()["key"].toInt(), 0);
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
}
|