Add grid scrolling to ProviderBrowse view

This commit is contained in:
2022-09-13 16:48:27 -06:00
parent e7004594fe
commit 1e7d9db9cc
2 changed files with 35 additions and 14 deletions
@@ -27,9 +27,9 @@ Rectangle {
width: parent.width
}
CoverGrid {
id: coverGrid
height: parent.height - 80
width: parent.width
id: coverGrid
provider: root.provider
shows: root.provider.showsAlphabetic
selected: currentView == 0
@@ -62,9 +62,20 @@ Rectangle {
coverGrid.xIndex++;
}
} else if (event.key == Qt.Key_Down) {
var max = Math.floor(coverGrid.shows.length / coverGrid.numColumns);
if (coverGrid.yIndex < max) {
coverGrid.yIndex++;
if (coverGrid.scrollIndex < coverGrid.yIndex - 1.5) {
coverGrid.scrollIndex++;
}
}
} else if (event.key == Qt.Key_Up) {
if (coverGrid.yIndex > 0) {
coverGrid.yIndex--;
if (coverGrid.scrollIndex > coverGrid.yIndex + 0.5) {
coverGrid.scrollIndex--;
}
}
}
} else if (currentView == 1) { // alphabet
if (event.key == Qt.Key_Left) {
@@ -5,15 +5,24 @@ import QtQuick.Controls 2.15
import Ikinuki.Client 1.0
Grid {
ScrollView {
id: root
clip: true
property bool selected
property int yIndex: 0
property int xIndex: 0
property int scrollIndex: 0
property int numColumns: 6
property var provider
property var shows: []
property var shows
contentHeight: Math.floor(shows.length / numColumns) * 400
ScrollBar.vertical.position: scrollIndex / Math.floor(shows.length / numColumns)
Behavior on ScrollBar.vertical.position {
NumberAnimation {
duration: 200
easing.type: Easing.Linear
}
}
Grid {
columns: numColumns
topPadding: 20
Repeater {
@@ -24,4 +33,5 @@ Grid {
elemSelected: selected && (index == (yIndex * numColumns + xIndex))
}
}
}
}