[vlc-commits] [Git][videolan/vlc][master] 8 commits: qml/MainDisplay: Add the 'positionSliderY' property

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri May 26 12:41:51 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
82fd5e1a by Benjamin Arnaud at 2023-05-26T12:10:34+00:00
qml/MainDisplay: Add the 'positionSliderY' property

- - - - -
465d167f by Benjamin Arnaud at 2023-05-26T12:10:34+00:00
qml/MiniPlayer: Add the 'sliderY' alias

- - - - -
d392f414 by Benjamin Arnaud at 2023-05-26T12:10:34+00:00
qml/TracksMenu: Remove the 'rootPlayer' dependency

- - - - -
ad71fab6 by Benjamin Arnaud at 2023-05-26T12:10:34+00:00
qml/LangButton: Code cleanup

No functional changes.

- - - - -
bf49ffb7 by Benjamin Arnaud at 2023-05-26T12:10:34+00:00
qml/LangButton: Add the 'g_mainDisplay' support

- - - - -
2ab47387 by Benjamin Arnaud at 2023-05-26T12:10:34+00:00
qml/TracksMenu: Take the theme into account into for opacity

- - - - -
6e36d3bc by Benjamin Arnaud at 2023-05-26T12:10:34+00:00
qml/ControlButtonPopup: Take the theme into account into for opacity

- - - - -
860f69df by Benjamin Arnaud at 2023-05-26T12:10:34+00:00
qml/LangButton: Apply the menu via signal

Co-authored-by: Pierre Lamot <pierre at videolabs.io>

- - - - -


9 changed files:

- modules/gui/qt/maininterface/qml/MainDisplay.qml
- modules/gui/qt/player/qml/ControlBar.qml
- modules/gui/qt/player/qml/ControlLayout.qml
- modules/gui/qt/player/qml/MiniPlayer.qml
- modules/gui/qt/player/qml/Player.qml
- modules/gui/qt/player/qml/PlayerControlLayout.qml
- modules/gui/qt/player/qml/TracksMenu.qml
- modules/gui/qt/player/qml/controlbarcontrols/ControlButtonPopup.qml
- modules/gui/qt/player/qml/controlbarcontrols/LangButton.qml


Changes:

