[vlc-commits] [Git][videolan/vlc][master] 5 commits: qml: allow null value in history property map
François Cartegnie (@fcartegnie)
gitlab at videolan.org
Fri Dec 8 19:03:29 UTC 2023
François Cartegnie pushed to branch master at VideoLAN / VLC
Commits:
8147f61f by Pierre Lamot at 2023-12-08T18:37:07+00:00
qml: allow null value in history property map
fix: #28427
- - - - -
89179610 by Pierre Lamot at 2023-12-08T18:37:07+00:00
qml: remove _oldViewProperties from MainDisplay
_oldViewProperties is never set
- - - - -
b8908881 by Pierre Lamot at 2023-12-08T18:37:07+00:00
qml: add isDefaulLoadedForPath method in PageLoader
the method returns true if the PageLoader is on the default page for
a given path, this allows to know whether we should push a page in History
given a path prefix
For instance if ["mc","video"] defaults to "all", when checking for ["mc", "video"]
* if ["mc","video", "all", "base"] is loaded, this returns true
* if ["mc","video", "playlist"] is loaded, this returns false
* if ["mc", "music", "xxx"] is loaded this returns false
- - - - -
441b77b5 by Pierre Lamot at 2023-12-08T18:37:07+00:00
qml: avoid re-pushing the same view in history when navigating from the banner
fix: #28408
- - - - -
7dee44bf by Pierre Lamot at 2023-12-08T18:37:07+00:00
qml: fix switching to medialib view from the player view from the menu
fix: #28409
- - - - -
7 changed files:
- modules/gui/qt/maininterface/qml/MainDisplay.qml
- modules/gui/qt/maininterface/qml/MainInterface.qml
- modules/gui/qt/medialibrary/qml/MusicDisplay.qml
- modules/gui/qt/medialibrary/qml/VideoDisplay.qml
- modules/gui/qt/network/qml/DiscoverDisplay.qml
- modules/gui/qt/util/navigation_history.cpp
- modules/gui/qt/widgets/qml/PageLoader.qml
Changes:
=====================================
modules/gui/qt/maininterface/qml/MainDisplay.qml
=====================================
@@ -56,7 +56,6 @@ FocusScope {
}
property bool _showMiniPlayer: false
- property var _oldViewProperties: ({}) // saves last state of the views
// functions
@@ -189,15 +188,15 @@ FocusScope {
plListView: playlist
onItemClicked: {
- if (selectedIndex === index)
+ const name = g_mainDisplay.tabModel.get(index).name
+
+ //don't add the ["mc"] prefix as we are only testing subviers from MainDisplay
+ if (stackView.isDefaulLoadedForPath([name])) {
return
+ }
- const name = g_mainDisplay.tabModel.get(index).name
selectedIndex = index
- if (_oldViewProperties[name] === undefined)
- History.push(["mc", name])
- else
- History.push(["mc", name], _oldViewProperties[name])
+ History.push(["mc", name])
}
Navigation.parentItem: mainColumn
=====================================
modules/gui/qt/maininterface/qml/MainInterface.qml
=====================================
@@ -168,6 +168,9 @@ Item {
onMediaLibraryVisibleChanged: {
if (MainCtx.mediaLibraryVisible) {
+ if (History.match(History.viewPath, ["mc"]))
+ return
+
// NOTE: Useful when we started the application on the 'player' view.
if (History.previousEmpty) {
if (MainCtx.hasEmbededVideo && MainCtx.canShowVideoPIP === false)
@@ -178,9 +181,6 @@ Item {
return
}
- if (History.match(History.viewPath, ["player"]))
- return
-
if (MainCtx.hasEmbededVideo && MainCtx.canShowVideoPIP === false)
MainPlaylistController.stop()
=====================================
modules/gui/qt/medialibrary/qml/MusicDisplay.qml
=====================================
@@ -57,7 +57,10 @@ Widgets.PageLoader {
]
function loadIndex(index) {
- History.push([...root.pagePrefix, root.pageModel[index].name])
+ const pageName = root.pageModel[index].name
+ if (root.isDefaulLoadedForPath([pageName]))
+ return
+ History.push([...root.pagePrefix, pageName])
}
property ListModel tabModel: ListModel {
=====================================
modules/gui/qt/medialibrary/qml/VideoDisplay.qml
=====================================
@@ -51,7 +51,12 @@ Widgets.PageLoader {
model: tabModel
- onClicked: (index) => History.push([...root.pagePrefix, root.pageModel[index].name])
+ onClicked: (index) => {
+ const pageName = root.pageModel[index].name
+ if (root.isDefaulLoadedForPath([pageName]))
+ return
+ History.push([...root.pagePrefix, pageName])
+ }
}
//---------------------------------------------------------------------------------------------
=====================================
modules/gui/qt/network/qml/DiscoverDisplay.qml
=====================================
@@ -47,10 +47,12 @@ Widgets.PageLoader {
Accessible.name: I18n.qtr("Discover view")
function loadIndex(index) {
- History.push([...root.pagePrefix, root.pageModel[index].name])
+ const pageName = root.pageModel[index].name
+ if (root.isDefaulLoadedForPath([pageName]))
+ return
+ History.push([...root.pagePrefix, pageName])
}
-
property ListModel tabModel: ListModel {
Component.onCompleted: {
pageModel.forEach(function(e) {
@@ -69,12 +71,7 @@ Widgets.PageLoader {
currentView: root.pageName
model: tabModel
- onClicked: {
- if (root.pageModel[index].name === root.pageName)
- return
-
- root.loadIndex(index)
- }
+ onClicked: (index) => root.loadIndex(index)
}
}
}
=====================================
modules/gui/qt/util/navigation_history.cpp
=====================================
@@ -82,6 +82,8 @@ static bool isNodeValid(const QVariant& value)
}
return true;
}
+ else if ( value.isNull() )
+ return true;
assert(false);
return false;
=====================================
modules/gui/qt/widgets/qml/PageLoader.qml
=====================================
@@ -65,11 +65,12 @@ StackViewExt {
currentItem.dismiss()
if (path.length === 0) {
- path = _getDefaultPage()
- if (path.length === 0) {
+ const defaultPage = _getDefaultPage()
+ if (defaultPage === undefined) {
console.assert("trying to load an empty view path")
return false
}
+ path = [defaultPage]
}
const head = path[0]
@@ -135,14 +136,47 @@ StackViewExt {
return true
}
+ /**
+ * @brief return true if the PageLoader is on the default page for
+ * the subpath @a path
+ * @arg {string[]} path - the (sub) path to check
+ * @return {boolean}
+ */
+ function isDefaulLoadedForPath(path) {
+ console.assert(Array.isArray(path))
+
+ let subPageName
+ if (path.length === 0) {
+ subPageName = _getDefaultPage()
+ } else {
+ //pops the first element of path, path now contains the tail of the list
+ subPageName = path.shift()
+ }
+
+ if (subPageName === undefined )
+ return false
+
+ if (subPageName !== root.pageName)
+ return false
+
+ if (!currentItem)
+ return false
+
+ if (typeof currentItem.isDefaulLoadedForPath === "function") {
+ return currentItem.isDefaulLoadedForPath(path)
+ }
+
+ return path.length === 0
+ }
+
function _getDefaultPage() {
for (let tab = 0; tab < pageModel.length; tab++ ) {
if (pageModel[tab].default) {
- return [pageModel[tab].name]
+ return pageModel[tab].name
}
}
console.assert("no default page set")
- return []
+ return undefined
}
function _reloadPage(path, properties, focusReason)
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a69e4c3298dbfa6b61e17fdfc99604ec0db0df8e...7dee44bfa637156f78bfa8c3ee55b0eafa309b23
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a69e4c3298dbfa6b61e17fdfc99604ec0db0df8e...7dee44bfa637156f78bfa8c3ee55b0eafa309b23
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