[vlc-commits] [Git][videolan/vlc][master] 7 commits: qt/navigation_history: Fix the 'getCurrent' function

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Jun 5 04:47:15 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
b999ac3a by Benjamin Arnaud at 2023-06-04T10:55:28+00:00
qt/navigation_history: Fix the 'getCurrent' function

- - - - -
4384389c by Benjamin Arnaud at 2023-06-04T10:55:28+00:00
qml/mainctx: Add the 'mediaLibraryVisible' property

- - - - -
fb83e2d9 by Benjamin Arnaud at 2023-06-04T10:55:28+00:00
qml/MainInterface: Add the 'mediaLibraryVisible' support

- - - - -
fba89f8e by Benjamin Arnaud at 2023-06-04T10:55:28+00:00
qml/TopBar: Update the 'pinned' implementation

This is notably important for the classic presets (pinned + menu bar).

- - - - -
ba3f37c4 by Benjamin Arnaud at 2023-06-04T10:55:28+00:00
qml/TopBar: Fix the 'menubar' margin

- - - - -
58fd4e90 by Benjamin Arnaud at 2023-06-04T10:55:28+00:00
qt/menus: Create 'media_library.svg'

- - - - -
7dc1fc2f by Benjamin Arnaud at 2023-06-04T10:55:28+00:00
qt/menus: Add the 'Media Library' entry

- - - - -


9 changed files:

- modules/gui/qt/Makefile.am
- modules/gui/qt/maininterface/mainctx.cpp
- modules/gui/qt/maininterface/mainctx.hpp
- modules/gui/qt/maininterface/qml/MainInterface.qml
- modules/gui/qt/menus/menus.cpp
- + modules/gui/qt/pixmaps/menu/media_library.svg
- modules/gui/qt/player/qml/TopBar.qml
- modules/gui/qt/util/navigation_history.cpp
- modules/gui/qt/vlc.qrc


Changes:

=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -731,6 +731,7 @@ libqt_plugin_la_RES = \
 	gui/qt/pixmaps/menu/folder.svg \
 	gui/qt/pixmaps/menu/help.svg \
 	gui/qt/pixmaps/menu/info.svg \
+	gui/qt/pixmaps/menu/media_library.svg \
 	gui/qt/pixmaps/menu/messages.svg \
 	gui/qt/pixmaps/menu/movie.svg \
 	gui/qt/pixmaps/menu/music.svg \


=====================================
modules/gui/qt/maininterface/mainctx.cpp
=====================================
@@ -488,6 +488,15 @@ inline void MainCtx::initSystray()
         createSystray();
 }
 