=====================================
modules/gui/qt/maininterface/qml/MainDisplay.qml
=====================================
@@ -50,6 +50,15 @@ FocusScope {
     property int displayMargin: (loaderProgress.active) ? miniPlayer.height + loaderProgress.height
                                                         : miniPlayer.height
 
+    readonly property int positionSliderY: {
+        var size = miniPlayer.y + miniPlayer.sliderY
+
+        if (MainCtx.pinVideoControls)
+            return size - VLCStyle.margin_xxxsmall
+        else
+            return size
+    }
+
     property bool _inhibitMiniPlayer: false
     property bool _showMiniPlayer: false
     property var _oldViewProperties: ({}) // saves last state of the views


=====================================
modules/gui/qt/player/qml/ControlBar.qml
=====================================
@@ -44,6 +44,8 @@ Control {
     property alias sliderHeight: trackPositionSlider.barHeight
     property real bookmarksHeight: VLCStyle.controlBarBookmarksHeight
 
+    property var menu: undefined
+
     signal requestLockUnlockAutoHide(bool lock)
 
     enabled: visible
@@ -68,6 +70,25 @@ Control {
         trackPositionSlider.showChapterMarks()
     }
 
+    function applyMenu(menu) {
+        if (root.menu === menu)
+            return
+
+        // NOTE: When applying a new menu we hide the previous one.
+        if (menu)
+            dismiss()
+
+        root.menu = menu
+    }
+
+    function dismiss() {
+        if ((typeof menu === undefined) || !menu)
+            return
+        if (menu.hasOwnProperty("dismiss"))
+            menu.dismiss()
+        else if (menu.hasOwnProperty("close"))
+            menu.close()
+    }
 
     function _layout() {
         switch (textPosition) {
@@ -152,6 +173,8 @@ Control {
             Navigation.upItem: trackPositionSlider.enabled ? trackPositionSlider : root.Navigation.upItem
 
             onRequestLockUnlockAutoHide: root.requestLockUnlockAutoHide(lock)
+
+            onMenuOpened: root.applyMenu(menu)
         }
     }
 


=====================================
modules/gui/qt/player/qml/ControlLayout.qml
=====================================
@@ -53,6 +53,8 @@ FocusScope {
 
     signal requestLockUnlockAutoHide(bool lock)
 
+    signal menuOpened(var menu)
+
     // Settings
 
     implicitWidth: {
@@ -242,6 +244,12 @@ FocusScope {
                             controlLayout.requestLockUnlockAutoHide(lock)
                         })
                     }
+
+                    if (item.menuOpened) {
+                        item.menuOpened.connect(function(menu) {
+                            controlLayout.menuOpened(menu)
+                        })
+                    }
                 }
 
                 // Connections


=====================================
modules/gui/qt/player/qml/MiniPlayer.qml
=====================================
@@ -29,6 +29,8 @@ import "qrc:///style/"
 T.Pane {
     id: root
 
+    readonly property alias sliderY: controlBar.sliderY
+
     height: 0
 
     implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
@@ -82,6 +84,8 @@ T.Pane {
     }
 
     contentItem: ControlBar {
+        id: controlBar
+
         focus: true
 
         // NOTE: When controls are pinned we keep the same slider in both views. Otherwise we make


=====================================
modules/gui/qt/player/qml/Player.qml
=====================================
@@ -36,9 +36,6 @@ FocusScope {
 
     // Properties
 
-    //menu/overlay to dismiss
-    property var menu: undefined
-
     property bool hasEmbededVideo: MainCtx.hasEmbededVideo
 
     readonly property int positionSliderY: controlBarView.y + controlBarView.sliderY
@@ -121,26 +118,6 @@ FocusScope {
 
     // Functions
 
-    function applyMenu(menu) {
-        if (rootPlayer.menu === menu)
-            return
-
-        // NOTE: When applying a new menu we hide the previous one.
-        if (menu)
-            dismiss()
-
-        rootPlayer.menu = menu
-    }
-
-    function dismiss() {
-        if ((typeof menu === undefined) || !menu)
-            return
-        if (menu.hasOwnProperty("dismiss"))
-            menu.dismiss()
-        else if (menu.hasOwnProperty("close"))
-            menu.close()
-    }
-
     function lockUnlockAutoHide(lock) {
         _lockAutoHide += lock ? 1 : -1;
         console.assert(_lockAutoHide >= 0)


=====================================
modules/gui/qt/player/qml/PlayerControlLayout.qml
=====================================
@@ -57,6 +57,8 @@ FocusScope {
 
     signal requestLockUnlockAutoHide(bool lock)
 
+    signal menuOpened(var menu)
+
     // Settings
 
     // NOTE: We want a smaller ControlBar when the controls are pinned.
@@ -178,6 +180,8 @@ FocusScope {
             onCountChanged: playerControlLayout._updateLayout()
 
             onRequestLockUnlockAutoHide: playerControlLayout.requestLockUnlockAutoHide(lock)
+
+            onMenuOpened: playerControlLayout.menuOpened(menu)
         }
     }
 
@@ -212,6 +216,8 @@ FocusScope {
             onCountChanged: playerControlLayout._updateLayout()
 
             onRequestLockUnlockAutoHide: playerControlLayout.requestLockUnlockAutoHide(lock)
+
+            onMenuOpened: playerControlLayout.menuOpened(menu)
         }
     }
 
@@ -246,6 +252,8 @@ FocusScope {
             onCountChanged: playerControlLayout._updateLayout()
 
             onRequestLockUnlockAutoHide: playerControlLayout.requestLockUnlockAutoHide(lock)
+
+            onMenuOpened: playerControlLayout.menuOpened(menu)
         }
     }
 }


=====================================
modules/gui/qt/player/qml/TracksMenu.qml
=====================================
@@ -35,7 +35,6 @@ T.Popup {
     // Settings
 
     height: VLCStyle.dp(296, VLCStyle.scale)
-    width: rootPlayer.width
 
     // Popup.CloseOnPressOutside doesn't work with non-model Popup on Qt < 5.15
     closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape
@@ -60,8 +59,19 @@ T.Popup {
     T.Overlay.modal: null
 
     background: Rectangle {
-        opacity: 0.8
-        color: popupTheme.bg.primary
+        // NOTE: The opacity should be stronger on a light background for readability.
+        color: (popupTheme.palette.isDark)
+               ? VLCStyle.setColorAlpha(popupTheme.bg.primary, 0.8)
+               : VLCStyle.setColorAlpha(popupTheme.bg.primary, 0.96)
+
+        Rectangle {
+            anchors.left: parent.left
+            anchors.right: parent.right
+
+            height: VLCStyle.margin_xxxsmall
+
+            color: popupTheme.border
+        }
     }
 
     contentItem: StackView {
@@ -134,10 +144,10 @@ T.Popup {
                 onCurrentItemChanged: {
                     if (currentItem instanceof TracksPage)
                         root.width = Qt.binding(function () {
-                            return Math.min(currentItem.preferredWidth, rootPlayer.width)
+                            return Math.min(currentItem.preferredWidth, root.parent.width)
                         })
                     else
-                        root.width = Qt.binding(function () { return rootPlayer.width })
+                        root.width = Qt.binding(function () { return root.parent.width })
                 }
             }
 


=====================================
modules/gui/qt/player/qml/controlbarcontrols/ControlButtonPopup.qml
=====================================
@@ -45,6 +45,8 @@ Widgets.IconControlButton {
 
     signal requestLockUnlockAutoHide(bool lock)
 
+    signal menuOpened(var menu)
+
     // Settings
 
     color: (popup.visible) ? control.colorContext.accent : control.colorContext.fg.primary
@@ -124,8 +126,7 @@ Widgets.IconControlButton {
 
             root.requestLockUnlockAutoHide(true)
 
-            if (root._isCurrentViewPlayer)
-                rootPlayer.applyMenu(popup)
+            root.menuOpened(popup)
         }
 
         onClosed: {
@@ -133,8 +134,7 @@ Widgets.IconControlButton {
 
             root.forceActiveFocus()
 
-            if (root._isCurrentViewPlayer)
-                rootPlayer.applyMenu(null)
+            root.menuOpened(null)
         }
 
         onWidthChanged: if (visible) root._updatePosition()
@@ -149,9 +149,10 @@ Widgets.IconControlButton {
 
             radius: VLCStyle.dp(8, VLCStyle.scale)
 
-            opacity: 0.85
-
-            color: popupTheme.bg.primary
+            // NOTE: The opacity should be stronger on a light background for readability.
+            color: (popupTheme.palette.isDark)
+                   ? VLCStyle.setColorAlpha(popupTheme.bg.primary, 0.8)
+                   : VLCStyle.setColorAlpha(popupTheme.bg.primary, 0.96)
         }
     }
 }


=====================================
modules/gui/qt/player/qml/controlbarcontrols/LangButton.qml
=====================================
@@ -15,6 +15,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
+
 import QtQuick 2.12
 
 import org.videolan.vlc 0.1
@@ -23,45 +24,67 @@ import "qrc:///widgets/" as Widgets
 import "qrc:///style/"
 import "qrc:///player/" as Player
 
-
 Widgets.IconControlButton {
-    id: langBtn
-    iconText: VLCIcons.audiosub
+    id: root
 
-    enabled: menuLoader.status === Loader.Ready
-    onClicked: menuLoader.item.open()
+    // Proprerties
+
+    readonly property var _parentItem: {
+        if ((typeof rootPlayer !== 'undefined') && (rootPlayer !== null))
+            return rootPlayer
+        else
+            return g_mainDisplay
+    }
+
+    // Signals
 
     signal requestLockUnlockAutoHide(bool lock)
 
+    signal menuOpened(var menu)
+
+    // Settings
+
+    iconText: VLCIcons.audiosub
+
+    enabled: menuLoader.status === Loader.Ready
+
     text: I18n.qtr("Languages and tracks")
 
+    // Events
+
+    onClicked: menuLoader.item.open()
+
+    // Children
+
     Loader {
         id: menuLoader
 
-        active: (typeof rootPlayer !== 'undefined') && (rootPlayer !== null)
-
         sourceComponent: Player.TracksMenu {
             id: menu
 
-            parent: rootPlayer
-            focus: true
+            parent: root._parentItem
+
+            width: parent.width
+
             x: 0
-            y: (rootPlayer.positionSliderY - height)
+            y: (parent.positionSliderY - height)
             z: 1
 
-            colorContext.palette: langBtn.colorContext.palette
+            focus: true
+
+            colorContext.palette: root.colorContext.palette
 
             onOpened: {
-                langBtn.requestLockUnlockAutoHide(true)
-                if (!!rootPlayer)
-                    rootPlayer.applyMenu(menu)
+                root.requestLockUnlockAutoHide(true)
+
+                root.menuOpened(menu)
             }
 
             onClosed: {
-                langBtn.requestLockUnlockAutoHide(false)
-                langBtn.forceActiveFocus()
-                if (!!rootPlayer)
-                    rootPlayer.applyMenu(null)
+                root.requestLockUnlockAutoHide(false)
+                root.forceActiveFocus()
+
+                root.menuOpened(null)
             }
         }
     }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0b303f07a49baea66c72ea3161eab05dd006fcbf...860f69dffd368f9f9d44128a354e5b20e4e5b6d7

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0b303f07a49baea66c72ea3161eab05dd006fcbf...860f69dffd368f9f9d44128a354e5b20e4e5b6d7
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