void PreferencesGraph::syncSettings() { QSettings s; s.beginGroup("GeneralSettings"); s.setValue("defaultsetpoint", rint(ui->defaultSetpoint->value() * 1000.0)); s.setValue("o2consumption", rint(ui->psro2rate->value() *1000.0)); s.setValue("pscr_ratio", rint(1000.0 / ui->pscrfactor->value())); s.endGroup(); s.beginGroup("TecDetails"); SAVE_OR_REMOVE("phethreshold", default_prefs.pp_graphs.phe_threshold, ui->pheThreshold->value()); SAVE_OR_REMOVE("po2threshold", default_prefs.pp_graphs.po2_threshold, ui->po2Threshold->value()); SAVE_OR_REMOVE("pn2threshold", default_prefs.pp_graphs.pn2_threshold, ui->pn2Threshold->value()); SAVE_OR_REMOVE("modpO2", default_prefs.modpO2, ui->maxpo2->value()); SAVE_OR_REMOVE("redceiling", default_prefs.redceiling, ui->red_ceiling->isChecked()); SAVE_OR_REMOVE("gflow", default_prefs.gflow, ui->gflow->value()); SAVE_OR_REMOVE("gfhigh", default_prefs.gfhigh, ui->gfhigh->value()); SAVE_OR_REMOVE("gf_low_at_maxdepth", default_prefs.gf_low_at_maxdepth, ui->gf_low_at_maxdepth->isChecked()); SAVE_OR_REMOVE("show_ccr_setpoint", default_prefs.show_ccr_setpoint, ui->show_ccr_setpoint->isChecked()); SAVE_OR_REMOVE("show_ccr_sensors", default_prefs.show_ccr_sensors, ui->show_ccr_sensors->isChecked()); SAVE_OR_REMOVE("display_unused_tanks", default_prefs.display_unused_tanks, ui->display_unused_tanks->isChecked()); SAVE_OR_REMOVE("show_average_depth", default_prefs.show_average_depth, ui->show_average_depth->isChecked()); s.endGroup(); }
void PreferencesNetwork::syncSettings() { QSettings s; s.setValue("subsurface_webservice_uid", ui->default_uid->text().toUpper()); set_save_userid_local(ui->save_uid_local->checkState()); s.beginGroup("Network"); s.setValue("proxy_type", ui->proxyType->itemData(ui->proxyType->currentIndex()).toInt()); s.setValue("proxy_host", ui->proxyHost->text()); s.setValue("proxy_port", ui->proxyPort->value()); SB("proxy_auth", ui->proxyAuthRequired); s.setValue("proxy_user", ui->proxyUsername->text()); s.setValue("proxy_pass", ui->proxyPassword->text()); s.endGroup(); s.beginGroup("CloudStorage"); QString email = ui->cloud_storage_email->text(); QString password = ui->cloud_storage_password->text(); QString newpassword = ui->cloud_storage_new_passwd->text(); if (prefs.cloud_verification_status == CS_VERIFIED && !newpassword.isEmpty()) { // deal with password change if (!email.isEmpty() && !password.isEmpty()) { // connect to backend server to check / create credentials QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$"); if (!reg.match(email).hasMatch() || (!password.isEmpty() && !reg.match(password).hasMatch())) { report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'."))); } else { CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this); connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(cloudPinNeeded())); connect(cloudAuth, SIGNAL(passwordChangeSuccessful()), this, SLOT(passwordUpdateSuccessfull())); QNetworkReply *reply = cloudAuth->backend(email, password, "", newpassword); ui->cloud_storage_new_passwd->setText(""); free(prefs.cloud_storage_newpassword); prefs.cloud_storage_newpassword = strdup(qPrintable(newpassword)); } } } else if (prefs.cloud_verification_status == CS_UNKNOWN || prefs.cloud_verification_status == CS_INCORRECT_USER_PASSWD || email != prefs.cloud_storage_email || password != prefs.cloud_storage_password) { // different credentials - reset verification status prefs.cloud_verification_status = CS_UNKNOWN; if (!email.isEmpty() && !password.isEmpty()) { // connect to backend server to check / create credentials QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$"); if (!reg.match(email).hasMatch() || (!password.isEmpty() && !reg.match(password).hasMatch())) { report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'."))); } else { CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this); connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(cloudPinNeeded())); QNetworkReply *reply = cloudAuth->backend(email, password); } } } else if (prefs.cloud_verification_status == CS_NEED_TO_VERIFY) { QString pin = ui->cloud_storage_pin->text(); if (!pin.isEmpty()) { // connect to backend server to check / create credentials QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$"); if (!reg.match(email).hasMatch() || !reg.match(password).hasMatch()) { report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'."))); } CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this); connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(cloudPinNeeded())); QNetworkReply *reply = cloudAuth->backend(email, password, pin); } } SAVE_OR_REMOVE("email", default_prefs.cloud_storage_email, email); SAVE_OR_REMOVE("save_password_local", default_prefs.save_password_local, ui->save_password_local->isChecked()); if (ui->save_password_local->isChecked()) { SAVE_OR_REMOVE("password", default_prefs.cloud_storage_password, password); } else { s.remove("password"); free(prefs.cloud_storage_password); prefs.cloud_storage_password = strdup(qPrintable(password)); } SAVE_OR_REMOVE("cloud_verification_status", default_prefs.cloud_verification_status, prefs.cloud_verification_status); SAVE_OR_REMOVE("cloud_background_sync", default_prefs.cloud_background_sync, ui->cloud_background_sync->isChecked()); // at this point we intentionally do not have a UI for changing this // it could go into some sort of "advanced setup" or something SAVE_OR_REMOVE("cloud_base_url", default_prefs.cloud_base_url, prefs.cloud_base_url); s.endGroup(); }