mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +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);
|
||||
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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue