diff options
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r-- | qt-ui/mainwindow.cpp | 54 |
1 files changed, 15 insertions, 39 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 53198902c..23c972741 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -557,6 +557,13 @@ bool MainWindow::askSaveChanges() else \ prefs.field = default_prefs.field +#define GET_TXT(name, field) \ + v = s.value(QString(name)); \ + if (v.isValid()) \ + prefs.field = strdup(v.toString().toUtf8().constData()); \ + else \ + prefs.field = default_prefs.field + void MainWindow::initialUiSetup() { @@ -620,18 +627,17 @@ void MainWindow::readSettings() GET_BOOL("show_sac", show_sac); s.endGroup(); + s.beginGroup("GeneralSettings"); + GET_TXT("default_filename", default_filename); + s.endGroup(); + s.beginGroup("Display"); - v = s.value(QString("divelist_font")); - if (v.isValid()) - prefs.divelist_font = strdup(v.toString().toUtf8().data()); + GET_TXT("divelist_font", divelist_font); + GET_INT("font_size", font_size); + GET_INT("displayinvalid", display_invalid_dives); + s.endGroup(); } -#define SAVE_VALUE(name, field) \ - if (prefs.field != default_prefs.field) \ - settings.setValue(name, prefs.field); \ - else \ - settings.remove(name) - void MainWindow::writeSettings() { QSettings settings; @@ -643,36 +649,6 @@ void MainWindow::writeSettings() saveSplitterSizes(); } settings.endGroup(); - - settings.beginGroup("Units"); - SAVE_VALUE("length", units.length); - SAVE_VALUE("pressure", units.pressure); - SAVE_VALUE("volume", units.volume); - SAVE_VALUE("temperature", units.temperature); - SAVE_VALUE("weight", units.weight); - SAVE_VALUE("vertical_speed_time", units.vertical_speed_time); - settings.endGroup(); - settings.beginGroup("TecDetails"); - SAVE_VALUE("po2graph", pp_graphs.po2); - SAVE_VALUE("pn2graph", pp_graphs.pn2); - SAVE_VALUE("phegraph", pp_graphs.phe); - SAVE_VALUE("po2threshold", pp_graphs.po2_threshold); - SAVE_VALUE("pn2threshold", pp_graphs.pn2_threshold); - SAVE_VALUE("phethreshold", pp_graphs.phe_threshold); - SAVE_VALUE("mod", mod); - SAVE_VALUE("modppO2", mod_ppO2); - SAVE_VALUE("ead", ead); - SAVE_VALUE("redceiling", profile_red_ceiling); - SAVE_VALUE("calcceiling", profile_calc_ceiling); - SAVE_VALUE("calcceiling3m", calc_ceiling_3m_incr); - SAVE_VALUE("calcalltissues", calc_all_tissues); - SAVE_VALUE("dcceiling", profile_dc_ceiling); - SAVE_VALUE("gflow", gflow); - SAVE_VALUE("gfhigh", gfhigh); - settings.endGroup(); - settings.beginGroup("GeneralSettings"); - SAVE_VALUE("default_filename", default_filename); - settings.endGroup(); } void MainWindow::closeEvent(QCloseEvent *event) |