[vlc-commits] [Git][videolan/vlc][master] 7 commits: qml: inline calls to g_mainDisplay.play

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed Sep 20 09:10:51 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
becc4b1e by Pierre Lamot at 2023-09-20T08:52:06+00:00
qml: inline calls to g_mainDisplay.play

this removes unqualified access to g_mainDisplay

- - - - -
957c1ef0 by Pierre Lamot at 2023-09-20T08:52:06+00:00
qml: fix access to missing variable

_inhibitMiniPlayer has be removed in c038375a31054a47c86cb90401fb7af7d1bffb8b

- - - - -
f4431c39 by Pierre Lamot at 2023-09-20T08:52:06+00:00
qml: avoid Navigation self parenting in ServiceSources

- - - - -
f087a1ba by Pierre Lamot at 2023-09-20T08:52:06+00:00
qml: provide default value for path in NetworkAddressbar

- - - - -
ba6aced1 by Pierre Lamot at 2023-09-20T08:52:06+00:00
qml: fix keyboard navigation in NoMedialibHome

- - - - -
3992d257 by Pierre Lamot at 2023-09-20T08:52:06+00:00
qt: expose History.viewPath as list

- - - - -
f27aa54b by Pierre Lamot at 2023-09-20T08:52:06+00:00
qml: add History.match History.exactMatch to check for current path

- - - - -


17 changed files:

- modules/gui/qt/maininterface/qml/BannerSources.qml
- modules/gui/qt/maininterface/qml/MainDisplay.qml
- modules/gui/qt/maininterface/qml/MainInterface.qml
- modules/gui/qt/maininterface/qml/NoMedialibHome.qml
- modules/gui/qt/medialibrary/qml/VideoAll.qml
- modules/gui/qt/medialibrary/qml/VideoAllSubDisplay.qml
- modules/gui/qt/medialibrary/qml/VideoDisplayRecentVideos.qml
- modules/gui/qt/medialibrary/qml/VideoGridItem.qml
- modules/gui/qt/network/qml/NetworkAddressbar.qml
- modules/gui/qt/network/qml/ServicesSources.qml
- modules/gui/qt/player/qml/controlbarcontrols/ArtworkInfoWidget.qml
- modules/gui/qt/player/qml/controlbarcontrols/ControlButtonPopup.qml
- modules/gui/qt/player/qml/controlbarcontrols/PlayerSwitchButton.qml
- modules/gui/qt/util/navigation_history.cpp
- modules/gui/qt/util/navigation_history.hpp
- modules/gui/qt/util/qml/ModelSortSettingHandler.qml
- modules/gui/qt/widgets/qml/TableColumns.qml


Changes:

=====================================
modules/gui/qt/maininterface/qml/BannerSources.qml
=====================================
@@ -194,7 +194,7 @@ FocusScope {
                             delegate: Widgets.BannerTabButton {
                                 iconTxt: model.icon
                                 showText: globalToolbar.colapseTabButtons
-                                selected: model.index === root.selectedIndex
+                                selected: History.match(History.viewPath, ["mc", model.name])
                                 onClicked: root.itemClicked(model.index)
                                 height: globalMenuGroup.height
                             }


=====================================
modules/gui/qt/maininterface/qml/MainDisplay.qml
=====================================
@@ -185,17 +185,6 @@ FocusScope {
         }
     }
 
-
-    function showPlayer() {
-        History.push(["player"])
-    }
-
-    function play(backend, ids) {
-        showPlayer();
-
-        backend.addAndPlay(ids);
-    }
-
     Util.ModelSortSettingHandler {
         id: modelSortSettingHandler
     }
