[vlc-commits] [Git][videolan/vlc][master] 3 commits: qml/Helpers: Add the 'applyVolume' function

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Jul 25 05:49:02 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
13dbeb62 by Benjamin Arnaud at 2023-07-25T05:29:30+00:00
qml/Helpers: Add the 'applyVolume' function

- - - - -
61cb184a by Benjamin Arnaud at 2023-07-25T05:29:30+00:00
qml/VolumeWidget: Use the 'applyVolume' function

- - - - -
ef1f8595 by Benjamin Arnaud at 2023-07-25T05:29:30+00:00
qml/Player: Add wheel support for volume

- - - - -


3 changed files:

- modules/gui/qt/player/qml/Player.qml
- modules/gui/qt/player/qml/controlbarcontrols/VolumeWidget.qml
- modules/gui/qt/util/qml/Helpers.js


Changes:

=====================================
modules/gui/qt/player/qml/Player.qml
=====================================
@@ -117,6 +117,12 @@ FocusScope {
             toolbarAutoHide.setVisibleControlBar(true)
     }
 
+    Connections {
+        target: Player
+
+        onVolumeChanged: animationVolume.restart()
+    }
+
     // Functions
 
     function lockUnlockAutoHide(lock) {
@@ -344,7 +350,7 @@ FocusScope {
         }
     }
 
-    Item {
+    MouseArea {
         id: centerContent
 
         readonly property ColorContext colorContext: ColorContext {
@@ -361,6 +367,23 @@ FocusScope {
             bottomMargin: VLCStyle.margin_xsmall
         }
 
+        onWheel: {
+            if (rootPlayer.hasEmbededVideo) {
+                wheel.accepted = false
+
+                return
+            }
+
+            wheel.accepted = true
+
+            var delta = wheel.angleDelta.y
+
+            if (delta === 0)
+                return
+
+            Helpers.applyVolume(Player, delta)
+        }
+
         ColumnLayout {
             anchors.centerIn: parent
             spacing: 0
@@ -498,6 +521,34 @@ FocusScope {
                 }
             }
         }
+
+        Widgets.SubtitleLabel {
+            id: labelVolume
+
+            anchors.right: parent.right
+            anchors.top: parent.top
+
+            anchors.rightMargin: VLCStyle.margin_normal
+            anchors.topMargin: VLCStyle.margin_xxsmall
+
+            visible: false
+
+            text: I18n.qtr("Volume %1%").arg(Math.round(Player.volume * 100))
+
+            color: centerTheme.fg.primary
+
+            font.weight: Font.Normal
+
+            SequentialAnimation {
+                id: animationVolume
+
+                PropertyAction { target: labelVolume; property: "visible"; value: true }
+
+                PauseAnimation { duration: VLCStyle.duration_humanMoment }
+
+                PropertyAction { target: labelVolume; property: "visible"; value: false }
+            }
+        }
     }
 
     Widgets.DrawerExt {


=====================================
modules/gui/qt/player/qml/controlbarcontrols/VolumeWidget.qml
=====================================
@@ -23,6 +23,7 @@ import QtGraphicalEffects 1.12
 import org.videolan.vlc 0.1
 
 import "qrc:///widgets/" as Widgets
+import "qrc:///util/Helpers.js" as Helpers
 import "qrc:///style/"
 
 T.Pane {
@@ -292,19 +293,8 @@ T.Pane {
 
                     if (fineControl)
                         volControl.value += 0.001 * delta
-                    else {
-                        // Degrees to steps for standard mouse
-                        delta = delta / 8 / 15
-
-                        const steps = Math.ceil(Math.abs(delta))
-
-                        Player.muted = false
-
-                        if (delta > 0)
-                            Player.setVolumeUp(steps)
-                        else
-                            Player.setVolumeDown(steps)
-                    }
+                    else
+                        Helpers.applyVolume(Player, delta)
 
                     wheel.accepted = true
                 }


=====================================
modules/gui/qt/util/qml/Helpers.js
=====================================
@@ -44,6 +44,20 @@ function enforceFocus(item, reason) {
     item.forceActiveFocus(reason);
 }
 
+function applyVolume(player, delta) {
+    // Degrees to steps for standard mouse
+    delta = delta / 8 / 15
+
+    const steps = Math.ceil(Math.abs(delta))
+
+    player.muted = false
+
+    if (delta > 0)
+        player.setVolumeUp(steps)
+    else
+        player.setVolumeDown(steps)
+}
+
 function pointInRadius(x, y, radius) {
      return (x * x + y * y < radius * radius)
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7c6b9a3c4b03ffb496c9fa7ce33839ba2aa42bdb...ef1f859516d9b78518552918f1a354d41a086324

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7c6b9a3c4b03ffb496c9fa7ce33839ba2aa42bdb...ef1f859516d9b78518552918f1a354d41a086324
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list