mirror of
https://github.com/tuxdotrs/tpanel.git
synced 2026-09-19 18:19:02 +05:30
refactor(bar): modularize bar widgets and layout
This commit is contained in:
51
modules/bar/CavaVisualizer.qml
Normal file
51
modules/bar/CavaVisualizer.qml
Normal file
@@ -0,0 +1,51 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import qs.config
|
||||
import qs.services
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
property int barCount: 14
|
||||
property real maxValue: 100
|
||||
readonly property bool shouldVisualize: barCount > 0 && Cava.values.some(v => v >= 0.001)
|
||||
|
||||
implicitWidth: 96
|
||||
implicitHeight: 32
|
||||
radius: Appearance.radius
|
||||
color: Appearance.colors.inActive
|
||||
visible: shouldVisualize
|
||||
|
||||
Row {
|
||||
id: barRow
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.margins: 8
|
||||
spacing: 3
|
||||
|
||||
Repeater {
|
||||
model: root.barCount
|
||||
|
||||
Rectangle {
|
||||
id: bar
|
||||
|
||||
required property int index
|
||||
readonly property real value: Cava.values[index] ?? 0
|
||||
|
||||
width: (barRow.width - barRow.spacing * (root.barCount - 1)) / root.barCount
|
||||
height: Math.max(2, (bar.value / root.maxValue) * barRow.height)
|
||||
anchors.bottom: parent.bottom
|
||||
radius: bar.width / 2
|
||||
color: Appearance.colors.accent
|
||||
antialiasing: true
|
||||
|
||||
Behavior on height {
|
||||
NumberAnimation {
|
||||
duration: Appearance.duration
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user