Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 37 additions & 38 deletions Modules/Cards/AudioCard.qml
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,32 @@ NBox {
onTriggered: {
// Only sync if sink hasn't changed
if (AudioService.sink && AudioService.sink.id === lastSinkId) {
if (Math.abs(localOutputVolume - AudioService.volume) >= 0.01) {
if (Math.round(Math.abs(localOutputVolume - AudioService.volume) * 100) / 100 >= 0.01) {
AudioService.setVolume(localOutputVolume);
}
}
// Only sync if source hasn't changed
if (AudioService.source && AudioService.source.id === lastSourceId) {
if (Math.abs(localInputVolume - AudioService.inputVolume) >= 0.01) {
if (Math.round(Math.abs(localInputVolume - AudioService.inputVolume) * 100) / 100 >= 0.01) {
AudioService.setInputVolume(localInputVolume);
}
}
}
}

// Timer to reset local*VolumeChanging variables after onWheel events
Timer {
id: wheelDebounceTimer
interval: 100
repeat: false
onTriggered: {
if (panelContent.localOutputVolumeChanging)
panelContent.localOutputVolumeChanging = false;
if (panelContent.localInputVolumeChanging)
panelContent.localInputVolumeChanging = false;
}
}

// Connections to update local volumes when AudioService changes
Connections {
target: AudioService
Expand Down Expand Up @@ -181,24 +194,17 @@ NBox {
onPressedChanged: localOutputVolumeChanging = pressed
tooltipText: `${Math.round(localOutputVolume * 100)}%`
tooltipDirection: "bottom"

// MouseArea to handle wheel events when hovering over the slider
MouseArea {
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.NoButton
propagateComposedEvents: true

onWheel: wheel => {
if (outputVolumeSlider.enabled && AudioService.sink) {
const delta = wheel.angleDelta.y || wheel.angleDelta.x;
const step = Settings.data.audio.volumeStep / 100.0; // Convert percentage to 0-1 range
const increment = delta > 0 ? step : -step;
const maxVolume = Settings.data.audio.volumeOverdrive ? 1.5 : 1.0;
const newValue = Math.max(0, Math.min(maxVolume, localOutputVolume + increment));
localOutputVolume = newValue;
}
}
onWheel: function (wheel) {
if (outputVolumeSlider.enabled && AudioService.sink) {
localOutputVolumeChanging = true;
wheelDebounceTimer.restart();
const delta = wheel.angleDelta.y || wheel.angleDelta.x;
const step = Settings.data.audio.volumeStep / 100.0; // Convert percentage to 0-1 range
const increment = delta > 0 ? step : -step;
const maxVolume = Settings.data.audio.volumeOverdrive ? 1.5 : 1.0;
const newValue = Math.max(0, Math.min(maxVolume, localOutputVolume + increment));
localOutputVolume = newValue;
}
}
}
}
Expand Down Expand Up @@ -249,24 +255,17 @@ NBox {
onPressedChanged: localInputVolumeChanging = pressed
tooltipText: `${Math.round(localInputVolume * 100)}%`
tooltipDirection: "bottom"

// MouseArea to handle wheel events when hovering over the slider
MouseArea {
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.NoButton
propagateComposedEvents: true

onWheel: wheel => {
if (inputVolumeSlider.enabled && AudioService.source) {
const delta = wheel.angleDelta.y || wheel.angleDelta.x;
const step = Settings.data.audio.volumeStep / 100.0; // Convert percentage to 0-1 range
const increment = delta > 0 ? step : -step;
const maxVolume = Settings.data.audio.volumeOverdrive ? 1.5 : 1.0;
const newValue = Math.max(0, Math.min(maxVolume, localInputVolume + increment));
localInputVolume = newValue;
}
}
onWheel: function (wheel) {
if (inputVolumeSlider.enabled && AudioService.source) {
localInputVolumeChanging = true;
wheelDebounceTimer.restart();
const delta = wheel.angleDelta.y || wheel.angleDelta.x;
const step = Settings.data.audio.volumeStep / 100.0; // Convert percentage to 0-1 range
const increment = delta > 0 ? step : -step;
const maxVolume = Settings.data.audio.volumeOverdrive ? 1.5 : 1.0;
const newValue = Math.max(0, Math.min(maxVolume, localInputVolume + increment));
localInputVolume = newValue;
}
}
}
}
Expand Down
53 changes: 51 additions & 2 deletions Modules/Panels/Audio/AudioPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,31 @@ SmartPanel {
onTriggered: {
// Only sync if sink hasn't changed
if (AudioService.sink && AudioService.sink.id === panelContent.lastSinkId) {
if (Math.abs(panelContent.localOutputVolume - AudioService.volume) >= 0.01) {
if (Math.round(Math.abs(panelContent.localOutputVolume - AudioService.volume) * 100) / 100 >= 0.01) {
AudioService.setVolume(panelContent.localOutputVolume);
}
}
// Only sync if source hasn't changed
if (AudioService.source && AudioService.source.id === panelContent.lastSourceId) {
if (Math.abs(panelContent.localInputVolume - AudioService.inputVolume) >= 0.01) {
if (Math.round(Math.abs(panelContent.localInputVolume - AudioService.inputVolume) * 100) / 100 >= 0.01) {
AudioService.setInputVolume(panelContent.localInputVolume);
}
}
}
}

Timer {
id: wheelDebounceTimer
interval: 100
repeat: false
onTriggered: {
if (panelContent.localOutputVolumeChanging)
panelContent.localOutputVolumeChanging = false;
if (panelContent.localInputVolumeChanging)
panelContent.localInputVolumeChanging = false;
}
}

// Find application streams that are actually playing audio (connected to default sink)
// Use linkGroups to find nodes connected to the default audio sink
// Note: We need to use link IDs since source/target properties require binding
Expand Down Expand Up @@ -284,6 +296,18 @@ SmartPanel {
onPressedChanged: function (pressed) {
localOutputVolumeChanging = pressed;
}
onWheel: function (event) {
if (AudioService.sink) {
localOutputVolumeChanging = true;
wheelDebounceTimer.restart();
const delta = event.angleDelta.y || event.angleDelta.x;
const step = Settings.data.audio.volumeStep / 100.0; // Convert percentage to 0-1 range
const increment = delta > 0 ? step : -step;
const maxVolume = Settings.data.audio.volumeOverdrive ? 1.5 : 1.0;
const newValue = Math.max(0, Math.min(maxVolume, localOutputVolume + increment));
localOutputVolume = newValue;
}
}
}

NText {
Expand Down Expand Up @@ -359,6 +383,18 @@ SmartPanel {
onPressedChanged: function (pressed) {
localInputVolumeChanging = pressed;
}
onWheel: function (event) {
if (AudioService.source) {
localInputVolumeChanging = true;
wheelDebounceTimer.restart();
const delta = event.angleDelta.y || event.angleDelta.x;
const step = Settings.data.audio.volumeStep / 100.0; // Convert percentage to 0-1 range
const increment = delta > 0 ? step : -step;
const maxVolume = Settings.data.audio.volumeOverdrive ? 1.5 : 1.0;
const newValue = Math.max(0, Math.min(maxVolume, localInputVolume + increment));
localInputVolume = newValue;
}
}
}

NText {
Expand Down Expand Up @@ -634,6 +670,19 @@ SmartPanel {
AudioService.setAppStreamVolume(key, value);
}
}
onWheel: function (event) {
if (appBox.nodeAudio && appBox.modelData && appBox.modelData.ready === true) {
const delta = event.angleDelta.y || event.angleDelta.x;
const step = Settings.data.audio.volumeStep / 100.0; // Convert percentage to 0-1 range
const increment = delta > 0 ? step : -step;
const maxVolume = Settings.data.audio.volumeOverdrive ? 1.5 : 1.0;
const newValue = Math.max(0, Math.min(maxVolume, appBox.nodeAudio.volume + increment));
appBox.nodeAudio.volume = newValue;
var key = AudioService.getAppKey(appBox.modelData);
if (key)
AudioService.setAppStreamVolume(key, newValue);
}
}
}

NText {
Expand Down
10 changes: 10 additions & 0 deletions Widgets/NSlider.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Slider {
readonly property real trackRadius: Math.min(Style.iRadiusL, trackHeight / 2)
readonly property real cutoutExtra: Math.round((Style.baseWidgetSize * 0.1 * Style.uiScaleRatio) / 2) * 2

signal wheel(WheelEvent event)

padding: cutoutExtra / 2

snapMode: snapAlways ? Slider.SnapAlways : Slider.SnapOnRelease
Expand Down Expand Up @@ -249,4 +251,12 @@ Slider {
}
}
}

MouseArea {
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.NoButton
propagateComposedEvents: true
onWheel: event => root.wheel(event)
}
}
2 changes: 2 additions & 0 deletions Widgets/NValueSlider.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ RowLayout {
// Signals
signal moved(real value)
signal pressedChanged(bool pressed, real value)
signal wheel(WheelEvent event)

readonly property bool isValueChanged: defaultValue !== undefined && (value !== defaultValue)
readonly property string indicatorTooltip: {
Expand Down Expand Up @@ -81,6 +82,7 @@ RowLayout {
heightRatio: root.customHeightRatio > 0 ? root.customHeightRatio : root.heightRatio
onMoved: root.moved(value)
onPressedChanged: root.pressedChanged(pressed, value)
onWheel: event => root.wheel(event)
}

NText {
Expand Down