profile: remove profile widget code from mainwindow

Create a new class that encapsulates the profile-widget UI.

This is called ProfileWidget, which might be confusing since
the actual display is called ProfileWidget2. However, the
plan is to rename the latter to ProfileView. After all, it
is also used to print and to show the profile on mobile.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-04-12 23:34:28 +02:00 committed by Dirk Hohndel
parent 6b615ccb4b
commit 13d4f595cb
7 changed files with 443 additions and 365 deletions

View file

@ -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

View file

@ -11,7 +11,6 @@
#include <QDesktopWidget>
#include <QSettings>
#include <QShortcut>
#include <QToolBar>
#include <QStatusBar>
#include <QNetworkProxy>
#include <QUndoStack>
@ -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<dive *> &dives, DiveField field)
{
Q_UNUSED(field)

View file

@ -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> mainTab;
std::unique_ptr<PlannerWidgets> plannerWidgets;
std::unique_ptr<StatsWidget> statistics;
std::unique_ptr<DiveListView> diveList;
std::unique_ptr<QWidget> profileContainer;
std::unique_ptr<ProfileWidget> profile;
std::unique_ptr<MapWidget> 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<QSplitter> topSplitter;
std::unique_ptr<QSplitter> bottomSplitter;
ProfileWidget2 *graphics;
QAction *actionNextDive;
QAction *actionPreviousDive;
QAction *undoAction;
@ -205,7 +202,6 @@ private:
QDialog *findMovedImagesDialog;
struct dive copyPasteDive;
struct dive_components what;
QList<QAction *> 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;

View file

@ -424,198 +424,6 @@
<string>Edit &amp;dive in planner</string>
</property>
</action>
<action name="profPO2">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:pp-o2-icon</normaloff>:pp-o2-icon</iconset>
</property>
<property name="text">
<string>Toggle pO₂ graph</string>
</property>
</action>
<action name="profPn2">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:pp-n2-icon</normaloff>:pp-n2-icon</iconset>
</property>
<property name="text">
<string>Toggle pN₂ graph</string>
</property>
</action>
<action name="profPhe">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:pp-he-icon</normaloff>:pp-he-icon</iconset>
</property>
<property name="text">
<string>Toggle pHe graph</string>
</property>
</action>
<action name="profDcCeiling">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:ceiling-dc-icon</normaloff>:ceiling-dc-icon</iconset>
</property>
<property name="text">
<string>Toggle DC reported ceiling</string>
</property>
</action>
<action name="profCalcCeiling">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:ceiling-calculated-icon</normaloff>:ceiling-calculated-icon</iconset>
</property>
<property name="text">
<string>Toggle calculated ceiling</string>
</property>
</action>
<action name="profCalcAllTissues">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:ceiling-tissues-icon</normaloff>:ceiling-tissues-icon</iconset>
</property>
<property name="text">
<string>Toggle calculating all tissues</string>
</property>
</action>
<action name="profIncrement3m">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:ceiling-increments-icon</normaloff>:ceiling-increments-icon</iconset>
</property>
<property name="text">
<string>Toggle calculated ceiling with 3m increments</string>
</property>
</action>
<action name="profHR">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:rate-heart-icon</normaloff>:rate-heart-icon</iconset>
</property>
<property name="text">
<string>Toggle heart rate</string>
</property>
</action>
<action name="profMod">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:depth-mod-icon</normaloff>:depth-mod-icon</iconset>
</property>
<property name="text">
<string>Toggle MOD</string>
</property>
</action>
<action name="profEad">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:depth-ead-icon</normaloff>:depth-ead-icon</iconset>
</property>
<property name="text">
<string>Toggle EAD, END, EADD</string>
</property>
</action>
<action name="profNdl_tts">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:depth-ndl-icon</normaloff>:depth-ndl-icon</iconset>
</property>
<property name="text">
<string>Toggle NDL, TTS</string>
</property>
</action>
<action name="profSAC">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:rate-sac-icon</normaloff>:rate-sac-icon</iconset>
</property>
<property name="text">
<string>Toggle SAC rate</string>
</property>
</action>
<action name="profRuler">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:ruler-icon</normaloff>:ruler-icon</iconset>
</property>
<property name="text">
<string>Toggle ruler</string>
</property>
</action>
<action name="profScaled">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:scale-graph-icon</normaloff>:scale-graph-icon</iconset>
</property>
<property name="text">
<string>Scale graph</string>
</property>
</action>
<action name="profTogglePicture">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:photo-icon</normaloff>:photo-icon</iconset>
</property>
<property name="text">
<string>Toggle media</string>
</property>
</action>
<action name="profTankbar">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:gaschange-icon</normaloff>:gaschange-icon</iconset>
</property>
<property name="text">
<string>Toggle gas bar</string>
</property>
</action>
<action name="actionFilterTags">
<property name="checkable">
<bool>false</bool>
@ -635,18 +443,6 @@
<string notr="true">Ctrl+T</string>
</property>
</action>
<action name="profTissues">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:heatmap-icon</normaloff>:heatmap-icon</iconset>
</property>
<property name="text">
<string>Toggle tissue heat-map</string>
</property>
</action>
<action name="action_Undo">
<property name="text">
<string>&amp;Undo</string>
@ -699,21 +495,6 @@
<string>Cloud stora&amp;ge online</string>
</property>
</action>
<action name="profDeco">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/tissue-icon</normaloff>:/tissue-icon</iconset>
</property>
<property name="text">
<string>Toggle deco information</string>
</property>
<property name="toolTip">
<string>Toggle deco information</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View file

@ -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 <QToolBar>
#include <QHBoxLayout>
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);
}

