1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2025-09-05 10:12:46 +00:00

QuickConnect: init

This adds a page in the settings page that allows the user to enter a
quick connect code to allow another device to log in.
This commit is contained in:
Chris Josten 2024-01-02 19:51:27 +01:00
parent 13786f01c9
commit a66434afa8
10 changed files with 242 additions and 3 deletions

View file

@ -0,0 +1,86 @@
import QtQuick 2.6
import Sailfish.Silica 1.0
Dialog {
id: qqDialog
canAccept: qqCode.length > 0
acceptDestination: ConnectingPage {
id: loadingPage
onStatusChanged: {
if (status == PageStatus.Active) {
submit()
}
}
Connections {
target: apiClient
onQuickConnectAccepted: pageStack.pop(pageStack.previousPage(qqDialog))
onQuickConnectRejected: {
qqCode.errorHighlight = true
pageStack.pop(qqDialog)
}
}
function submit() {
console.log("Accepted QuickConnect with code", qqCode.text)
apiClient.submitQuickConnectCode(qqCode.text)
}
}
Column {
width: parent.width
DialogHeader {
//: Dialog title
title: "Quick Connect"
//: Accept button on dialog for submitting a Quick Connect code
defaultAcceptText: qsTr("Allow login")
}
Label {
anchors {
left: parent.left
right: parent.right
leftMargin: Theme.horizontalPageMargin
rightMargin: Theme.horizontalPageMargin
}
color: Theme.highlightColor
wrapMode: Text.WordWrap
//: Instructions on page that tells the user a bit about how Quick Connect works
text: qsTr("To log a device in with Quick Connect, select the Quick Connect button and enter the displayed code in the field below.")
}
TextField {
id: qqCode
//: Label for textfield for entering the Quick Connect codeyy
label: qsTr("Quick Connect code")
focus: true
//: Placeholder text for textfield for entering the Quick Connect codeyy
placeholderText: qsTr("Quick Connect code")
inputMethodHints: Qt.ImhDigitsOnly
EnterKey.iconSource: "image://theme/icon-m-enter-accept"
EnterKey.onClicked: accept()
onTextChanged: {
if (errorHighlight) {
errorHighlight = false
}
}
}
Label {
id: errorText
visible: qqCode.errorHighlight
anchors {
left: parent.left
right: parent.right
leftMargin: Theme.horizontalPageMargin
rightMargin: Theme.horizontalPageMargin
}
color: Theme.errorColor
//: Error message shown below the textfield when it is not connected
text: qsTr("The Quick Connect code was not accepted")
}
}
}

View file

@ -106,6 +106,11 @@ Page {
Item { width: 1; height: Theme.paddingLarge; }
ButtonLayout {
Button {
//: This is a name used by Jellyfin and seems to be untranslated in other languages
text: qsTr("Quick Connect")
onClicked: pageStack.push(Qt.resolvedUrl("QuickConnectDialog.qml"))
}
Button {
text: qsTr("Log out")
onClicked: remorse.execute(qsTr("Logging out"), apiClient.deleteSession)