+void MainCtx::setMediaLibraryVisible( bool visible )
+{
+    if (m_mediaLibraryVisible == visible)
+        return;
+
+    m_mediaLibraryVisible = visible;
+
+    emit mediaLibraryVisibleChanged(visible);
+}
 
 void MainCtx::setPlaylistDocked( bool docked )
 {


=====================================
modules/gui/qt/maininterface/mainctx.hpp
=====================================
@@ -148,6 +148,8 @@ class MainCtx : public QObject
 {
     Q_OBJECT
 
+    Q_PROPERTY(bool mediaLibraryVisible READ isMediaLibraryVisible WRITE setMediaLibraryVisible
+               NOTIFY mediaLibraryVisibleChanged FINAL)
     Q_PROPERTY(bool playlistDocked READ isPlaylistDocked WRITE setPlaylistDocked NOTIFY playlistDockedChanged FINAL)
     Q_PROPERTY(bool playlistVisible READ isPlaylistVisible WRITE setPlaylistVisible NOTIFY playlistVisibleChanged FINAL)
     Q_PROPERTY(double playlistWidthFactor READ getPlaylistWidthFactor WRITE setPlaylistWidthFactor NOTIFY playlistWidthFactorChanged FINAL)
@@ -231,6 +233,7 @@ public:
 
     inline bool isInterfaceFullScreen() const { return m_windowVisibility == QWindow::FullScreen; }
     inline bool isInterfaceVisible() const { return m_windowVisibility != QWindow::Hidden; }
+    bool isMediaLibraryVisible() { return m_mediaLibraryVisible; }
     bool isPlaylistDocked() { return b_playlistDocked; }
     bool isPlaylistVisible() { return playlistVisible; }
     inline double getPlaylistWidthFactor() const { return playlistWidthFactor; }
@@ -364,6 +367,7 @@ protected:
     QUrl                 m_dialogFilepath; /* Last path used in dialogs */
 
     /* States */
+    bool                 m_mediaLibraryVisible = true;
     bool                 playlistVisible = false;       ///< Is the playlist visible ?
     double               playlistWidthFactor = 4.;   ///< playlist size: root.width / playlistScaleFactor
 
@@ -390,6 +394,7 @@ public slots:
     void hideUpdateSystrayMenu();
     void toggleToolbarMenu();
     void toggleInterfaceFullScreen();
+    void setMediaLibraryVisible( bool );
     void setPlaylistDocked( bool );
     void setPlaylistVisible( bool );
     void setPlaylistWidthFactor( double );
@@ -436,6 +441,7 @@ signals:
     void askRaise();
     void kc_pressed(); /* easter eggs */
 
+    void mediaLibraryVisibleChanged(bool);
     void playlistDockedChanged(bool);
     void playlistVisibleChanged(bool);
     void playlistWidthFactorChanged(double);


=====================================
modules/gui/qt/maininterface/qml/MainInterface.qml
=====================================
@@ -107,6 +107,8 @@ Item {
             return
         }
         stackView.loadView(g_mainInterface.pageModel, current.name, current.properties)
+
+        MainCtx.mediaLibraryVisible = (current.name !== "player")
     }
 
     Connections {
@@ -114,6 +116,39 @@ Item {
         onCurrentChanged: loadCurrentHistoryView()
     }
 
+    Connections {
+        target: MainCtx
+
+        onMediaLibraryVisibleChanged: {
+            if (MainCtx.mediaLibraryVisible) {
+                // NOTE: Useful when we started the application on the 'player' view.
+                if (History.previousEmpty) {
+                    if (MainCtx.hasEmbededVideo && MainCtx.canShowVideoPIP === false)
+                        mainPlaylistController.stop()
+
+                    _pushHome()
+
+                    return
+                }
+
+                if (History.current.name !== "player")
+                    return
+
+                if (MainCtx.hasEmbededVideo && MainCtx.canShowVideoPIP === false)
+                    mainPlaylistController.stop()
+
+                History.previous()
+            } else {
+                if (History.current.name === "player")
+                    return
+
+                stackView.currentItem._inhibitMiniPlayer = true
+
+                History.push(["player"])
+            }
+        }
+    }
+
     function setInitialView() {
         //set the initial view
         const loadPlayer = !mainPlaylistController.empty;
@@ -127,6 +162,12 @@ Item {
             History.push(["player"])
     }
 
+    function _pushHome() {
+        if (MainCtx.mediaLibraryAvailable)
+            History.push(["mc", "video"])
+        else
+            History.push(["mc", "home"])
+    }
 
     Component.onCompleted: {
         g_mainInterface._interfaceReady = true;
@@ -177,12 +218,7 @@ Item {
                     if (Player.playingState === Player.PLAYING_STATE_STOPPED
                             && History.current.name === "player") {
                         if (History.previousEmpty)
-                        {
-                            if (MainCtx.mediaLibraryAvailable)
-                                History.push(["mc", "video"])
-                            else
-                                History.push(["mc", "home"])
-                        }
+                            _pushHome()
                         else
                             History.previous()
                     }


=====================================
modules/gui/qt/menus/menus.cpp
=====================================
@@ -296,6 +296,22 @@ void VLCMenuBar::ViewMenu( qt_intf_t *p_intf, QMenu *menu )
         if( m && m->parent() == menu ) delete m;
     }
 
+    QString title;
+
+    if (mi->hasMediaLibrary())
+        title = qtr("Media Library");
+    else
+        title = qtr("Browse and Discover");
+
+    action = menu->addAction(
+#ifndef __APPLE__
+            QIcon( ":/menu/media_library.svg" ),
+#endif
+            title);
+    action->setCheckable( true );
+    connect( action, &QAction::triggered, mi, &MainCtx::setMediaLibraryVisible );
+    action->setChecked( mi->isMediaLibraryVisible() );
+
     action = menu->addAction(
 #ifndef __APPLE__
             QIcon( ":/menu/playlist.svg" ),


=====================================
modules/gui/qt/pixmaps/menu/media_library.svg
=====================================
@@ -0,0 +1,7 @@
+<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
+  <g fill="#747474">
+    <path d="M8 8v5l32-.001v-5zm0 10v5l32-.001v-5zm0 10v5l18-.001v-5z"/>
+    <path d="m40 34-9 6V28z" fill-rule="evenodd"/>
+  </g>
+</svg>
+


=====================================
modules/gui/qt/player/qml/TopBar.qml
=====================================
@@ -46,6 +46,12 @@ FocusScope{
 
     property int reservedHeight: 0
 
+    // Private
+
+    property bool _showTopBar: (pinControls === false || root.showToolbar === false)
+
+    property bool _showCenterText: (pinControls && showToolbar === false && showCSD)
+
     readonly property int _sideMargin: VLCStyle.margin_small + sideMargin
 
     // Aliases
@@ -70,6 +76,9 @@ FocusScope{
     onTopMarginChanged: root._layout()
     onSideMarginChanged: root._layout()
 
+    on_ShowTopBarChanged: _layout()
+    on_ShowCenterText: _layout()
+
     function _layoutLine(c1, c2, offset)
     {
         let c1Height = c1 !== undefined ? c1.implicitHeight : 0
@@ -100,7 +109,7 @@ FocusScope{
     function _layout() {
         let offset = root.topMargin
 
-        if (root.pinControls && !root.showToolbar && root.showCSD) {
+        if (root._showCenterText) {
             //place everything on one line
             //csdDecorations.implicitHeight gets overwritten when the height is set,
             //VLCStyle.icon_normal is its initial value
@@ -156,16 +165,8 @@ FocusScope{
 
             right = playlistGroup
 
-            const secondLineOffset = offset
-            const secondLineHeight = root._layoutLine(left, right, offset)
-
-            offset += secondLineHeight
-
-            if (root.pinControls) {
-                centerTitleText.y = secondLineOffset
-                centerTitleText.height = secondLineHeight
-            }
-
+            if (_showTopBar)
+                offset += _layoutLine(left, right, offset)
         }
 
         root.implicitHeight = offset
@@ -192,7 +193,7 @@ FocusScope{
 
         anchors.top: parent.top
         anchors.left: parent.left
-        anchors.leftMargin: root._sideMargin
+        anchors.leftMargin: root.sideMargin
 
         width: implicitWidth
 
@@ -203,7 +204,6 @@ FocusScope{
         onMenuOpenedChanged: root.requestLockUnlockAutoHide(menuOpened)
     }
 
-
     Item {
         id: logoOrResume
 
@@ -214,8 +214,14 @@ FocusScope{
         implicitWidth: resumeVisible ? resumeDialog.implicitWidth
                                      : logoGroup.implicitWidth
 
-        implicitHeight: resumeVisible ? resumeDialog.implicitHeight
-                                      : logoGroup.implicitHeight
+        implicitHeight: {
+            if (root.resumeVisible)
+                return resumeDialog.implicitHeight
+            else if (_showTopBar)
+                return logoGroup.implicitHeight
+            else
+                return 0
+        }
 
         onImplicitHeightChanged: root._layout()
 
@@ -223,7 +229,8 @@ FocusScope{
             id: logoGroup
 
             anchors.fill: parent
-            visible: !resumeVisible
+
+            visible: (root._showTopBar && root.resumeVisible === false)
 
             implicitHeight: VLCStyle.icon_banner + VLCStyle.margin_xxsmall * 2
             implicitWidth: backBtn.implicitWidth + logo.implicitWidth + VLCStyle.margin_xxsmall
@@ -266,7 +273,6 @@ FocusScope{
             }
         }
 
-
         ResumeDialog {
             id: resumeDialog
 
@@ -305,7 +311,8 @@ FocusScope{
         readonly property bool _alignHCenter: _centerX > _leftLimit
                                               && _centerX + centerTitleText.implicitWidth < _rightLimit
 
-        visible: root.pinControls && !resumeVisible
+        visible: (_showCenterText && root.resumeVisible === false)
+
         enabled: visible
 
         width: Math.min(centerTitleText._availableWidth, centerTitleText.implicitWidth)
@@ -345,6 +352,7 @@ FocusScope{
         width: root.textWidth - VLCStyle.margin_normal
 
         visible: !root.pinControls
+
         enabled: visible
 
         topPadding: VLCStyle.margin_large
@@ -392,6 +400,8 @@ FocusScope{
         anchors.right: parent.right
         anchors.rightMargin: root._sideMargin + extraRightMargin
 
+        visible: root._showTopBar
+
         Widgets.IconControlButton {
             id: menuSelector
 


=====================================
modules/gui/qt/util/navigation_history.cpp
=====================================
@@ -11,6 +11,8 @@ NavigationHistory::NavigationHistory(QObject *parent)
 
 QVariant NavigationHistory::getCurrent()
 {
+    assert(m_history.isEmpty() == false);
+
     return m_history.back();
 }
 


=====================================
modules/gui/qt/vlc.qrc
=====================================
@@ -24,6 +24,7 @@
         <file alias="folder.svg">pixmaps/menu/folder.svg</file>
         <file alias="help.svg">pixmaps/menu/help.svg</file>
         <file alias="info.svg">pixmaps/menu/info.svg</file>
+        <file alias="media_library.svg">pixmaps/menu/media_library.svg</file>
         <file alias="messages.svg">pixmaps/menu/messages.svg</file>
         <file alias="movie.svg">pixmaps/menu/movie.svg</file>
         <file alias="music.svg">pixmaps/menu/music.svg</file>



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d17cb406dd1f03a96de568246455d43f0d5405a7...7dc1fc2f60ace07723bd6f420f5be926666e2999

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