add focus navigation to qml

This commit is contained in:
Cyril Anisimov 2024-09-19 20:27:48 +02:00
parent cecee3769e
commit 01e31b4b4d
23 changed files with 103 additions and 196 deletions

View file

@ -25,8 +25,6 @@ PageType {
}
}
// defaultActiveFocusItem: focusItem
FlickableType {
id: fl
anchors.top: parent.top
@ -136,6 +134,8 @@ PageType {
}
ParagraphTextType {
objectName: "insertKeyLabel"
Layout.fillWidth: true
Layout.topMargin: 32
Layout.rightMargin: 16
@ -155,6 +155,8 @@ PageType {
headerText: qsTr("Insert key")
buttonText: qsTr("Insert")
parentFlickable: fl
clickedFunc: function() {
textField.text = ""
textField.paste()
@ -169,14 +171,7 @@ PageType {
Layout.rightMargin: 16
Layout.leftMargin: 16
onFocusChanged: {
console.debug("MOVE THIS LOGIC TO CPP!")
if (activeFocus) {
if (fl) {
fl.ensureVisible(this)
}
}
}
parentFlickable: fl
visible: textKey.textFieldText !== ""
@ -214,14 +209,7 @@ PageType {
rightImageSource: "qrc:/images/controls/chevron-right.svg"
leftImageSource: "qrc:/images/controls/amnezia.svg"
focusItem.onFocusChanged: {
console.debug("MOVE THIS LOGIC TO CPP!")
if (focusItem.activeFocus) {
if (fl) {
fl.ensureVisible(apiInstalling)
}
}
}
parentFlickable: fl
onClicked: function() {
PageController.showBusyIndicator(true)
@ -247,14 +235,7 @@ PageType {
rightImageSource: "qrc:/images/controls/chevron-right.svg"
leftImageSource: "qrc:/images/controls/server.svg"
focusItem.onFocusChanged: {
console.debug("MOVE THIS LOGIC TO CPP!")
if (focusItem.activeFocus) {
if (fl) {
fl.ensureVisible(manualInstalling)
}
}
}
parentFlickable: fl
onClicked: {
PageController.goToPage(PageEnum.PageSetupWizardCredentials)
@ -276,14 +257,7 @@ PageType {
rightImageSource: "qrc:/images/controls/chevron-right.svg"
leftImageSource: "qrc:/images/controls/archive-restore.svg"
focusItem.onFocusChanged: {
console.debug("MOVE THIS LOGIC TO CPP!")
if (focusItem.activeFocus) {
if (fl) {
fl.ensureVisible(backupRestore)
}
}
}
parentFlickable: fl
onClicked: {
var filePath = SystemController.getFileName(qsTr("Open backup file"),
@ -309,12 +283,7 @@ PageType {
rightImageSource: "qrc:/images/controls/chevron-right.svg"
leftImageSource: "qrc:/images/controls/folder-search-2.svg"
focusItem.onFocusChanged: {
console.debug("MOVE THIS LOGIC TO CPP!")
if (fl) {
fl.ensureVisible(openFile)
}
}
parentFlickable: fl
onClicked: {
var nameFilter = !ServersModel.getServersCount() ? "Config or backup files (*.vpn *.ovpn *.conf *.json *.backup)" :
@ -343,14 +312,7 @@ PageType {
rightImageSource: "qrc:/images/controls/chevron-right.svg"
leftImageSource: "qrc:/images/controls/scan-line.svg"
focusItem.onFocusChanged: {
console.debug("MOVE THIS LOGIC TO CPP!")
if (focusItem.activeFocus) {
if (fl) {
fl.ensureVisible(scanQr)
}
}
}
parentFlickable: fl
onClicked: {
ImportController.startDecodingQr()
@ -375,14 +337,7 @@ PageType {
rightImageSource: "qrc:/images/controls/chevron-right.svg"
leftImageSource: "qrc:/images/controls/help-circle.svg"
focusItem.onFocusChanged: {
console.debug("MOVE THIS LOGIC TO CPP!")
if (focusItem.activeFocus) {
if (fl) {
fl.ensureVisible(siteLink)
}
}
}
parentFlickable: fl
onClicked: {
Qt.openUrlExternally(LanguageModel.getCurrentSiteUrl())