add noctalia and fuzzel
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import QtQuick
|
||||
import qs.Commons
|
||||
|
||||
Item {
|
||||
id: root
|
||||
property color fillColor: Color.mPrimary
|
||||
property color strokeColor: Color.mOnSurface
|
||||
property int strokeWidth: 0
|
||||
property var values: []
|
||||
property bool vertical: false
|
||||
property string barPosition: "top" // "top", "bottom", "left", "right"
|
||||
property bool mirrored: true
|
||||
|
||||
// Minimum signal properties
|
||||
property bool showMinimumSignal: false
|
||||
property real minimumSignalValue: 0.01 // Default to 1% of height
|
||||
|
||||
// Pre compute horizontal mirroring
|
||||
readonly property int valuesCount: (values && values.length !== undefined) ? values.length : 0
|
||||
readonly property int totalBars: mirrored ? valuesCount * 2 : valuesCount
|
||||
readonly property real barSlotSize: totalBars > 0 ? (vertical ? height : width) / totalBars : 0
|
||||
readonly property bool highQuality: (Settings.data.audio.visualizerType === "low") ? false : true
|
||||
|
||||
Repeater {
|
||||
model: root.totalBars
|
||||
|
||||
Rectangle {
|
||||
property int valueIndex: root.mirrored ? (index < root.valuesCount ? root.valuesCount - 1 - index : index - root.valuesCount) : index
|
||||
|
||||
property real rawAmp: (root.values && root.values[valueIndex] !== undefined) ? root.values[valueIndex] : 0
|
||||
property real amp: (root.showMinimumSignal && rawAmp === 0) ? root.minimumSignalValue : rawAmp
|
||||
|
||||
color: root.fillColor
|
||||
border.color: root.strokeColor
|
||||
border.width: root.strokeWidth
|
||||
antialiasing: root.highQuality
|
||||
smooth: root.highQuality
|
||||
|
||||
// Only update when value actually changes - reduces GPU load
|
||||
width: vertical ? root.width * amp : root.barSlotSize * 0.5
|
||||
height: vertical ? root.barSlotSize * 0.5 : root.height * amp
|
||||
x: vertical ? (root.barPosition === "left" ? 0 : root.width - width) : index * root.barSlotSize + (root.barSlotSize * 0.25)
|
||||
y: vertical ? index * root.barSlotSize + (root.barSlotSize * 0.25) : root.height - height
|
||||
|
||||
// Disable updates when invisible to save GPU
|
||||
visible: root.visible
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import QtQuick
|
||||
import qs.Commons
|
||||
|
||||
Item {
|
||||
id: root
|
||||
property color fillColor: Color.mPrimary
|
||||
property color strokeColor: Color.mOnSurface
|
||||
property int strokeWidth: 0
|
||||
property var values: []
|
||||
property bool vertical: false
|
||||
property bool mirrored: true
|
||||
|
||||
// Minimum signal properties
|
||||
property bool showMinimumSignal: false
|
||||
property real minimumSignalValue: 0.01 // Default to 1% of height
|
||||
|
||||
// Pre-compute mirroring
|
||||
readonly property int valuesCount: (values && values.length !== undefined) ? values.length : 0
|
||||
readonly property int totalBars: mirrored ? valuesCount * 2 : valuesCount
|
||||
readonly property real barSlotSize: totalBars > 0 ? (vertical ? height : width) / totalBars : 0
|
||||
readonly property bool highQuality: (Settings.data.audio.visualizerType === "low") ? false : true
|
||||
readonly property real centerY: height / 2
|
||||
readonly property real centerX: width / 2
|
||||
|
||||
Repeater {
|
||||
model: root.totalBars
|
||||
|
||||
Rectangle {
|
||||
property int valueIndex: root.mirrored ? (index < root.valuesCount ? root.valuesCount - 1 - index : index - root.valuesCount) : index
|
||||
|
||||
property real rawAmp: (root.values && root.values[valueIndex] !== undefined) ? root.values[valueIndex] : 0
|
||||
property real amp: (root.showMinimumSignal && rawAmp === 0) ? root.minimumSignalValue : rawAmp
|
||||
|
||||
property real barSize: (vertical ? root.width : root.height) * amp
|
||||
|
||||
color: root.fillColor
|
||||
border.color: root.strokeColor
|
||||
border.width: root.strokeWidth
|
||||
antialiasing: root.highQuality
|
||||
smooth: root.highQuality
|
||||
|
||||
width: vertical ? barSize : root.barSlotSize * 0.8
|
||||
height: vertical ? root.barSlotSize * 0.8 : barSize
|
||||
x: vertical ? root.centerX - (barSize / 2) : index * root.barSlotSize + (root.barSlotSize * 0.25)
|
||||
y: vertical ? index * root.barSlotSize + (root.barSlotSize * 0.25) : root.centerY - (barSize / 2)
|
||||
|
||||
// Disable updates when invisible to save GPU
|
||||
visible: root.visible
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import qs.Commons
|
||||
|
||||
Item {
|
||||
id: root
|
||||
property color fillColor: Color.mPrimary
|
||||
property color strokeColor: Color.mOnSurface
|
||||
property int strokeWidth: 0
|
||||
property var values: []
|
||||
property bool vertical: false
|
||||
property bool mirrored: true
|
||||
|
||||
// Minimum signal properties
|
||||
property bool showMinimumSignal: false
|
||||
property real minimumSignalValue: 0.01 // Default to 1% of height
|
||||
|
||||
readonly property int valuesCount: (values && values.length !== undefined) ? values.length : 0
|
||||
readonly property bool hasData: valuesCount >= 2
|
||||
|
||||
// Data texture: one pixel per value, R channel = amplitude
|
||||
Item {
|
||||
id: dataRow
|
||||
width: Math.max(root.valuesCount, 4)
|
||||
height: 1
|
||||
|
||||
Repeater {
|
||||
model: dataRow.width
|
||||
|
||||
Rectangle {
|
||||
required property int index
|
||||
x: index
|
||||
width: 1
|
||||
height: 1
|
||||
color: {
|
||||
if (index >= root.valuesCount)
|
||||
return Qt.rgba(0, 0, 0, 1);
|
||||
var v = root.values[index];
|
||||
if (v === undefined || v === null || !isFinite(v))
|
||||
v = 0;
|
||||
if (root.showMinimumSignal && v === 0)
|
||||
v = root.minimumSignalValue;
|
||||
return Qt.rgba(Math.max(0, Math.min(1, v)), 0, 0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShaderEffectSource {
|
||||
id: dataTex
|
||||
sourceItem: dataRow
|
||||
textureSize: Qt.size(dataRow.width, 1)
|
||||
live: true
|
||||
smooth: false
|
||||
hideSource: true
|
||||
}
|
||||
|
||||
ShaderEffect {
|
||||
anchors.fill: parent
|
||||
visible: root.hasData && root.width > 0 && root.height > 0
|
||||
|
||||
property variant dataSource: dataTex
|
||||
property color fillColor: root.fillColor
|
||||
property real count: root.valuesCount
|
||||
property real texWidth: dataRow.width
|
||||
property real vertical: root.vertical ? 1.0 : 0.0
|
||||
property real mirrored: root.mirrored ? 1.0 : 0.0
|
||||
|
||||
fragmentShader: Qt.resolvedUrl(Quickshell.shellDir + "/Shaders/qsb/wave_spectrum.frag.qsb")
|
||||
blending: true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user