- Moved all input/output logic out of UI into the Audio service - Removed volume overdrive which does not work and is out of scope - Reworked the audio input/output selector with radio buttons instead of NComboBox - Hacked a bit the main volume slider so it does not crash PW
63 lines
1.6 KiB
QML
63 lines
1.6 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Services.Pipewire
|
|
import qs.Services
|
|
import qs.Widgets
|
|
|
|
Item {
|
|
id: root
|
|
|
|
width: pill.width
|
|
height: pill.height
|
|
|
|
Component.onCompleted: {
|
|
console.log("[Volume] settingsPanel received:", !!settingsPanel)
|
|
}
|
|
|
|
// Used to avoid opening the pill on Quickshell startup
|
|
property bool firstVolumeReceived: false
|
|
|
|
function getIcon() {
|
|
if (Audio.muted) {
|
|
return "volume_off"
|
|
}
|
|
return Audio.volume <= Number.EPSILON ? "volume_off" : (Audio.volume < 0.33 ? "volume_down" : "volume_up")
|
|
}
|
|
|
|
// Connection used to open the pill when volume changes
|
|
Connections {
|
|
target: Audio.sink?.audio ? Audio.sink?.audio : null
|
|
function onVolumeChanged() {
|
|
// console.log("[Bar:Volume] onVolumeChanged")
|
|
if (!firstVolumeReceived) {
|
|
// Ignore the first volume change
|
|
firstVolumeReceived = true
|
|
} else {
|
|
pill.show()
|
|
}
|
|
}
|
|
}
|
|
|
|
NPill {
|
|
id: pill
|
|
icon: getIcon()
|
|
iconCircleColor: Colors.accentPrimary
|
|
collapsedIconColor: Colors.textPrimary
|
|
autoHide: true
|
|
text: Math.floor(Audio.volume * 100) + "%"
|
|
tooltipText: "Volume: " + Math.round(
|
|
Audio.volume * 100) + "%\nLeft click for advanced settings.\nScroll up/down to change volume."
|
|
|
|
onWheel: function (angle) {
|
|
if (angle > 0) {
|
|
Audio.volumeIncrement()
|
|
} else if (angle < 0) {
|
|
Audio.volumeDecrement()
|
|
}
|
|
}
|
|
onClicked: {
|
|
settingsPanel.requestedTab = settingsPanel.tabsIds.AUDIO
|
|
settingsPanel.isLoaded = true
|
|
}
|
|
}
|
|
}
|