Files
glassMxrph/quickshell/dashboard/Equalizer.qml
T
mxandClaude Opus 5.5 99e64a7713 Add glassMxrph shell sources
Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:36:17 +02:00

207 lines
7.6 KiB
QML

pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Layouts
import "../components"
import "../services"
import "../theme"
// EasyEffects equalizer (serpantinum-style): ten ±12 dB bands, eight presets.
// Presets apply at once; dragged bands wait for Apply.
DashCard {
id: root
objectName: "dashEqualizer"
readonly property bool usable: EasyEffectsService.installed
implicitWidth: 400
implicitHeight: body.implicitHeight + 32
function freq(f) {
return f >= 1000 ? f / 1000 + "k" : String(f);
}
ColumnLayout {
id: body
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.margins: 16
spacing: 12
RowLayout {
Layout.fillWidth: true
spacing: 10
ColumnLayout {
Layout.fillWidth: true
spacing: 0
Text {
text: "Equalizer"
color: Theme.text
font.pixelSize: 15
font.weight: Font.DemiBold
}
Text {
text: !EasyEffectsService.known ? "Checking EasyEffects…" : !root.usable ? "EasyEffects is not installed" : EasyEffectsService.error ? EasyEffectsService.error : !EasyEffectsService.running ? "EasyEffects · starts on apply" : EasyEffectsService.bypass ? "EasyEffects · bypassed" : "EasyEffects · " + EasyEffectsService.preset
color: EasyEffectsService.error ? Theme.urgent : Theme.textSecondary
font.pixelSize: 11
elide: Text.ElideRight
Layout.fillWidth: true
}
}
GlassToggle {
objectName: "eqEnabled"
enabled: root.usable && EasyEffectsService.running
checked: !EasyEffectsService.bypass
onToggled: EasyEffectsService.setBypass(!checked)
Accessible.name: "Effects enabled"
}
GlassButton {
objectName: "eqApply"
implicitHeight: 30
text: EasyEffectsService.busy ? "Applying…" : EasyEffectsService.pending ? "Apply" : "Saved"
accented: EasyEffectsService.pending
enabled: root.usable && EasyEffectsService.pending && !EasyEffectsService.busy
onClicked: EasyEffectsService.apply()
}
}
Row {
id: bands
Layout.alignment: Qt.AlignHCenter
spacing: 6
opacity: root.usable ? 1 : 0.45
Repeater {
model: 10
Band {}
}
}
GridLayout {
Layout.fillWidth: true
columns: 4
rowSpacing: 6
columnSpacing: 6
opacity: root.usable ? 1 : 0.45
Repeater {
model: EasyEffectsService.presetNames
Rectangle {
id: chip
required property string modelData
readonly property bool active: EasyEffectsService.preset === modelData
objectName: "eqPreset-" + modelData
Layout.fillWidth: true
Layout.preferredWidth: 1
implicitHeight: 28
radius: 14
color: active ? Theme.accent : chipArea.containsMouse ? Theme.hover : Theme.fill
border.width: active ? 0 : 1
border.color: Theme.hairline
Behavior on color {
ColorAnimation {
duration: Theme.duration
}
}
Text {
anchors.centerIn: parent
text: chip.modelData
color: chip.active ? Theme.accentText : Theme.text
font.pixelSize: 12
}
MouseArea {
id: chipArea
anchors.fill: parent
hoverEnabled: true
enabled: root.usable
cursorShape: Qt.PointingHandCursor
onClicked: EasyEffectsService.usePreset(chip.modelData)
}
}
}
}
}
// Vertical ±12 dB slider: drag or scroll; the fill grows from the 0 dB line.
component Band: Column {
id: band
required property int index
readonly property real gain: EasyEffectsService.bands[index] || 0
objectName: "eqBand" + index
spacing: 4
Text {
anchors.horizontalCenter: parent.horizontalCenter
text: (band.gain > 0 ? "+" : "") + Math.round(band.gain)
color: band.gain === 0 ? Theme.textSecondary : Theme.text
font.pixelSize: 10
font.features: {
"tnum": 1
}
}
Item {
id: track
width: 30
height: 120
readonly property real zero: height / 2
property real shown: band.gain
Behavior on shown {
enabled: !drag.pressed
NumberAnimation {
duration: Theme.duration * 1.5
easing.type: Easing.OutCubic
}
}
readonly property real knobY: zero - shown / 12 * (height / 2 - 8)
Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
width: 6
height: parent.height
radius: 3
color: Qt.alpha(Theme.text, 0.1)
}
Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
width: 6
y: Math.min(track.zero, track.knobY)
height: Math.abs(track.knobY - track.zero)
radius: 3
color: Theme.accentVivid
}
Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
width: 14
height: 1
y: track.zero
color: Theme.hairline
}
Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
y: track.knobY - height / 2
width: drag.pressed ? 20 : 16
height: width
radius: width / 2
color: Theme.text
border.width: 2
border.color: Theme.accentVivid
Behavior on width {
NumberAnimation {
duration: Theme.duration / 2
}
}
}
MouseArea {
id: drag
anchors.fill: parent
enabled: root.usable
cursorShape: Qt.SizeVerCursor
function set(y) {
EasyEffectsService.setBand(band.index, (track.zero - y) / (track.height / 2 - 8) * 12);
}
onPressed: event => set(event.y)
onPositionChanged: event => {
if (pressed)
set(event.y);
}
onWheel: event => EasyEffectsService.setBand(band.index, band.gain + (event.angleDelta.y > 0 ? 1 : -1))
}
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
text: root.freq(EasyEffectsService.frequencies[band.index] || 0)
color: Theme.textSecondary
font.pixelSize: 10
}
}
}