vlc | branch: master | Prince Gupta <guptaprince8...@gmail.com> | Tue Mar 2 17:08:43 2021 +0530| [929c1b2678ae01c186e3066f713d3dc4b6400f1f] | committer: Pierre Lamot
qml: lazily update availableRowWidth of KeyNaviagableTableView solves slow animation of Playlist collapsing and expanding Signed-off-by: Pierre Lamot <pie...@videolabs.io> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=929c1b2678ae01c186e3066f713d3dc4b6400f1f --- .../gui/qt/widgets/qml/KeyNavigableTableView.qml | 45 ++++++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml b/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml index 14c8864a1b..b732198e52 100644 --- a/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml +++ b/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml @@ -74,12 +74,12 @@ NavigableFocusScope { property var selectionDelegateModel property real rowHeight: VLCStyle.tableRow_height readonly property int _contextButtonHorizontalSpace: VLCStyle.icon_normal + VLCStyle.margin_xxsmall * 2 - readonly property real availableRowWidth: width - - ( !!section.property ? VLCStyle.table_section_width * 2 : 0 ) - - _contextButtonHorizontalSpace property alias spacing: view.spacing property int horizontalSpacing: VLCStyle.column_margin_width + property real availableRowWidth: 0 + property real _availabeRowWidthLastUpdateTime: Date.now() + property alias fadeColor: view.fadeColor property alias fadeRectBottomHovered: view.fadeRectBottomHovered property alias fadeRectTopHovered: view.fadeRectTopHovered @@ -96,6 +96,45 @@ NavigableFocusScope { view.positionViewAtIndex(index, mode) } + Timer { + id: availableRowWidthUpdater + + interval: 100 + triggeredOnStart: false + repeat: false + onTriggered: { + _update() + } + + function _update() { + root.availableRowWidth = root.width + - ( !!section.property ? VLCStyle.table_section_width * 2 : 0 ) + - _contextButtonHorizontalSpace + root._availabeRowWidthLastUpdateTime = Date.now() + } + + function enqueueUpdate() { + // updating availableRowWidth is expensive because of property bindings in sortModel + // and availableRowWidth is dependent on root.width which can update in a burst + // so try to maintain a minimum time gap between subsequent availableRowWidth updates + var sinceLastUpdate = Date.now() - root._availabeRowWidthLastUpdateTime + if ((root.availableRowWidth === 0) || (sinceLastUpdate > 128 && !availableRowWidthUpdater.running)) { + _update() + } else if (!availableRowWidthUpdater.running) { + availableRowWidthUpdater.interval = Math.max(128 - sinceLastUpdate, 32) + availableRowWidthUpdater.start() + } + } + } + + onWidthChanged: { + availableRowWidthUpdater.enqueueUpdate() + } + + onSectionChanged: { + availableRowWidthUpdater.enqueueUpdate() + } + KeyNavigableListView { id: view _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits