Skip to content

Commit

Permalink
Added code to receive settings from Android app
Browse files Browse the repository at this point in the history
  • Loading branch information
km2442 committed Jun 25, 2019
1 parent a860c5c commit 6960a2d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Windows/AutoSwitch/Source/Classes/communicatorthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
18 changes: 17 additions & 1 deletion Windows/AutoSwitch/Source/Main/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<int>(json.value("TrayVisible").toBool()));
ui->Settings_Log->setCurrentIndex(static_cast<int>(json.value("Logs").toBool()));
ui->Settings_Statistics->setCurrentIndex(static_cast<int>(json.value("Statistics").toBool()));
ui->Settings_MultiInstance->setCurrentIndex(static_cast<int>(json.value("MultiInstance").toBool()));
ui->Settings_DeveloperMode->setCurrentIndex(static_cast<int>(json.value("TestMode").toBool()));
ui->Settings_HideDialogWarning->setCurrentIndex(static_cast<int>(json.value("HideWarning").toBool()));

settingsSave(0, "");
settingsLoad();
qApp->processEvents();
}

void Settings::on_Settings_PasswordButton_clicked()
{
PasswordConfig *pc = PasswordConfig::getInstance();
Expand Down
1 change: 1 addition & 0 deletions Windows/AutoSwitch/Source/Main/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6960a2d

Please sign in to comment.