From bb841dee9c5c8ea9b91e0d955f0f0ce4d3e6fdda Mon Sep 17 00:00:00 2001 From: cutefishd Date: Sun, 9 May 2021 16:51:19 +0800 Subject: [PATCH] Fix battery history --- src/images/performance.svg | 170 +++++++++++++++++++++++++++++++++++++ src/images/powersave.svg | 119 ++++++++++++++++++++++++++ src/qml/BatteryItem.qml | 2 +- src/qml/BatteryPage.qml | 4 +- src/qml/HistoryGraph.qml | 4 + src/qml/Power/main.qml | 47 ++++++++++ src/qml/SideBar.qml | 7 ++ src/resources.qrc | 3 + 8 files changed, 353 insertions(+), 3 deletions(-) create mode 100644 src/images/performance.svg create mode 100644 src/images/powersave.svg create mode 100644 src/qml/Power/main.qml diff --git a/src/images/performance.svg b/src/images/performance.svg new file mode 100644 index 0000000..eea9a08 --- /dev/null +++ b/src/images/performance.svg @@ -0,0 +1,170 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/images/powersave.svg b/src/images/powersave.svg new file mode 100644 index 0000000..a18c805 --- /dev/null +++ b/src/images/powersave.svg @@ -0,0 +1,119 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/qml/BatteryItem.qml b/src/qml/BatteryItem.qml index 0d50f49..4b4d8cf 100644 --- a/src/qml/BatteryItem.qml +++ b/src/qml/BatteryItem.qml @@ -9,7 +9,7 @@ Item { height: 150 property int value: 0 - property int radius: height * 0.2 + property int radius: height * 0.15 property bool enableAnimation: false Rectangle { diff --git a/src/qml/BatteryPage.qml b/src/qml/BatteryPage.qml index 313e278..544e304 100644 --- a/src/qml/BatteryPage.qml +++ b/src/qml/BatteryPage.qml @@ -99,7 +99,7 @@ ItemPage { } RoundedItem { - visible: history.count + visible: history.count > 2 Label { text: qsTr("History") @@ -143,7 +143,7 @@ ItemPage { } } yStep: batteryPage.historyType === BatteryHistoryModel.RateType ? 10 : 20 - visible: history.count > 1 + visible: history.count > 2 } } diff --git a/src/qml/HistoryGraph.qml b/src/qml/HistoryGraph.qml index fdd688d..e9f07ff 100644 --- a/src/qml/HistoryGraph.qml +++ b/src/qml/HistoryGraph.qml @@ -108,6 +108,10 @@ Canvas { } } + // The data is empty. + if (point === undefined) + return + c.stroke(); c.strokeStyle = 'rgba(0, 0, 0, 0)'; c.lineTo(point.x, height - yPadding); diff --git a/src/qml/Power/main.qml b/src/qml/Power/main.qml new file mode 100644 index 0000000..9627386 --- /dev/null +++ b/src/qml/Power/main.qml @@ -0,0 +1,47 @@ +import QtQuick 2.4 +import QtQuick.Controls 2.4 +import QtQuick.Layouts 1.3 +import QtGraphicalEffects 1.0 + +import FishUI 1.0 as FishUI +import "../" + +ItemPage { + id: control + headerTitle: qsTr("Power") + + Scrollable { + anchors.fill: parent + contentHeight: layout.implicitHeight + + ColumnLayout { + id: layout + anchors.fill: parent + spacing: FishUI.Units.largeSpacing * 2 + + RoundedItem { + Label { + text: qsTr("Mode") + color: FishUI.Theme.disabledTextColor + bottomPadding: FishUI.Units.smallSpacing + } + + RowLayout { + spacing: FishUI.Units.largeSpacing * 2 + + IconCheckBox { + source: "qrc:/images/powersave.svg" + text: qsTr("Power Save") + checked: true + } + + IconCheckBox { + source: "qrc:/images/performance.svg" + text: qsTr("Performance") + checked: false + } + } + } + } + } +} diff --git a/src/qml/SideBar.qml b/src/qml/SideBar.qml index dd12a62..250dff1 100644 --- a/src/qml/SideBar.qml +++ b/src/qml/SideBar.qml @@ -92,6 +92,13 @@ Item { iconSource: "battery.svg" } +// ListElement { +// title: qsTr("Power") +// name: "power" +// page: "qrc:/qml/Power/main.qml" +// iconSource: "battery.svg" +// } + ListElement { title: qsTr("About") name: "about" diff --git a/src/resources.qrc b/src/resources.qrc index 52635b9..85e12bf 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -87,5 +87,8 @@ qml/NetworkPage/WirelessDetailsDialog.qml qml/NetworkPage/WiredItem.qml qml/RoundedItem.qml + images/powersave.svg + images/performance.svg + qml/Power/main.qml