ContentView tabs now switch based on sidebar
This required a change to the Provider URL format to simplify testing of tabs with different content.
This commit is contained in:
@@ -49,9 +49,9 @@ def getUrl(base: str, path: str) -> dict:
|
||||
|
||||
|
||||
class Provider(QObject):
|
||||
def __init__(self, ip: str, port: int, parent=None):
|
||||
def __init__(self, url: str, parent=None):
|
||||
super().__init__(parent)
|
||||
self.url: str = f"http://{ip}:{port}"
|
||||
self.url: str = url
|
||||
|
||||
describe: dict = getUrl(self.url, "describe")
|
||||
self._name: str = describe["name"]
|
||||
@@ -85,9 +85,7 @@ class Provider(QObject):
|
||||
|
||||
class DataSource:
|
||||
def __init__(self, providers=[]):
|
||||
self.providers: list[Provider] = [
|
||||
Provider(ip, port) for (ip, port) in providers
|
||||
]
|
||||
self.providers: list[Provider] = [Provider(url) for url in providers]
|
||||
|
||||
|
||||
def DatabaseType(data_source) -> Type:
|
||||
@@ -109,7 +107,11 @@ def main():
|
||||
|
||||
# data_source = DataSource(["Anime", "TV", "Movies", "Settings"])
|
||||
data_source = DataSource(
|
||||
[("127.0.0.1", "8080"), ("127.0.0.1", "8080"), ("127.0.0.1", "8080")]
|
||||
[
|
||||
"http://127.0.0.1:8080/a/",
|
||||
"http://127.0.0.1:8080/b/",
|
||||
"http://127.0.0.1:8080/c/",
|
||||
]
|
||||
)
|
||||
|
||||
qmlRegisterType(DatabaseType(data_source), "Ikinuki.Client", 1, 0, "Database")
|
||||
|
||||
@@ -7,6 +7,9 @@ TabView {
|
||||
property var providers
|
||||
width: parent.width * 0.7
|
||||
height: parent.height
|
||||
|
||||
property var maxElements: providers.length
|
||||
|
||||
tabsVisible: false
|
||||
Repeater {
|
||||
model: providers
|
||||
|
||||
@@ -38,9 +38,16 @@ ApplicationWindow {
|
||||
selectedView = 1;
|
||||
}
|
||||
sidebar.Keys.pressed(event);
|
||||
|
||||
if (event.key == Qt.Key_Down) {
|
||||
view.currentIndex = mod(view.currentIndex + 1, view.maxElements)
|
||||
} else if (event.key == Qt.Key_Up) {
|
||||
view.currentIndex = mod(view.currentIndex - 1, view.maxElements)
|
||||
}
|
||||
console.log(view.currentIndex)
|
||||
event.accepted = true;
|
||||
} else {
|
||||
|
||||
view.Keys.pressed(event);
|
||||
}
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user