File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6464 readonly property bool shouldHideEmpty: ! hasPlayer && hideMode === " hidden"
6565 readonly property bool isHidden: shouldHideIdle || shouldHideEmpty
6666
67+ // Volume scroll
68+ property int wheelAccumulator: 0
69+
6770 // Title
6871 readonly property string title: {
6972 if (! hasPlayer)
@@ -392,6 +395,27 @@ Item {
392395 cursorShape: Qt .PointingHandCursor
393396 acceptedButtons: Qt .LeftButton | Qt .RightButton | Qt .MiddleButton | Qt .ForwardButton | Qt .BackButton
394397
398+ onWheel : function (ev ) {
399+ // Hide tooltip as soon as the user starts scrolling to adjust volume
400+ TooltipService .hide ();
401+
402+ ev .accepted = true ;
403+
404+ var delta = ev .pixelDelta .y ;
405+
406+ if (ev .inverted )
407+ delta *= - 1 ;
408+
409+ wheelAccumulator += delta;
410+ if (wheelAccumulator >= 120 ) {
411+ wheelAccumulator = 0 ;
412+ MediaService .increaseVolume ();
413+ } else if (wheelAccumulator <= - 120 ) {
414+ wheelAccumulator = 0 ;
415+ MediaService .decreaseVolume ();
416+ }
417+ }
418+
395419 onClicked : mouse => {
396420 TooltipService .hide ();
397421 if (mouse .button === Qt .LeftButton ) {
Original file line number Diff line number Diff line change @@ -814,6 +814,14 @@ Singleton {
814814 }
815815 MediaService .seekByRatio (positionVal);
816816 }
817+
818+ function increase () {
819+ MediaService .increaseVolume ();
820+ }
821+
822+ function decrease () {
823+ MediaService .decreaseVolume ();
824+ }
817825 }
818826
819827 IpcHandler {
Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ Singleton {
4545 property string lengthString: formatTime (trackLength)
4646 property real infiniteTrackLength: 922337203685
4747
48+ readonly property real stepVolume: Settings .data .audio .volumeStep / 100.0
49+
4850 Component .onCompleted : {
4951 updateCurrentPlayer ();
5052 }
@@ -292,6 +294,20 @@ Singleton {
292294 }
293295 }
294296
297+ function increaseVolume () {
298+ let target = currentPlayer ? (currentPlayer ._controlTarget || currentPlayer) : null ;
299+ if (target && target .canControl && target .volumeSupported ) {
300+ target .volume = Math .min (1.0 , target .volume + stepVolume);
301+ }
302+ }
303+
304+ function decreaseVolume () {
305+ let target = currentPlayer ? (currentPlayer ._controlTarget || currentPlayer) : null ;
306+ if (target && target .canControl && target .volumeSupported ) {
307+ target .volume = Math .max (0.0 , target .volume - stepVolume);
308+ }
309+ }
310+
295311 // Update progress bar every second while playing
296312 Timer {
297313 id: positionTimer
You can’t perform that action at this time.
0 commit comments