diff --git a/Windows/AutoSwitch/Source/Classes/communicatorthread.cpp b/Windows/AutoSwitch/Source/Classes/communicatorthread.cpp index 36766a8..948cb32 100644 --- a/Windows/AutoSwitch/Source/Classes/communicatorthread.cpp +++ b/Windows/AutoSwitch/Source/Classes/communicatorthread.cpp @@ -47,6 +47,15 @@ void CommunicatorThread::readyRead() qDebug() << "Data out: " << json; socket->write(json); } + else if(jsonObject.value("Exec").toString() == "SetSettings") + { + Settings *s = Settings::getInstance(); + s->JsonToSettings(jsonObject.value("PCSettings").toObject()); + + QByteArray res = "Settings Setted\n"; + qDebug() << "Data out: " << res; + socket->write(res); + } } void CommunicatorThread::disconnected() diff --git a/Windows/AutoSwitch/Source/Main/settings.cpp b/Windows/AutoSwitch/Source/Main/settings.cpp index 71d4c5f..b3b194f 100644 --- a/Windows/AutoSwitch/Source/Main/settings.cpp +++ b/Windows/AutoSwitch/Source/Main/settings.cpp @@ -695,7 +695,7 @@ QJsonObject Settings::settingsToJson() { QJsonObject qjo; qjo["Type"] = "Settings"; - qjo["Language"] = language; + qjo["Language"] = language - 1; qjo["Theme"] = current_theme; qjo["TrayVisible"] = TrayVisible; qjo["Statistics"] = sendStatistics; @@ -707,6 +707,22 @@ QJsonObject Settings::settingsToJson() return qjo; } +void Settings::JsonToSettings(QJsonObject json) +{ + ui->Settings_Theme_Choose->setCurrentIndex(json.value("Theme").toInt()); + ui->Settings_LanguageSelect->setCurrentIndex(json.value("Language").toInt()); + ui->Settings_Tray_Switch->setCurrentIndex(static_cast(json.value("TrayVisible").toBool())); + ui->Settings_Log->setCurrentIndex(static_cast(json.value("Logs").toBool())); + ui->Settings_Statistics->setCurrentIndex(static_cast(json.value("Statistics").toBool())); + ui->Settings_MultiInstance->setCurrentIndex(static_cast(json.value("MultiInstance").toBool())); + ui->Settings_DeveloperMode->setCurrentIndex(static_cast(json.value("TestMode").toBool())); + ui->Settings_HideDialogWarning->setCurrentIndex(static_cast(json.value("HideWarning").toBool())); + + settingsSave(0, ""); + settingsLoad(); + qApp->processEvents(); +} + void Settings::on_Settings_PasswordButton_clicked() { PasswordConfig *pc = PasswordConfig::getInstance(); diff --git a/Windows/AutoSwitch/Source/Main/settings.h b/Windows/AutoSwitch/Source/Main/settings.h index bcc56a7..ad9e2a4 100644 --- a/Windows/AutoSwitch/Source/Main/settings.h +++ b/Windows/AutoSwitch/Source/Main/settings.h @@ -43,6 +43,7 @@ class Settings : public QDialog void settingsLoad(); void changeHideDialog(bool i); QJsonObject settingsToJson(); + void JsonToSettings(QJsonObject json); ~Settings(); int getCurrent_theme() const;