summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-12 10:29:37 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-13 11:39:36 -0800
commit4454cf0381625d91a74310e8abe3eb1de8ea83a1 (patch)
treecfe119493de4776e96c2843c5cdc6d85ded85075
parent12842f4a86761569d867e54a523a586409a03dc5 (diff)
downloadsubsurface-4454cf0381625d91a74310e8abe3eb1de8ea83a1.tar.gz
mobile/statistics: allow chart selection for statistics
Based on a dummy commit from Berthold, this provides a styled popup of the available chart types for the current variables. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--mobile-widgets/qml/StatisticsPage.qml79
1 files changed, 75 insertions, 4 deletions
diff --git a/mobile-widgets/qml/StatisticsPage.qml b/mobile-widgets/qml/StatisticsPage.qml
index cf9f88368..6b02b0401 100644
--- a/mobile-widgets/qml/StatisticsPage.qml
+++ b/mobile-widgets/qml/StatisticsPage.qml
@@ -19,6 +19,9 @@ Kirigami.Page {
StatsManager {
id: statsManager
}
+ ChartListModel {
+ id: chartListModel
+ }
onVisibleChanged: {
if (visible)
statsManager.doit()
@@ -29,6 +32,53 @@ Kirigami.Page {
}
}
+ Component {
+ id: chartListDelegate
+ Kirigami.AbstractListItem {
+ id: chartListDelegateItem
+ height: isHeader ? 1 + 8 * Kirigami.Units.smallSpacing : 11 * Kirigami.Units.smallSpacing // delegateInnerItem.height
+ onClicked: {
+ if (!isHeader) {
+ chartTypePopup.close()
+ statsManager.setChart(id)
+ }
+ }
+ Item {
+ id: chartListDelegateInnerItem
+ Row {
+ height: childrenRect.height
+ spacing: Kirigami.Units.smallSpacing
+ Kirigami.Icon {
+ id: chartIcon
+ source: icon
+ width: iconSize !== undefined ? iconSize.width : 0
+ }
+ Label {
+ text: chartName
+ font.bold: isHeader
+ }
+ }
+ }
+ }
+ }
+ Popup {
+ id: chartTypePopup
+ x: Kirigami.Units.gridUnit * 2
+ y: Kirigami.Units.gridUnit
+ width: Math.min(Kirigami.Units.gridUnit * 12, statisticsPage.width * 0.6)
+ height: Math.min(statisticsPage.height - 3 * Kirigami.Units.gridUnit, chartListModel.count * Kirigami.Units.gridUnit * 2.75)
+ modal: true
+ focus: true
+ clip: true
+ closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
+ ListView {
+ id: chartTypes
+ model: chartListModel
+ anchors.fill: parent
+ delegate: chartListDelegate
+ }
+ }
+
GridLayout {
anchors.fill: parent
ColumnLayout {
@@ -120,19 +170,40 @@ Kirigami.Page {
}
}
}
- Item {
+ Button {
+ id: chartTypeButton
Layout.column: wide ? 0 : 1
Layout.row: wide ? 5 : 2
+ Layout.leftMargin: Kirigami.Units.smallSpacing
+ Layout.topMargin: Kirigami.Units.largeSpacing
+ Layout.preferredHeight: Kirigami.Units.gridUnit * 2
+ Layout.preferredWidth: Kirigami.Units.gridUnit * 8
+ background: Rectangle {
+ color: chartTypeButton.pressed ? subsurfaceTheme.darkerPrimaryColor : subsurfaceTheme.primaryColor
+ antialiasing: true
+ radius: Kirigami.Units.smallSpacing * 2
+ height: Kirigami.Units.gridUnit * 2
+ }
+ contentItem: Text {
+ verticalAlignment: Qt.AlignVCenter
+ horizontalAlignment: Qt.AlignHCenter
+ color: subsurfaceTheme.primaryTextColor
+ text: qsTr("Chart type")
+ }
+ onClicked: chartTypePopup.open()
+ }
+ Item {
+ Layout.column: wide ? 0 : 1
+ Layout.row: wide ? 6 : 2
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.column: wide ? 1 : 0
Layout.row: wide ? 0 : 3
Layout.columnSpan: wide ? 1 : 3
- Layout.rowSpan: wide ? 6 : 1
+ Layout.rowSpan: wide ? 7 : 1
id: statsView
Layout.margins: Kirigami.Units.smallSpacing
Layout.fillWidth: true
@@ -148,7 +219,7 @@ Kirigami.Page {
}
}
Component.onCompleted: {
- statsManager.init(statsView, var1)
+ statsManager.init(statsView, chartListModel)
console.log("Statistics widget loaded")
}
}