feat(spectrum): adding support for both band and bar properties during the migration

This commit is contained in:
Lemmy
2026-03-20 22:26:07 -04:00
parent 2aa0c7a78d
commit 40a64b6aa6
+26 -1
View File
@@ -9,12 +9,21 @@ import qs.Services.UI
Singleton {
id: root
// TODO Remove in may 2026
property bool _initialized: false
// Register a component that needs audio data, call this when a visualizer becomes active.
// Pass a unique identifier (e.g., "lockscreen", "controlcenter:screen1", "plugin:fancy-audiovisualizer")
function registerComponent(componentId) {
root._registeredComponents[componentId] = true;
root._registeredComponents = Object.assign({}, root._registeredComponents);
Logger.d("Spectrum", "Component registered:", componentId, "- total:", root.registeredCount);
// TODO Remove in may 2026
if (!_initialized) {
_initialized: true;
_setBandsCount();
}
}
// Unregister a component when it no longer needs audio data.
@@ -41,7 +50,8 @@ Singleton {
id: spectrum
node: Pipewire.defaultAudioSink
enabled: root._shouldRun
barCount: Settings.data.audio.spectrumMirrored ? 32 : 64
// TODO Uncomment this in may 2026
// bandCount: Settings.data.audio.spectrumMirrored ? 32 : 64
frameRate: Settings.data.audio.spectrumFrameRate
lowerCutoff: 50
upperCutoff: 12000
@@ -56,4 +66,19 @@ Singleton {
root.isIdle = spectrum.idle;
}
}
// TODO Remove in may 2026 - temporary until noctalia-qs is fully propagated
Connections {
target: Settings.data.audio
function onSpectrumMirroredChanged() {
_setBandsCount();
}
}
function _setBandsCount() {
if (spectrum.bandCount !== undefined) {
spectrum.bandCount = Settings.data.audio.spectrumMirrored ? 32 : 64;
} else if (spectrum.barCount !== undefined) {
spectrum.barCount = Settings.data.audio.spectrumMirrored ? 32 : 64;
}
}
}