aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/preferences.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-09-25 16:15:37 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-30 10:36:50 -0700
commit1d2d046c0f80d8884d783aad57340c9b6867985a (patch)
tree1af74f6bf1fdc91a04078afb6d940fb71c42ecb9 /desktop-widgets/preferences.cpp
parent7cd9e2b7bb101719ec5c50a10fc889ba4b7bd9c5 (diff)
downloadsubsurface-1d2d046c0f80d8884d783aad57340c9b6867985a.tar.gz
Preferences: Port the default preferences to the new system
Simple port of the default preferences to the new preferences structure. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/preferences.cpp')
-rw-r--r--desktop-widgets/preferences.cpp83
1 files changed, 2 insertions, 81 deletions
diff --git a/desktop-widgets/preferences.cpp b/desktop-widgets/preferences.cpp
index 6450c41cb..cb19ce759 100644
--- a/desktop-widgets/preferences.cpp
+++ b/desktop-widgets/preferences.cpp
@@ -118,12 +118,8 @@ void PreferencesDialog::cloudPinNeeded()
ui.cloud_storage_new_passwd_label->setVisible(prefs.cloud_verification_status == CS_VERIFIED);
if (prefs.cloud_verification_status == CS_VERIFIED) {
ui.cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (credentials verified)"));
- ui.cloudDefaultFile->setEnabled(true);
} else {
ui.cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage"));
- if (ui.cloudDefaultFile->isChecked())
- ui.noDefaultFile->setChecked(true);
- ui.cloudDefaultFile->setEnabled(false);
}
MainWindow::instance()->enableDisableCloudActions();
}
@@ -186,24 +182,11 @@ void PreferencesDialog::setUiFromPrefs()
ui.kg->setChecked(prefs.units.weight == units::KG);
ui.lbs->setChecked(prefs.units.weight == units::LBS);
- ui.font->setCurrentFont(QString(prefs.divelist_font));
- ui.fontsize->setValue(prefs.font_size);
- ui.defaultfilename->setText(prefs.default_filename);
- ui.noDefaultFile->setChecked(prefs.default_file_behavior == NO_DEFAULT_FILE);
- ui.cloudDefaultFile->setChecked(prefs.default_file_behavior == CLOUD_DEFAULT_FILE);
- ui.localDefaultFile->setChecked(prefs.default_file_behavior == LOCAL_DEFAULT_FILE);
- ui.default_cylinder->clear();
- for (int i = 0; tank_info[i].name != NULL; i++) {
- ui.default_cylinder->addItem(tank_info[i].name);
- if (prefs.default_cylinder && strcmp(tank_info[i].name, prefs.default_cylinder) == 0)
- ui.default_cylinder->setCurrentIndex(i);
- }
- ui.displayinvalid->setChecked(prefs.display_invalid_dives);
ui.display_unused_tanks->setChecked(prefs.display_unused_tanks);
ui.show_average_depth->setChecked(prefs.show_average_depth);
ui.vertical_speed_minutes->setChecked(prefs.units.vertical_speed_time == units::MINUTES);
ui.vertical_speed_seconds->setChecked(prefs.units.vertical_speed_time == units::SECONDS);
- ui.velocitySlider->setValue(prefs.animation_speed);
+
QSortFilterProxyModel *filterModel = new QSortFilterProxyModel();
filterModel->setSourceModel(LanguageModel::instance());
@@ -232,7 +215,7 @@ void PreferencesDialog::setUiFromPrefs()
ui.proxyUsername->setText(prefs.proxy_user);
ui.proxyPassword->setText(prefs.proxy_pass);
ui.proxyType->setCurrentIndex(ui.proxyType->findData(prefs.proxy_type));
- ui.btnUseDefaultFile->setChecked(prefs.use_default_file);
+
ui.cloud_storage_email->setText(prefs.cloud_storage_email);
ui.cloud_storage_password->setText(prefs.cloud_storage_password);
@@ -302,27 +285,11 @@ void PreferencesDialog::syncSettings()
// Defaults
s.beginGroup("GeneralSettings");
- s.setValue("default_filename", ui.defaultfilename->text());
- s.setValue("default_cylinder", ui.default_cylinder->currentText());
- s.setValue("use_default_file", ui.btnUseDefaultFile->isChecked());
- if (ui.noDefaultFile->isChecked())
- s.setValue("default_file_behavior", NO_DEFAULT_FILE);
- else if (ui.localDefaultFile->isChecked())
- s.setValue("default_file_behavior", LOCAL_DEFAULT_FILE);
- else if (ui.cloudDefaultFile->isChecked())
- s.setValue("default_file_behavior", CLOUD_DEFAULT_FILE);
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("Display");
- SAVE_OR_REMOVE_SPECIAL("divelist_font", system_divelist_default_font, ui.font->currentFont().toString(), ui.font->currentFont());
- SAVE_OR_REMOVE("font_size", system_divelist_default_font_size, ui.fontsize->value());
- s.setValue("displayinvalid", ui.displayinvalid->isChecked());
- s.endGroup();
- s.sync();
-
// Locale
QLocale loc;
s.beginGroup("Language");
@@ -336,11 +303,6 @@ void PreferencesDialog::syncSettings()
s.setValue("UiLanguage", ui.languageView->currentIndex().data(Qt::UserRole));
s.endGroup();
- // Animation
- s.beginGroup("Animations");
- s.setValue("animation_speed", ui.velocitySlider->value());
- s.endGroup();
-
s.beginGroup("Network");
s.setValue("proxy_type", ui.proxyType->itemData(ui.proxyType->currentIndex()).toInt());
s.setValue("proxy_host", ui.proxyHost->text());
@@ -445,10 +407,6 @@ void PreferencesDialog::loadSettings()
ui.save_uid_local->setChecked(s.value("save_uid_local").toBool());
ui.default_uid->setText(s.value("subsurface_webservice_uid").toString().toUpper());
-
- ui.defaultfilename->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE);
- ui.btnUseDefaultFile->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE);
- ui.chooseFile->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE);
}
void PreferencesDialog::buttonClicked(QAbstractButton *button)
@@ -472,15 +430,6 @@ void PreferencesDialog::buttonClicked(QAbstractButton *button)
}
#undef SB
-void PreferencesDialog::on_chooseFile_clicked()
-{
- QFileInfo fi(system_default_filename());
- QString choosenFileName = QFileDialog::getOpenFileName(this, tr("Open default log file"), fi.absolutePath(), tr("Subsurface XML files (*.ssrf *.xml *.XML)"));
-
- if (!choosenFileName.isEmpty())
- ui.defaultfilename->setText(choosenFileName);
-}
-
void PreferencesDialog::on_resetSettings_clicked()
{
QSettings s;
@@ -529,31 +478,3 @@ void PreferencesDialog::proxyType_changed(int idx)
ui.proxyPassword->setEnabled(hpEnabled & ui.proxyAuthRequired->isChecked());
ui.proxyAuthRequired->setChecked(ui.proxyAuthRequired->isChecked());
}
-
-void PreferencesDialog::on_btnUseDefaultFile_toggled(bool toggle)
-{
- if (toggle) {
- ui.defaultfilename->setText(system_default_filename());
- ui.defaultfilename->setEnabled(false);
- } else {
- ui.defaultfilename->setEnabled(true);
- }
-}
-
-void PreferencesDialog::on_noDefaultFile_toggled(bool toggle)
-{
- prefs.default_file_behavior = NO_DEFAULT_FILE;
-}
-
-void PreferencesDialog::on_localDefaultFile_toggled(bool toggle)
-{
- ui.defaultfilename->setEnabled(toggle);
- ui.btnUseDefaultFile->setEnabled(toggle);
- ui.chooseFile->setEnabled(toggle);
- prefs.default_file_behavior = LOCAL_DEFAULT_FILE;
-}
-
-void PreferencesDialog::on_cloudDefaultFile_toggled(bool toggle)
-{
- prefs.default_file_behavior = CLOUD_DEFAULT_FILE;
-}