Create new ContentViewTab to control input logic
This commit is contained in:
@@ -15,7 +15,7 @@ Row {
|
||||
ContentView {
|
||||
id: view
|
||||
viewSelected: selectedView == 1
|
||||
selectedElement: selectedProvider
|
||||
currentIndex: selectedProvider
|
||||
providers: db.Providers
|
||||
}
|
||||
function mod(n, m) {
|
||||
@@ -25,7 +25,6 @@ Row {
|
||||
if (selectedView == 0) {
|
||||
if (event.key == Qt.Key_Right) {
|
||||
selectedView = 1;
|
||||
//view.viewSelected = true
|
||||
} else if (event.key == Qt.Key_Down) {
|
||||
selectedProvider = mod(selectedProvider + 1, db.Providers.length)
|
||||
} else if (event.key == Qt.Key_Up) {
|
||||
|
||||
@@ -11,80 +11,15 @@ StackLayout {
|
||||
id: tabView
|
||||
property var providers
|
||||
property bool viewSelected
|
||||
property int selectedElement
|
||||
state: viewSelected ? "selected" : "deselected"
|
||||
property int ySelect: 0
|
||||
width: parent.width * viewSelected ? 0.95 : 0.8
|
||||
height: parent.height
|
||||
|
||||
Item {
|
||||
Item { // fake object to create notifying array
|
||||
id: rowSelector
|
||||
Item {
|
||||
property int xIndex: 0
|
||||
}
|
||||
Item {
|
||||
property int xIndex: 0
|
||||
}
|
||||
}
|
||||
Repeater {
|
||||
model: providers
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "#22282A"
|
||||
Row {
|
||||
Item {
|
||||
height: 10
|
||||
width: 40
|
||||
}
|
||||
Column {
|
||||
height: tabView.height
|
||||
width: tabView.width - 40
|
||||
ShowDetails {
|
||||
z: 1.2
|
||||
height: parent.height * 0.25
|
||||
width: parent.width
|
||||
show: modelData.getShow(elementColumn.children[ySelect].repeaterModel[elementColumn.children[ySelect].xIndex])
|
||||
}
|
||||
ScrollView {
|
||||
z: 1.0
|
||||
height: parent.height * 0.75
|
||||
width: parent.width
|
||||
contentWidth: 2000
|
||||
contentHeight: 2000
|
||||
ScrollBar.vertical.position: ySelect * 0.22
|
||||
Behavior on ScrollBar.vertical.position {
|
||||
NumberAnimation {
|
||||
duration: 200
|
||||
easing.type: Easing.Linear
|
||||
}
|
||||
}
|
||||
Flickable{
|
||||
clip: true
|
||||
Column {
|
||||
id: elementColumn
|
||||
spacing: 20
|
||||
width: parent.width
|
||||
Element {
|
||||
title: "In Progress"
|
||||
provider: modelData
|
||||
repeaterModel: modelData.inProgress
|
||||
elemSelected: viewSelected && (0 == ySelect)
|
||||
xIndex: rowSelector.children[0].xIndex
|
||||
}
|
||||
Element {
|
||||
title: "Recently Added"
|
||||
provider: modelData
|
||||
repeaterModel: modelData.recentlyAdded
|
||||
elemSelected: viewSelected && (1 == ySelect)
|
||||
xIndex: rowSelector.children[1].xIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Repeater {
|
||||
model: providers
|
||||
ContentViewTab{
|
||||
provider: modelData
|
||||
}
|
||||
}
|
||||
states: [
|
||||
@@ -114,22 +49,10 @@ StackLayout {
|
||||
]
|
||||
|
||||
Keys.onPressed: (event)=> {
|
||||
if (event.key == Qt.Key_Left) {
|
||||
if (rowSelector.children[ySelect].xIndex == 0) {
|
||||
ySelect = 0;
|
||||
parent.selectedView = 0;
|
||||
for (var i = 0; i < rowSelector.children.length; i++) {
|
||||
rowSelector.children[i].xIndex = 0;
|
||||
}
|
||||
} else {
|
||||
rowSelector.children[ySelect].xIndex--;
|
||||
}
|
||||
} else if (event.key == Qt.Key_Right) {
|
||||
rowSelector.children[ySelect].xIndex++;
|
||||
} else if (event.key == Qt.Key_Down) {
|
||||
ySelect++;
|
||||
} else if (event.key == Qt.Key_Up) {
|
||||
ySelect--;
|
||||
tabView.children[currentIndex].Keys.pressed(event);
|
||||
if (tabView.children[currentIndex].viewExit) {
|
||||
tabView.children[currentIndex].viewExit = false;
|
||||
parent.selectedView = 0;
|
||||
}
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls 2.15
|
||||
|
||||
import Ikinuki.Client 1.0
|
||||
|
||||
import "./ContentViewTab"
|
||||
|
||||
Rectangle {
|
||||
property var provider
|
||||
property int ySelect: 0
|
||||
property int xSelect: 0
|
||||
property bool viewExit: false
|
||||
anchors.fill: parent
|
||||
color: "#22282A"
|
||||
Row {
|
||||
Item {
|
||||
height: 10
|
||||
width: 40
|
||||
}
|
||||
Column {
|
||||
height: tabView.height
|
||||
width: tabView.width - 40
|
||||
ShowDetails {
|
||||
z: 1.2
|
||||
height: parent.height * 0.25
|
||||
width: parent.width
|
||||
show: provider.getShow(elementColumn.children[ySelect].showId)
|
||||
}
|
||||
ScrollView {
|
||||
z: 1.0
|
||||
height: parent.height * 0.75
|
||||
width: parent.width
|
||||
contentWidth: 2000
|
||||
contentHeight: 2000
|
||||
ScrollBar.vertical.position: ySelect * 0.22
|
||||
Behavior on ScrollBar.vertical.position {
|
||||
NumberAnimation {
|
||||
duration: 200
|
||||
easing.type: Easing.Linear
|
||||
}
|
||||
}
|
||||
Flickable{
|
||||
clip: true
|
||||
Column {
|
||||
id: elementColumn
|
||||
spacing: 20
|
||||
width: parent.width
|
||||
Element {
|
||||
title: "In Progress"
|
||||
provider: modelData
|
||||
repeaterModel: modelData.inProgress
|
||||
elemSelected: viewSelected && (0 == ySelect)
|
||||
}
|
||||
Element {
|
||||
title: "Recently Added"
|
||||
provider: modelData
|
||||
repeaterModel: modelData.recentlyAdded
|
||||
elemSelected: viewSelected && (1 == ySelect)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: (event)=> {
|
||||
if (event.key == Qt.Key_Left) {
|
||||
if (elementColumn.children[ySelect].xIndex == 0) {
|
||||
ySelect = 0;
|
||||
viewExit = true;
|
||||
for (var i = 0; i < elementColumn.children.length; i++) {
|
||||
elementColumn.children[i].xIndex = 0;
|
||||
}
|
||||
} else {
|
||||
elementColumn.children[ySelect].xIndex--;
|
||||
}
|
||||
} else if (event.key == Qt.Key_Right) {
|
||||
elementColumn.children[ySelect].xIndex++;
|
||||
} else if (event.key == Qt.Key_Down) {
|
||||
ySelect++;
|
||||
} else if (event.key == Qt.Key_Up) {
|
||||
ySelect--;
|
||||
}
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
}
|
||||
+3
-2
@@ -7,7 +7,8 @@ Column {
|
||||
property var provider
|
||||
property var repeaterModel
|
||||
property bool elemSelected
|
||||
property int xIndex
|
||||
property int xIndex: 0
|
||||
property int showId: repeaterModel[xIndex]
|
||||
width: parent.width
|
||||
Item {
|
||||
width: 10
|
||||
@@ -58,4 +59,4 @@ Column {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user