2021-03-04 16:26:51 +00:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
|
2021-03-24 19:04:03 +00:00
|
|
|
import nl.netsoj.chris.Jellyfin 1.0 as J
|
2021-03-04 16:26:51 +00:00
|
|
|
|
2021-03-07 15:26:13 +00:00
|
|
|
import "../../components"
|
|
|
|
import "../../.."
|
2021-03-24 19:04:03 +00:00
|
|
|
import "../.."
|
2021-03-04 16:26:51 +00:00
|
|
|
|
|
|
|
Page {
|
2021-03-07 15:26:13 +00:00
|
|
|
property string selectedServerName
|
|
|
|
property StackView stackView: StackView.view
|
2021-03-04 16:26:51 +00:00
|
|
|
header: ToolBar {
|
|
|
|
Label {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
font.pixelSize: SailfinStyle.fontSizeLarge
|
|
|
|
text: qsTr("Select a server")
|
|
|
|
}
|
|
|
|
}
|
2021-03-07 15:26:13 +00:00
|
|
|
|
|
|
|
ListView {
|
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
top: parent.top
|
|
|
|
bottom: parent.bottom
|
|
|
|
}
|
|
|
|
width: Math.min(80 * SailfinStyle.unit, parent.width - 2 * SailfinStyle.largePadding)
|
|
|
|
model: discoveryModel
|
|
|
|
|
|
|
|
header: Column {
|
|
|
|
width: parent.width
|
|
|
|
Label {
|
2021-08-01 22:57:14 +00:00
|
|
|
text: "Enter the Jellyfin server URL"
|
2021-03-07 15:26:13 +00:00
|
|
|
width: parent.width
|
|
|
|
}
|
2021-08-01 22:57:14 +00:00
|
|
|
Row {
|
2021-03-07 15:26:13 +00:00
|
|
|
width: parent.width
|
2021-08-01 22:57:14 +00:00
|
|
|
TextField {
|
|
|
|
id: serverAddressField
|
|
|
|
width: parent.width - goButton.width
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
id: goButton
|
|
|
|
text: "Go"
|
|
|
|
onClicked: {
|
|
|
|
selectedServerName = serverAddressField.text
|
|
|
|
ApiClient.baseUrl = serverAddressField.text
|
|
|
|
ApiClient.setupConnection()
|
|
|
|
busyDialog.open()
|
|
|
|
}
|
|
|
|
}
|
2021-03-07 15:26:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
delegate: RadioDelegate {
|
|
|
|
text: name
|
|
|
|
width: parent.width
|
|
|
|
onClicked: {
|
|
|
|
selectedServerName = name
|
|
|
|
ApiClient.baseUrl = address
|
|
|
|
ApiClient.setupConnection()
|
|
|
|
busyDialog.open()
|
|
|
|
//StackView.view.push()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
footer: BusyIndicator {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
2021-03-04 16:26:51 +00:00
|
|
|
}
|
|
|
|
|
2021-03-24 19:04:03 +00:00
|
|
|
J.ServerDiscoveryModel {
|
2021-03-04 16:26:51 +00:00
|
|
|
id: discoveryModel
|
|
|
|
}
|
|
|
|
|
2021-03-07 15:26:13 +00:00
|
|
|
StackView.onActivated: {
|
|
|
|
console.log("Hello")
|
|
|
|
discoveryModel.refresh()
|
|
|
|
}
|
|
|
|
|
|
|
|
BusyDialog {
|
|
|
|
id: busyDialog
|
|
|
|
anchors.centerIn: Overlay.overlay
|
|
|
|
title: qsTr("Connecting to %1").arg(selectedServerName)
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: ApiClient
|
|
|
|
onConnectionSuccess: {
|
|
|
|
busyDialog.close()
|
|
|
|
stackView.push(Qt.resolvedUrl("LoginPage.qml"), {"loginMessage": loginMessage})
|
|
|
|
}
|
|
|
|
onConnectionFailed: {
|
|
|
|
busyDialog.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-04 16:26:51 +00:00
|
|
|
}
|