Compare commits

...

2 Commits

Author SHA1 Message Date
vladimir.kuznetsov
4ced0c27d6 Merge branch 'dev' of github.com:amnezia-vpn/amnezia-client into button-focus-fix 2024-03-11 14:13:38 +05:00
Garegin866
8d07a910bc - Remove additional focus frames for buttons inside text fields.
- For mobile platforms, disabled auto-focus on the first element when navigating on the page.
- Added auto-focus for the rest of the Drawer components
2024-03-10 00:20:32 +04:00
26 changed files with 240 additions and 14 deletions

View File

@@ -26,6 +26,14 @@ DrawerType2 {
root.expandedHeight = content.implicitHeight + 32
}
Connections {
target: root
enabled: !GC.isMobile()
function onOpened() {
config.rightButton.forceActiveFocus()
}
}
Header2Type {
Layout.fillWidth: true
Layout.topMargin: 24
@@ -37,7 +45,7 @@ DrawerType2 {
}
LabelWithButtonType {
id: ip
id: config
Layout.fillWidth: true
Layout.topMargin: 16
@@ -48,11 +56,14 @@ DrawerType2 {
PageController.goToPage(PageEnum.PageSetupWizardCredentials)
root.close()
}
KeyNavigation.tab: configFromFile.rightButton
}
DividerType {}
LabelWithButtonType {
id: configFromFile
Layout.fillWidth: true
text: qsTr("Open config file, key or QR code")
@@ -62,6 +73,8 @@ DrawerType2 {
PageController.goToPage(PageEnum.PageSetupWizardConfigSource)
root.close()
}
KeyNavigation.tab: config.rightButton
}
DividerType {}

View File

@@ -22,6 +22,18 @@ DrawerType2 {
anchors.right: parent.right
spacing: 0
Connections {
target: root
enabled: !GC.isMobile()
function onOpened() {
if (splitTunneling.visible) {
splitTunneling.rightButton.forceActiveFocus()
} else {
splitTunnelingSiteBased.rightButton.forceActiveFocus()
}
}
}
Header2Type {
Layout.fillWidth: true
Layout.topMargin: 24
@@ -34,6 +46,7 @@ DrawerType2 {
}
LabelWithButtonType {
id: splitTunneling
Layout.fillWidth: true
Layout.topMargin: 16
@@ -47,6 +60,8 @@ DrawerType2 {
// PageController.goToPage(PageEnum.PageSettingsSplitTunneling)
// root.close()
}
KeyNavigation.tab: splitTunnelingSiteBased.rightButton
}
DividerType {
@@ -54,6 +69,7 @@ DrawerType2 {
}
LabelWithButtonType {
id: splitTunnelingSiteBased
Layout.fillWidth: true
Layout.topMargin: 16
@@ -67,12 +83,14 @@ DrawerType2 {
PageController.goToPage(PageEnum.PageSettingsSplitTunneling)
root.close()
}
KeyNavigation.tab: appBasedSplitTunneling.visible ? appBasedSplitTunneling.rightButton : null
}
DividerType {
}
LabelWithButtonType {
id: appBasedSplitTunneling
Layout.fillWidth: true
visible: false
@@ -83,6 +101,8 @@ DrawerType2 {
// PageController.goToPage(PageEnum.PageSetupWizardConfigSource)
root.close()
}
KeyNavigation.tab: splitTunneling.rightButton
}
DividerType {

View File

@@ -4,6 +4,7 @@ import QtQuick.Layouts
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
DrawerType2 {
id: root
@@ -29,6 +30,14 @@ DrawerType2 {
root.expandedHeight = content.implicitHeight + 32
}
Connections {
target: root
enabled: !GC.isMobile()
function onOpened() {
yesButton.forceActiveFocus()
}
}
Header2TextType {
Layout.fillWidth: true
Layout.topMargin: 16
@@ -48,6 +57,7 @@ DrawerType2 {
}
BasicButtonType {
id: yesButton
Layout.fillWidth: true
Layout.topMargin: 16
Layout.rightMargin: 16
@@ -60,9 +70,11 @@ DrawerType2 {
yesButtonFunction()
}
}
KeyNavigation.tab: noButton
}
BasicButtonType {
id: noButton
Layout.fillWidth: true
Layout.rightMargin: 16
Layout.leftMargin: 16
@@ -81,6 +93,7 @@ DrawerType2 {
noButtonFunction()
}
}
KeyNavigation.tab: yesButton
}
}
}

View File

@@ -40,9 +40,9 @@ DrawerType2 {
Connections {
target: root
enabled: !GC.isMobile()
function onOpened() {
header.forceActiveFocus()
shareButton.forceActiveFocus()
}
}
@@ -56,8 +56,6 @@ DrawerType2 {
anchors.rightMargin: 16
headerText: root.headerText
KeyNavigation.tab: shareButton
}
FlickableType {
@@ -85,8 +83,6 @@ DrawerType2 {
text: qsTr("Share")
imageSource: "qrc:/images/controls/share-2.svg"
KeyNavigation.tab: copyConfigTextButton
clickedFunc: function() {
var fileName = ""
if (GC.isMobile()) {
@@ -104,6 +100,8 @@ DrawerType2 {
PageController.showBusyIndicator(false)
}
}
KeyNavigation.tab: copyConfigTextButton
}
BasicButtonType {
@@ -163,7 +161,7 @@ DrawerType2 {
configContentDrawer.open()
}
KeyNavigation.tab: header
KeyNavigation.tab: shareButton
}
DrawerType2 {

View File

@@ -12,6 +12,9 @@ Button {
property string pressedColor: Qt.rgba(1, 1, 1, 0.12)
property string disableColor: "#2C2D30"
property string borderFocusedColor: "#D7D8DB"
property int borderFocusedWidth: 1
property string imageColor: "#878B91"
property string disableImageColor: "#2C2D30"
@@ -31,6 +34,9 @@ Button {
id: background
anchors.fill: parent
border.color: root.activeFocus ? root.borderFocusedColor : "transparent"
border.width: root.activeFocus ? root.borderFocusedWidth : "transparent"
color: {
if (root.enabled) {
if (root.pressed) {

View File

@@ -27,6 +27,8 @@ Item {
property string rightImageColor: "#d7d8db"
property alias rightButton: rightImage
property bool descriptionOnTop: false
implicitWidth: content.implicitWidth + content.anchors.topMargin + content.anchors.bottomMargin
@@ -207,4 +209,16 @@ Item {
}
}
}
Keys.onEnterPressed: {
if (clickedFunction && typeof clickedFunction === "function") {
clickedFunction()
}
}
Keys.onReturnPressed: {
if (clickedFunction && typeof clickedFunction === "function") {
clickedFunction()
}
}
}

View File

@@ -2,6 +2,8 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import "../Config"
Item {
id: root
@@ -9,6 +11,12 @@ Item {
property var defaultActiveFocusItem: null
onVisibleChanged: {
if (visible && !GC.isMobile()) {
timer.start()
}
}
// MouseArea {
// id: globalMouseArea
// z: 99
@@ -32,6 +40,6 @@ Item {
}
}
repeat: false // Stop the timer after one trigger
running: true // Start the timer
running: !GC.isMobile() // Start the timer
}
}

View File

@@ -137,6 +137,7 @@ Item {
// textColor: "#D7D8DB"
// borderWidth: 0
focusPolicy: Qt.NoFocus
text: root.buttonText
imageSource: root.buttonImageSource
@@ -191,10 +192,12 @@ Item {
}
Keys.onEnterPressed: {
KeyNavigation.tab.forceActiveFocus();
if (KeyNavigation.tab)
KeyNavigation.tab.forceActiveFocus();
}
Keys.onReturnPressed: {
KeyNavigation.tab.forceActiveFocus();
if (KeyNavigation.tab)
KeyNavigation.tab.forceActiveFocus();
}
}

View File

@@ -28,6 +28,8 @@ PageType {
}
}
defaultActiveFocusItem: removeButton.rightButton
FlickableType {
id: fl
anchors.top: backButton.bottom

View File

@@ -13,6 +13,8 @@ import "../Config"
PageType {
id: root
defaultActiveFocusItem: servers.rightButton
FlickableType {
id: fl
anchors.top: parent.top
@@ -38,6 +40,7 @@ PageType {
}
LabelWithButtonType {
id: servers
Layout.fillWidth: true
Layout.topMargin: 16
@@ -48,11 +51,14 @@ PageType {
clickedFunction: function() {
PageController.goToPage(PageEnum.PageSettingsServersList)
}
KeyNavigation.tab: connection.rightButton
}
DividerType {}
LabelWithButtonType {
id: connection
Layout.fillWidth: true
text: qsTr("Connection")
@@ -62,11 +68,13 @@ PageType {
clickedFunction: function() {
PageController.goToPage(PageEnum.PageSettingsConnection)
}
KeyNavigation.tab: application.rightButton
}
DividerType {}
LabelWithButtonType {
id: application
Layout.fillWidth: true
text: qsTr("Application")
@@ -76,11 +84,13 @@ PageType {
clickedFunction: function() {
PageController.goToPage(PageEnum.PageSettingsApplication)
}
KeyNavigation.tab: backup.rightButton
}
DividerType {}
LabelWithButtonType {
id: backup
Layout.fillWidth: true
text: qsTr("Backup")
@@ -90,6 +100,7 @@ PageType {
clickedFunction: function() {
PageController.goToPage(PageEnum.PageSettingsBackup)
}
KeyNavigation.tab: about.rightButton
}
DividerType {}
@@ -105,6 +116,7 @@ PageType {
clickedFunction: function() {
PageController.goToPage(PageEnum.PageSettingsAbout)
}
KeyNavigation.tab: root.defaultActiveFocusItem
}
DividerType {}

View File

@@ -13,6 +13,8 @@ import "../Components"
PageType {
id: root
defaultActiveFocusItem: donateButton
BackButtonType {
id: backButton
@@ -74,6 +76,7 @@ PageType {
}
BasicButtonType {
id: donateButton
Layout.fillWidth: true
Layout.topMargin: 24
Layout.leftMargin: 16
@@ -84,9 +87,12 @@ PageType {
clickedFunc: function() {
Qt.openUrlExternally(qsTr("https://www.patreon.com/amneziavpn"))
}
KeyNavigation.tab: donateButton2
}
BasicButtonType {
id: donateButton2
Layout.fillWidth: true
Layout.topMargin: 8
Layout.leftMargin: 16
@@ -104,6 +110,8 @@ PageType {
clickedFunc: function() {
Qt.openUrlExternally(qsTr("https://github.com/amnezia-vpn/amnezia-client#donate"))
}
KeyNavigation.tab: donateButton
}
ParagraphTextType {

View File

@@ -13,6 +13,8 @@ import "../Components"
PageType {
id: root
defaultActiveFocusItem: languageLabel.rightButton
BackButtonType {
id: backButton
@@ -127,6 +129,7 @@ PageType {
}
LabelWithButtonType {
id: languageLabel
Layout.fillWidth: true
text: qsTr("Language")
@@ -136,12 +139,15 @@ PageType {
clickedFunction: function() {
selectLanguageDrawer.open()
}
KeyNavigation.tab: loggingLabel.rightButton
}
DividerType {}
LabelWithButtonType {
id: loggingLabel
Layout.fillWidth: true
text: qsTr("Logging")
@@ -151,11 +157,14 @@ PageType {
clickedFunction: function() {
PageController.goToPage(PageEnum.PageSettingsLogging)
}
KeyNavigation.tab: resetLabel.rightButton
}
DividerType {}
LabelWithButtonType {
id: resetLabel
Layout.fillWidth: true
text: qsTr("Reset settings and remove all data from the application")
@@ -171,12 +180,21 @@ PageType {
var yesButtonFunction = function() {
SettingsController.clearSettings()
PageController.replaceStartPage()
if (!GC.isMobile()) {
languageLabel.rightButton.forceActiveFocus()
}
}
var noButtonFunction = function() {
if (!GC.isMobile()) {
languageLabel.rightButton.forceActiveFocus()
}
}
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
}
KeyNavigation.tab: defaultActiveFocusItem
}
DividerType {}

View File

@@ -34,6 +34,8 @@ PageType {
}
}
defaultActiveFocusItem: makeBackupButton
BackButtonType {
id: backButton
@@ -106,9 +108,12 @@ PageType {
PageController.showNotificationMessage(qsTr("Backup file saved"))
}
}
KeyNavigation.tab: restoreBackupButton
}
BasicButtonType {
id: restoreBackupButton
Layout.fillWidth: true
Layout.topMargin: -8
@@ -128,6 +133,8 @@ PageType {
restoreBackup(filePath)
}
}
KeyNavigation.tab: makeBackupButton
}
}
}

View File

@@ -11,6 +11,8 @@ import "../Config"
PageType {
id: root
defaultActiveFocusItem: dnsServersButton.rightButton
BackButtonType {
id: backButton
@@ -59,6 +61,7 @@ PageType {
DividerType {}
LabelWithButtonType {
id: dnsServersButton
Layout.fillWidth: true
text: qsTr("DNS servers")
@@ -68,11 +71,14 @@ PageType {
clickedFunction: function() {
PageController.goToPage(PageEnum.PageSettingsDns)
}
KeyNavigation.tab: splitTunnelingButton.rightButton
}
DividerType {}
LabelWithButtonType {
id: splitTunnelingButton
visible: true
Layout.fillWidth: true
@@ -84,6 +90,7 @@ PageType {
clickedFunction: function() {
PageController.goToPage(PageEnum.PageSettingsSplitTunneling)
}
KeyNavigation.tab: splitTunnelingButton2.visible ? splitTunnelingButton2.rightButton : root.defaultActiveFocusItem
}
DividerType {
@@ -91,6 +98,7 @@ PageType {
}
LabelWithButtonType {
id: splitTunnelingButton2
visible: false
Layout.fillWidth: true
@@ -101,6 +109,7 @@ PageType {
clickedFunction: function() {
}
KeyNavigation.tab: root.defaultActiveFocusItem
}
DividerType {

View File

@@ -87,10 +87,11 @@ PageType {
regularExpression: InstallController.ipAddressRegExp()
}
KeyNavigation.tab: saveButton
KeyNavigation.tab: restoreDefaultButton
}
BasicButtonType {
id: restoreDefaultButton
Layout.fillWidth: true
defaultColor: "transparent"
@@ -113,12 +114,19 @@ PageType {
SettingsController.secondaryDns = "1.0.0.1"
secondaryDns.textFieldText = SettingsController.secondaryDns
PageController.showNotificationMessage(qsTr("Settings have been reset"))
if (!GC.isMobile()) {
primaryDns.textField.forceActiveFocus()
}
}
var noButtonFunction = function() {
if (!GC.isMobile()) {
primaryDns.textField.forceActiveFocus()
}
}
showQuestionDrawer(headerText, "", yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
}
KeyNavigation.tab: saveButton
}
BasicButtonType {
@@ -137,6 +145,7 @@ PageType {
}
PageController.showNotificationMessage(qsTr("Settings saved"))
}
KeyNavigation.tab: primaryDns.textField
}
}
}

View File

@@ -93,6 +93,7 @@ PageType {
Connections {
target: serverNameEditDrawer
enabled: !GC.isMobile()
function onOpened() {
serverName.textField.forceActiveFocus()
}
@@ -127,6 +128,8 @@ PageType {
}
serverNameEditDrawer.close()
}
KeyNavigation.tab: serverName.textField
}
Component.onCompleted: {

View File

@@ -17,6 +17,8 @@ import "../Components"
PageType {
id: root
defaultActiveFocusItem: servers.currentItem.focusItem
ColumnLayout {
id: header
@@ -63,6 +65,8 @@ PageType {
implicitWidth: servers.width
implicitHeight: delegateContent.implicitHeight
property alias focusItem: server.rightButton
ColumnLayout {
id: delegateContent

View File

@@ -296,6 +296,14 @@ PageType {
anchors.left: parent.left
anchors.right: parent.right
Connections{
target: moreActionsDrawer
enabled: !GC.isMobile()
function onOpened(){
importSitesButton.rightButton.forceActiveFocus()
}
}
Header2Type {
Layout.fillWidth: true
Layout.margins: 16
@@ -304,6 +312,7 @@ PageType {
}
LabelWithButtonType {
id: importSitesButton
Layout.fillWidth: true
text: qsTr("Import")
@@ -317,6 +326,7 @@ PageType {
DividerType {}
LabelWithButtonType {
id: saveSitesButton
Layout.fillWidth: true
text: qsTr("Save site list")

View File

@@ -13,6 +13,8 @@ import "../Config"
PageType {
id: root
defaultActiveFocusItem:fileButton.rightButton
Connections {
target: ImportController
@@ -61,6 +63,7 @@ PageType {
}
LabelWithButtonType {
id: fileButton
Layout.fillWidth: true
Layout.topMargin: 16
@@ -83,11 +86,14 @@ PageType {
}
}
}
KeyNavigation.tab: qrButton.visible ? qrButton.rightButton : textButton.rightButton
}
DividerType {}
LabelWithButtonType {
id: qrButton
Layout.fillWidth: true
visible: SettingsController.isCameraPresent()
@@ -101,6 +107,8 @@ PageType {
PageController.goToPage(PageEnum.PageSetupWizardQrReader)
}
}
KeyNavigation.tab: textButton.rightButton
}
DividerType {
@@ -108,6 +116,7 @@ PageType {
}
LabelWithButtonType {
id: textButton
Layout.fillWidth: true
text: qsTr("Key as text")
@@ -117,6 +126,8 @@ PageType {
clickedFunction: function() {
PageController.goToPage(PageEnum.PageSetupWizardTextKey)
}
KeyNavigation.tab: defaultActiveFocusItem
}
DividerType {}

View File

@@ -121,6 +121,8 @@ PageType {
PageController.goToPage(PageEnum.PageSetupWizardEasy)
}
KeyNavigation.tab: hostname.textField
}
LabelTextType {

View File

@@ -17,6 +17,8 @@ PageType {
property bool isEasySetup: true
defaultActiveFocusItem: continueButton
SortFilterProxyModel {
id: proxyContainersModel
sourceModel: ContainersModel
@@ -169,6 +171,7 @@ PageType {
PageController.goToPage(PageEnum.PageSetupWizardProtocols)
}
}
KeyNavigation.tab: setupLaterButton
}
BasicButtonType {
@@ -200,6 +203,8 @@ PageType {
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
InstallController.addEmptyServer()
}
KeyNavigation.tab: continueButton
}
}
}

View File

@@ -15,6 +15,8 @@ PageType {
property bool isControlsDisabled: false
defaultActiveFocusItem: startButton
Connections {
target: PageController
@@ -118,6 +120,7 @@ PageType {
}
BasicButtonType {
id: startButton
Layout.fillWidth: true
Layout.topMargin: 32
Layout.leftMargin: 16
@@ -128,9 +131,11 @@ PageType {
clickedFunc: function() {
connectionTypeSelection.open()
}
KeyNavigation.tab: startButton2
}
BasicButtonType {
id: startButton2
Layout.fillWidth: true
Layout.topMargin: 8
Layout.leftMargin: 16
@@ -148,6 +153,7 @@ PageType {
clickedFunc: function() {
Qt.openUrlExternally(qsTr("https://amnezia.org/instructions/0_starter-guide"))
}
KeyNavigation.tab: startButton
}
}
}

View File

@@ -80,5 +80,6 @@ PageType {
ImportController.extractConfigFromCode(textKey.textFieldText)
PageController.goToPage(PageEnum.PageSetupWizardViewConfig)
}
KeyNavigation.tab: textKey.textField
}
}

View File

@@ -15,6 +15,8 @@ PageType {
property bool showContent: false
defaultActiveFocusItem: showContentButton
Connections {
target: ImportController
@@ -53,7 +55,7 @@ PageType {
id: fl
anchors.top: backButton.bottom
anchors.bottom: parent.bottom
contentHeight: content.implicitHeight + connectButton.implicitHeight
contentHeight: content.implicitHeight + connectButtonLayout.implicitHeight
ColumnLayout {
id: content
@@ -97,6 +99,7 @@ PageType {
}
BasicButtonType {
id: showContentButton
Layout.topMargin: 16
Layout.leftMargin: -8
implicitHeight: 32
@@ -112,6 +115,8 @@ PageType {
clickedFunc: function() {
showContent = !showContent
}
KeyNavigation.tab: connectButton
}
Rectangle {
@@ -138,7 +143,7 @@ PageType {
}
ColumnLayout {
id: connectButton
id: connectButtonLayout
anchors.bottom: parent.bottom
anchors.left: parent.left
@@ -147,6 +152,7 @@ PageType {
anchors.leftMargin: 16
BasicButtonType {
id: connectButton
Layout.fillWidth: true
Layout.bottomMargin: 32
@@ -154,6 +160,8 @@ PageType {
clickedFunc: function() {
ImportController.importConfig()
}
KeyNavigation.tab: defaultActiveFocusItem
}
}
}

View File

@@ -12,6 +12,7 @@ import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Components"
import "../Config"
PageType {
id: root
@@ -181,6 +182,14 @@ PageType {
spacing: 0
Connections {
target: shareFullAccessDrawer
enabled: !GC.isMobile()
function onOpened() {
shareFullAccessButton.rightButton.forceActiveFocus()
}
}
Header2Type {
Layout.fillWidth: true
Layout.bottomMargin: 16
@@ -193,6 +202,7 @@ PageType {
LabelWithButtonType {
id: shareFullAccessButton
Layout.fillWidth: true
text: qsTr("Share")
@@ -499,8 +509,12 @@ PageType {
clickedFunc: function(){
if (clientNameTextField.textFieldText !== "") {
ExportController.generateConfig(root.connectionTypesModel[exportTypeSelector.currentIndex].type)
} else{
clientNameTextField.textField.forceActiveFocus()
}
}
KeyNavigation.tab: clientNameTextField.textField
}
Header2Type {
@@ -514,6 +528,7 @@ PageType {
actionButtonImage: "qrc:/images/controls/search.svg"
actionButtonFunction: function() {
root.isSearchBarVisible = true
searchTextField.textField.forceActiveFocus()
}
}
@@ -575,6 +590,7 @@ PageType {
anchors.leftMargin: -16
LabelWithButtonType {
id: clientItem
Layout.fillWidth: true
text: clientName
@@ -605,6 +621,14 @@ PageType {
spacing: 8
Connections {
target: clientInfoDrawer
enabled: !GC.isMobile()
function onOpened() {
renameButton.forceActiveFocus()
}
}
Header2Type {
Layout.fillWidth: true
Layout.bottomMargin: 24
@@ -614,6 +638,7 @@ PageType {
}
BasicButtonType {
id: renameButton
Layout.fillWidth: true
Layout.topMargin: 24
@@ -648,6 +673,7 @@ PageType {
Connections {
target: clientNameEditDrawer
enabled: !GC.isMobile()
function onOpened() {
clientNameEditor.textField.forceActiveFocus()
}
@@ -686,12 +712,17 @@ PageType {
clientNameEditDrawer.close()
}
}
KeyNavigation.tab: clientNameEditor.textField
}
}
}
KeyNavigation.tab: revokeButton
}
BasicButtonType {
id: revokeButton
Layout.fillWidth: true
defaultColor: "transparent"
@@ -718,6 +749,8 @@ PageType {
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
}
KeyNavigation.tab: renameButton
}
}
}

View File

@@ -16,6 +16,8 @@ import "../Components"
PageType {
id: root
defaultActiveFocusItem: shareButton
BackButtonType {
id: backButton
@@ -117,6 +119,7 @@ PageType {
}
BasicButtonType {
id: shareButton
Layout.fillWidth: true
Layout.topMargin: 40