import QtQuick import "../services" as S import NovaStats as NS Item { id: root required property int percent required property color accentColor signal setPercent(real pct) implicitHeight: 36 Text { id: _icon anchors.left: parent.left anchors.leftMargin: 12 anchors.verticalCenter: parent.verticalCenter text: "\uF185" color: root.accentColor font.pixelSize: NS.ThemeService.fontSize + 2 font.family: NS.ThemeService.iconFontFamily } Item { id: _slider anchors.left: _icon.right anchors.leftMargin: 8 anchors.right: _label.left anchors.rightMargin: 8 anchors.verticalCenter: parent.verticalCenter height: 6 Rectangle { anchors.fill: parent color: NS.ThemeService.base02 radius: 3 } Rectangle { width: parent.width * root.percent / 100 height: parent.height color: root.accentColor radius: 3 Behavior on width { NumberAnimation { duration: 80 } } } MouseArea { anchors.fill: parent anchors.margins: -6 cursorShape: Qt.PointingHandCursor onPressed: mouse => _set(mouse) onPositionChanged: mouse => { if (pressed) _set(mouse); } function _set(mouse) { root.setPercent(mouse.x / _slider.width * 100); } } } Text { id: _label anchors.right: parent.right anchors.rightMargin: 12 anchors.verticalCenter: parent.verticalCenter text: root.percent + "%" color: NS.ThemeService.base05 font.pixelSize: NS.ThemeService.fontSize font.family: NS.ThemeService.fontFamily width: 30 } }