[vlc-commits] [Git][videolan/vlc][master] 7 commits: qml: fix overriding initialIndex in video views
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Fri Jul 1 12:20:59 UTC 2022
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC
Commits:
8e9ee52c by Prince Gupta at 2022-07-01T12:01:27+00:00
qml: fix overriding initialIndex in video views
- - - - -
b91b7528 by Prince Gupta at 2022-07-01T12:01:27+00:00
qml: remove unrequired property
- - - - -
2339c03a by Prince Gupta at 2022-07-01T12:01:27+00:00
qml: don't handle active focus changes in table view
it interferes with views' resetFocus calls,
it may not be necessary, ExpandGridView doesn't have it
- - - - -
04f82a56 by Prince Gupta at 2022-07-01T12:01:27+00:00
qml: fix header focus handling in ExpandGridView
- - - - -
98632ec1 by Prince Gupta at 2022-07-01T12:01:27+00:00
qml: handle header height change during initialization and reset focus in video view
- - - - -
bb12df65 by Prince Gupta at 2022-07-01T12:01:27+00:00
qml: set current index on reset focus in video view
- - - - -
91b6dd6c by Prince Gupta at 2022-07-01T12:01:27+00:00
qml: use direct condition of visibility
binding through another variable cause unnecessary implicitHeight calculation of parent Column
- - - - -
5 changed files:
- modules/gui/qt/medialibrary/qml/VideoAll.qml
- modules/gui/qt/medialibrary/qml/VideoAllSubDisplay.qml
- modules/gui/qt/medialibrary/qml/VideoDisplayRecentVideos.qml
- modules/gui/qt/widgets/qml/ExpandGridView.qml
- modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
Changes:
=====================================
modules/gui/qt/medialibrary/qml/VideoAll.qml
=====================================
@@ -109,8 +109,13 @@ FocusScope {
modelSelect.select(model.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
- if (_currentView)
+ if (_currentView) {
_currentView.positionViewAtIndex(initialIndex, ItemView.Contain)
+
+ // Table View require this for focus handling
+ if (!MainCtx.gridView)
+ _currentView.currentIndex = initialIndex
+ }
}
function getLabel(model) {
@@ -193,10 +198,6 @@ FocusScope {
MainInterface.MainGridView {
id: gridView
- // Properties
-
- property Item currentItem: Item{}
-
// Settings
cellWidth : VLCStyle.gridItem_video_width
@@ -230,7 +231,7 @@ FocusScope {
if (activeFocus == false || model.count === 0 || modelSelect.hasSelection)
return;
- modelSelect.select(model.index(0,0), ItemSelectionModel.ClearAndSelect);
+ resetFocus() // restores initialIndex
}
onActionAtIndex: root.onAction(modelSelect.selectedIndexes)
=====================================
modules/gui/qt/medialibrary/qml/VideoAllSubDisplay.qml
=====================================
@@ -236,5 +236,13 @@ VideoAll {
_currentView.setCurrentItemFocus(Qt.TabFocusReason);
}
+ onImplicitHeightChanged: {
+ // implicitHeight depends on underlying ml model initialization
+ // and may update after view did resetFocus on initialization which
+ // will break resetFocus's scrolling (because header height changed)
+ // try to reapply reset focus here (ref #27071)
+ if (root.currentIndex <= 0 || root.currentIndex === root.initialIndex)
+ root.resetFocus()
+ }
}
}
=====================================
modules/gui/qt/medialibrary/qml/VideoDisplayRecentVideos.qml
=====================================
@@ -70,7 +70,7 @@ FocusScope {
Widgets.SubtitleLabel {
text: I18n.qtr("Continue Watching")
- visible: listView.visible
+ visible: listView.count > 0
}
Widgets.KeyNavigableListView {
=====================================
modules/gui/qt/widgets/qml/ExpandGridView.qml
=====================================
@@ -594,13 +594,6 @@ FocusScope {
visible: flickable.contentY < (root.headerHeight + root._effectiveCellHeight + root.topMargin)
focus: (status === Loader.Ready) ? item.focus : false
- onFocusChanged: {
- if (!focus)
- return;
-
- // when we gain the focus ensure the widget is fully visible
- animateFlickableContentY(0);
- }
}
Loader {
@@ -613,10 +606,26 @@ FocusScope {
}
Connections {
- target: headerItemLoader
+ target: headerItem
+
+ function _scrollToHeaderOnFocus() {
+ if (!headerItem.activeFocus)
+ return;
+
+ // when we gain the focus ensure the widget is fully visible
+ animateFlickableContentY(0)
+ }
+
onHeightChanged: {
flickable.layout(true)
}
+
+ onActiveFocusChanged: {
+ // when header loads because of setting headerItem.focus == true, it will suddenly attain the active focus
+ // but then a queued flickable.layout() may take away it's focus and assign it to current item,
+ // using Qt.callLater we save unnecessary scrolling
+ Qt.callLater(_scrollToHeaderOnFocus)
+ }
}
Connections {
=====================================
modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
=====================================
@@ -148,25 +148,6 @@ FocusScope {
on_CurrentAvailableRowWidthChanged: availableRowWidthUpdater.enqueueUpdate()
- /*
- *define the initial position/selection
- * This is done on activeFocus rather than Component.onCompleted because delegateModel.
- * selectedGroup update itself after this event
- */
- onActiveFocusChanged: {
- if (activeFocus == false || view.count == 0)
- return;
-
- if (view.currentIndex == -1)
- view.currentIndex = 0;
-
- if (selectionDelegateModel.hasSelection === false)
- selectionDelegateModel.select(model.index(view.currentIndex, 0),
- ItemSelectionModel.ClearAndSelect);
-
- view.forceActiveFocus();
- }
-
// Functions
function setCurrentItemFocus(reason) {
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/47a6e95a74af2c36d120db37ae53c7e3684a77c6...91b6dd6cf141542f0f35db2e4f3f4b24e21c8617
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/47a6e95a74af2c36d120db37ae53c7e3684a77c6...91b6dd6cf141542f0f35db2e4f3f4b24e21c8617
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