@@ -565,8 +554,9 @@ FocusScope {
             target: Player
             onHasVideoOutputChanged: {
                 if (Player.hasVideoOutput && MainCtx.hasEmbededVideo) {
-                    if (History.current.view !== "player")
+                    if (!History.match(History.viewPath, ["player"]))
                         g_mainDisplay.showPlayer()
+                        History.push(["player"])
                 } else {
                     _showMiniPlayer = false;
                 }


=====================================
modules/gui/qt/maininterface/qml/MainInterface.qml
=====================================
@@ -72,7 +72,7 @@ Item {
         }
         stackView.loadView(_pageModel, current.name, current.properties)
 
-        MainCtx.mediaLibraryVisible = (current.name !== "player")
+        MainCtx.mediaLibraryVisible = !History.match(History.viewPath, ["player"])
     }
 
     Item {
@@ -168,7 +168,7 @@ Item {
                         return
                     }
 
-                    if (History.current.name !== "player")
+                    if (History.match(History.viewPath, ["player"]))
                         return
 
                     if (MainCtx.hasEmbededVideo && MainCtx.canShowVideoPIP === false)
@@ -176,11 +176,9 @@ Item {
 
                     History.previous()
                 } else {
-                    if (History.current.name === "player")
+                    if (History.match(History.viewPath, ["player"]))
                         return
 
-                    stackView.currentItem._inhibitMiniPlayer = true
-
                     History.push(["player"])
                 }
             }
@@ -234,7 +232,7 @@ Item {
                     target: Player
                     onPlayingStateChanged: {
                         if (Player.playingState === Player.PLAYING_STATE_STOPPED
-                                && History.current.name === "player") {
+                                && History.match(History.viewPath, ["player"]) ) {
                             if (History.previousEmpty)
                                 _pushHome()
                             else


=====================================
modules/gui/qt/maininterface/qml/NoMedialibHome.qml
=====================================
@@ -23,6 +23,7 @@ import "qrc:///style/"
 import "qrc:///widgets/" as Widgets
 
 FocusScope {
+    id: root
 
     Accessible.role: Accessible.Client
     Accessible.name: I18n.qtr("Home view")
@@ -56,6 +57,7 @@ FocusScope {
             focus: true
             anchors.horizontalCenter: parent.horizontalCenter
             onClicked: DialogsProvider.simpleOpenDialog()
+            Navigation.parentItem: root
         }
     }
 }


=====================================
modules/gui/qt/medialibrary/qml/VideoAll.qml
=====================================
@@ -90,11 +90,12 @@ MainInterface.MainViewLoader {
 
     function onAction(indexes) {
         model.addAndPlay( indexes )
-        g_mainDisplay.showPlayer()
+        History.push(["player"])
     }
 
     function onDoubleClick(object) {
-        g_mainDisplay.play(MediaLib, object.id)
+        MediaLib.addAndPlay(object.id)
+        History.push(["player"])
     }
 
     function onLabelGrid(object) { return getLabel(object) }


=====================================
modules/gui/qt/medialibrary/qml/VideoAllSubDisplay.qml
=====================================
@@ -143,10 +143,13 @@ VideoAll {
 
             function onAction(indexes) {
                 model.addAndPlay( indexes )
-                g_mainDisplay.showPlayer()
+                History.push(["player"])
             }
 
-            function onDoubleClick(object) { g_mainDisplay.play(MediaLib, object.id) }
+            function onDoubleClick(object) {
+                MediaLib.addAndPlay(object.id)
+                History.push(["player"])
+            }
 
             function isInfoExpandPanelAvailable(modelIndexData) { return true }
         }
@@ -184,7 +187,7 @@ VideoAll {
 
                 if (object.isVideo) {
                     model.addAndPlay( indexes )
-                    g_mainDisplay.showPlayer()
+                    History.push(["player"])
 
                     return
                 }
@@ -194,8 +197,8 @@ VideoAll {
 
             function onDoubleClick(object) {
                 if (object.isVideo) {
-                    g_mainDisplay.play(MediaLib, object.id)
-
+                    MediaLib.addAndPlay(object.id)
+                    History.push(["player"])
                     return
                 }
 


=====================================
modules/gui/qt/medialibrary/qml/VideoDisplayRecentVideos.qml
=====================================
@@ -49,12 +49,12 @@ FocusScope {
 
     function _play(id) {
         MediaLib.addAndPlay( id, [":restore-playback-pos=2"] )
-        g_mainDisplay.showPlayer()
+        History.push(["player"])
     }
 
     function _playIndex(idx) {
         recentModel.addAndPlay( [idx], [":restore-playback-pos=2"] )
-        g_mainDisplay.showPlayer()
+        History.push(["player"])
     }
 
     // Childs


=====================================
modules/gui/qt/medialibrary/qml/VideoGridItem.qml
=====================================
@@ -37,7 +37,7 @@ Widgets.GridItem {
     function play() {
         if ( model.id !== undefined ) {
             MediaLib.addAndPlay( model.id )
-            g_mainDisplay.showPlayer()
+            History.push(["player"])
         }
     }
 


=====================================
modules/gui/qt/network/qml/NetworkAddressbar.qml
=====================================
@@ -27,7 +27,7 @@ import "qrc:///widgets/" as Widgets
 T.Control {
     id: control
 
-    property var path
+    property var path: []
 
     property var _contentModel
     property var _menuModel


=====================================
modules/gui/qt/network/qml/ServicesSources.qml
=====================================
@@ -105,8 +105,6 @@ MainInterface.MainGridView {
                           { source_name: itemData.name }], Qt.TabFocusReason)
     }
 
-    Navigation.parentItem: root
-
     Navigation.cancelAction: function() {
         History.previous(Qt.BacktabFocusReason)
     }


=====================================
modules/gui/qt/player/qml/controlbarcontrols/ArtworkInfoWidget.qml
=====================================
@@ -85,13 +85,13 @@ AbstractButton {
         if (KeyHelper.matchOk(event)) {
             event.accepted = true
 
-            g_mainDisplay.showPlayer()
+            History.push(["player"])
         }
     }
 
     // Events
 
-    onClicked: g_mainDisplay.showPlayer()
+    onClicked: History.push(["player"])
 
     background: Widgets.AnimatedBackground {
         active: visualFocus


=====================================
modules/gui/qt/player/qml/controlbarcontrols/ControlButtonPopup.qml
=====================================
@@ -33,7 +33,7 @@ Widgets.IconControlButton {
 
     // Private
 
-    readonly property bool _isCurrentViewPlayer: (History.current.name === "player")
+    readonly property bool _isCurrentViewPlayer: History.match(History.viewPath, ["player"])
 
     // Aliases
 


=====================================
modules/gui/qt/player/qml/controlbarcontrols/PlayerSwitchButton.qml
=====================================
@@ -26,10 +26,10 @@ Widgets.IconControlButton {
     iconText: VLCIcons.fullscreen
 
     onClicked: {
-        if (History.current.view === "player")
+        if (History.match(History.viewPath, ["player"]))
             History.previous()
         else
-            g_mainDisplay.showPlayer()
+            History.push(["player"])
     }
 
     text: I18n.qtr("Switch Player")


=====================================
modules/gui/qt/util/navigation_history.cpp
=====================================
@@ -137,13 +137,16 @@ static bool isNodeValid(QVariant& value)
     return false;
 }
 
-static QString getViewPath(QVariantMap map)
+static QStringList getViewPath(QVariantMap map)
 {
-    QString r;
+    QStringList r;
     if (map.contains("view"))
-        r = getViewPath(map.value("view").toMap());
+        return getViewPath(map.value("view").toMap());
     else if (map.contains("name"))
-        r = "/" + map.value("name").toString() + getViewPath(map.value("properties").toMap());
+    {
+        r = QStringList( map.value("name").toString() );
+        r.append(std::move(getViewPath(map.value("properties").toMap())));
+    }
     return r;
 }
 
@@ -219,7 +222,7 @@ void NavigationHistory::updateViewPath()
     emit viewPathChanged( m_viewPath );
 }
 
-QString NavigationHistory::viewPath() const
+QStringList NavigationHistory::viewPath() const
 {
     return m_viewPath;
 }
@@ -232,3 +235,27 @@ Qt::FocusReason NavigationHistory::takeFocusReason()
 
     return reason;
 }
+
+Q_INVOKABLE bool NavigationHistory::match(const QStringList& path,  const QStringList& pattern)
+{
+    if (pattern.length() > path.length())
+        return false;
+    for (qsizetype i = 0; i < pattern.length(); i++)
+    {
+        if (pattern[i] != path[i])
+            return false;
+    }
+    return true;
+}
+
+Q_INVOKABLE bool NavigationHistory::exactMatch(const QStringList& path,  const QStringList& pattern)
+{
+    if (pattern.length() != path.length())
+        return false;
+    for (qsizetype i = 0; i < pattern.length(); i++)
+    {
+        if (pattern[i] != path[i])
+            return false;
+    }
+    return true;
+}


=====================================
modules/gui/qt/util/navigation_history.hpp
=====================================
@@ -10,7 +10,7 @@ class NavigationHistory : public QObject
 public:
     Q_PROPERTY(QVariant current READ getCurrent NOTIFY currentChanged FINAL)
     Q_PROPERTY(bool previousEmpty READ isPreviousEmpty NOTIFY previousEmptyChanged FINAL)
-    Q_PROPERTY(QString viewPath READ viewPath NOTIFY viewPathChanged FINAL)
+    Q_PROPERTY(QStringList viewPath READ viewPath NOTIFY viewPathChanged FINAL)
 
     enum class PostAction{
         Stay,
@@ -23,15 +23,18 @@ public:
 
     QVariant getCurrent();
     bool isPreviousEmpty();
-    QString viewPath() const;
+    QStringList viewPath() const;
 
     // NOTE: The first item to call this takes ownership over the focus reason.
     Q_INVOKABLE Qt::FocusReason takeFocusReason();
 
+    Q_INVOKABLE bool match(const QStringList& path,  const QStringList& pattern);
+    Q_INVOKABLE bool exactMatch(const QStringList& path,  const QStringList& pattern);
+
 signals:
     void currentChanged(QVariant current);
     void previousEmptyChanged(bool empty);
-    void viewPathChanged(QString viewPath);
+    void viewPathChanged(const QStringList& viewPath);
 
 public slots:
     /**
@@ -102,7 +105,7 @@ private:
     void updateViewPath();
 
     QVariantList m_history;
-    QString m_viewPath;
+    QStringList m_viewPath;
 
     Qt::FocusReason m_reason;
 };


=====================================
modules/gui/qt/util/qml/ModelSortSettingHandler.qml
=====================================
@@ -51,7 +51,7 @@ QtObject {
 
     function set(model, key) {
         _model = model
-        _key = key
+        _key = key.join("/")
 
         if (!_model)
             return


=====================================
modules/gui/qt/widgets/qml/TableColumns.qml
=====================================
@@ -121,7 +121,10 @@ Item {
 
                 playCoverVisible: (titleDel.currentlyFocused || titleDel.containsMouse)
                 playIconSize: VLCStyle.play_cover_small
-                onPlayIconClicked: g_mainDisplay.play(MediaLib, titleDel.rowModel.id)
+                onPlayIconClicked: {
+                    MediaLib.addAndPlay(titleDel.rowModel.id)
+                    History.push(["player"])
+                }
                 radius: root.titleCover_radius
                 color: titleDel.colorContext.bg.secondary
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7c71cd835672b16a3394ff0b62f84332c67700b7...f27aa54bf22db48b89eba982e2452d202e84ac71

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