diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 0c042cae5..69ffdb224 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -40,6 +40,8 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow()) ui->setupUi(this); setWindowIcon(QIcon(":subsurface-icon")); connect(ui->ListWidget, SIGNAL(currentDiveChanged(int)), this, SLOT(current_dive_changed(int))); + connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(readSettings())); + connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui->ProfileWidget, SLOT(refresh())); ui->mainErrorMessage->hide(); ui->ProfileWidget->setFocusProxy(ui->ListWidget); ui->ListWidget->reload(); @@ -355,11 +357,11 @@ void MainWindow::readSettings() settings.endGroup(); settings.beginGroup("Units"); - GET_UNIT(v, "feet", length, units::FEET, units::METERS); - GET_UNIT(v, "psi", pressure, units::PSI, units::BAR); - GET_UNIT(v, "cuft", volume, units::CUFT, units::LITER); - GET_UNIT(v, "fahrenheit", temperature, units::FAHRENHEIT, units::CELSIUS); - GET_UNIT(v, "lbs", weight, units::LBS, units::KG); + GET_UNIT(v, "length", length, units::FEET, units::METERS); + GET_UNIT(v, "pressure", pressure, units::PSI, units::BAR); + GET_UNIT(v, "volume", volume, units::CUFT, units::LITER); + GET_UNIT(v, "temperature", temperature, units::FAHRENHEIT, units::CELSIUS); + GET_UNIT(v, "weight", weight, units::LBS, units::KG); settings.endGroup(); settings.beginGroup("DisplayListColumns"); GET_BOOL(v, "CYLINDER", prefs.visible_cols.cylinder); @@ -437,11 +439,11 @@ void MainWindow::writeSettings() settings.setValue(QString("colwidth%1").arg(i), ui->ListWidget->columnWidth(i)); settings.endGroup(); settings.beginGroup("Units"); - SAVE_VALUE("feet", units.length); - SAVE_VALUE("psi", units.pressure); - SAVE_VALUE("cuft", units.volume); - SAVE_VALUE("fahrenheit", units.temperature); - SAVE_VALUE("lbs", units.weight); + 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); settings.endGroup(); settings.beginGroup("DisplayListColumns"); SAVE_VALUE("TEMPERATURE", visible_cols.temperature); diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index a5b1a9b48..2366617c6 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -85,6 +85,9 @@ private Q_SLOTS: protected: void closeEvent(QCloseEvent *); +public Q_SLOTS: + void readSettings(); + private: Ui::MainWindow *ui; QAction *actionNextDive; @@ -92,7 +95,6 @@ private: QString filter(); bool askSaveChanges(); - void readSettings(); void writeSettings(); void redrawProfile(); void file_save(); diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index 1c38fe317..3e684d88a 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -21,6 +21,7 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : QDial QSettings s; // Graph + s.beginGroup("TecDetails"); ui->calculated_ceiling->setChecked(B(show_calculated_ceiling)); ui->phe->setChecked(B(show_phe)); ui->po2->setChecked(B(show_po2)); @@ -34,39 +35,44 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : QDial ui->increment_3m->setChecked(B(show_3m_increments)); ui->gflow->setValue(D(gflow)); ui->gfhigh->setValue(D(gfhigh)); + s.endGroup(); // Units + s.beginGroup("Units"); bool value = s.value("units_metric").toBool(); ui->metric->setChecked(value); ui->imperial->setChecked(!value); - value = s.value("units_celcius").toBool(); - ui->celsius->setChecked( value); - ui->fahrenheit->setChecked( !value); + int unit = s.value("temperature").toInt(); + ui->celsius->setChecked(unit == units::CELSIUS); + ui->fahrenheit->setChecked(unit == units::FAHRENHEIT); - value = s.value("units_meters").toBool(); - ui->meter->setChecked(value); - ui->feet->setChecked(!value); + unit = s.value("length").toInt(); + ui->meter->setChecked(unit == units::METERS); + ui->feet->setChecked(unit == units::FEET); - value = s.value("units_bar").toBool(); - ui->bar->setChecked(value); - ui->psi->setChecked(!value); + unit = s.value("pressure").toInt(); + ui->bar->setChecked(unit == units::BAR); + ui->psi->setChecked(unit == units::PSI); - value = s.value("units_liter").toBool(); - ui->liter->setChecked(value); - ui->cuft->setChecked(!value); + unit = s.value("volume").toInt(); + ui->liter->setChecked(unit == units::LITER); + ui->cuft->setChecked(unit == units::CUFT); - value = s.value("units_kgs").toBool(); - ui->kgs->setChecked(value); - ui->lbs->setChecked(!value); + unit = s.value("weight").toInt(); + ui->kgs->setChecked(unit == units::KG); + ui->lbs->setChecked(unit == units::LBS); + + s.endGroup(); // Defaults + s.beginGroup("GeneralSettings"); ui->font->setFont( QFont(s.value("table_fonts").toString())); ui->fontsize->setValue(D(font_size)); ui->defaultfilename->setText(s.value("default_file").toString()); ui->displayinvalid->setChecked(B(show_invalid)); - + s.endGroup(); #undef B #undef D } @@ -95,11 +101,11 @@ void PreferencesDialog::syncSettings() // Units s.beginGroup("Units"); s.setValue("units_metric", ui->metric->isChecked()); - s.setValue("fahrenheit", ui->fahrenheit->isChecked() ? units::FAHRENHEIT : units::CELSIUS); - s.setValue("feet", ui->feet->isChecked() ? units::FEET : units::METERS); - s.setValue("psi", ui->psi->isChecked() ? units::PSI : units::BAR); - s.setValue("cuft", ui->cuft->isChecked() ? units::CUFT : units::LITER); - s.setValue("lbs", ui->lbs->isChecked() ? units::LBS : units::KG); + 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); s.endGroup(); // Defaults s.beginGroup("GeneralSettings"); diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp index deef8a9d5..722cea6bd 100644 --- a/qt-ui/profilegraphics.cpp +++ b/qt-ui/profilegraphics.cpp @@ -220,14 +220,19 @@ void ProfileGraphicsView::clear() toolTip = 0; } -void ProfileGraphicsView::plot(struct dive *d) +void ProfileGraphicsView::refresh() +{ + plot(current_dive, TRUE); +} + +void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw) { struct divecomputer *dc; if (d) dc = select_dc(&d->dc); - if (dive == d && (d && dc == diveDC)) + if (!forceRedraw && dive == d && (d && dc == diveDC)) return; clear(); diff --git a/qt-ui/profilegraphics.h b/qt-ui/profilegraphics.h index 715c81ebf..963dd7d90 100644 --- a/qt-ui/profilegraphics.h +++ b/qt-ui/profilegraphics.h @@ -62,7 +62,7 @@ class ProfileGraphicsView : public QGraphicsView Q_OBJECT public: ProfileGraphicsView(QWidget* parent = 0); - void plot(struct dive *d); + void plot(struct dive *d, bool forceRedraw = FALSE); bool eventFilter(QObject* obj, QEvent* event); void clear(); @@ -72,6 +72,9 @@ protected: void wheelEvent(QWheelEvent* event); void showEvent(QShowEvent* event); +public Q_SLOTS: + void refresh(); + private: void plot_depth_profile(); QGraphicsSimpleTextItem* plot_text(text_render_options_t *tro, const QPointF& pos, const QString &text, QGraphicsItem *parent = 0);