mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Hook up most of the Preferences dialog
The imperial/metric super setting doesn't have any effect. But changing the individual units now works and is tracked. And causes the display to change after clicking "OK" (but not yet when clicking "Apply"). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
96f74d9939
commit
b947cc924f
5 changed files with 53 additions and 35 deletions
|
@ -40,6 +40,8 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow())
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setWindowIcon(QIcon(":subsurface-icon"));
|
setWindowIcon(QIcon(":subsurface-icon"));
|
||||||
connect(ui->ListWidget, SIGNAL(currentDiveChanged(int)), this, SLOT(current_dive_changed(int)));
|
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->mainErrorMessage->hide();
|
||||||
ui->ProfileWidget->setFocusProxy(ui->ListWidget);
|
ui->ProfileWidget->setFocusProxy(ui->ListWidget);
|
||||||
ui->ListWidget->reload();
|
ui->ListWidget->reload();
|
||||||
|
@ -355,11 +357,11 @@ void MainWindow::readSettings()
|
||||||
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
settings.beginGroup("Units");
|
settings.beginGroup("Units");
|
||||||
GET_UNIT(v, "feet", length, units::FEET, units::METERS);
|
GET_UNIT(v, "length", length, units::FEET, units::METERS);
|
||||||
GET_UNIT(v, "psi", pressure, units::PSI, units::BAR);
|
GET_UNIT(v, "pressure", pressure, units::PSI, units::BAR);
|
||||||
GET_UNIT(v, "cuft", volume, units::CUFT, units::LITER);
|
GET_UNIT(v, "volume", volume, units::CUFT, units::LITER);
|
||||||
GET_UNIT(v, "fahrenheit", temperature, units::FAHRENHEIT, units::CELSIUS);
|
GET_UNIT(v, "temperature", temperature, units::FAHRENHEIT, units::CELSIUS);
|
||||||
GET_UNIT(v, "lbs", weight, units::LBS, units::KG);
|
GET_UNIT(v, "weight", weight, units::LBS, units::KG);
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
settings.beginGroup("DisplayListColumns");
|
settings.beginGroup("DisplayListColumns");
|
||||||
GET_BOOL(v, "CYLINDER", prefs.visible_cols.cylinder);
|
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.setValue(QString("colwidth%1").arg(i), ui->ListWidget->columnWidth(i));
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
settings.beginGroup("Units");
|
settings.beginGroup("Units");
|
||||||
SAVE_VALUE("feet", units.length);
|
SAVE_VALUE("length", units.length);
|
||||||
SAVE_VALUE("psi", units.pressure);
|
SAVE_VALUE("pressure", units.pressure);
|
||||||
SAVE_VALUE("cuft", units.volume);
|
SAVE_VALUE("volume", units.volume);
|
||||||
SAVE_VALUE("fahrenheit", units.temperature);
|
SAVE_VALUE("temperature", units.temperature);
|
||||||
SAVE_VALUE("lbs", units.weight);
|
SAVE_VALUE("weight", units.weight);
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
settings.beginGroup("DisplayListColumns");
|
settings.beginGroup("DisplayListColumns");
|
||||||
SAVE_VALUE("TEMPERATURE", visible_cols.temperature);
|
SAVE_VALUE("TEMPERATURE", visible_cols.temperature);
|
||||||
|
|
|
@ -85,6 +85,9 @@ private Q_SLOTS:
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *);
|
void closeEvent(QCloseEvent *);
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void readSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
QAction *actionNextDive;
|
QAction *actionNextDive;
|
||||||
|
@ -92,7 +95,6 @@ private:
|
||||||
|
|
||||||
QString filter();
|
QString filter();
|
||||||
bool askSaveChanges();
|
bool askSaveChanges();
|
||||||
void readSettings();
|
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
void redrawProfile();
|
void redrawProfile();
|
||||||
void file_save();
|
void file_save();
|
||||||
|
|
|
@ -21,6 +21,7 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : QDial
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
|
||||||
// Graph
|
// Graph
|
||||||
|
s.beginGroup("TecDetails");
|
||||||
ui->calculated_ceiling->setChecked(B(show_calculated_ceiling));
|
ui->calculated_ceiling->setChecked(B(show_calculated_ceiling));
|
||||||
ui->phe->setChecked(B(show_phe));
|
ui->phe->setChecked(B(show_phe));
|
||||||
ui->po2->setChecked(B(show_po2));
|
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->increment_3m->setChecked(B(show_3m_increments));
|
||||||
ui->gflow->setValue(D(gflow));
|
ui->gflow->setValue(D(gflow));
|
||||||
ui->gfhigh->setValue(D(gfhigh));
|
ui->gfhigh->setValue(D(gfhigh));
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
// Units
|
// Units
|
||||||
|
s.beginGroup("Units");
|
||||||
bool value = s.value("units_metric").toBool();
|
bool value = s.value("units_metric").toBool();
|
||||||
ui->metric->setChecked(value);
|
ui->metric->setChecked(value);
|
||||||
ui->imperial->setChecked(!value);
|
ui->imperial->setChecked(!value);
|
||||||
|
|
||||||
value = s.value("units_celcius").toBool();
|
int unit = s.value("temperature").toInt();
|
||||||
ui->celsius->setChecked( value);
|
ui->celsius->setChecked(unit == units::CELSIUS);
|
||||||
ui->fahrenheit->setChecked( !value);
|
ui->fahrenheit->setChecked(unit == units::FAHRENHEIT);
|
||||||
|
|
||||||
value = s.value("units_meters").toBool();
|
unit = s.value("length").toInt();
|
||||||
ui->meter->setChecked(value);
|
ui->meter->setChecked(unit == units::METERS);
|
||||||
ui->feet->setChecked(!value);
|
ui->feet->setChecked(unit == units::FEET);
|
||||||
|
|
||||||
value = s.value("units_bar").toBool();
|
unit = s.value("pressure").toInt();
|
||||||
ui->bar->setChecked(value);
|
ui->bar->setChecked(unit == units::BAR);
|
||||||
ui->psi->setChecked(!value);
|
ui->psi->setChecked(unit == units::PSI);
|
||||||
|
|
||||||
value = s.value("units_liter").toBool();
|
unit = s.value("volume").toInt();
|
||||||
ui->liter->setChecked(value);
|
ui->liter->setChecked(unit == units::LITER);
|
||||||
ui->cuft->setChecked(!value);
|
ui->cuft->setChecked(unit == units::CUFT);
|
||||||
|
|
||||||
value = s.value("units_kgs").toBool();
|
unit = s.value("weight").toInt();
|
||||||
ui->kgs->setChecked(value);
|
ui->kgs->setChecked(unit == units::KG);
|
||||||
ui->lbs->setChecked(!value);
|
ui->lbs->setChecked(unit == units::LBS);
|
||||||
|
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
// Defaults
|
// Defaults
|
||||||
|
s.beginGroup("GeneralSettings");
|
||||||
ui->font->setFont( QFont(s.value("table_fonts").toString()));
|
ui->font->setFont( QFont(s.value("table_fonts").toString()));
|
||||||
ui->fontsize->setValue(D(font_size));
|
ui->fontsize->setValue(D(font_size));
|
||||||
|
|
||||||
ui->defaultfilename->setText(s.value("default_file").toString());
|
ui->defaultfilename->setText(s.value("default_file").toString());
|
||||||
ui->displayinvalid->setChecked(B(show_invalid));
|
ui->displayinvalid->setChecked(B(show_invalid));
|
||||||
|
s.endGroup();
|
||||||
#undef B
|
#undef B
|
||||||
#undef D
|
#undef D
|
||||||
}
|
}
|
||||||
|
@ -95,11 +101,11 @@ void PreferencesDialog::syncSettings()
|
||||||
// Units
|
// Units
|
||||||
s.beginGroup("Units");
|
s.beginGroup("Units");
|
||||||
s.setValue("units_metric", ui->metric->isChecked());
|
s.setValue("units_metric", ui->metric->isChecked());
|
||||||
s.setValue("fahrenheit", ui->fahrenheit->isChecked() ? units::FAHRENHEIT : units::CELSIUS);
|
s.setValue("temperature", ui->fahrenheit->isChecked() ? units::FAHRENHEIT : units::CELSIUS);
|
||||||
s.setValue("feet", ui->feet->isChecked() ? units::FEET : units::METERS);
|
s.setValue("length", ui->feet->isChecked() ? units::FEET : units::METERS);
|
||||||
s.setValue("psi", ui->psi->isChecked() ? units::PSI : units::BAR);
|
s.setValue("pressure", ui->psi->isChecked() ? units::PSI : units::BAR);
|
||||||
s.setValue("cuft", ui->cuft->isChecked() ? units::CUFT : units::LITER);
|
s.setValue("volume", ui->cuft->isChecked() ? units::CUFT : units::LITER);
|
||||||
s.setValue("lbs", ui->lbs->isChecked() ? units::LBS : units::KG);
|
s.setValue("weight", ui->lbs->isChecked() ? units::LBS : units::KG);
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
// Defaults
|
// Defaults
|
||||||
s.beginGroup("GeneralSettings");
|
s.beginGroup("GeneralSettings");
|
||||||
|
|
|
@ -220,14 +220,19 @@ void ProfileGraphicsView::clear()
|
||||||
toolTip = 0;
|
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;
|
struct divecomputer *dc;
|
||||||
|
|
||||||
if (d)
|
if (d)
|
||||||
dc = select_dc(&d->dc);
|
dc = select_dc(&d->dc);
|
||||||
|
|
||||||
if (dive == d && (d && dc == diveDC))
|
if (!forceRedraw && dive == d && (d && dc == diveDC))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
|
|
@ -62,7 +62,7 @@ class ProfileGraphicsView : public QGraphicsView
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ProfileGraphicsView(QWidget* parent = 0);
|
ProfileGraphicsView(QWidget* parent = 0);
|
||||||
void plot(struct dive *d);
|
void plot(struct dive *d, bool forceRedraw = FALSE);
|
||||||
bool eventFilter(QObject* obj, QEvent* event);
|
bool eventFilter(QObject* obj, QEvent* event);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
@ -72,6 +72,9 @@ protected:
|
||||||
void wheelEvent(QWheelEvent* event);
|
void wheelEvent(QWheelEvent* event);
|
||||||
void showEvent(QShowEvent* event);
|
void showEvent(QShowEvent* event);
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void refresh();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void plot_depth_profile();
|
void plot_depth_profile();
|
||||||
QGraphicsSimpleTextItem* plot_text(text_render_options_t *tro, const QPointF& pos, const QString &text, QGraphicsItem *parent = 0);
|
QGraphicsSimpleTextItem* plot_text(text_render_options_t *tro, const QPointF& pos, const QString &text, QGraphicsItem *parent = 0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue