[vlc-commits] [Git][videolan/vlc][master] 4 commits: qt/mainctx: Add the 'pinOpacity' property

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Mar 17 13:41:04 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
debe7eac by Benjamin Arnaud at 2023-03-17T13:28:56+00:00
qt/mainctx: Add the 'pinOpacity' property

- - - - -
45875b43 by Benjamin Arnaud at 2023-03-17T13:28:56+00:00
qml/TopBar: Add the 'resumeVisible' property

- - - - -
a965917a by Benjamin Arnaud at 2023-03-17T13:28:56+00:00
qml/Player: Update the 'pinned' behavior

When pinned in fullscreen, we want the controlbar to retain the default design and hide
everything at the top.

- - - - -
cb8d5930 by Benjamin Arnaud at 2023-03-17T13:28:56+00:00
qml/Player: Add pin background opacity

- - - - -


4 changed files:

- modules/gui/qt/maininterface/mainctx.cpp
- modules/gui/qt/maininterface/mainctx.hpp
- modules/gui/qt/player/qml/Player.qml
- modules/gui/qt/player/qml/TopBar.qml


Changes:

=====================================
modules/gui/qt/maininterface/mainctx.cpp
=====================================
@@ -96,6 +96,12 @@ int loadVLCOption<int>(vlc_object_t *obj, const char *name)
     return var_InheritInteger(obj, name);
 }
 
+template <>
+float loadVLCOption<float>(vlc_object_t *obj, const char *name)
+{
+    return var_InheritFloat(obj, name);
+}
+
 template <>
 bool loadVLCOption<bool>(vlc_object_t *obj, const char *name)
 {
@@ -303,6 +309,7 @@ void MainCtx::loadPrefs(const bool callSignals)
 
     loadFromVLCOption(m_pinVideoControls, "qt-pin-controls", &MainCtx::pinVideoControlsChanged);
 
+    loadFromVLCOption(m_pinOpacity, "qt-fs-opacity", &MainCtx::pinOpacityChanged);
 }
 
 void MainCtx::loadFromSettingsImpl(const bool callSignals)
@@ -443,6 +450,16 @@ void MainCtx::setPinVideoControls(bool pinVideoControls)
     emit pinVideoControlsChanged();
 }
 
