summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-10-28 12:23:41 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-03 13:41:15 -0800
commit106f7a8e0ed43a775bec5fa96f6e072c47653850 (patch)
tree25c2f694b50d2d6d569a7682a33f340aa5497293 /desktop-widgets
parent165dce4a0eb8c0832861ede8dfb874933667eae8 (diff)
downloadsubsurface-106f7a8e0ed43a775bec5fa96f6e072c47653850.tar.gz
desktop: add statistics widget dummy and application state
Add a new "statistics" application state. In the statistics state show the statistics widget and the filter in the top quadrants. The idea is to allow filtering and doing statistics at the same time. Sadly, we can't use the filter-widget in different quadrants, because Qt's ownership model is completely broken / inflexible. It does not support a widget having different parents and thus a widget can only belong to one QStackedWidget. Hiding the map in the statistics view is quite hacky: Since the view of the quadrants is not determined by the "ApplicationState", we have to restore the original quadrant visibility when exiting the stats mode. Therefore, set the original visibility-state when changing application state. The MainWindow-quadrant code really needs to be rewritten! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/CMakeLists.txt3
-rw-r--r--desktop-widgets/mainwindow.cpp18
-rw-r--r--desktop-widgets/mainwindow.h3
-rw-r--r--desktop-widgets/mainwindow.ui10
4 files changed, 33 insertions, 1 deletions
diff --git a/desktop-widgets/CMakeLists.txt b/desktop-widgets/CMakeLists.txt
index 7fc76ece3..30a001056 100644
--- a/desktop-widgets/CMakeLists.txt
+++ b/desktop-widgets/CMakeLists.txt
@@ -40,6 +40,7 @@ set (SUBSURFACE_UI
setpoint.ui
shiftimagetimes.ui
shifttimes.ui
+ statswidget.ui
tableview.ui
templateedit.ui
tripselectiodialog.ui
@@ -104,6 +105,8 @@ set(SUBSURFACE_INTERFACE
simplewidgets.cpp
simplewidgets.h
starwidget.cpp
+ statswidget.h
+ statswidget.cpp
starwidget.h
subsurfacewebservices.cpp
subsurfacewebservices.h
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index e56384540..99040aecf 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -50,6 +50,7 @@
#include "desktop-widgets/tab-widgets/maintab.h"
#include "desktop-widgets/updatemanager.h"
#include "desktop-widgets/simplewidgets.h"
+#include "desktop-widgets/statswidget.h"
#include "commands/command.h"
#include "profile-widget/profilewidget2.h"
@@ -141,6 +142,7 @@ MainWindow::MainWindow() : QMainWindow(),
graphics = new ProfileWidget2(this);
MapWidget *mapWidget = MapWidget::instance();
plannerWidgets.reset(new PlannerWidgets);
+ StatsWidget *statistics = new StatsWidget(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
@@ -183,6 +185,8 @@ MainWindow::MainWindow() : QMainWindow(),
{ diveList, FLAG_DISABLED }, { mapWidget, FLAG_NONE } });
registerApplicationState(ApplicationState::FilterDive, { { mainTab.get(), FLAG_NONE }, { profileContainer, FLAG_NONE },
{ diveList, FLAG_NONE }, { &filterWidget, FLAG_NONE } });
+ registerApplicationState(ApplicationState::Statistics, { { statistics, FLAG_NONE }, { profileContainer, FLAG_NONE },
+ { diveList, FLAG_DISABLED }, { &filterWidget, FLAG_NONE } });
setApplicationState(ApplicationState::Default);
setWindowIcon(QIcon(":subsurface-icon"));
@@ -1593,6 +1597,15 @@ void MainWindow::on_actionFilterTags_triggered()
showFilterIfEnabled();
}
+void MainWindow::on_actionStats_triggered()
+{
+ setApplicationState(getAppState() == ApplicationState::Statistics ? ApplicationState::Default : ApplicationState::Statistics);
+ toggleCollapsible(true);
+ ui.topSplitter->setSizes({ EXPANDED, COLLAPSED });
+ ui.mainSplitter->setSizes({ EXPANDED, EXPANDED });
+ ui.bottomSplitter->setSizes({ EXPANDED, EXPANDED });
+}
+
void MainWindow::showFilterIfEnabled()
{
if (getAppState() == ApplicationState::FilterDive) {
@@ -1642,6 +1655,11 @@ void MainWindow::setApplicationState(ApplicationState state)
setQuadrant(quadrants.topRight, ui.topRight);
setQuadrant(quadrants.bottomLeft, ui.bottomLeft);
setQuadrant(quadrants.bottomRight, ui.bottomRight);
+
+ // The statistics view does its own thing with respect to visibility
+ // of quadrants. So in case we leave that state, change to the
+ // original visibility of the quadrants.
+ enterState(this->state);
}
void MainWindow::showProgressBar()
diff --git a/desktop-widgets/mainwindow.h b/desktop-widgets/mainwindow.h
index eb5d76447..6734eb7bd 100644
--- a/desktop-widgets/mainwindow.h
+++ b/desktop-widgets/mainwindow.h
@@ -51,7 +51,7 @@ public:
MAP_MAXIMIZED,
INFO_MAXIMIZED,
PROFILE_MAXIMIZED,
- LIST_MAXIMIZED,
+ LIST_MAXIMIZED
};
MainWindow();
@@ -131,6 +131,7 @@ slots:
void on_copy_triggered();
void on_paste_triggered();
void on_actionFilterTags_triggered();
+ void on_actionStats_triggered();
void on_actionConfigure_Dive_Computer_triggered();
void setDefaultState();
void setAutomaticTitle();
diff --git a/desktop-widgets/mainwindow.ui b/desktop-widgets/mainwindow.ui
index 071e4fe53..c7c464f71 100644
--- a/desktop-widgets/mainwindow.ui
+++ b/desktop-widgets/mainwindow.ui
@@ -97,6 +97,7 @@
<addaction name="actionAutoGroup"/>
<addaction name="separator"/>
<addaction name="actionFilterTags"/>
+ <addaction name="actionStats"/>
</widget>
<widget class="QMenu" name="menuView">
<property name="title">
@@ -107,6 +108,7 @@
<addaction name="actionViewProfile"/>
<addaction name="actionViewInfo"/>
<addaction name="actionViewMap"/>
+ <addaction name="actionViewStats"/>
<addaction name="separator"/>
<addaction name="actionYearlyStatistics"/>
<addaction name="actionPreviousDC"/>
@@ -640,6 +642,14 @@
<string notr="true">Ctrl+F</string>
</property>
</action>
+ <action name="actionStats">
+ <property name="text">
+ <string>Dive statistics</string>
+ </property>
+ <property name="shortcut">
+ <string notr="true">Ctrl+T</string>
+ </property>
+ </action>
<action name="profTissues">
<property name="checkable">
<bool>true</bool>