[vlc-commits] [Git][videolan/vlc][master] 3 commits: qml/PageLoader: Add the '_ready' property

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Thu Feb 23 16:05:06 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
54e3df29 by Benjamin Arnaud at 2023-02-23T15:50:54+00:00
qml/PageLoader: Add the '_ready' property

It allows us to wait for the item to be fully loaded before loading the view. Which
effectively avoids size glitches when switching between views.

- - - - -
80efac32 by Benjamin Arnaud at 2023-02-23T15:50:54+00:00
qml/KeyNavigableTableView: Add the '_ready' property

It allows us to wait for the item to be fully loaded before updating 'availableRowWidth'.
With the previous implementation we had size glitches while loading the Table.

- - - - -
a47798f2 by Benjamin Arnaud at 2023-02-23T15:50:54+00:00
qml/BrowseHomeDisplay: Update Column sizes

With the previous implementation we had size glitches while loading the items.

- - - - -


3 changed files:

- modules/gui/qt/network/qml/BrowseHomeDisplay.qml
- modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
- modules/gui/qt/widgets/qml/PageLoader.qml


Changes:

=====================================
modules/gui/qt/network/qml/BrowseHomeDisplay.qml
=====================================
@@ -119,7 +119,7 @@ FocusScope {
         focus: true
 
         Column {
-            width: parent.width
+            width: foldersSection.width
             height: implicitHeight
 
             spacing: VLCStyle.margin_small
@@ -127,7 +127,7 @@ FocusScope {
             BrowseDeviceView {
                 id: foldersSection
 
-                width: flickable.width
+                width: root.width
                 height: contentHeight
 
                 // NOTE: We are not capping the list when filtering.
@@ -164,7 +164,7 @@ FocusScope {
             BrowseDeviceView {
                 id: deviceSection
 
-                width: flickable.width
+                width: root.width
                 height: contentHeight
 
                 maximumRows: foldersSection.maximumRows
@@ -211,7 +211,7 @@ FocusScope {
             BrowseDeviceView {
                 id: lanSection
 
-                width: flickable.width
+                width: root.width
                 height: contentHeight
 
                 maximumRows: foldersSection.maximumRows


=====================================
modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
=====================================
@@ -74,13 +74,18 @@ FocusScope {
     property real rowHeight: VLCStyle.tableRow_height
 
     property real availableRowWidth: 0
-    property real _availabeRowWidthLastUpdateTime: Date.now()
-
-    readonly property real _currentAvailableRowWidth: width - leftMargin - rightMargin
 
     property Item dragItem
     property bool acceptDrop: false
 
+    // Private
+
+    property bool _ready: false
+
+    property real _availabeRowWidthLastUpdateTime: Date.now()
+
+    readonly property real _currentAvailableRowWidth: width - leftMargin - rightMargin
+
     // Aliases
 
     property alias topMargin: view.topMargin
@@ -143,11 +148,15 @@ FocusScope {
 
     // Events
 
-    Component.onDestruction: {
-        _qtAvoidSectionUpdate()
+    Component.onCompleted: {
+        _ready = true
+
+        availableRowWidthUpdater.enqueueUpdate()
     }
 
-    on_CurrentAvailableRowWidthChanged: availableRowWidthUpdater.enqueueUpdate()
+    Component.onDestruction: _qtAvoidSectionUpdate()
+
+    on_CurrentAvailableRowWidthChanged: if (_ready) availableRowWidthUpdater.enqueueUpdate()
 
     // Functions
 


=====================================
modules/gui/qt/widgets/qml/PageLoader.qml
=====================================
@@ -21,6 +21,8 @@ import org.videolan.vlc 0.1
 FocusScope {
     id: root
 
+    // Properties
+
     property var view: null
 
     property var pageModel: []
@@ -31,20 +33,39 @@ FocusScope {
     // one may use `loadPage(string pageName)` to load the page from 'pageModel'
     property var loadDefaultView: null
 
+    // Private
+
+    property bool _ready: false
+
+    // Aliases
+
     property alias leftPadding: stackView.leftPadding
     property alias rightPadding: stackView.rightPadding
 
     property alias stackView: stackView
 
+    // Signals
+
     signal pageChanged(string page)
     signal currentItemChanged(var currentItem)
 
-    Component.onCompleted: loadView()
-    onViewChanged: {
+    // Events
+
+    Component.onCompleted: {
+        _ready = true
+
         loadView()
     }
 
+    onViewChanged: loadView()
+
+    // Functions
+
     function loadView() {
+        // NOTE: We wait for the item to be fully loaded to avoid size glitches.
+        if (_ready === false)
+            return
+
         if (view === null) {
             if (!loadDefaultView)
                 console.error("both 'view' and 'loadDefaultView' is null, history -", JSON.stringify(History.current))
@@ -79,6 +100,8 @@ FocusScope {
         stackView.setCurrentItemFocus(reason);
     }
 
+    // Children
+
     StackViewExt {
         id: stackView
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/86e598311e2b941ed87073526e8e8c9537c29470...a47798f25eeba8e18283d48fe7f6b237400b1352

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