diff --git a/desktop-widgets/CMakeLists.txt b/desktop-widgets/CMakeLists.txt index 95c4b1e9a..12085de3a 100644 --- a/desktop-widgets/CMakeLists.txt +++ b/desktop-widgets/CMakeLists.txt @@ -35,6 +35,7 @@ set (SUBSURFACE_UI plannerDetails.ui plannerSettings.ui printoptions.ui + profilewidget.ui renumber.ui searchbar.ui setpoint.ui @@ -99,6 +100,8 @@ set(SUBSURFACE_INTERFACE modeldelegates.h notificationwidget.cpp notificationwidget.h + profilewidget.cpp + profilewidget.h qtwaitingspinner.cpp qtwaitingspinner.h simplewidgets.cpp diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index c426d753a..5bb2c4307 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -33,8 +32,6 @@ #include "core/settings/qPrefCloudStorage.h" #include "core/settings/qPrefDisplay.h" -#include "core/settings/qPrefPartialPressureGas.h" -#include "core/settings/qPrefTechnicalDetails.h" #include "desktop-widgets/about.h" #include "desktop-widgets/divelistview.h" @@ -53,6 +50,7 @@ #include "desktop-widgets/statswidget.h" #include "commands/command.h" +#include "profilewidget.h" #include "profile-widget/profilewidget2.h" #ifndef NO_PRINTING @@ -134,57 +132,30 @@ MainWindow::MainWindow() : QMainWindow(), // for the "default" mode mainTab.reset(new MainTab); diveList.reset(new DiveListView); - graphics = new ProfileWidget2(DivePlannerPointsModel::instance(), this); mapWidget.reset(MapWidget::instance()); // Yes, this is ominous see comment in mapwidget.cpp. plannerWidgets.reset(new PlannerWidgets); statistics.reset(new StatsWidget); - profileContainer.reset(new QWidget); - - // what is a sane order for those icons? we should have the ones the user is - // most likely to want towards the top so they are always visible - // and the ones that someone likely sets and then never touches again towards the bottom - profileToolbarActions = { ui.profCalcCeiling, ui.profCalcAllTissues, // start with various ceilings - ui.profIncrement3m, ui.profDcCeiling, - ui.profPhe, ui.profPn2, ui.profPO2, // partial pressure graphs - ui.profRuler, ui.profScaled, // measuring and scaling - ui.profTogglePicture, ui.profTankbar, - ui.profMod, ui.profDeco, ui.profNdl_tts, // various values that a user is either interested in or not - ui.profEad, ui.profSAC, - ui.profHR, // very few dive computers support this - ui.profTissues}; // maybe less frequently used - - QToolBar *toolBar = new QToolBar(); - Q_FOREACH (QAction *a, profileToolbarActions) - toolBar->addAction(a); - toolBar->setOrientation(Qt::Vertical); - toolBar->setIconSize(QSize(24,24)); - QHBoxLayout *profLayout = new QHBoxLayout(); - profLayout->setSpacing(0); - profLayout->setMargin(0); - profLayout->setContentsMargins(0,0,0,0); - profLayout->addWidget(toolBar); - profLayout->addWidget(graphics); - profileContainer->setLayout(profLayout); + profile.reset(new ProfileWidget); diveSiteEdit.reset(new LocationInformationWidget); - registerApplicationState(ApplicationState::Default, { true, { mainTab.get(), FLAG_NONE }, { profileContainer.get(), FLAG_NONE }, + registerApplicationState(ApplicationState::Default, { true, { mainTab.get(), FLAG_NONE }, { profile.get(), FLAG_NONE }, { diveList.get(), FLAG_NONE }, { mapWidget.get(), FLAG_NONE } }); - registerApplicationState(ApplicationState::EditDive, { false, { mainTab.get(), FLAG_NONE }, { profileContainer.get(), FLAG_NONE }, + registerApplicationState(ApplicationState::EditDive, { false, { mainTab.get(), FLAG_NONE }, { profile.get(), FLAG_NONE }, { diveList.get(), FLAG_NONE }, { mapWidget.get(), FLAG_NONE } }); - registerApplicationState(ApplicationState::PlanDive, { false, { &plannerWidgets->plannerWidget, FLAG_NONE }, { profileContainer.get(), FLAG_NONE }, + registerApplicationState(ApplicationState::PlanDive, { false, { &plannerWidgets->plannerWidget, FLAG_NONE }, { profile.get(), FLAG_NONE }, { &plannerWidgets->plannerSettingsWidget, FLAG_NONE }, { &plannerWidgets->plannerDetails, FLAG_NONE } }); - registerApplicationState(ApplicationState::EditPlannedDive, { true, { &plannerWidgets->plannerWidget, FLAG_NONE }, { profileContainer.get(), FLAG_NONE }, + registerApplicationState(ApplicationState::EditPlannedDive, { true, { &plannerWidgets->plannerWidget, FLAG_NONE }, { profile.get(), FLAG_NONE }, { diveList.get(), FLAG_NONE }, { mapWidget.get(), FLAG_NONE } }); - registerApplicationState(ApplicationState::EditDiveSite, { false, { diveSiteEdit.get(), FLAG_NONE }, { profileContainer.get(), FLAG_DISABLED }, + registerApplicationState(ApplicationState::EditDiveSite, { false, { diveSiteEdit.get(), FLAG_NONE }, { profile.get(), FLAG_DISABLED }, { diveList.get(), FLAG_DISABLED }, { mapWidget.get(), FLAG_NONE } }); - registerApplicationState(ApplicationState::FilterDive, { true, { mainTab.get(), FLAG_NONE }, { profileContainer.get(), FLAG_NONE }, + registerApplicationState(ApplicationState::FilterDive, { true, { mainTab.get(), FLAG_NONE }, { profile.get(), FLAG_NONE }, { diveList.get(), FLAG_NONE }, { &filterWidget, FLAG_NONE } }); registerApplicationState(ApplicationState::Statistics, { true, { statistics.get(), FLAG_NONE }, { nullptr, FLAG_NONE }, { diveList.get(), FLAG_DISABLED }, { &filterWidget, FLAG_NONE } }); registerApplicationState(ApplicationState::MapMaximized, { true, { nullptr, FLAG_NONE }, { nullptr, FLAG_NONE }, { nullptr, FLAG_NONE }, { mapWidget.get(), FLAG_NONE } }); - registerApplicationState(ApplicationState::ProfileMaximized, { true, { nullptr, FLAG_NONE }, { profileContainer.get(), FLAG_NONE }, + registerApplicationState(ApplicationState::ProfileMaximized, { true, { nullptr, FLAG_NONE }, { profile.get(), FLAG_NONE }, { nullptr, FLAG_NONE }, { nullptr, FLAG_NONE } }); registerApplicationState(ApplicationState::ListMaximized, { true, { nullptr, FLAG_NONE }, { nullptr, FLAG_NONE }, { diveList.get(), FLAG_NONE }, { nullptr, FLAG_NONE } }); @@ -224,7 +195,7 @@ MainWindow::MainWindow() : QMainWindow(), ui.mainErrorMessage->hide(); setEnabledToolbar(false); - graphics->setEmptyState(); + profile->view->setEmptyState(); initialUiSetup(); readSettings(); diveList->setFocus(); @@ -270,54 +241,7 @@ MainWindow::MainWindow() : QMainWindow(), set_git_update_cb(&updateProgress); set_error_cb(&showErrorFromC); - // Toolbar Connections related to the Profile Update - 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.profDeco, &QAction::triggered, tec, &qPrefTechnicalDetails::set_decoinfo); - 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); - - 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(graphics, &ProfileWidget2::editCurrentDive, this, &MainWindow::editCurrentDive); - - connect(&diveListNotifier, &DiveListNotifier::settingsChanged, graphics, &ProfileWidget2::settingsChanged); - - 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.profDeco->setChecked(qPrefTechnicalDetails::decoinfo()); - 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()); + connect(profile->view.get(), &ProfileWidget2::editCurrentDive, this, &MainWindow::editCurrentDive); // full screen support is buggy on Windows and Ubuntu. // require the FULLSCREEN_SUPPORT macro to enable it! @@ -398,41 +322,12 @@ void MainWindow::refreshDisplay() ui.actionAutoGroup->setChecked(autogroup); } -void MainWindow::plotCurrentDive() -{ - setEnabledToolbar(current_dive != nullptr); - if (current_dive) { - bool freeDiveMode = current_dive->dc.divemode == FREEDIVE; - ui.profCalcCeiling->setDisabled(freeDiveMode); - ui.profCalcCeiling->setDisabled(freeDiveMode); - ui.profCalcAllTissues ->setDisabled(freeDiveMode); - ui.profIncrement3m->setDisabled(freeDiveMode); - ui.profDcCeiling->setDisabled(freeDiveMode); - ui.profPhe->setDisabled(freeDiveMode); - ui.profPn2->setDisabled(freeDiveMode); //TODO is the same as scuba? - ui.profPO2->setDisabled(freeDiveMode); //TODO is the same as scuba? - ui.profTankbar->setDisabled(freeDiveMode); - ui.profMod->setDisabled(freeDiveMode); - ui.profNdl_tts->setDisabled(freeDiveMode); - ui.profDeco->setDisabled(freeDiveMode); - ui.profEad->setDisabled(freeDiveMode); - ui.profSAC->setDisabled(freeDiveMode); - ui.profTissues->setDisabled(freeDiveMode); - - ui.profRuler->setDisabled(false); - ui.profScaled->setDisabled(false); // measuring and scaling - ui.profTogglePicture->setDisabled(false); - ui.profHR->setDisabled(false); - } - graphics->plotDive(current_dive, dc_number); -} - void MainWindow::selectionChanged() { mainTab->updateDiveInfo(); if (current_dive) enableDisableOtherDCsActions(); - plotCurrentDive(); + profile->plotCurrentDive(); MapWidget::instance()->selectionChanged(); } @@ -683,7 +578,7 @@ void MainWindow::enableShortcuts() void MainWindow::showProfile() { enableShortcuts(); - graphics->setProfileState(current_dive, dc_number); + profile->view->setProfileState(current_dive, dc_number); setApplicationState(ApplicationState::Default); } @@ -735,7 +630,7 @@ bool MainWindow::plannerStateClean() void MainWindow::refreshProfile() { showProfile(); - plotCurrentDive(); + profile->plotCurrentDive(); } void MainWindow::planCanceled() @@ -769,7 +664,7 @@ void MainWindow::on_actionReplanDive_triggered() setApplicationState(ApplicationState::PlanDive); disableShortcuts(true); - graphics->setPlanState(&displayed_dive, 0); + profile->setPlanState(&displayed_dive, 0); plannerWidgets->replanDive(); } @@ -782,7 +677,7 @@ void MainWindow::on_actionDivePlanner_triggered() setApplicationState(ApplicationState::PlanDive); disableShortcuts(true); - graphics->setPlanState(&displayed_dive, 0); + profile->setPlanState(&displayed_dive, 0); plannerWidgets->planDive(); } @@ -919,7 +814,7 @@ void MainWindow::on_actionPreviousDC_triggered() { unsigned nrdc = number_of_computers(current_dive); dc_number = (dc_number + nrdc - 1) % nrdc; - plotCurrentDive(); + profile->plotCurrentDive(); mainTab->updateDiveInfo(); } @@ -927,7 +822,7 @@ void MainWindow::on_actionNextDC_triggered() { unsigned nrdc = number_of_computers(current_dive); dc_number = (dc_number + 1) % nrdc; - plotCurrentDive(); + profile->plotCurrentDive(); mainTab->updateDiveInfo(); } @@ -1515,7 +1410,7 @@ void MainWindow::editCurrentDive() copy_dive(current_dive, &displayed_dive); // Work on a copy of the dive DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD); DivePlannerPointsModel::instance()->loadFromDive(&displayed_dive); - graphics->setEditState(&displayed_dive, 0); + profile->setEditState(&displayed_dive, 0); setApplicationState(ApplicationState::EditDive); mainTab->enableEdition(); } @@ -1534,8 +1429,7 @@ void MainWindow::on_actionConfigure_Dive_Computer_triggered() void MainWindow::setEnabledToolbar(bool arg1) { - Q_FOREACH (QAction *b, profileToolbarActions) - b->setEnabled(arg1); + profile->setEnabledToolbar(arg1); } void MainWindow::on_copy_triggered() @@ -1674,18 +1568,6 @@ void MainWindow::hideProgressBar() } } -void MainWindow::unsetProfHR() -{ - ui.profHR->setChecked(false); - qPrefTechnicalDetails::set_hrgraph(false); -} - -void MainWindow::unsetProfTissues() -{ - ui.profTissues->setChecked(false); - qPrefTechnicalDetails::set_percentagegraph(false); -} - void MainWindow::divesChanged(const QVector &dives, DiveField field) { Q_UNUSED(field) diff --git a/desktop-widgets/mainwindow.h b/desktop-widgets/mainwindow.h index a1c3a646e..91673f814 100644 --- a/desktop-widgets/mainwindow.h +++ b/desktop-widgets/mainwindow.h @@ -35,7 +35,7 @@ class QSettings; class UpdateManager; class UserManual; class PlannerWidgets; -class ProfileWidget2; +class ProfileWidget; class StatsWidget; class LocationInformationWidget; @@ -76,12 +76,13 @@ public: void enableDisableCloudActions(); void enableDisableOtherDCsActions(); void editDiveSite(dive_site *ds); + void setEnabledToolbar(bool arg1); std::unique_ptr mainTab; std::unique_ptr plannerWidgets; std::unique_ptr statistics; std::unique_ptr diveList; - std::unique_ptr profileContainer; + std::unique_ptr profile; std::unique_ptr mapWidget; private slots: @@ -141,8 +142,6 @@ slots: void setDefaultState(); void setAutomaticTitle(); void cancelCloudStorageOperation(); - void unsetProfHR(); - void unsetProfTissues(); protected: void closeEvent(QCloseEvent *); @@ -159,7 +158,6 @@ slots: void editCurrentDive(); void planCanceled(); void planCreated(); - void setEnabledToolbar(bool arg1); // Some shortcuts like "change DC" or "copy/paste dive components" // should only be enabled when the profile's visible. void startDiveSiteEdit(); @@ -170,7 +168,6 @@ private: FilterWidget filterWidget; std::unique_ptr topSplitter; std::unique_ptr bottomSplitter; - ProfileWidget2 *graphics; QAction *actionNextDive; QAction *actionPreviousDive; QAction *undoAction; @@ -205,7 +202,6 @@ private: QDialog *findMovedImagesDialog; struct dive copyPasteDive; struct dive_components what; - QList profileToolbarActions; QStringList recentFiles; QAction *actionsRecent[NUM_RECENT_FILES]; @@ -234,7 +230,6 @@ private: void setQuadrantWidgets(QSplitter &splitter, const Quadrant &left, const Quadrant &right); void registerApplicationState(ApplicationState state, Quadrants q); void disableShortcuts(bool disablePaste = true); - void plotCurrentDive(); void enableShortcuts(); QMenu *connections; diff --git a/desktop-widgets/mainwindow.ui b/desktop-widgets/mainwindow.ui index 7916d5aad..61541b1ef 100644 --- a/desktop-widgets/mainwindow.ui +++ b/desktop-widgets/mainwindow.ui @@ -424,198 +424,6 @@ Edit &dive in planner - - - true - - - - :pp-o2-icon:pp-o2-icon - - - Toggle pO₂ graph - - - - - true - - - - :pp-n2-icon:pp-n2-icon - - - Toggle pN₂ graph - - - - - true - - - - :pp-he-icon:pp-he-icon - - - Toggle pHe graph - - - - - true - - - - :ceiling-dc-icon:ceiling-dc-icon - - - Toggle DC reported ceiling - - - - - true - - - - :ceiling-calculated-icon:ceiling-calculated-icon - - - Toggle calculated ceiling - - - - - true - - - - :ceiling-tissues-icon:ceiling-tissues-icon - - - Toggle calculating all tissues - - - - - true - - - - :ceiling-increments-icon:ceiling-increments-icon - - - Toggle calculated ceiling with 3m increments - - - - - true - - - - :rate-heart-icon:rate-heart-icon - - - Toggle heart rate - - - - - true - - - - :depth-mod-icon:depth-mod-icon - - - Toggle MOD - - - - - true - - - - :depth-ead-icon:depth-ead-icon - - - Toggle EAD, END, EADD - - - - - true - - - - :depth-ndl-icon:depth-ndl-icon - - - Toggle NDL, TTS - - - - - true - - - - :rate-sac-icon:rate-sac-icon - - - Toggle SAC rate - - - - - true - - - - :ruler-icon:ruler-icon - - - Toggle ruler - - - - - true - - - - :scale-graph-icon:scale-graph-icon - - - Scale graph - - - - - true - - - - :photo-icon:photo-icon - - - Toggle media - - - - - true - - - - :gaschange-icon:gaschange-icon - - - Toggle gas bar - - false @@ -635,18 +443,6 @@ Ctrl+T - - - true - - - - :heatmap-icon:heatmap-icon - - - Toggle tissue heat-map - - &Undo @@ -699,21 +495,6 @@ Cloud stora&ge online - - - true - - - - :/tissue-icon:/tissue-icon - - - Toggle deco information - - - Toggle deco information - - diff --git a/desktop-widgets/profilewidget.cpp b/desktop-widgets/profilewidget.cpp new file mode 100644 index 000000000..96335790a --- /dev/null +++ b/desktop-widgets/profilewidget.cpp @@ -0,0 +1,158 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include "profilewidget.h" +#include "profile-widget/profilewidget2.h" +#include "core/settings/qPrefTechnicalDetails.h" +#include "core/settings/qPrefPartialPressureGas.h" +#include "qt-models/diveplannermodel.h" + +#include +#include + +ProfileWidget::ProfileWidget() +{ + ui.setupUi(this); + + // what is a sane order for those icons? we should have the ones the user is + // most likely to want towards the top so they are always visible + // and the ones that someone likely sets and then never touches again towards the bottom + toolbarActions = { ui.profCalcCeiling, ui.profCalcAllTissues, // start with various ceilings + ui.profIncrement3m, ui.profDcCeiling, + ui.profPhe, ui.profPn2, ui.profPO2, // partial pressure graphs + ui.profRuler, ui.profScaled, // measuring and scaling + ui.profTogglePicture, ui.profTankbar, + ui.profMod, ui.profDeco, ui.profNdl_tts, // various values that a user is either interested in or not + ui.profEad, ui.profSAC, + ui.profHR, // very few dive computers support this + ui.profTissues }; // maybe less frequently used + + view.reset(new ProfileWidget2(DivePlannerPointsModel::instance(), this)); + QToolBar *toolBar = new QToolBar(this); + for (QAction *a: toolbarActions) + toolBar->addAction(a); + toolBar->setOrientation(Qt::Vertical); + toolBar->setIconSize(QSize(24, 24)); + QHBoxLayout *layout = new QHBoxLayout(this); + layout->setSpacing(0); + layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(toolBar); + layout->addWidget(view.get()); + setLayout(layout); + + // Toolbar Connections related to the Profile Update + 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.profDeco, &QAction::triggered, tec, &qPrefTechnicalDetails::set_decoinfo); + 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, &ProfileWidget::unsetProfHR); + connect(ui.profHR, &QAction::triggered, this, &ProfileWidget::unsetProfTissues); + + 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(&diveListNotifier, &DiveListNotifier::settingsChanged, view.get(), &ProfileWidget2::settingsChanged); + + 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.profDeco->setChecked(qPrefTechnicalDetails::decoinfo()); + 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()); +} + +ProfileWidget::~ProfileWidget() +{ +} + +void ProfileWidget::setEnabledToolbar(bool enabled) +{ + for (QAction *b: toolbarActions) + b->setEnabled(enabled); +} + +void ProfileWidget::setDive(const struct dive *d) +{ + stack->setCurrentIndex(1); // show profile + + bool freeDiveMode = d->dc.divemode == FREEDIVE; + ui.profCalcCeiling->setDisabled(freeDiveMode); + ui.profCalcCeiling->setDisabled(freeDiveMode); + ui.profCalcAllTissues ->setDisabled(freeDiveMode); + ui.profIncrement3m->setDisabled(freeDiveMode); + ui.profDcCeiling->setDisabled(freeDiveMode); + ui.profPhe->setDisabled(freeDiveMode); + ui.profPn2->setDisabled(freeDiveMode); //TODO is the same as scuba? + ui.profPO2->setDisabled(freeDiveMode); //TODO is the same as scuba? + ui.profTankbar->setDisabled(freeDiveMode); + ui.profMod->setDisabled(freeDiveMode); + ui.profNdl_tts->setDisabled(freeDiveMode); + ui.profDeco->setDisabled(freeDiveMode); + ui.profEad->setDisabled(freeDiveMode); + ui.profSAC->setDisabled(freeDiveMode); + ui.profTissues->setDisabled(freeDiveMode); + + ui.profRuler->setDisabled(false); + ui.profScaled->setDisabled(false); // measuring and scaling + ui.profTogglePicture->setDisabled(false); + ui.profHR->setDisabled(false); +} + +void ProfileWidget::plotCurrentDive() +{ + setEnabledToolbar(current_dive != nullptr); + if (current_dive) + setDive(current_dive); + view->plotDive(current_dive, dc_number); +} + +void ProfileWidget::setPlanState(const struct dive *d, int dc) +{ + setDive(d); // show subsurface logo + view->setPlanState(d, dc); +} + +void ProfileWidget::setEditState(const struct dive *d, int dc) +{ + setDive(d); + view->setEditState(d, dc); +} + +void ProfileWidget::unsetProfHR() +{ + ui.profHR->setChecked(false); + qPrefTechnicalDetails::set_hrgraph(false); +} + +void ProfileWidget::unsetProfTissues() +{ + ui.profTissues->setChecked(false); + qPrefTechnicalDetails::set_percentagegraph(false); +} diff --git a/desktop-widgets/profilewidget.h b/desktop-widgets/profilewidget.h new file mode 100644 index 000000000..8d19aaa32 --- /dev/null +++ b/desktop-widgets/profilewidget.h @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0 +// The profile and its toolbars. + +#ifndef PROFILEWIDGET_H +#define PROFILEWIDGET_H + +#include "ui_profilewidget.h" + +#include +#include + +class ProfileWidget2; + +class ProfileWidget : public QWidget { + Q_OBJECT +public: + ProfileWidget(); + ~ProfileWidget(); + std::unique_ptr view; + void plotCurrentDive(); + void setPlanState(const struct dive *d, int dc); + void setEditState(const struct dive *d, int dc); + void setEnabledToolbar(bool enabled); +private +slots: + void unsetProfHR(); + void unsetProfTissues(); +private: + std::vector toolbarActions; + Ui::ProfileWidget ui; + void setDive(const struct dive *d); +}; + +#endif // PROFILEWIDGET_H diff --git a/desktop-widgets/profilewidget.ui b/desktop-widgets/profilewidget.ui new file mode 100644 index 000000000..4930aedb4 --- /dev/null +++ b/desktop-widgets/profilewidget.ui @@ -0,0 +1,225 @@ + + + ProfileWidget + + + + true + + + + :heatmap-icon:heatmap-icon + + + Toggle tissue heat-map + + + + + true + + + + :pp-o2-icon:pp-o2-icon + + + Toggle pO₂ graph + + + + + true + + + + :pp-n2-icon:pp-n2-icon + + + Toggle pN₂ graph + + + + + true + + + + :pp-he-icon:pp-he-icon + + + Toggle pHe graph + + + + + true + + + + :ceiling-dc-icon:ceiling-dc-icon + + + Toggle DC reported ceiling + + + + + true + + + + :ceiling-calculated-icon:ceiling-calculated-icon + + + Toggle calculated ceiling + + + + + true + + + + :ceiling-tissues-icon:ceiling-tissues-icon + + + Toggle calculating all tissues + + + + + true + + + + :ceiling-increments-icon:ceiling-increments-icon + + + Toggle calculated ceiling with 3m increments + + + + + true + + + + :rate-heart-icon:rate-heart-icon + + + Toggle heart rate + + + + + true + + + + :depth-mod-icon:depth-mod-icon + + + Toggle MOD + + + + + true + + + + :depth-ead-icon:depth-ead-icon + + + Toggle EAD, END, EADD + + + + + true + + + + :depth-ndl-icon:depth-ndl-icon + + + Toggle NDL, TTS + + + + + true + + + + :rate-sac-icon:rate-sac-icon + + + Toggle SAC rate + + + + + true + + + + :ruler-icon:ruler-icon + + + Toggle ruler + + + + + true + + + + :scale-graph-icon:scale-graph-icon + + + Scale graph + + + + + true + + + + :photo-icon:photo-icon + + + Toggle media + + + + + true + + + + :gaschange-icon:gaschange-icon + + + Toggle gas bar + + + + + true + + + + :/tissue-icon:/tissue-icon + + + Toggle deco information + + + Toggle deco information + + + +