Commit ab250412 authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Add a "Used/Total" display element to the Pie Chart face

It gets used when there are 2 total sensors, showing the first one on
top and the second one below.
parent 89847645
......@@ -58,7 +58,8 @@ ChartControls.PieChartControl {
chart.backgroundColor: Qt.rgba(0.0, 0.0, 0.0, 0.2)
text: sensor.formattedValue
text: root.controller.totalSensors.length == 1 ? sensor.formattedValue : ""
valueSources: Charts.ModelSource {
model: Sensors.SensorDataModel {
id: sensorsModel
......@@ -83,5 +84,14 @@ ChartControls.PieChartControl {
id: sensor
sensorId: root.controller.totalSensors.length > 0 ? root.controller.totalSensors[0] : ""
}
UsedTotalDisplay {
anchors.centerIn: parent
visible: root.controller.totalSensors.length == 2
usedSensor: root.controller.totalSensors.length > 0 ? root.controller.totalSensors[0] : ""
totalSensor: root.controller.totalSensors.length > 1 ? root.controller.totalSensors[1] : ""
}
}
/*
* Copyright 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.12
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.2
import org.kde.kirigami 2.4 as Kirigami
import org.kde.ksysguard.formatter 1.0 as Formatter
import org.kde.ksysguard.sensors 1.0 as Sensors
ColumnLayout {
spacing: 0
property alias usedSensor: usedSensorObject.sensorId
property alias totalSensor: totalSensorObject.sensorId
Label {
id: usedLabel
Layout.alignment: Text.AlignHCenter;
text: usedSensorObject.shortName;
font: Kirigami.Theme.smallFont
color: Kirigami.Theme.disabledTextColor
}
Label {
id: usedValue
Layout.alignment: Text.AlignHCenter;
text: usedSensorObject.formattedValue
}
Kirigami.Separator { Layout.fillWidth: true }
Label {
id: totalValue
Layout.alignment: Text.AlignHCenter;
text: totalSensorObject.formattedValue
}
Label {
id: totalLabel
Layout.alignment: Text.AlignHCenter;
text: totalSensorObject.shortName
font: Kirigami.Theme.smallFont
color: Kirigami.Theme.disabledTextColor
}
Sensors.Sensor {
id: usedSensorObject
}
Sensors.Sensor {
id: totalSensorObject
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment