small component patches + code cleanup
This commit is contained in:
@@ -14,41 +14,24 @@ ModuleChip {
|
||||
property int outputMaxVolume: Cfg.Config.volumeOutputMax
|
||||
property int inputMaxVolume: Cfg.Config.volumeInputMax
|
||||
|
||||
// Path to config.qml — using HOME to avoid Qt.resolvedUrl ambiguity
|
||||
readonly property string configPath:
|
||||
Quickshell.env("HOME") + "/.config/quickshell/config/config.qml"
|
||||
|
||||
// Process that patches volumeOutputMax / volumeInputMax in config.qml
|
||||
Process {
|
||||
id: volConfigWriter
|
||||
running: false
|
||||
onExited: (code) => {
|
||||
if (code !== 0)
|
||||
console.warn("[Volume] Failed to patch config.qml (exit " + code + ")")
|
||||
}
|
||||
ConfigWriter {
|
||||
id: configWriter
|
||||
}
|
||||
|
||||
// Debounce: write to disk 800 ms after the last limit change
|
||||
Timer {
|
||||
id: saveDebounce
|
||||
interval: 800
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
const outMax = Math.round(root.outputMaxVolume).toString()
|
||||
const inMax = Math.round(root.inputMaxVolume).toString()
|
||||
const cfgPath = root.configPath
|
||||
const sh =
|
||||
"sed -i" +
|
||||
" -e 's/\\(property int[ ]\\+volumeOutputMax:[ ]\\+\\)[0-9.]\\+/\\1" + outMax + "/'" +
|
||||
" -e 's/\\(property int[ ]\\+volumeInputMax:[ ]\\+\\)[0-9.]\\+/\\1" + inMax + "/'" +
|
||||
" " + JSON.stringify(cfgPath)
|
||||
volConfigWriter.command = ["/bin/sh", "-c", sh]
|
||||
volConfigWriter.running = true
|
||||
configWriter.writeInts([
|
||||
{ key: "volumeOutputMax", value: root.outputMaxVolume },
|
||||
{ key: "volumeInputMax", value: root.inputMaxVolume }
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
onOutputMaxVolumeChanged: { if (root.outputMaxVolume >= 10) saveDebounce.restart() }
|
||||
onInputMaxVolumeChanged: { if (root.inputMaxVolume >= 10) saveDebounce.restart() }
|
||||
onOutputMaxVolumeChanged: saveDebounce.restart()
|
||||
onInputMaxVolumeChanged: saveDebounce.restart()
|
||||
|
||||
readonly property var sink: Pipewire.defaultAudioSink
|
||||
readonly property var source: Pipewire.defaultAudioSource
|
||||
@@ -115,24 +98,22 @@ ModuleChip {
|
||||
}
|
||||
|
||||
width: chipLayout.implicitWidth + 15
|
||||
height: Cfg.Config.moduleHeight
|
||||
radius: panelRadius
|
||||
|
||||
color: hoverHandler.hovered ? t.volBgHover : t.volBg
|
||||
border.color: (hoverHandler.hovered || volumePopup.popupOpen) ? t.volBorderHover : t.volBorder
|
||||
border.width: borderWidth
|
||||
chipColor: t.volBg
|
||||
chipColorHovered: t.volBgHover
|
||||
chipBorderColor: t.volBorder
|
||||
chipBorderColorHovered: t.volBorderHover
|
||||
chipHoverEnabled: true
|
||||
chipTapAction: () => volumePopup.toggle()
|
||||
popupOpen: volumePopup.popupOpen
|
||||
|
||||
Behavior on color { ColorAnimation { duration: 150 } }
|
||||
Behavior on border.color { ColorAnimation { duration: 150 } }
|
||||
|
||||
HoverHandler {
|
||||
id: hoverHandler
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
HoverHandler {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onHoveredChanged: {
|
||||
if (hovered && Cfg.Config.volumeShakeEnabled) shakeAnim.restart()
|
||||
}
|
||||
}
|
||||
TapHandler { onTapped: volumePopup.toggle() }
|
||||
|
||||
SequentialAnimation {
|
||||
id: shakeAnim
|
||||
@@ -159,29 +140,21 @@ ModuleChip {
|
||||
}
|
||||
}
|
||||
|
||||
PopupPanel {
|
||||
StandardPopup {
|
||||
id: volumePopup
|
||||
ns: "volume"
|
||||
chipRoot: root
|
||||
cardWidth: Cfg.Config.volumePopupWidth
|
||||
cardColor: t.volPopupBg
|
||||
cardBorderColor: t.volPopupBorder
|
||||
cardHeight: popupCol.implicitHeight + 34
|
||||
|
||||
PopupCard {
|
||||
popupOpen: volumePopup.popupOpen
|
||||
isTop: root.isTop
|
||||
animEnabled: volumePopup.visible
|
||||
height: popupCol.implicitHeight + 32
|
||||
|
||||
radius: Cfg.Config.popupRadius
|
||||
color: root.t.volPopupBg
|
||||
border.color: root.t.volPopupBorder
|
||||
border.width: Cfg.Config.popupBorderWidth
|
||||
|
||||
ColumnLayout {
|
||||
id: popupCol
|
||||
anchors { left: parent.left; right: parent.right; top: parent.top }
|
||||
anchors.margins: 16
|
||||
anchors.topMargin: 18
|
||||
spacing: 14
|
||||
ColumnLayout {
|
||||
id: popupCol
|
||||
anchors { left: parent.left; right: parent.right; top: parent.top }
|
||||
anchors.margins: 16
|
||||
anchors.topMargin: 18
|
||||
spacing: 14
|
||||
|
||||
VolumeSection {
|
||||
id: outputSection
|
||||
@@ -272,7 +245,6 @@ ModuleChip {
|
||||
}
|
||||
Item { height: 2 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
component VolumeSection: ColumnLayout {
|
||||
|
||||
Reference in New Issue
Block a user