mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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>
This commit is contained in:
parent
7cd9e2b7bb
commit
1d2d046c0f
8 changed files with 402 additions and 361 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ signals:
|
|||
public
|
||||
slots:
|
||||
void buttonClicked(QAbstractButton *button);
|
||||
void on_chooseFile_clicked();
|
||||
void on_resetSettings_clicked();
|
||||
void syncSettings();
|
||||
void loadSettings();
|
||||
|
@ -33,10 +32,6 @@ slots:
|
|||
void gflowChanged(int gf);
|
||||
void gfhighChanged(int gf);
|
||||
void proxyType_changed(int idx);
|
||||
void on_btnUseDefaultFile_toggled(bool toggle);
|
||||
void on_noDefaultFile_toggled(bool toggle);
|
||||
void on_localDefaultFile_toggled(bool toggle);
|
||||
void on_cloudDefaultFile_toggled(bool toggle);
|
||||
void facebookLoggedIn();
|
||||
void facebookDisconnect();
|
||||
void cloudPinNeeded();
|
||||
|
|
|
@ -164,7 +164,7 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="defaults_page">
|
||||
<property name="sizePolicy">
|
||||
|
@ -180,232 +180,6 @@
|
|||
<property name="margin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Lists and tables</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||
<property name="margin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Font</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFontComboBox" name="font"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Font size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="fontsize"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Dives</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="horizontalSpacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="defaultDiveLogFileLabel">
|
||||
<property name="text">
|
||||
<string>Default dive log file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="defaultFileBehaviorLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="noDefaultFile">
|
||||
<property name="text">
|
||||
<string>No default file</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">defaultFileGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="localDefaultFile">
|
||||
<property name="text">
|
||||
<string>&Local default file</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">defaultFileGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="cloudDefaultFile">
|
||||
<property name="text">
|
||||
<string>Clo&ud storage default file</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">defaultFileGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Local dive log file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3b">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="defaultfilename"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnUseDefaultFile">
|
||||
<property name="text">
|
||||
<string>Use default</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="chooseFile">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Display invalid</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="displayinvalid">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<property name="title">
|
||||
<string>Default cylinder</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_6">
|
||||
<property name="horizontalSpacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Use default cylinder</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QComboBox" name="default_cylinder"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_7">
|
||||
<property name="title">
|
||||
<string>Animations</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<property name="margin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Speed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="velocitySlider">
|
||||
<property name="maximum">
|
||||
<number>500</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="velocitySpinBox">
|
||||
<property name="maximum">
|
||||
<number>500</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_9">
|
||||
<property name="title">
|
||||
<string>Clear all settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7b">
|
||||
<property name="spacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="resetSettings">
|
||||
<property name="text">
|
||||
<string>Reset all settings to their default value</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
|
@ -1788,38 +1562,6 @@
|
|||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>velocitySlider</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>velocitySpinBox</receiver>
|
||||
<slot>setValue(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>236</x>
|
||||
<y>52</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>236</x>
|
||||
<y>52</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>velocitySpinBox</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>velocitySlider</receiver>
|
||||
<slot>setValue(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>236</x>
|
||||
<y>52</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>236</x>
|
||||
<y>52</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>proxyAuthRequired</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
|
@ -1852,22 +1594,6 @@
|
|||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>btnUseDefaultFile</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>chooseFile</receiver>
|
||||
<slot>setHidden(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>236</x>
|
||||
<y>44</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>236</x>
|
||||
<y>44</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<buttongroups>
|
||||
<buttongroup name="verticalSpeed"/>
|
||||
|
|
|
@ -14,6 +14,7 @@ set(SUBSURFACE_PREFERENCES_LIB_SRCS
|
|||
preferencesdialog.cpp
|
||||
preferences_language.cpp
|
||||
preferences_georeference.cpp
|
||||
preferences_defaults.cpp
|
||||
)
|
||||
|
||||
source_group("Subsurface Preferences" FILES ${SUBSURFACE_PREFERENCES_LIB_SRCS})
|
||||
|
|
115
desktop-widgets/preferences/preferences_defaults.cpp
Normal file
115
desktop-widgets/preferences/preferences_defaults.cpp
Normal file
|
@ -0,0 +1,115 @@
|
|||
#include "preferences_defaults.h"
|
||||
#include "ui_preferences_defaults.h"
|
||||
#include "dive.h"
|
||||
#include "subsurface-core/prefs-macros.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QFileDialog>
|
||||
|
||||
PreferencesDefaults::PreferencesDefaults(): AbstractPreferencesWidget(tr("Defaults"), QIcon(":defaults"), 0 ), ui(new Ui::PreferencesDefaults())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
PreferencesDefaults::~PreferencesDefaults()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PreferencesDefaults::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 PreferencesDefaults::on_btnUseDefaultFile_toggled(bool toggle)
|
||||
{
|
||||
if (toggle) {
|
||||
ui->defaultfilename->setText(system_default_filename());
|
||||
ui->defaultfilename->setEnabled(false);
|
||||
} else {
|
||||
ui->defaultfilename->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void PreferencesDefaults::on_noDefaultFile_toggled(bool toggle)
|
||||
{
|
||||
prefs.default_file_behavior = NO_DEFAULT_FILE;
|
||||
}
|
||||
|
||||
void PreferencesDefaults::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 PreferencesDefaults::on_cloudDefaultFile_toggled(bool toggle)
|
||||
{
|
||||
prefs.default_file_behavior = CLOUD_DEFAULT_FILE;
|
||||
}
|
||||
|
||||
void PreferencesDefaults::refreshSettings()
|
||||
{
|
||||
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->velocitySlider->setValue(prefs.animation_speed);
|
||||
ui->btnUseDefaultFile->setChecked(prefs.use_default_file);
|
||||
|
||||
if (prefs.cloud_verification_status == CS_VERIFIED) {
|
||||
ui->cloudDefaultFile->setEnabled(true);
|
||||
} else {
|
||||
if (ui->cloudDefaultFile->isChecked())
|
||||
ui->noDefaultFile->setChecked(true);
|
||||
ui->cloudDefaultFile->setEnabled(false);
|
||||
}
|
||||
|
||||
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 PreferencesDefaults::syncSettings()
|
||||
{
|
||||
QSettings s;
|
||||
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.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();
|
||||
|
||||
// Animation
|
||||
s.beginGroup("Animations");
|
||||
s.setValue("animation_speed", ui->velocitySlider->value());
|
||||
s.endGroup();
|
||||
}
|
30
desktop-widgets/preferences/preferences_defaults.h
Normal file
30
desktop-widgets/preferences/preferences_defaults.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
#ifndef PREFERENCES_DEFAULTS_H
|
||||
#define PREFERENCES_DEFAULTS_H
|
||||
|
||||
#include "abstractpreferenceswidget.h"
|
||||
#include "subsurface-core/pref.h"
|
||||
|
||||
namespace Ui {
|
||||
class PreferencesDefaults;
|
||||
}
|
||||
|
||||
class PreferencesDefaults : public AbstractPreferencesWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PreferencesDefaults();
|
||||
virtual ~PreferencesDefaults();
|
||||
virtual void refreshSettings();
|
||||
virtual void syncSettings();
|
||||
public slots:
|
||||
void on_chooseFile_clicked();
|
||||
void on_btnUseDefaultFile_toggled(bool toggled);
|
||||
void on_noDefaultFile_toggled(bool toggled);
|
||||
void on_localDefaultFile_toggled(bool toggled);
|
||||
void on_cloudDefaultFile_toggled(bool toggled);
|
||||
|
||||
private:
|
||||
Ui::PreferencesDefaults *ui;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
251
desktop-widgets/preferences/preferences_defaults.ui
Normal file
251
desktop-widgets/preferences/preferences_defaults.ui
Normal file
|
@ -0,0 +1,251 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PreferencesDefaults</class>
|
||||
<widget class="QWidget" name="PreferencesDefaults">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>555</width>
|
||||
<height>558</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Lists and tables</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||
<property name="margin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Font</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFontComboBox" name="font"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Font size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="fontsize"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Dives</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="horizontalSpacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="defaultDiveLogFileLabel">
|
||||
<property name="text">
|
||||
<string>Default dive log file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="defaultFileBehaviorLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="noDefaultFile">
|
||||
<property name="text">
|
||||
<string>No default file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="localDefaultFile">
|
||||
<property name="text">
|
||||
<string>&Local default file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="cloudDefaultFile">
|
||||
<property name="text">
|
||||
<string>Clo&ud storage default file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Local dive log file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3b">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="defaultfilename"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnUseDefaultFile">
|
||||
<property name="text">
|
||||
<string>Use default</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="chooseFile">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Display invalid</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="displayinvalid">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<property name="title">
|
||||
<string>Default cylinder</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_6">
|
||||
<property name="horizontalSpacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Use default cylinder</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QComboBox" name="default_cylinder"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_7">
|
||||
<property name="title">
|
||||
<string>Animations</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<property name="margin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Speed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="velocitySlider">
|
||||
<property name="maximum">
|
||||
<number>500</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="velocitySpinBox">
|
||||
<property name="maximum">
|
||||
<number>500</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_9">
|
||||
<property name="title">
|
||||
<string>Clear all settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7b">
|
||||
<property name="spacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="resetSettings">
|
||||
<property name="text">
|
||||
<string>Reset all settings to their default value</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>195</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -3,6 +3,7 @@
|
|||
#include "abstractpreferenceswidget.h"
|
||||
#include "preferences_language.h"
|
||||
#include "preferences_georeference.h"
|
||||
#include "preferences_defaults.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
@ -35,6 +36,7 @@ PreferencesDialogV2::PreferencesDialogV2()
|
|||
|
||||
addPreferencePage(new PreferencesLanguage());
|
||||
addPreferencePage(new PreferencesGeoreference());
|
||||
addPreferencePage(new PreferencesDefaults());
|
||||
refreshPages();
|
||||
|
||||
connect(pagesList, &QListWidget::currentRowChanged,
|
||||
|
|
Loading…
Reference in a new issue