harbour-seaprint/qml/components/SupplyItem.qml

51 lines
1.4 KiB
QML
Raw Normal View History

2020-09-29 22:47:37 +03:00
import QtQuick 2.6
import Sailfish.Silica 1.0
2020-10-10 14:01:56 +03:00
import "../components"
2020-09-29 22:47:37 +03:00
Row
{
id: item
property var color: "white"
property int level: 100
property int high_level: 100
2022-01-13 23:09:25 +03:00
property int low_level: 10
2021-02-13 17:23:14 +03:00
property string name: ""
property string type: ""
2022-05-27 15:28:32 +03:00
property real value_fraction: level/(high_level == 0 ? 100 : high_level)
2020-09-29 22:47:37 +03:00
spacing: Theme.paddingMedium
bottomPadding: Theme.paddingMedium
2020-10-10 14:01:56 +03:00
CylinderGraph
2020-09-29 22:47:37 +03:00
{
anchors.verticalCenter: parent.verticalCenter
2020-10-10 14:01:56 +03:00
color: parent.color
2022-05-27 15:28:32 +03:00
value: value_fraction
2020-09-29 22:47:37 +03:00
}
Label
{
anchors.verticalCenter: parent.verticalCenter
2020-10-10 17:59:22 +03:00
width: Theme.itemSizeExtraSmall
2022-05-27 15:28:32 +03:00
text: ""+(100*value_fraction)+"%"
2022-01-13 23:09:25 +03:00
color: level <= low_level ? "red" : Theme.highlightColor
2020-10-10 17:59:22 +03:00
font.pixelSize: Theme.fontSizeExtraSmall
2020-09-29 22:47:37 +03:00
}
Column
{
2020-10-10 17:59:22 +03:00
anchors.verticalCenter: parent.verticalCenter
2020-09-29 22:47:37 +03:00
Label
{
2021-02-13 19:34:22 +03:00
text: name != "" ? name : qsTr("Unnamed supply")
2020-09-29 22:47:37 +03:00
font.pixelSize: Theme.fontSizeExtraSmall
}
Label
{
2021-02-13 17:23:14 +03:00
text: type != "" ? type : qsTr("Unknown type")
2020-09-29 22:47:37 +03:00
font.pixelSize: Theme.fontSizeExtraSmall
color: Theme.secondaryColor
}
}
}