+void MainCtx::setPinOpacity(float pinOpacity)
+{
+    if (m_pinOpacity == pinOpacity)
+        return;
+
+    m_pinOpacity = pinOpacity;
+
+    emit pinOpacityChanged();
+}
+
 inline void MainCtx::initSystray()
 {
     bool b_systrayAvailable = QSystemTrayIcon::isSystemTrayAvailable();


=====================================
modules/gui/qt/maininterface/mainctx.hpp
=====================================
@@ -168,6 +168,7 @@ class MainCtx : public QObject
     Q_PROPERTY(bool hasToolbarMenu READ hasToolbarMenu WRITE setHasToolbarMenu NOTIFY hasToolbarMenuChanged FINAL)
     Q_PROPERTY(bool canShowVideoPIP READ canShowVideoPIP CONSTANT FINAL)
     Q_PROPERTY(bool pinVideoControls READ pinVideoControls WRITE setPinVideoControls NOTIFY pinVideoControlsChanged FINAL)
+    Q_PROPERTY(float pinOpacity READ pinOpacity WRITE setPinOpacity NOTIFY pinOpacityChanged FINAL)
     Q_PROPERTY(ControlbarProfileModel* controlbarProfileModel READ controlbarProfileModel CONSTANT FINAL)
     Q_PROPERTY(bool hasAcrylicSurface READ hasAcrylicSurface NOTIFY hasAcrylicSurfaceChanged FINAL)
     Q_PROPERTY(PlaylistPtr mainPlaylist READ getMainPlaylist CONSTANT FINAL)
@@ -251,7 +252,10 @@ public:
     inline bool hasToolbarMenu() const { return m_hasToolbarMenu; }
     inline bool canShowVideoPIP() const { return m_canShowVideoPIP; }
     inline void setCanShowVideoPIP(bool canShowVideoPIP) { m_canShowVideoPIP = canShowVideoPIP; }
+
     inline bool pinVideoControls() const { return m_pinVideoControls; }
+    inline float pinOpacity() const { return m_pinOpacity; }
+
     inline ControlbarProfileModel* controlbarProfileModel() const { return m_controlbarProfileModel; }
     inline QUrl getDialogFilePath() const { return m_dialogFilepath; }
     inline void setDialogFilePath(const QUrl& filepath ){ m_dialogFilepath = filepath; }
@@ -348,7 +352,11 @@ protected:
     // NOTE: Ideally this should be a QVLCBool.
     bool                 m_hasToolbarMenu = false;
     bool                 m_canShowVideoPIP = false;
+
+    /* Pinned */
     bool                 m_pinVideoControls = false;
+    float                m_pinOpacity       = 1.0f;
+
     bool                 m_useGlobalShortcuts = true;
     QUrl                 m_dialogFilepath; /* Last path used in dialogs */
 
@@ -387,7 +395,10 @@ public slots:
     void incrementIntfUserScaleFactor( bool increment);
     void setIntfUserScaleFactor( double );
     void setHasToolbarMenu( bool );
+
     void setPinVideoControls( bool );
+    void setPinOpacity( float );
+
     void updateIntfScaleFactor();
     void onWindowVisibilityChanged(QWindow::Visibility);
     void setHasAcrylicSurface(bool);
@@ -440,7 +451,10 @@ signals:
     void requestInterfaceMinimized();
 
     void intfScaleFactorChanged();
+
     void pinVideoControlsChanged();
+    void pinOpacityChanged();
+
     void hasAcrylicSurfaceChanged();
 
     void acrylicActiveChanged();


=====================================
modules/gui/qt/player/qml/Player.qml
=====================================
@@ -34,17 +34,15 @@ import "qrc:///dialogs/" as DG
 FocusScope {
     id: rootPlayer
 
+    // Properties
+
     //menu/overlay to dismiss
     property var menu: undefined
-    property int _lockAutoHide: 0
-    readonly property bool _autoHide: _lockAutoHide == 0
-                                      && rootPlayer.hasEmbededVideo
-                                      && Player.hasVideoOutput
-                                      && playlistpopup.state !== "visible"
 
-    property bool pinVideoControls: MainCtx.pinVideoControls && (MainCtx.intfMainWindow.visibility !== Window.FullScreen)
     property bool hasEmbededVideo: MainCtx.hasEmbededVideo
+
     readonly property int positionSliderY: controlBarView.y + controlBarView.sliderY
+
     readonly property string coverSource: {
         if (mainPlaylistController.currentItem.artwork && mainPlaylistController.currentItem.artwork.toString())
             mainPlaylistController.currentItem.artwork
@@ -54,8 +52,24 @@ FocusScope {
             VLCStyle.noArtAlbumCover
 
     }
+
+    // Private
+
+    property int _lockAutoHide: 0
+
+    readonly property bool _autoHide: _lockAutoHide == 0
+                                      && rootPlayer.hasEmbededVideo
+                                      && Player.hasVideoOutput
+                                      && playlistpopup.state !== "visible"
+
+    property bool _controlsUnderVideo: (MainCtx.pinVideoControls
+                                        &&
+                                        (MainCtx.intfMainWindow.visibility !== Window.FullScreen))
+
     property bool _keyPressed: false
 
+    // Settings
+
     layer.enabled: (StackView.status === StackView.Deactivating || StackView.status === StackView.Activating)
 
     // Events
@@ -96,9 +110,9 @@ FocusScope {
             toolbarAutoHide.restart()
     }
 
-    onPinVideoControlsChanged: {
-        lockUnlockAutoHide(pinVideoControls)
-        if (pinVideoControls)
+    on_ControlsUnderVideoChanged: {
+        lockUnlockAutoHide(_controlsUnderVideo)
+        if (_controlsUnderVideo)
             toolbarAutoHide.setVisibleControlBar(true)
     }
 
@@ -145,9 +159,12 @@ FocusScope {
     //we draw both the view and the window here
     ColorContext {
         id: windowTheme
+
         // NOTE: We force the night theme when playing a video.
-        palette: (MainCtx.hasEmbededVideo && !rootPlayer.pinVideoControls) ? VLCStyle.darkPalette
-                                                                           : VLCStyle.palette
+        palette: (MainCtx.hasEmbededVideo && MainCtx.pinVideoControls === false)
+                 ? VLCStyle.darkPalette
+                 : VLCStyle.palette
+
         colorSet: ColorContext.Window
     }
 
@@ -181,8 +198,8 @@ FocusScope {
         visible: rootPlayer.hasEmbededVideo
         enabled: rootPlayer.hasEmbededVideo
         anchors.fill: parent
-        anchors.topMargin: rootPlayer.pinVideoControls ? topcontrolView.height : 0
-        anchors.bottomMargin: rootPlayer.pinVideoControls ? controlBarView.height : 0
+        anchors.topMargin: rootPlayer._controlsUnderVideo ? topcontrolView.height : 0
+        anchors.bottomMargin: rootPlayer._controlsUnderVideo ? controlBarView.height : 0
 
         onMouseMoved: {
             //short interval for mouse events
@@ -219,12 +236,15 @@ FocusScope {
         }
     }
 
-    /// Backgrounds of topControlbar and controlBar are drawn separately since they can outgrow their content
+    // Backgrounds of topControlbar and controlBar are drawn separately since they can outgrow their content
     Component {
         id: backgroundForPinnedControls
 
         Rectangle {
             width: rootPlayer.width
+
+            opacity: MainCtx.pinOpacity
+
             color: windowTheme.bg.primary
         }
     }
@@ -234,26 +254,33 @@ FocusScope {
 
         Widgets.AcrylicBackground {
             width: rootPlayer.width
+
+            visible: (rootPlayer._controlsUnderVideo || topcontrolView.resumeVisible)
+
+            opacity: (MainCtx.intfMainWindow.visibility === Window.FullScreen) ? MainCtx.pinOpacity
+                                                                               : 1.0
+
             tintColor: windowTheme.bg.primary
         }
     }
 
     /* top control bar background */
     Widgets.LoaderFade {
-        state: topcontrolView.state
         width: parent.width
-        visible: rootPlayer.hasEmbededVideo || rootPlayer.pinVideoControls
+
+        state: topcontrolView.state
+
         height: item.height
 
         sourceComponent: {
-            if (rootPlayer.pinVideoControls)
+            if (MainCtx.pinVideoControls)
                 return acrylicBackground
             else
                 return topcontrolViewBackground
         }
 
         onItemChanged: {
-            if (rootPlayer.pinVideoControls)
+            if (rootPlayer._controlsUnderVideo)
                 item.height = Qt.binding(function () { return topcontrolView.height + topcontrolView.anchors.topMargin; })
         }
 
@@ -263,6 +290,9 @@ FocusScope {
             Rectangle {
                 width: rootPlayer.width
                 height: VLCStyle.dp(206, VLCStyle.scale)
+
+                visible: rootPlayer.hasEmbededVideo
+
                 gradient: Gradient {
                     GradientStop { position: 0; color: Qt.rgba(0, 0, 0, .8) }
                     GradientStop { position: 1; color: "transparent" }
@@ -281,11 +311,12 @@ FocusScope {
 
         state: controlBarView.state
 
-        sourceComponent: rootPlayer.pinVideoControls
+        sourceComponent: (MainCtx.pinVideoControls)
                          ? backgroundForPinnedControls
                          : (rootPlayer.hasEmbededVideo ? forVideoMedia : forMusicMedia)
+
         onItemChanged: {
-            if (rootPlayer.pinVideoControls)
+            if (rootPlayer._controlsUnderVideo)
                 item.height = Qt.binding(function () { return rootPlayer.height - rootPlayer.positionSliderY; })
         }
 
@@ -315,9 +346,11 @@ FocusScope {
         }
     }
 
-    Widgets.LoaderFade{
+    Widgets.LoaderFade {
         id: topcontrolView
 
+        property bool resumeVisible: (item) ? item.resumeVisible : false
+
         anchors {
             top: parent.top
             left: parent.left
@@ -326,8 +359,6 @@ FocusScope {
 
         z: 1
 
-        state: "visible"
-
         sourceComponent: TopBar {
             id: topbar
 
@@ -340,10 +371,19 @@ FocusScope {
             textWidth: (MainCtx.playlistVisible) ? rootPlayer.width - playlistpopup.width
                                                  : rootPlayer.width
 
+            // NOTE: With pinned controls, the top controls are hidden when switching to
+            //       fullScreen. Except when resume is visible
+            visible: (MainCtx.pinVideoControls === false
+                      ||
+                      MainCtx.intfMainWindow.visibility !== Window.FullScreen
+                      ||
+                      resumeVisible)
+
             focus: true
             title: mainPlaylistController.currentItem.title
 
-            pinControls: rootPlayer.pinVideoControls
+            pinControls: MainCtx.pinVideoControls
+
             showCSD: MainCtx.clientSideDecoration && (MainCtx.intfMainWindow.visibility !== Window.FullScreen)
             showToolbar: MainCtx.hasToolbarMenu && (MainCtx.intfMainWindow.visibility !== Window.FullScreen)
 
@@ -525,8 +565,9 @@ FocusScope {
 
         anchors {
             // NOTE: When the controls are pinned we display the playqueue under the topBar.
-            top: (rootPlayer.pinVideoControls) ? topcontrolView.bottom
-                                               : parent.top
+            top: (rootPlayer._controlsUnderVideo) ? topcontrolView.bottom
+                                                  : parent.top
+
             right: parent.right
             bottom: parent.bottom
 
@@ -555,7 +596,7 @@ FocusScope {
                 anchors.fill: parent
                 rightPadding: VLCStyle.applicationHorizontalMargin
                 topPadding:  {
-                    if (rootPlayer.pinVideoControls)
+                    if (rootPlayer._controlsUnderVideo)
                         return VLCStyle.margin_normal
                     else
                         // NOTE: We increase the padding accordingly to avoid overlapping the TopBar.
@@ -606,14 +647,18 @@ FocusScope {
             bottom: controlBarView.item.visible ? controlBarView.top : rootPlayer.bottom
             left: parent.left
             right: parent.right
-            bottomMargin: rootPlayer.pinVideoControls || !controlBarView.item.visible ? 0 : - VLCStyle.margin_large
+
+            bottomMargin: (rootPlayer._controlsUnderVideo || !controlBarView.item.visible)
+                          ? 0 : - VLCStyle.margin_large
         }
     }
 
     Widgets.LoaderFade {
         id: controlBarView
 
-        readonly property int sliderY: rootPlayer.pinVideoControls ? item.sliderY - VLCStyle.margin_xxxsmall : item.sliderY
+        readonly property int sliderY: (MainCtx.pinVideoControls) ? item.sliderY
+                                                                    - VLCStyle.margin_xxxsmall
+                                                                  : item.sliderY
 
         anchors {
             bottom: parent.bottom
@@ -623,10 +668,8 @@ FocusScope {
 
         focus: true
 
-        state: "visible"
-
         onStateChanged: {
-            if (state === "visible")
+            if (state === "visible" && item)
                 item.showChapterMarks()
         }
 
@@ -654,7 +697,9 @@ FocusScope {
                 anchors.rightMargin: VLCStyle.applicationHorizontalMargin
                 anchors.bottomMargin: VLCStyle.applicationVerticalMargin
 
-                textPosition: rootPlayer.pinVideoControls ? ControlBar.TimeTextPosition.LeftRightSlider : ControlBar.TimeTextPosition.AboveSlider
+                textPosition: (MainCtx.pinVideoControls)
+                              ? ControlBar.TimeTextPosition.LeftRightSlider
+                              : ControlBar.TimeTextPosition.AboveSlider
 
                 Navigation.parentItem: rootPlayer
                 Navigation.upItem: playlistpopup.showPlaylist ? playlistpopup : (audioControls.visible ? audioControls : topcontrolView)


=====================================
modules/gui/qt/player/qml/TopBar.qml
=====================================
@@ -31,6 +31,8 @@ import "qrc:///menus/" as Menus
 FocusScope{
     id: root
 
+    // Properties
+
     /* required */ property int textWidth
 
     property string title
@@ -46,6 +48,12 @@ FocusScope{
 
     readonly property int _sideMargin: VLCStyle.margin_small + sideMargin
 
+    // Aliases
+
+    property alias resumeVisible: resumeDialog.visible
+
+    // Signals
+
     signal togglePlaylistVisibility()
     signal requestLockUnlockAutoHide(bool lock)
     signal backRequested()
@@ -202,11 +210,11 @@ FocusScope{
         anchors.top: root.top
         anchors.leftMargin:  root._sideMargin
 
-        implicitWidth: resumeDialog.visible ? resumeDialog.implicitWidth
-                                            : logoGroup.implicitWidth
+        implicitWidth: resumeVisible ? resumeDialog.implicitWidth
+                                     : logoGroup.implicitWidth
 
-        implicitHeight: resumeDialog.visible ? resumeDialog.implicitHeight
-                                             : logoGroup.implicitHeight
+        implicitHeight: resumeVisible ? resumeDialog.implicitHeight
+                                      : logoGroup.implicitHeight
 
         onImplicitHeightChanged: root._layout()
 
@@ -214,7 +222,7 @@ FocusScope{
             id: logoGroup
 
             anchors.fill: parent
-            visible: !resumeDialog.visible
+            visible: !resumeVisible
 
             implicitHeight: VLCStyle.icon_banner + VLCStyle.margin_xxsmall * 2
             implicitWidth: backBtn.implicitWidth + logo.implicitWidth + VLCStyle.margin_xxsmall
@@ -296,7 +304,7 @@ FocusScope{
         readonly property bool _alignHCenter: _centerX > _leftLimit
                                               && _centerX + centerTitleText.implicitWidth < _rightLimit
 
-        visible: root.pinControls && !resumeDialog.visible
+        visible: root.pinControls && !resumeVisible
 
         width: Math.min(centerTitleText._availableWidth, centerTitleText.implicitWidth)
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a26e2ba370d898dda04c718176af7d2e329dab7a...cb8d5930131fac647a08b035352b628edcda8d85

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a26e2ba370d898dda04c718176af7d2e329dab7a...cb8d5930131fac647a08b035352b628edcda8d85
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