Changed the glass animations to a more bubble-like animation
This commit is contained in:
@@ -14,8 +14,16 @@ ModuleChip {
|
||||
property int outputMaxVolume: Cfg.Config.volumeOutputMax
|
||||
property int inputMaxVolume: Cfg.Config.volumeInputMax
|
||||
|
||||
ConfigWriter {
|
||||
id: configWriter
|
||||
readonly property string configPath:
|
||||
Quickshell.env("HOME") + "/.config/quickshell/config/config.qml"
|
||||
|
||||
Process {
|
||||
id: volConfigWriter
|
||||
running: false
|
||||
onExited: (code) => {
|
||||
if (code !== 0)
|
||||
console.warn("[Volume] Failed to patch config.qml (exit " + code + ")")
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
@@ -23,15 +31,21 @@ ModuleChip {
|
||||
interval: 800
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
configWriter.writeInts([
|
||||
{ key: "volumeOutputMax", value: root.outputMaxVolume },
|
||||
{ key: "volumeInputMax", value: root.inputMaxVolume }
|
||||
])
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
onOutputMaxVolumeChanged: saveDebounce.restart()
|
||||
onInputMaxVolumeChanged: saveDebounce.restart()
|
||||
onOutputMaxVolumeChanged: { if (root.outputMaxVolume >= 10) saveDebounce.restart() }
|
||||
onInputMaxVolumeChanged: { if (root.inputMaxVolume >= 10) saveDebounce.restart() }
|
||||
|
||||
readonly property var sink: Pipewire.defaultAudioSink
|
||||
readonly property var source: Pipewire.defaultAudioSource
|
||||
@@ -98,22 +112,24 @@ ModuleChip {
|
||||
}
|
||||
|
||||
width: chipLayout.implicitWidth + 15
|
||||
height: Cfg.Config.moduleHeight
|
||||
radius: panelRadius
|
||||
|
||||
chipColor: t.volBg
|
||||
chipColorHovered: t.volBgHover
|
||||
chipBorderColor: t.volBorder
|
||||
chipBorderColorHovered: t.volBorderHover
|
||||
chipHoverEnabled: true
|
||||
chipTapAction: () => volumePopup.toggle()
|
||||
popupOpen: volumePopup.popupOpen
|
||||
color: hoverHandler.hovered ? t.volBgHover : t.volBg
|
||||
border.color: (hoverHandler.hovered || volumePopup.popupOpen) ? t.volBorderHover : t.volBorder
|
||||
border.width: borderWidth
|
||||
|
||||
HoverHandler {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
Behavior on color { ColorAnimation { duration: 150 } }
|
||||
Behavior on border.color { ColorAnimation { duration: 150 } }
|
||||
|
||||
HoverHandler {
|
||||
id: hoverHandler
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onHoveredChanged: {
|
||||
if (hovered && Cfg.Config.volumeShakeEnabled) shakeAnim.restart()
|
||||
}
|
||||
}
|
||||
TapHandler { onTapped: volumePopup.toggle() }
|
||||
|
||||
SequentialAnimation {
|
||||
id: shakeAnim
|
||||
@@ -140,29 +156,48 @@ ModuleChip {
|
||||
}
|
||||
}
|
||||
|
||||
StandardPopup {
|
||||
PopupPanel {
|
||||
id: volumePopup
|
||||
ns: "volume"
|
||||
chipRoot: root
|
||||
cardWidth: Cfg.Config.volumePopupWidth
|
||||
cardColor: t.volPopupBg
|
||||
cardBorderColor: t.volPopupBorder
|
||||
cardHeight: popupCol.implicitHeight + 34
|
||||
hasKeyboardFocus: true
|
||||
|
||||
Item {
|
||||
id: popupCol
|
||||
anchors { left: parent.left; right: parent.right; top: parent.top }
|
||||
anchors.margins: 16
|
||||
anchors.topMargin: 18
|
||||
implicitWidth: popupContent.implicitWidth
|
||||
implicitHeight: popupContent.implicitHeight
|
||||
focus: true
|
||||
Rectangle {
|
||||
id: volCard
|
||||
width: parent.width
|
||||
height: popupCol.implicitHeight + 32
|
||||
|
||||
ColumnLayout {
|
||||
id: popupContent
|
||||
anchors.fill: parent
|
||||
spacing: 14
|
||||
anchors.top: root.isTop ? parent.top : undefined
|
||||
anchors.bottom: root.isTop ? undefined : parent.bottom
|
||||
|
||||
transform: Scale {
|
||||
yScale: volumePopup.popupOpen ? 1 : 0
|
||||
origin.y: root.isTop ? 0 : volCard.height
|
||||
Behavior on yScale {
|
||||
NumberAnimation {
|
||||
duration: Cfg.Config.popupAnimDuration
|
||||
easing.type: Easing.OutBack
|
||||
}
|
||||
enabled: volumePopup.visible
|
||||
}
|
||||
}
|
||||
|
||||
opacity: volumePopup.popupOpen ? 1.0 : 0.0
|
||||
Behavior on opacity { NumberAnimation { duration: 200 } }
|
||||
|
||||
radius: Cfg.Config.popupRadius
|
||||
color: root.t.volPopupBg
|
||||
border.color: root.t.volPopupBorder
|
||||
border.width: Cfg.Config.popupBorderWidth
|
||||
|
||||
MouseArea { anchors.fill: parent; propagateComposedEvents: false }
|
||||
|
||||
ColumnLayout {
|
||||
id: popupCol
|
||||
anchors { left: parent.left; right: parent.right; top: parent.top }
|
||||
anchors.margins: 16
|
||||
anchors.topMargin: 18
|
||||
spacing: 14
|
||||
|
||||
VolumeSection {
|
||||
id: outputSection
|
||||
@@ -235,7 +270,6 @@ ModuleChip {
|
||||
borderColor: root.t.volPopupBorder
|
||||
onDecrement: root.outputMaxVolume = Math.max(10, root.outputMaxVolume - 10)
|
||||
onIncrement: root.outputMaxVolume = Math.min(300, root.outputMaxVolume + 10)
|
||||
onValueSet: root.outputMaxVolume = Math.max(10, Math.min(300, val))
|
||||
}
|
||||
LimitRow {
|
||||
Layout.fillWidth: true
|
||||
@@ -250,18 +284,11 @@ ModuleChip {
|
||||
borderColor: root.t.volPopupBorder
|
||||
onDecrement: root.inputMaxVolume = Math.max(10, root.inputMaxVolume - 10)
|
||||
onIncrement: root.inputMaxVolume = Math.min(300, root.inputMaxVolume + 10)
|
||||
onValueSet: root.inputMaxVolume = Math.max(10, Math.min(300, val))
|
||||
}
|
||||
}
|
||||
Item { height: 2 }
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
z: -1
|
||||
onClicked: popupCol.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
component VolumeSection: ColumnLayout {
|
||||
@@ -308,36 +335,14 @@ ModuleChip {
|
||||
Layout.fillWidth: true
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
TextInput {
|
||||
Text {
|
||||
text: vs.muted ? "muted" : vs.volume + "%"
|
||||
color: vs.muted ? vs.dimColor : vs.textColor
|
||||
font.pixelSize: 12
|
||||
font.bold: !vs.muted
|
||||
horizontalAlignment: TextInput.AlignHCenter
|
||||
verticalAlignment: TextInput.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
Layout.preferredWidth: 44
|
||||
renderType: Text.NativeRendering
|
||||
readOnly: vs.muted
|
||||
selectByMouse: true
|
||||
activeFocusOnPress: true
|
||||
onAccepted: {
|
||||
if (!vs.muted) {
|
||||
let val = parseInt(text.replace("%", "").trim(), 10)
|
||||
if (!isNaN(val)) vs.sliderMoved(Math.max(0, Math.min(vs.maxVolume, val)))
|
||||
text = Qt.binding(function() { return vs.muted ? "muted" : vs.volume + "%" })
|
||||
}
|
||||
popupCol.forceActiveFocus()
|
||||
}
|
||||
onActiveFocusChanged: {
|
||||
if (activeFocus && !vs.muted) {
|
||||
text = vs.volume.toString()
|
||||
selectAll()
|
||||
} else if (!activeFocus && !vs.muted) {
|
||||
let val = parseInt(text.replace("%", "").trim(), 10)
|
||||
if (!isNaN(val)) vs.sliderMoved(Math.max(0, Math.min(vs.maxVolume, val)))
|
||||
text = Qt.binding(function() { return vs.muted ? "muted" : vs.volume + "%" })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -504,7 +509,6 @@ ModuleChip {
|
||||
|
||||
signal decrement()
|
||||
signal increment()
|
||||
signal valueSet(int val)
|
||||
|
||||
Text { text: lr.icon; color: lr.iconColor; font.pixelSize: 13; font.bold: true; renderType: Text.NativeRendering }
|
||||
Text {
|
||||
@@ -531,32 +535,13 @@ ModuleChip {
|
||||
HoverHandler { id: decHover; cursorShape: Qt.PointingHandCursor }
|
||||
TapHandler { onTapped: { if (lr.value > lr.minValue) lr.decrement() } }
|
||||
}
|
||||
TextInput {
|
||||
Text {
|
||||
text: lr.value + "%"
|
||||
color: lr.textColor
|
||||
font.pixelSize: 12; font.bold: true
|
||||
horizontalAlignment: TextInput.AlignHCenter
|
||||
verticalAlignment: TextInput.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
Layout.preferredWidth: 44
|
||||
renderType: Text.NativeRendering
|
||||
selectByMouse: true
|
||||
activeFocusOnPress: true
|
||||
onAccepted: {
|
||||
let val = parseInt(text.replace("%", "").trim(), 10)
|
||||
if (!isNaN(val)) lr.valueSet(Math.max(lr.minValue, Math.min(lr.maxValue, val)))
|
||||
text = Qt.binding(function() { return lr.value + "%" })
|
||||
popupCol.forceActiveFocus()
|
||||
}
|
||||
onActiveFocusChanged: {
|
||||
if (activeFocus) {
|
||||
text = lr.value.toString()
|
||||
selectAll()
|
||||
} else {
|
||||
let val = parseInt(text.replace("%", "").trim(), 10)
|
||||
if (!isNaN(val)) lr.valueSet(Math.max(lr.minValue, Math.min(lr.maxValue, val)))
|
||||
text = Qt.binding(function() { return lr.value + "%" })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -576,3 +561,5 @@ ModuleChip {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user