summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'desktop-widgets/mainwindow.cpp')
-rw-r--r--desktop-widgets/mainwindow.cpp186
1 files changed, 82 insertions, 104 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index cc3bc7c54..f45f27b71 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -61,7 +61,6 @@
#include "core/color.h"
#include "core/isocialnetworkintegration.h"
#include "core/pluginmanager.h"
-#include "core/subsurface-qt/SettingsObjectWrapper.h"
#if defined(FBSUPPORT)
#include "plugins/facebook/facebook_integration.h"
@@ -284,47 +283,48 @@ MainWindow::MainWindow() : QMainWindow(),
set_error_cb(&showErrorFromC);
// Toolbar Connections related to the Profile Update
- SettingsObjectWrapper *sWrapper = SettingsObjectWrapper::instance();
- connect(ui.profCalcAllTissues, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_calcalltissues);
- connect(ui.profCalcCeiling, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_calcceiling);
- connect(ui.profDcCeiling, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_dcceiling);
- connect(ui.profEad, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_ead);
- connect(ui.profIncrement3m, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_calcceiling3m);
- connect(ui.profMod, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_mod);
- connect(ui.profNdl_tts, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_calcndltts);
- connect(ui.profHR, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_hrgraph);
- connect(ui.profRuler, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_rulergraph);
- connect(ui.profSAC, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_show_sac);
- connect(ui.profScaled, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_zoomed_plot);
- connect(ui.profTogglePicture, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_show_pictures_in_profile);
- connect(ui.profTankbar, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_tankbar);
- connect(ui.profTissues, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_percentagegraph);
+ auto tec = qPrefTechnicalDetails::instance();
+ connect(ui.profCalcAllTissues, &QAction::triggered, tec, &qPrefTechnicalDetails::set_calcalltissues);
+ connect(ui.profCalcCeiling, &QAction::triggered, tec, &qPrefTechnicalDetails::set_calcceiling);
+ connect(ui.profDcCeiling, &QAction::triggered, tec, &qPrefTechnicalDetails::set_dcceiling);
+ connect(ui.profEad, &QAction::triggered, tec, &qPrefTechnicalDetails::set_ead);
+ connect(ui.profIncrement3m, &QAction::triggered, tec, &qPrefTechnicalDetails::set_calcceiling3m);
+ connect(ui.profMod, &QAction::triggered, tec, &qPrefTechnicalDetails::set_mod);
+ connect(ui.profNdl_tts, &QAction::triggered, tec, &qPrefTechnicalDetails::set_calcndltts);
+ connect(ui.profHR, &QAction::triggered, tec, &qPrefTechnicalDetails::set_hrgraph);
+ connect(ui.profRuler, &QAction::triggered, tec, &qPrefTechnicalDetails::set_rulergraph);
+ connect(ui.profSAC, &QAction::triggered, tec, &qPrefTechnicalDetails::set_show_sac);
+ connect(ui.profScaled, &QAction::triggered, tec, &qPrefTechnicalDetails::set_zoomed_plot);
+ connect(ui.profTogglePicture, &QAction::triggered, tec, &qPrefTechnicalDetails::set_show_pictures_in_profile);
+ connect(ui.profTankbar, &QAction::triggered, tec, &qPrefTechnicalDetails::set_tankbar);
+ connect(ui.profTissues, &QAction::triggered, tec, &qPrefTechnicalDetails::set_percentagegraph);
connect(ui.profTissues, &QAction::triggered, this, &MainWindow::unsetProfHR);
connect(ui.profHR, &QAction::triggered, this, &MainWindow::unsetProfTissues);
- connect(ui.profPhe, &QAction::triggered, sWrapper->pp_gas, &PartialPressureGasSettings::setShowPhe);
- connect(ui.profPn2, &QAction::triggered, sWrapper->pp_gas, &PartialPressureGasSettings::setShowPn2);
- connect(ui.profPO2, &QAction::triggered, sWrapper->pp_gas, &PartialPressureGasSettings::setShowPo2);
-
- connect(sWrapper->techDetails, &qPrefTechnicalDetails::calcalltissues_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
- connect(sWrapper->techDetails, &qPrefTechnicalDetails::calcceiling_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
- connect(sWrapper->techDetails, &qPrefTechnicalDetails::dcceiling_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
- connect(sWrapper->techDetails, &qPrefTechnicalDetails::ead_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
- connect(sWrapper->techDetails, &qPrefTechnicalDetails::calcceiling3m_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
- connect(sWrapper->techDetails, &qPrefTechnicalDetails::mod_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
- connect(sWrapper->techDetails, &qPrefTechnicalDetails::calcndltts_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
- connect(sWrapper->techDetails, &qPrefTechnicalDetails::hrgraph_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
- connect(sWrapper->techDetails, &qPrefTechnicalDetails::rulergraph_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
- connect(sWrapper->techDetails, &qPrefTechnicalDetails::show_sac_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
- connect(sWrapper->techDetails, &qPrefTechnicalDetails::zoomed_plot_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
- connect(sWrapper->techDetails, &qPrefTechnicalDetails::show_pictures_in_profile_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
- connect(sWrapper->techDetails, &qPrefTechnicalDetails::tankbar_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
- connect(sWrapper->techDetails, &qPrefTechnicalDetails::percentagegraph_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
-
- connect(sWrapper->pp_gas, &PartialPressureGasSettings::showPheChanged, graphics(), &ProfileWidget2::actionRequestedReplot);
- connect(sWrapper->pp_gas, &PartialPressureGasSettings::showPn2Changed, graphics(), &ProfileWidget2::actionRequestedReplot);
- connect(sWrapper->pp_gas, &PartialPressureGasSettings::showPo2Changed, graphics(), &ProfileWidget2::actionRequestedReplot);
+ auto pp_gas = qPrefPartialPressureGas::instance();
+ connect(ui.profPhe, &QAction::triggered, pp_gas, &qPrefPartialPressureGas::set_phe);
+ connect(ui.profPn2, &QAction::triggered, pp_gas, &qPrefPartialPressureGas::set_pn2);
+ connect(ui.profPO2, &QAction::triggered, pp_gas, &qPrefPartialPressureGas::set_po2);
+
+ connect(tec, &qPrefTechnicalDetails::calcalltissues_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
+ connect(tec, &qPrefTechnicalDetails::calcceiling_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
+ connect(tec, &qPrefTechnicalDetails::dcceiling_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
+ connect(tec, &qPrefTechnicalDetails::ead_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
+ connect(tec, &qPrefTechnicalDetails::calcceiling3m_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
+ connect(tec, &qPrefTechnicalDetails::mod_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
+ connect(tec, &qPrefTechnicalDetails::calcndltts_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
+ connect(tec, &qPrefTechnicalDetails::hrgraph_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
+ connect(tec, &qPrefTechnicalDetails::rulergraph_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
+ connect(tec, &qPrefTechnicalDetails::show_sac_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
+ connect(tec, &qPrefTechnicalDetails::zoomed_plot_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
+ connect(tec, &qPrefTechnicalDetails::show_pictures_in_profile_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
+ connect(tec, &qPrefTechnicalDetails::tankbar_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
+ connect(tec, &qPrefTechnicalDetails::percentagegraph_changed , graphics(), &ProfileWidget2::actionRequestedReplot);
+
+ connect(pp_gas, &qPrefPartialPressureGas::phe_changed, graphics(), &ProfileWidget2::actionRequestedReplot);
+ connect(pp_gas, &qPrefPartialPressureGas::pn2_changed, graphics(), &ProfileWidget2::actionRequestedReplot);
+ connect(pp_gas, &qPrefPartialPressureGas::po2_changed, graphics(), &ProfileWidget2::actionRequestedReplot);
// now let's set up some connections
connect(graphics(), &ProfileWidget2::enableToolbar ,this, &MainWindow::setEnabledToolbar);
@@ -336,23 +336,23 @@ MainWindow::MainWindow() : QMainWindow(),
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), graphics(), SLOT(settingsChanged()));
- ui.profCalcAllTissues->setChecked(sWrapper->techDetails->calcalltissues());
- ui.profCalcCeiling->setChecked(sWrapper->techDetails->calcceiling());
- ui.profDcCeiling->setChecked(sWrapper->techDetails->dcceiling());
- ui.profEad->setChecked(sWrapper->techDetails->ead());
- ui.profIncrement3m->setChecked(sWrapper->techDetails->calcceiling3m());
- ui.profMod->setChecked(sWrapper->techDetails->mod());
- ui.profNdl_tts->setChecked(sWrapper->techDetails->calcndltts());
- ui.profPhe->setChecked(sWrapper->pp_gas->showPhe());
- ui.profPn2->setChecked(sWrapper->pp_gas->showPn2());
- ui.profPO2->setChecked(sWrapper->pp_gas->showPo2());
- ui.profHR->setChecked(sWrapper->techDetails->hrgraph());
- ui.profRuler->setChecked(sWrapper->techDetails->rulergraph());
- ui.profSAC->setChecked(sWrapper->techDetails->show_sac());
- ui.profTogglePicture->setChecked(sWrapper->techDetails->show_pictures_in_profile());
- ui.profTankbar->setChecked(sWrapper->techDetails->tankbar());
- ui.profTissues->setChecked(sWrapper->techDetails->percentagegraph());
- ui.profScaled->setChecked(sWrapper->techDetails->zoomed_plot());
+ ui.profCalcAllTissues->setChecked(qPrefTechnicalDetails::calcalltissues());
+ ui.profCalcCeiling->setChecked(qPrefTechnicalDetails::calcceiling());
+ ui.profDcCeiling->setChecked(qPrefTechnicalDetails::dcceiling());
+ ui.profEad->setChecked(qPrefTechnicalDetails::ead());
+ ui.profIncrement3m->setChecked(qPrefTechnicalDetails::calcceiling3m());
+ ui.profMod->setChecked(qPrefTechnicalDetails::mod());
+ ui.profNdl_tts->setChecked(qPrefTechnicalDetails::calcndltts());
+ ui.profPhe->setChecked(pp_gas->phe());
+ ui.profPn2->setChecked(pp_gas->pn2());
+ ui.profPO2->setChecked(pp_gas->po2());
+ ui.profHR->setChecked(qPrefTechnicalDetails::hrgraph());
+ ui.profRuler->setChecked(qPrefTechnicalDetails::rulergraph());
+ ui.profSAC->setChecked(qPrefTechnicalDetails::show_sac());
+ ui.profTogglePicture->setChecked(qPrefTechnicalDetails::show_pictures_in_profile());
+ ui.profTankbar->setChecked(qPrefTechnicalDetails::tankbar());
+ ui.profTissues->setChecked(qPrefTechnicalDetails::percentagegraph());
+ ui.profScaled->setChecked(qPrefTechnicalDetails::zoomed_plot());
// full screen support is buggy on Windows and Ubuntu.
// require the FULLSCREEN_SUPPORT macro to enable it!
@@ -549,13 +549,10 @@ void MainWindow::on_actionNew_triggered()
static QString lastUsedDir()
{
- QSettings settings;
QString lastDir = QDir::homePath();
- settings.beginGroup("FileDialog");
- if (settings.contains("LastDir"))
- if (QDir(settings.value("LastDir").toString()).exists())
- lastDir = settings.value("LastDir").toString();
+ if (QDir(qPrefDisplay::lastDir()).exists())
+ lastDir = qPrefDisplay::lastDir();
return lastDir;
}
@@ -620,7 +617,7 @@ void MainWindow::on_actionCloudstorageopen_triggered()
showProgressBar();
QByteArray fileNamePtr = QFile::encodeName(filename);
- if (!parse_file(fileNamePtr.data()))
+ if (!parse_file(fileNamePtr.data(), &dive_table))
setCurrentFile(fileNamePtr.data());
process_dives(false, false);
hideProgressBar();
@@ -773,9 +770,7 @@ void MainWindow::on_actionClose_triggered()
void MainWindow::updateLastUsedDir(const QString &dir)
{
- QSettings s;
- s.beginGroup("FileDialog");
- s.setValue("LastDir", dir);
+ qPrefDisplay::set_lastDir(dir);
}
void MainWindow::on_actionPrint_triggered()
@@ -1187,12 +1182,10 @@ void MainWindow::on_actionViewAll_triggered()
listGlobeSizes.append(lrint(appW * 0.3));
}
- QSettings settings;
- settings.beginGroup("MainWindow");
- if (settings.value("mainSplitter").isValid()) {
- ui.mainSplitter->restoreState(settings.value("mainSplitter").toByteArray());
- ui.topSplitter->restoreState(settings.value("topSplitter").toByteArray());
- ui.bottomSplitter->restoreState(settings.value("bottomSplitter").toByteArray());
+ if (qPrefDisplay::mainSplitter() != "") {
+ ui.mainSplitter->restoreState(qPrefDisplay::mainSplitter());
+ ui.topSplitter->restoreState(qPrefDisplay::topSplitter());
+ ui.bottomSplitter->restoreState(qPrefDisplay::bottomSplitter());
if (ui.mainSplitter->sizes().first() == 0 || ui.mainSplitter->sizes().last() == 0)
ui.mainSplitter->setSizes(mainSizes);
if (ui.topSplitter->sizes().first() == 0 || ui.topSplitter->sizes().last() == 0)
@@ -1225,10 +1218,8 @@ void MainWindow::enterEditState()
int appW = qApp->desktop()->size().width();
QList<int> infoProfileSizes { (int)lrint(appW * 0.3), (int)lrint(appW * 0.7) };
- QSettings settings;
- settings.beginGroup("MainWindow");
- if (settings.value("mainSplitter").isValid()) {
- ui.topSplitter->restoreState(settings.value("topSplitter").toByteArray());
+ if (qPrefDisplay::mainSplitter() != "") {
+ ui.topSplitter->restoreState(qPrefDisplay::topSplitter());
if (ui.topSplitter->sizes().first() == 0 || ui.topSplitter->sizes().last() == 0)
ui.topSplitter->setSizes(infoProfileSizes);
} else {
@@ -1278,11 +1269,9 @@ void MainWindow::beginChangeState(CurrentState s)
void MainWindow::saveSplitterSizes()
{
- QSettings settings;
- settings.beginGroup("MainWindow");
- settings.setValue("mainSplitter", ui.mainSplitter->saveState());
- settings.setValue("topSplitter", ui.topSplitter->saveState());
- settings.setValue("bottomSplitter", ui.bottomSplitter->saveState());
+ qPrefDisplay::set_mainSplitter(ui.mainSplitter->saveState());
+ qPrefDisplay::set_topSplitter(ui.topSplitter->saveState());
+ qPrefDisplay::set_bottomSplitter(ui.bottomSplitter->saveState());
}
void MainWindow::on_actionPreviousDC_triggered()
@@ -1469,17 +1458,14 @@ bool MainWindow::askSaveChanges()
void MainWindow::initialUiSetup()
{
- QSettings settings;
- settings.beginGroup("MainWindow");
- if (settings.value("maximized", isMaximized()).value<bool>()) {
+ if (qPrefDisplay::maximized()) {
showMaximized();
} else {
- restoreGeometry(settings.value("geometry").toByteArray());
- restoreState(settings.value("windowState", 0).toByteArray());
+ restoreGeometry(qPrefDisplay::geometry());
+ restoreState(qPrefDisplay::windowState());
}
- enterState((CurrentState)settings.value("lastState", 0).toInt());
- settings.endGroup();
+ enterState((CurrentState)qPrefDisplay::lastState());
show();
}
@@ -1511,7 +1497,7 @@ void MainWindow::checkSurvey()
// wait a week for production versions, but not at all for non-tagged builds
int waitTime = 7;
QDate firstUse42 = s.value("FirstUse42").toDate();
- if (run_survey || (firstUse42.daysTo(QDate().currentDate()) > waitTime && !s.contains("SurveyDone"))) {
+ if (run_survey || (firstUse42.daysTo(QDate().currentDate()) > waitTime && qPrefDisplay::UserSurvey() == "")) {
if (!survey)
survey = new UserSurvey(this);
survey->show();
@@ -1521,16 +1507,12 @@ void MainWindow::checkSurvey()
void MainWindow::writeSettings()
{
- QSettings settings;
-
- settings.beginGroup("MainWindow");
- settings.setValue("geometry", saveGeometry());
- settings.setValue("windowState", saveState());
- settings.setValue("maximized", isMaximized());
- settings.setValue("lastState", (int)state);
+ qPrefDisplay::set_geometry(saveGeometry());
+ qPrefDisplay::set_windowState(saveState());
+ qPrefDisplay::set_maximized(isMaximized());
+ qPrefDisplay::set_lastState((int)state);
if (state == VIEWALL)
saveSplitterSizes();
- settings.endGroup();
}
void MainWindow::closeEvent(QCloseEvent *event)
@@ -1776,7 +1758,7 @@ void MainWindow::importFiles(const QStringList fileNames)
for (int i = 0; i < fileNames.size(); ++i) {
fileNamePtr = QFile::encodeName(fileNames.at(i));
- parse_file(fileNamePtr.data());
+ parse_file(fileNamePtr.data(), &dive_table);
}
process_dives(true, false);
refreshDisplay();
@@ -1823,7 +1805,7 @@ void MainWindow::loadFiles(const QStringList fileNames)
showProgressBar();
for (int i = 0; i < fileNames.size(); ++i) {
fileNamePtr = QFile::encodeName(fileNames.at(i));
- if (!parse_file(fileNamePtr.data())) {
+ if (!parse_file(fileNamePtr.data(), &dive_table)) {
setCurrentFile(fileNamePtr.data());
addRecentFile(fileNamePtr, false);
}
@@ -1910,7 +1892,7 @@ void MainWindow::editCurrentDive()
void MainWindow::turnOffNdlTts()
{
- SettingsObjectWrapper::instance()->techDetails->set_calcndltts(false);
+ qPrefTechnicalDetails::set_calcndltts(false);
}
#undef TOOLBOX_PREF_PROFILE
@@ -2046,16 +2028,12 @@ void MainWindow::hideProgressBar()
void MainWindow::unsetProfHR()
{
- SettingsObjectWrapper *sWrapper = SettingsObjectWrapper::instance();
-
ui.profHR->setChecked(false);
- sWrapper->techDetails->set_hrgraph(false);
+ qPrefTechnicalDetails::set_hrgraph(false);
}
void MainWindow::unsetProfTissues()
{
- SettingsObjectWrapper *sWrapper = SettingsObjectWrapper::instance();
-
ui.profTissues->setChecked(false);
- sWrapper->techDetails->set_percentagegraph(false);
+ qPrefTechnicalDetails::set_percentagegraph(false);
}