mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
mobile/statistics: add a statistics page on mobile
This adds a reasonably flexibile mobile page that tries to do the right thing for both portrait and landscape mode. In order to get the most out of a mobile screen, it's implemented in a way that always gives it the full screen (it does so by emptying out the page stack and being the only page shown - brutal, but effective). This commit also contains a bunch of other random cleanups that didn't really justify being in separate commits. Parts of this was written by Berthold, hence the double SOB. Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
d77f254328
commit
eb2b0f0a3e
5 changed files with 229 additions and 3 deletions
119
mobile-widgets/qml/StatisticsPage.qml
Normal file
119
mobile-widgets/qml/StatisticsPage.qml
Normal file
|
@ -0,0 +1,119 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
import QtQuick 2.6
|
||||
import QtQuick.Controls 2.4
|
||||
import QtQuick.Layouts 1.2
|
||||
import org.subsurfacedivelog.mobile 1.0
|
||||
import org.kde.kirigami 2.4 as Kirigami
|
||||
|
||||
Kirigami.Page {
|
||||
id: statisticsPage
|
||||
objectName: "StatisticsPage"
|
||||
title: qsTr("Statistics")
|
||||
leftPadding: 0
|
||||
topPadding: 0
|
||||
rightPadding: 0
|
||||
bottomPadding: 0
|
||||
width: rootItem.width
|
||||
implicitWidth: rootItem.width
|
||||
property bool wide: width > height
|
||||
StatsManager {
|
||||
id: statsManager
|
||||
}
|
||||
onVisibleChanged: {
|
||||
if (visible)
|
||||
statsManager.doit()
|
||||
}
|
||||
|
||||
GridLayout {
|
||||
anchors.fill: parent
|
||||
ColumnLayout {
|
||||
id: i1
|
||||
Layout.column: 0
|
||||
Layout.row: 0
|
||||
Layout.margins: Kirigami.Units.smallSpacing
|
||||
TemplateLabelSmall {
|
||||
text: qsTr("Base variable")
|
||||
}
|
||||
TemplateComboBox {
|
||||
id: var1
|
||||
model: statsManager.var1List
|
||||
Layout.fillWidth: false
|
||||
onCurrentIndexChanged: {
|
||||
statsManager.var1Changed(currentIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
ColumnLayout {
|
||||
id: i2
|
||||
Layout.column: wide ? 0 : 1
|
||||
Layout.row: wide ? 1 : 0
|
||||
Layout.margins: Kirigami.Units.smallSpacing
|
||||
TemplateLabelSmall {
|
||||
text: qsTr("Binning")
|
||||
}
|
||||
TemplateComboBox {
|
||||
id: var1Binner
|
||||
model: statsManager.binner1List
|
||||
Layout.fillWidth: false
|
||||
onCurrentIndexChanged: {
|
||||
statsManager.var1BinnerChanged(currentIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
ColumnLayout {
|
||||
id: i3
|
||||
Layout.column: wide ? 0 : 2
|
||||
Layout.row: wide ? 2 : 0
|
||||
Layout.margins: Kirigami.Units.smallSpacing
|
||||
TemplateLabelSmall {
|
||||
text: qsTr("Data")
|
||||
}
|
||||
TemplateComboBox {
|
||||
id: var2
|
||||
model: statsManager.var2List
|
||||
Layout.fillWidth: false
|
||||
onCurrentIndexChanged: {
|
||||
statsManager.var2Changed(currentIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
ColumnLayout {
|
||||
id: i4
|
||||
Layout.column: wide ? 0 : 3
|
||||
Layout.row: wide ? 3 : 0
|
||||
Layout.margins: Kirigami.Units.smallSpacing
|
||||
TemplateLabelSmall {
|
||||
text: qsTr("Binning")
|
||||
}
|
||||
TemplateComboBox {
|
||||
id: var2Binner
|
||||
model: statsManager.binner2List
|
||||
Layout.fillWidth: false
|
||||
onCurrentIndexChanged: {
|
||||
statsManager.var2BinnerChanged(currentIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
Item {
|
||||
Layout.column: wide ? 0 : 4
|
||||
Layout.row: wide ? 4 : 0
|
||||
Layout.preferredHeight: wide ? parent.height - Kirigami.Units.gridUnit * 16 : Kirigami.Units.gridUnit
|
||||
Layout.preferredWidth: wide ? parent.width - i1.implicitWidt - i2.implicitWidt - i3.implicitWidt - i4.implicitWidth : Kirigami.Units.gridUnit
|
||||
// just used for spacing
|
||||
}
|
||||
|
||||
StatsView {
|
||||
Layout.row: wide ? 0 : 1
|
||||
Layout.column: wide ? 1 : 0
|
||||
Layout.rowSpan: wide ? 5 : 1
|
||||
Layout.columnSpan: wide ? 1 : 5
|
||||
id: statsView
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
statsManager.init(statsView, var1)
|
||||
console.log("Statistics widget loaded")
|
||||
}
|
||||
}
|
|
@ -88,6 +88,9 @@ Kirigami.ApplicationWindow {
|
|||
for (var i=pageStack.depth; i>1; i--) {
|
||||
pageStack.pop()
|
||||
}
|
||||
if (pageStack.currentItem !== diveList) {
|
||||
showDiveList()
|
||||
}
|
||||
detailsWindow.endEditMode()
|
||||
}
|
||||
|
||||
|
@ -96,6 +99,15 @@ Kirigami.ApplicationWindow {
|
|||
}
|
||||
|
||||
function showPage(page) {
|
||||
if (page === statistics) {
|
||||
manager.appendTextToLog("switching to statistics page, clearing out stack")
|
||||
pageStack.clear()
|
||||
}
|
||||
if (pageStack.currentItem === statistics) {
|
||||
manager.appendTextToLog("switching away from statistics page, clearing out stack")
|
||||
pageStack.clear()
|
||||
}
|
||||
|
||||
if (page !== mapPage)
|
||||
hackToOpenMap = 0 // we really want a different page
|
||||
if (globalDrawer.drawerOpen)
|
||||
|
@ -440,6 +452,12 @@ if you have network connectivity and want to sync your data to cloud storage."),
|
|||
}
|
||||
}
|
||||
},
|
||||
Kirigami.Action {
|
||||
text: qsTr("Statistics")
|
||||
onTriggered: {
|
||||
showPage(statistics)
|
||||
}
|
||||
},
|
||||
Kirigami.Action {
|
||||
icon {
|
||||
name: ":/icons/ic_settings.svg"
|
||||
|
@ -859,9 +877,13 @@ if you have network connectivity and want to sync your data to cloud storage."),
|
|||
visible: false
|
||||
}
|
||||
|
||||
StatisticsPage {
|
||||
id: statistics
|
||||
visible: false
|
||||
}
|
||||
|
||||
Settings {
|
||||
id: settingsWindow
|
||||
visible: false
|
||||
}
|
||||
|
||||
CopySettings {
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
<file>Log.qml</file>
|
||||
<file>main.qml</file>
|
||||
<file>MapPage.qml</file>
|
||||
<file>StatisticsPage.qml</file>
|
||||
<file>Settings.qml</file>
|
||||
<file>CopySettings.qml</file>
|
||||
<file>ThemeTest.qml</file>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue