2013-05-24 18:19:48 +00:00
|
|
|
#include "preferences.h"
|
2013-11-30 17:18:04 +00:00
|
|
|
#include "mainwindow.h"
|
2013-05-24 18:19:48 +00:00
|
|
|
#include <QSettings>
|
2013-06-02 10:52:18 +00:00
|
|
|
#include <QDebug>
|
2013-10-14 04:19:13 +00:00
|
|
|
#include <QFileDialog>
|
2013-12-06 16:29:38 +00:00
|
|
|
#include <QMessageBox>
|
2013-12-06 19:14:50 +00:00
|
|
|
#include <QSortFilterProxyModel>
|
2014-04-25 18:32:02 +00:00
|
|
|
#include <QShortcut>
|
2013-05-24 18:19:48 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
PreferencesDialog *PreferencesDialog::instance()
|
2013-05-24 18:19:48 +00:00
|
|
|
{
|
2014-02-12 14:22:54 +00:00
|
|
|
static PreferencesDialog *dialog = new PreferencesDialog(MainWindow::instance());
|
2013-06-28 12:20:42 +00:00
|
|
|
dialog->setAttribute(Qt::WA_QuitOnClose, false);
|
2013-12-06 16:29:38 +00:00
|
|
|
LanguageModel::instance();
|
2013-05-24 18:19:48 +00:00
|
|
|
return dialog;
|
|
|
|
}
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f)
|
2013-05-24 18:19:48 +00:00
|
|
|
{
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.setupUi(this);
|
2014-02-28 04:09:57 +00:00
|
|
|
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *)));
|
2013-12-04 23:48:37 +00:00
|
|
|
connect(ui.gflow, SIGNAL(valueChanged(int)), this, SLOT(gflowChanged(int)));
|
|
|
|
connect(ui.gfhigh, SIGNAL(valueChanged(int)), this, SLOT(gfhighChanged(int)));
|
2014-04-25 18:32:02 +00:00
|
|
|
QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this);
|
|
|
|
connect(close, SIGNAL(activated()), this, SLOT(close()));
|
|
|
|
QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this);
|
|
|
|
connect(quit, SIGNAL(activated()), parent, SLOT(close()));
|
2014-02-08 17:07:06 +00:00
|
|
|
loadSettings();
|
2013-06-03 12:08:49 +00:00
|
|
|
setUiFromPrefs();
|
|
|
|
rememberPrefs();
|
2013-06-02 20:58:50 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
#define DANGER_GF (gf > 100) ? "* { color: red; }" : ""
|
2013-12-04 23:48:37 +00:00
|
|
|
void PreferencesDialog::gflowChanged(int gf)
|
|
|
|
{
|
2013-12-06 16:35:23 +00:00
|
|
|
ui.gflow->setStyleSheet(DANGER_GF);
|
2013-12-04 23:48:37 +00:00
|
|
|
}
|
|
|
|
void PreferencesDialog::gfhighChanged(int gf)
|
|
|
|
{
|
2013-12-06 16:35:23 +00:00
|
|
|
ui.gfhigh->setStyleSheet(DANGER_GF);
|
2013-12-04 23:48:37 +00:00
|
|
|
}
|
2013-12-06 16:35:23 +00:00
|
|
|
#undef DANGER_GF
|
2013-12-04 23:48:37 +00:00
|
|
|
|
2013-06-02 20:58:50 +00:00
|
|
|
void PreferencesDialog::showEvent(QShowEvent *event)
|
|
|
|
{
|
2013-06-03 12:08:49 +00:00
|
|
|
setUiFromPrefs();
|
|
|
|
rememberPrefs();
|
2013-06-02 20:58:50 +00:00
|
|
|
QDialog::showEvent(event);
|
|
|
|
}
|
|
|
|
|
2013-06-03 12:08:49 +00:00
|
|
|
void PreferencesDialog::setUiFromPrefs()
|
2013-06-02 20:58:50 +00:00
|
|
|
{
|
2013-06-03 12:08:49 +00:00
|
|
|
// graphs
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.pheThreshold->setValue(prefs.pp_graphs.phe_threshold);
|
|
|
|
ui.po2Threshold->setValue(prefs.pp_graphs.po2_threshold);
|
|
|
|
ui.pn2Threshold->setValue(prefs.pp_graphs.pn2_threshold);
|
2014-04-16 20:03:44 +00:00
|
|
|
ui.maxppo2->setValue(prefs.modppO2);
|
|
|
|
ui.red_ceiling->setChecked(prefs.redceiling);
|
2013-12-08 13:18:26 +00:00
|
|
|
ui.units_group->setEnabled(ui.personalize->isChecked());
|
2013-10-03 18:54:25 +00:00
|
|
|
|
|
|
|
ui.gflow->setValue(prefs.gflow);
|
|
|
|
ui.gfhigh->setValue(prefs.gfhigh);
|
2013-11-20 15:11:22 +00:00
|
|
|
ui.gf_low_at_maxdepth->setChecked(prefs.gf_low_at_maxdepth);
|
2013-06-03 12:08:49 +00:00
|
|
|
|
|
|
|
// units
|
|
|
|
if (prefs.unit_system == METRIC)
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.metric->setChecked(true);
|
2013-06-03 12:08:49 +00:00
|
|
|
else if (prefs.unit_system == IMPERIAL)
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.imperial->setChecked(true);
|
2013-06-03 12:08:49 +00:00
|
|
|
else
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.personalize->setChecked(true);
|
|
|
|
|
|
|
|
ui.celsius->setChecked(prefs.units.temperature == units::CELSIUS);
|
|
|
|
ui.fahrenheit->setChecked(prefs.units.temperature == units::FAHRENHEIT);
|
|
|
|
ui.meter->setChecked(prefs.units.length == units::METERS);
|
|
|
|
ui.feet->setChecked(prefs.units.length == units::FEET);
|
|
|
|
ui.bar->setChecked(prefs.units.pressure == units::BAR);
|
|
|
|
ui.psi->setChecked(prefs.units.pressure == units::PSI);
|
|
|
|
ui.liter->setChecked(prefs.units.volume == units::LITER);
|
|
|
|
ui.cuft->setChecked(prefs.units.volume == units::CUFT);
|
2013-12-08 13:18:27 +00:00
|
|
|
ui.kg->setChecked(prefs.units.weight == units::KG);
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.lbs->setChecked(prefs.units.weight == units::LBS);
|
2013-12-08 13:18:26 +00:00
|
|
|
|
2013-12-18 21:06:51 +00:00
|
|
|
ui.font->setCurrentFont(QString(prefs.divelist_font));
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.fontsize->setValue(prefs.font_size);
|
|
|
|
ui.defaultfilename->setText(prefs.default_filename);
|
2013-11-24 22:21:29 +00:00
|
|
|
ui.default_cylinder->clear();
|
2014-02-28 04:09:57 +00:00
|
|
|
for (int i = 0; tank_info[i].name != NULL; i++) {
|
2013-11-24 22:21:29 +00:00
|
|
|
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);
|
|
|
|
}
|
2013-11-20 12:40:14 +00:00
|
|
|
ui.displayinvalid->setChecked(prefs.display_invalid_dives);
|
2014-01-11 14:57:06 +00:00
|
|
|
ui.display_unused_tanks->setChecked(prefs.display_unused_tanks);
|
2014-03-27 18:38:07 +00:00
|
|
|
ui.show_average_depth->setChecked(prefs.show_average_depth);
|
2013-10-04 05:57:48 +00:00
|
|
|
ui.vertical_speed_minutes->setChecked(prefs.units.vertical_speed_time == units::MINUTES);
|
|
|
|
ui.vertical_speed_seconds->setChecked(prefs.units.vertical_speed_time == units::SECONDS);
|
2014-04-07 17:12:34 +00:00
|
|
|
ui.velocitySlider->setValue(prefs.animation);
|
2013-12-06 16:29:38 +00:00
|
|
|
|
2013-12-06 19:14:50 +00:00
|
|
|
QSortFilterProxyModel *filterModel = new QSortFilterProxyModel();
|
|
|
|
filterModel->setSourceModel(LanguageModel::instance());
|
|
|
|
filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
|
|
|
ui.languageView->setModel(filterModel);
|
2013-12-07 15:32:17 +00:00
|
|
|
filterModel->sort(0);
|
2013-12-06 19:14:50 +00:00
|
|
|
connect(ui.languageFilter, SIGNAL(textChanged(QString)), filterModel, SLOT(setFilterFixedString(QString)));
|
2013-12-06 16:29:38 +00:00
|
|
|
|
|
|
|
QSettings s;
|
2014-04-11 06:17:35 +00:00
|
|
|
|
|
|
|
ui.save_uid_local->setChecked(s.value("save_uid_local").toBool());
|
|
|
|
ui.default_uid->setText(s.value("subsurface_webservice_uid").toString().toUpper());
|
|
|
|
|
2013-12-06 16:29:38 +00:00
|
|
|
s.beginGroup("Language");
|
2013-12-12 05:44:09 +00:00
|
|
|
ui.languageSystemDefault->setChecked(s.value("UseSystemLanguage", true).toBool());
|
2013-12-18 20:18:33 +00:00
|
|
|
QAbstractItemModel *m = ui.languageView->model();
|
2014-02-28 04:09:57 +00:00
|
|
|
QModelIndexList languages = m->match(m->index(0, 0), Qt::UserRole, s.value("UiLanguage").toString());
|
2013-12-18 20:18:33 +00:00
|
|
|
if (languages.count())
|
|
|
|
ui.languageView->setCurrentIndex(languages.first());
|
2014-03-11 20:36:49 +00:00
|
|
|
|
|
|
|
s.endGroup();
|
2013-06-03 12:08:49 +00:00
|
|
|
}
|
2013-05-24 18:19:48 +00:00
|
|
|
|
2013-06-03 12:08:49 +00:00
|
|
|
void PreferencesDialog::restorePrefs()
|
|
|
|
{
|
|
|
|
prefs = oldPrefs;
|
2013-11-20 12:40:14 +00:00
|
|
|
setUiFromPrefs();
|
2013-06-03 12:08:49 +00:00
|
|
|
}
|
2013-05-24 18:19:48 +00:00
|
|
|
|
2013-06-03 12:08:49 +00:00
|
|
|
void PreferencesDialog::rememberPrefs()
|
|
|
|
{
|
|
|
|
oldPrefs = prefs;
|
2013-05-28 18:21:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define SB(V, B) s.setValue(V, (int)(B->isChecked() ? 1 : 0))
|
|
|
|
|
2014-02-06 16:18:00 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
#define GET_UNIT(name, field, f, t) \
|
|
|
|
v = s.value(QString(name)); \
|
|
|
|
if (v.isValid()) \
|
2014-02-06 16:18:00 +00:00
|
|
|
prefs.units.field = (v.toInt() == (t)) ? (t) : (f); \
|
2014-02-28 04:09:57 +00:00
|
|
|
else \
|
2014-05-05 22:56:11 +00:00
|
|
|
prefs.units.field = default_prefs.units.field
|
2014-02-28 04:09:57 +00:00
|
|
|
|
|
|
|
#define GET_BOOL(name, field) \
|
|
|
|
v = s.value(QString(name)); \
|
|
|
|
if (v.isValid()) \
|
2014-05-05 22:56:49 +00:00
|
|
|
prefs.field = v.toBool(); \
|
2014-02-28 04:09:57 +00:00
|
|
|
else \
|
2014-05-05 22:56:11 +00:00
|
|
|
prefs.field = default_prefs.field
|
2014-02-28 04:09:57 +00:00
|
|
|
|
|
|
|
#define GET_DOUBLE(name, field) \
|
|
|
|
v = s.value(QString(name)); \
|
|
|
|
if (v.isValid()) \
|
|
|
|
prefs.field = v.toDouble(); \
|
|
|
|
else \
|
2014-05-05 22:56:11 +00:00
|
|
|
prefs.field = default_prefs.field
|
2014-02-28 04:09:57 +00:00
|
|
|
|
|
|
|
#define GET_INT(name, field) \
|
|
|
|
v = s.value(QString(name)); \
|
|
|
|
if (v.isValid()) \
|
|
|
|
prefs.field = v.toInt(); \
|
|
|
|
else \
|
2014-05-05 22:56:11 +00:00
|
|
|
prefs.field = default_prefs.field
|
2014-02-28 04:09:57 +00:00
|
|
|
|
|
|
|
#define GET_TXT(name, field) \
|
|
|
|
v = s.value(QString(name)); \
|
|
|
|
if (v.isValid()) \
|
|
|
|
prefs.field = strdup(v.toString().toUtf8().constData()); \
|
|
|
|
else \
|
2014-05-05 22:56:11 +00:00
|
|
|
prefs.field = default_prefs.field
|
2014-02-28 04:09:57 +00:00
|
|
|
|
|
|
|
#define GET_TXT(name, field) \
|
|
|
|
v = s.value(QString(name)); \
|
|
|
|
if (v.isValid()) \
|
|
|
|
prefs.field = strdup(v.toString().toUtf8().constData()); \
|
|
|
|
else \
|
2014-05-05 22:56:11 +00:00
|
|
|
prefs.field = default_prefs.field
|
2014-02-06 16:18:00 +00:00
|
|
|
|
2013-05-24 18:19:48 +00:00
|
|
|
void PreferencesDialog::syncSettings()
|
|
|
|
{
|
|
|
|
QSettings s;
|
|
|
|
|
2014-04-11 06:17:35 +00:00
|
|
|
s.setValue("subsurface_webservice_uid", ui.default_uid->text().toUpper());
|
|
|
|
set_save_userid_local(ui.save_uid_local->checkState());
|
|
|
|
|
2013-05-24 18:19:48 +00:00
|
|
|
// Graph
|
2013-05-26 17:49:05 +00:00
|
|
|
s.beginGroup("TecDetails");
|
2013-10-03 18:54:25 +00:00
|
|
|
s.setValue("phethreshold", ui.pheThreshold->value());
|
|
|
|
s.setValue("po2threshold", ui.po2Threshold->value());
|
|
|
|
s.setValue("pn2threshold", ui.pn2Threshold->value());
|
2013-11-20 15:11:22 +00:00
|
|
|
s.setValue("modppO2", ui.maxppo2->value());
|
2013-10-03 18:54:25 +00:00
|
|
|
SB("redceiling", ui.red_ceiling);
|
|
|
|
s.setValue("gflow", ui.gflow->value());
|
|
|
|
s.setValue("gfhigh", ui.gfhigh->value());
|
2013-11-20 15:11:22 +00:00
|
|
|
SB("gf_low_at_maxdepth", ui.gf_low_at_maxdepth);
|
2014-01-11 14:57:06 +00:00
|
|
|
SB("display_unused_tanks", ui.display_unused_tanks);
|
2014-03-27 18:38:07 +00:00
|
|
|
SB("show_average_depth", ui.show_average_depth);
|
2013-05-26 17:49:05 +00:00
|
|
|
s.endGroup();
|
2013-05-28 18:21:27 +00:00
|
|
|
|
2013-05-24 18:19:48 +00:00
|
|
|
// Units
|
2013-05-26 17:49:05 +00:00
|
|
|
s.beginGroup("Units");
|
2013-10-03 18:54:25 +00:00
|
|
|
QString unitSystem = ui.metric->isChecked() ? "metric" : (ui.imperial->isChecked() ? "imperial" : "personal");
|
2013-06-02 10:52:18 +00:00
|
|
|
s.setValue("unit_system", unitSystem);
|
2013-10-03 18:54:25 +00:00
|
|
|
s.setValue("temperature", ui.fahrenheit->isChecked() ? units::FAHRENHEIT : units::CELSIUS);
|
|
|
|
s.setValue("length", ui.feet->isChecked() ? units::FEET : units::METERS);
|
|
|
|
s.setValue("pressure", ui.psi->isChecked() ? units::PSI : units::BAR);
|
|
|
|
s.setValue("volume", ui.cuft->isChecked() ? units::CUFT : units::LITER);
|
|
|
|
s.setValue("weight", ui.lbs->isChecked() ? units::LBS : units::KG);
|
2013-10-04 05:57:48 +00:00
|
|
|
s.setValue("vertical_speed_time", ui.vertical_speed_minutes->isChecked() ? units::MINUTES : units::SECONDS);
|
2013-05-26 17:49:05 +00:00
|
|
|
s.endGroup();
|
2014-04-16 20:03:44 +00:00
|
|
|
|
2013-05-24 18:19:48 +00:00
|
|
|
// Defaults
|
2013-05-26 17:49:05 +00:00
|
|
|
s.beginGroup("GeneralSettings");
|
2013-11-24 05:54:51 +00:00
|
|
|
s.setValue("default_filename", ui.defaultfilename->text());
|
2013-11-24 22:21:29 +00:00
|
|
|
s.setValue("default_cylinder", ui.default_cylinder->currentText());
|
2013-11-20 12:40:14 +00:00
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("Display");
|
2013-12-18 21:06:51 +00:00
|
|
|
s.setValue("divelist_font", ui.font->currentFont());
|
2013-12-06 16:30:59 +00:00
|
|
|
s.setValue("font_size", ui.fontsize->value());
|
|
|
|
s.setValue("displayinvalid", ui.displayinvalid->isChecked());
|
2013-05-26 17:49:05 +00:00
|
|
|
s.endGroup();
|
2013-05-24 18:19:48 +00:00
|
|
|
s.sync();
|
|
|
|
|
2014-04-16 20:03:44 +00:00
|
|
|
// Locale
|
2013-12-06 16:29:38 +00:00
|
|
|
QLocale loc;
|
|
|
|
s.beginGroup("Language");
|
2013-12-12 05:44:09 +00:00
|
|
|
bool useSystemLang = s.value("UseSystemLanguage", true).toBool();
|
|
|
|
if (useSystemLang != ui.languageSystemDefault->isChecked() ||
|
|
|
|
(!useSystemLang && s.value("UiLanguage").toString() != ui.languageView->currentIndex().data(Qt::UserRole))) {
|
2014-02-12 14:22:54 +00:00
|
|
|
QMessageBox::warning(MainWindow::instance(), tr("Restart required"),
|
2013-12-06 16:29:38 +00:00
|
|
|
tr("To correctly load a new language you must restart Subsurface."));
|
|
|
|
}
|
2013-12-06 19:48:38 +00:00
|
|
|
s.setValue("UseSystemLanguage", ui.languageSystemDefault->isChecked());
|
2013-12-06 16:29:38 +00:00
|
|
|
s.setValue("UiLanguage", ui.languageView->currentIndex().data(Qt::UserRole));
|
2014-02-06 16:18:00 +00:00
|
|
|
s.endGroup();
|
2014-02-08 17:07:06 +00:00
|
|
|
|
2014-04-16 20:03:44 +00:00
|
|
|
// Animation
|
2014-03-11 20:36:49 +00:00
|
|
|
s.beginGroup("Animations");
|
2014-05-22 18:40:22 +00:00
|
|
|
s.setValue("animation_speed", ui.velocitySlider->value());
|
2014-04-16 20:03:44 +00:00
|
|
|
s.endGroup();
|
|
|
|
|
2014-02-08 17:07:06 +00:00
|
|
|
loadSettings();
|
|
|
|
emit settingsChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreferencesDialog::loadSettings()
|
|
|
|
{
|
2014-02-06 16:18:00 +00:00
|
|
|
// This code was on the mainwindow, it should belong nowhere, but since we dind't
|
|
|
|
// correctly fixed this code yet ( too much stuff on the code calling preferences )
|
|
|
|
// force this here.
|
2013-12-06 16:29:38 +00:00
|
|
|
|
2014-02-08 17:07:06 +00:00
|
|
|
QSettings s;
|
2014-02-06 16:18:00 +00:00
|
|
|
QVariant v;
|
2014-04-11 06:17:35 +00:00
|
|
|
|
|
|
|
ui.save_uid_local->setChecked(s.value("save_uid_local").toBool());
|
|
|
|
ui.default_uid->setText(s.value("subsurface_webservice_uid").toString().toUpper());
|
|
|
|
|
2014-02-06 16:18:00 +00:00
|
|
|
s.beginGroup("Units");
|
|
|
|
if (s.value("unit_system").toString() == "metric") {
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units = SI_units;
|
|
|
|
} else if (s.value("unit_system").toString() == "imperial") {
|
|
|
|
prefs.unit_system = IMPERIAL;
|
|
|
|
prefs.units = IMPERIAL_units;
|
|
|
|
} else {
|
|
|
|
prefs.unit_system = PERSONALIZE;
|
|
|
|
GET_UNIT("length", length, units::FEET, units::METERS);
|
|
|
|
GET_UNIT("pressure", pressure, units::PSI, units::BAR);
|
|
|
|
GET_UNIT("volume", volume, units::CUFT, units::LITER);
|
|
|
|
GET_UNIT("temperature", temperature, units::FAHRENHEIT, units::CELSIUS);
|
|
|
|
GET_UNIT("weight", weight, units::LBS, units::KG);
|
|
|
|
}
|
|
|
|
GET_UNIT("vertical_speed_time", vertical_speed_time, units::MINUTES, units::SECONDS);
|
|
|
|
s.endGroup();
|
|
|
|
s.beginGroup("TecDetails");
|
|
|
|
GET_BOOL("po2graph", pp_graphs.po2);
|
|
|
|
GET_BOOL("pn2graph", pp_graphs.pn2);
|
|
|
|
GET_BOOL("phegraph", pp_graphs.phe);
|
|
|
|
GET_DOUBLE("po2threshold", pp_graphs.po2_threshold);
|
|
|
|
GET_DOUBLE("pn2threshold", pp_graphs.pn2_threshold);
|
|
|
|
GET_DOUBLE("phethreshold", pp_graphs.phe_threshold);
|
|
|
|
GET_BOOL("mod", mod);
|
2014-04-16 20:03:44 +00:00
|
|
|
GET_DOUBLE("modppO2", modppO2);
|
2014-02-06 16:18:00 +00:00
|
|
|
GET_BOOL("ead", ead);
|
2014-04-16 20:03:44 +00:00
|
|
|
GET_BOOL("redceiling", redceiling);
|
|
|
|
GET_BOOL("dcceiling", dcceiling);
|
|
|
|
GET_BOOL("calcceiling", calcceiling);
|
|
|
|
GET_BOOL("calcceiling3m", calcceiling3m);
|
|
|
|
GET_BOOL("calcndltts", calcndltts);
|
|
|
|
GET_BOOL("calcalltissues", calcalltissues);
|
|
|
|
GET_BOOL("hrgraph", hrgraph);
|
2014-02-06 16:18:00 +00:00
|
|
|
GET_INT("gflow", gflow);
|
|
|
|
GET_INT("gfhigh", gfhigh);
|
|
|
|
GET_BOOL("gf_low_at_maxdepth", gf_low_at_maxdepth);
|
2014-02-27 15:31:00 +00:00
|
|
|
GET_BOOL("zoomed_plot", zoomed_plot);
|
2014-02-06 16:18:00 +00:00
|
|
|
set_gf(prefs.gflow, prefs.gfhigh, prefs.gf_low_at_maxdepth);
|
|
|
|
GET_BOOL("show_sac", show_sac);
|
|
|
|
GET_BOOL("display_unused_tanks", display_unused_tanks);
|
2014-03-27 18:38:07 +00:00
|
|
|
GET_BOOL("show_average_depth", show_average_depth);
|
2014-02-06 16:18:00 +00:00
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("GeneralSettings");
|
|
|
|
GET_TXT("default_filename", default_filename);
|
|
|
|
GET_TXT("default_cylinder", default_cylinder);
|
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("Display");
|
|
|
|
QFont defaultFont = s.value("divelist_font", qApp->font()).value<QFont>();
|
|
|
|
defaultFont.setPointSizeF(s.value("font_size", qApp->font().pointSizeF()).toFloat());
|
|
|
|
qApp->setFont(defaultFont);
|
2014-02-26 19:33:27 +00:00
|
|
|
|
2014-02-06 16:18:00 +00:00
|
|
|
GET_TXT("divelist_font", divelist_font);
|
|
|
|
GET_INT("font_size", font_size);
|
2014-02-26 19:33:27 +00:00
|
|
|
if (prefs.font_size < 0)
|
|
|
|
prefs.font_size = defaultFont.pointSizeF();
|
2014-02-06 16:18:00 +00:00
|
|
|
GET_INT("displayinvalid", display_invalid_dives);
|
|
|
|
s.endGroup();
|
2014-03-11 20:36:49 +00:00
|
|
|
|
|
|
|
s.beginGroup("Animations");
|
2014-04-07 17:12:34 +00:00
|
|
|
GET_INT("animation_speed", animation);
|
2013-05-24 18:19:48 +00:00
|
|
|
}
|
2013-05-28 18:21:27 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
void PreferencesDialog::buttonClicked(QAbstractButton *button)
|
2013-06-02 20:58:50 +00:00
|
|
|
{
|
2014-01-16 04:50:56 +00:00
|
|
|
switch (ui.buttonBox->standardButton(button)) {
|
2013-06-02 20:58:50 +00:00
|
|
|
case QDialogButtonBox::Discard:
|
2013-06-03 12:08:49 +00:00
|
|
|
restorePrefs();
|
2014-04-07 17:12:34 +00:00
|
|
|
syncSettings();
|
2013-06-02 20:58:50 +00:00
|
|
|
close();
|
|
|
|
break;
|
|
|
|
case QDialogButtonBox::Apply:
|
|
|
|
syncSettings();
|
|
|
|
break;
|
|
|
|
case QDialogButtonBox::FirstButton:
|
|
|
|
syncSettings();
|
|
|
|
close();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break; // ignore warnings.
|
|
|
|
}
|
|
|
|
}
|
2013-05-28 18:21:27 +00:00
|
|
|
#undef SB
|
2013-10-14 04:19:13 +00:00
|
|
|
|
|
|
|
void PreferencesDialog::on_chooseFile_clicked()
|
|
|
|
{
|
2013-11-20 07:08:20 +00:00
|
|
|
QFileInfo fi(system_default_filename());
|
2014-02-11 18:49:56 +00:00
|
|
|
QString choosenFileName = QFileDialog::getOpenFileName(this, tr("Open Default Log File"), fi.absolutePath(), tr("Subsurface XML files (*.ssrf *.xml *.XML)"));
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
if (!choosenFileName.isEmpty())
|
2014-02-11 18:49:56 +00:00
|
|
|
ui.defaultfilename->setText(choosenFileName);
|
2013-10-14 04:19:13 +00:00
|
|
|
}
|
2014-02-06 13:38:28 +00:00
|
|
|
|
|
|
|
void PreferencesDialog::emitSettingsChanged()
|
|
|
|
{
|
|
|
|
emit settingsChanged();
|
|
|
|
}
|