View file

@ -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 <vector>
#include <memory>
class ProfileWidget2;
class ProfileWidget : public QWidget {
Q_OBJECT
public:
ProfileWidget();
~ProfileWidget();
std::unique_ptr<ProfileWidget2> 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<QAction *> toolbarActions;
Ui::ProfileWidget ui;
void setDive(const struct dive *d);
};
#endif // PROFILEWIDGET_H

View file

@ -0,0 +1,225 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProfileWidget</class>
<widget class="QWidget" name="ProfileWidget">
<action name="profTissues">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:heatmap-icon</normaloff>:heatmap-icon</iconset>
</property>
<property name="text">
<string>Toggle tissue heat-map</string>
</property>
</action>
<action name="profPO2">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:pp-o2-icon</normaloff>:pp-o2-icon</iconset>
</property>
<property name="text">
<string>Toggle pO₂ graph</string>
</property>
</action>
<action name="profPn2">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:pp-n2-icon</normaloff>:pp-n2-icon</iconset>
</property>
<property name="text">
<string>Toggle pN₂ graph</string>
</property>
</action>
<action name="profPhe">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:pp-he-icon</normaloff>:pp-he-icon</iconset>
</property>
<property name="text">
<string>Toggle pHe graph</string>
</property>
</action>
<action name="profDcCeiling">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:ceiling-dc-icon</normaloff>:ceiling-dc-icon</iconset>
</property>
<property name="text">
<string>Toggle DC reported ceiling</string>
</property>
</action>
<action name="profCalcCeiling">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:ceiling-calculated-icon</normaloff>:ceiling-calculated-icon</iconset>
</property>
<property name="text">
<string>Toggle calculated ceiling</string>
</property>
</action>
<action name="profCalcAllTissues">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:ceiling-tissues-icon</normaloff>:ceiling-tissues-icon</iconset>
</property>
<property name="text">
<string>Toggle calculating all tissues</string>
</property>
</action>
<action name="profIncrement3m">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:ceiling-increments-icon</normaloff>:ceiling-increments-icon</iconset>
</property>
<property name="text">
<string>Toggle calculated ceiling with 3m increments</string>
</property>
</action>
<action name="profHR">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:rate-heart-icon</normaloff>:rate-heart-icon</iconset>
</property>
<property name="text">
<string>Toggle heart rate</string>
</property>
</action>
<action name="profMod">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:depth-mod-icon</normaloff>:depth-mod-icon</iconset>
</property>
<property name="text">
<string>Toggle MOD</string>
</property>
</action>
<action name="profEad">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:depth-ead-icon</normaloff>:depth-ead-icon</iconset>
</property>
<property name="text">
<string>Toggle EAD, END, EADD</string>
</property>
</action>
<action name="profNdl_tts">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:depth-ndl-icon</normaloff>:depth-ndl-icon</iconset>
</property>
<property name="text">
<string>Toggle NDL, TTS</string>
</property>
</action>
<action name="profSAC">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:rate-sac-icon</normaloff>:rate-sac-icon</iconset>
</property>
<property name="text">
<string>Toggle SAC rate</string>
</property>
</action>
<action name="profRuler">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:ruler-icon</normaloff>:ruler-icon</iconset>
</property>
<property name="text">
<string>Toggle ruler</string>
</property>
</action>
<action name="profScaled">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:scale-graph-icon</normaloff>:scale-graph-icon</iconset>
</property>
<property name="text">
<string>Scale graph</string>
</property>
</action>
<action name="profTogglePicture">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:photo-icon</normaloff>:photo-icon</iconset>
</property>
<property name="text">
<string>Toggle media</string>
</property>
</action>
<action name="profTankbar">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:gaschange-icon</normaloff>:gaschange-icon</iconset>
</property>
<property name="text">
<string>Toggle gas bar</string>
</property>
</action>
<action name="profDeco">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/tissue-icon</normaloff>:/tissue-icon</iconset>
</property>
<property name="text">
<string>Toggle deco information</string>
</property>
<property name="toolTip">
<string>Toggle deco information</string>
</property>
</action>
</widget>
</ui>