Merge pull request #789 from amnezia-vpn/bugfix/page-application-settings-warnings

fixed qml warnings
This commit is contained in:
pokamest
2024-05-02 17:11:23 -07:00
committed by GitHub
2 changed files with 27 additions and 46 deletions
@@ -15,43 +15,9 @@ PageType {
defaultActiveFocusItem: focusItem defaultActiveFocusItem: focusItem
function getNextComponentInFocusChain(componentId) {
const componentsList = [focusItem,
backButton,
switcher,
switcherAutoStart,
switcherAutoConnect,
switcherStartMinimized,
labelWithButtonLanguage,
labelWithButtonLogging,
labelWithButtonReset,
]
const idx = componentsList.indexOf(componentId)
if (idx === -1) {
return null
}
let nextIndex = idx + 1
if (nextIndex >= componentsList.length) {
nextIndex = 0
}
if (componentsList[nextIndex].visible) {
if ((nextIndex) >= 6) {
return componentsList[nextIndex].rightButton
} else {
return componentsList[nextIndex]
}
} else {
return getNextComponentInFocusChain(componentsList[nextIndex])
}
}
Item { Item {
id: focusItem id: focusItem
KeyNavigation.tab: root.getNextComponentInFocusChain(focusItem) KeyNavigation.tab: backButton
onFocusChanged: { onFocusChanged: {
if (focusItem.activeFocus) { if (focusItem.activeFocus) {
@@ -68,7 +34,7 @@ PageType {
anchors.right: parent.right anchors.right: parent.right
anchors.topMargin: 20 anchors.topMargin: 20
KeyNavigation.tab: root.getNextComponentInFocusChain(backButton) KeyNavigation.tab: GC.isMobile() ? switcher : switcherAutoStart
} }
FlickableType { FlickableType {
@@ -108,7 +74,7 @@ PageType {
} }
} }
KeyNavigation.tab: root.getNextComponentInFocusChain(switcher) KeyNavigation.tab: labelWithButtonLanguage.rightButton
parentFlickable: fl parentFlickable: fl
} }
@@ -126,7 +92,7 @@ PageType {
text: qsTr("Auto start") text: qsTr("Auto start")
descriptionText: qsTr("Launch the application every time the device is starts") descriptionText: qsTr("Launch the application every time the device is starts")
KeyNavigation.tab: root.getNextComponentInFocusChain(switcherAutoStart) KeyNavigation.tab: switcherAutoConnect
parentFlickable: fl parentFlickable: fl
checked: SettingsController.isAutoStartEnabled() checked: SettingsController.isAutoStartEnabled()
@@ -151,7 +117,7 @@ PageType {
text: qsTr("Auto connect") text: qsTr("Auto connect")
descriptionText: qsTr("Connect to VPN on app start") descriptionText: qsTr("Connect to VPN on app start")
KeyNavigation.tab: root.getNextComponentInFocusChain(switcherAutoConnect) KeyNavigation.tab: switcherStartMinimized
parentFlickable: fl parentFlickable: fl
checked: SettingsController.isAutoConnectEnabled() checked: SettingsController.isAutoConnectEnabled()
@@ -176,7 +142,7 @@ PageType {
text: qsTr("Start minimized") text: qsTr("Start minimized")
descriptionText: qsTr("Launch application minimized") descriptionText: qsTr("Launch application minimized")
KeyNavigation.tab: root.getNextComponentInFocusChain(switcherStartMinimized) KeyNavigation.tab: labelWithButtonLanguage.rightButton
parentFlickable: fl parentFlickable: fl
checked: SettingsController.isStartMinimizedEnabled() checked: SettingsController.isStartMinimizedEnabled()
@@ -199,7 +165,7 @@ PageType {
descriptionText: LanguageModel.currentLanguageName descriptionText: LanguageModel.currentLanguageName
rightImageSource: "qrc:/images/controls/chevron-right.svg" rightImageSource: "qrc:/images/controls/chevron-right.svg"
KeyNavigation.tab: root.getNextComponentInFocusChain(labelWithButtonLanguage) KeyNavigation.tab: labelWithButtonLogging.rightButton
parentFlickable: fl parentFlickable: fl
clickedFunction: function() { clickedFunction: function() {
@@ -218,7 +184,7 @@ PageType {
descriptionText: SettingsController.isLoggingEnabled ? qsTr("Enabled") : qsTr("Disabled") descriptionText: SettingsController.isLoggingEnabled ? qsTr("Enabled") : qsTr("Disabled")
rightImageSource: "qrc:/images/controls/chevron-right.svg" rightImageSource: "qrc:/images/controls/chevron-right.svg"
KeyNavigation.tab: root.getNextComponentInFocusChain(labelWithButtonLogging) KeyNavigation.tab: labelWithButtonReset.rightButton
parentFlickable: fl parentFlickable: fl
clickedFunction: function() { clickedFunction: function() {
@@ -101,9 +101,15 @@ PageType {
PageController.goToPage(PageEnum.PageSettingsSplitTunneling) PageController.goToPage(PageEnum.PageSettingsSplitTunneling)
} }
Keys.onTabPressed: splitTunnelingButton2.visible ? Keys.onTabPressed: {
splitTunnelingButton2.forceActiveFocus() : if (splitTunnelingButton2.visible) {
lastItemTabClicked() return splitTunnelingButton2.rightButton.forceActiveFocus()
} else if (killSwitchSwitcher.visible) {
return killSwitchSwitcher.forceActiveFocus()
} else {
lastItemTabClicked()
}
}
} }
DividerType { DividerType {
@@ -124,7 +130,13 @@ PageType {
PageController.goToPage(PageEnum.PageSettingsAppSplitTunneling) PageController.goToPage(PageEnum.PageSettingsAppSplitTunneling)
} }
Keys.onTabPressed: lastItemTabClicked() Keys.onTabPressed: {
if (killSwitchSwitcher.visible) {
return killSwitchSwitcher.forceActiveFocus()
} else {
lastItemTabClicked()
}
}
} }
DividerType { DividerType {
@@ -132,6 +144,7 @@ PageType {
} }
SwitcherType { SwitcherType {
id: killSwitchSwitcher
visible: !GC.isMobile() visible: !GC.isMobile()
Layout.fillWidth: true Layout.fillWidth: true
@@ -152,6 +165,8 @@ PageType {
PageController.showNotificationMessage(qsTr("Cannot change killSwitch settings during active connection")) PageController.showNotificationMessage(qsTr("Cannot change killSwitch settings during active connection"))
} }
} }
Keys.onTabPressed: lastItemTabClicked()
} }
DividerType { DividerType {