2023-04-14 19:31:10 +03:00
import QtQuick
import QtQuick . Controls
import QtQuick . Layouts
import SortFilterProxyModel 0.2
import PageEnum 1.0
import ProtocolEnum 1.0
import "./"
import "../Controls2"
import "../Config"
2023-05-25 15:40:17 +08:00
PageType {
2023-04-14 19:31:10 +03:00
id: root
2024-04-18 17:54:55 +04:00
defaultActiveFocusItem: focusItem
Item {
id: focusItem
KeyNavigation.tab: backButton
}
2023-04-14 19:31:10 +03:00
SortFilterProxyModel {
2023-05-03 19:06:16 +03:00
id: proxyContainersModel
sourceModel: ContainersModel
2023-04-14 19:31:10 +03:00
filters: [
ValueFilter {
2023-05-22 00:10:51 +08:00
roleName: "serviceType"
2023-04-14 19:31:10 +03:00
value: ProtocolEnum . Vpn
2023-05-22 00:10:51 +08:00
} ,
ValueFilter {
roleName: "isSupported"
value: true
2023-04-14 19:31:10 +03:00
}
]
}
2023-06-30 13:45:11 +09:00
ColumnLayout {
2024-04-18 17:54:55 +04:00
id: backButtonLayout
2023-06-30 13:45:11 +09:00
anchors.top: parent . top
anchors.left: parent . left
anchors.right: parent . right
anchors.topMargin: 20
BackButtonType {
2024-04-18 17:54:55 +04:00
id: backButton
KeyNavigation.tab: containers
2023-06-30 13:45:11 +09:00
}
}
2023-04-14 19:31:10 +03:00
FlickableType {
id: fl
2024-04-18 17:54:55 +04:00
anchors.top: backButtonLayout . bottom
2023-06-20 10:25:24 +09:00
anchors.bottom: parent . bottom
2023-06-30 13:45:11 +09:00
contentHeight: content . implicitHeight + content . anchors . topMargin + content . anchors . bottomMargin
2023-04-14 19:31:10 +03:00
Column {
id: content
anchors.top: parent . top
anchors.left: parent . left
anchors.right: parent . right
2023-06-30 13:45:11 +09:00
anchors.bottomMargin: 20
2023-06-05 15:49:10 +08:00
2023-06-30 10:40:43 +09:00
Item {
2023-04-14 19:31:10 +03:00
width: parent . width
2023-06-30 10:40:43 +09:00
height: header . implicitHeight
2023-04-14 19:31:10 +03:00
2023-06-30 10:40:43 +09:00
HeaderType {
id: header
anchors.fill: parent
anchors.leftMargin: 16
anchors.rightMargin: 16
width: parent . width
2023-07-31 12:54:59 +09:00
headerText: qsTr ( "VPN protocol" )
2023-07-24 16:33:58 +09:00
descriptionText: qsTr ( "Choose the one with the highest priority for you. Later, you can install other protocols and additional services, such as DNS proxy and SFTP." )
2023-06-30 10:40:43 +09:00
}
2023-04-14 19:31:10 +03:00
}
ListView {
id: containers
width: parent . width
height: containers . contentItem . height
2024-04-18 17:54:55 +04:00
// currentIndex: -1
2023-04-14 19:31:10 +03:00
clip: true
interactive: false
2023-05-03 19:06:16 +03:00
model: proxyContainersModel
2023-04-14 19:31:10 +03:00
2024-04-18 17:54:55 +04:00
function ensureCurrentItemVisible ( ) {
if ( currentIndex >= 0 ) {
if ( currentItem . y < fl . contentY ) {
fl . contentY = currentItem . y
} else if ( currentItem . y + currentItem . height + header . height > fl . contentY + fl . height ) {
fl . contentY = currentItem . y + currentItem . height + header . height - fl . height + 40 // 40 is a bottom margin
}
}
}
activeFocusOnTab: true
Keys.onTabPressed: {
if ( currentIndex < this . count - 1 ) {
this . incrementCurrentIndex ( )
} else {
this . currentIndex = 0
focusItem . forceActiveFocus ( )
}
ensureCurrentItemVisible ( )
}
onVisibleChanged: {
if ( visible ) {
currentIndex = 0
}
}
2023-04-14 19:31:10 +03:00
delegate: Item {
implicitWidth: containers . width
implicitHeight: delegateContent . implicitHeight
2024-04-18 17:54:55 +04:00
onActiveFocusChanged: {
if ( activeFocus ) {
container . rightButton . forceActiveFocus ( )
}
}
2023-04-14 19:31:10 +03:00
ColumnLayout {
id: delegateContent
anchors.top: parent . top
anchors.left: parent . left
anchors.right: parent . right
LabelWithButtonType {
id: container
Layout.fillWidth: true
2023-05-22 00:10:51 +08:00
text: name
descriptionText: description
2023-06-20 10:25:24 +09:00
rightImageSource: "qrc:/images/controls/chevron-right.svg"
2023-04-14 19:31:10 +03:00
2023-05-25 15:40:17 +08:00
clickedFunction: function ( ) {
2024-04-01 20:20:02 +07:00
ContainersModel . setProcessedContainerIndex ( proxyContainersModel . mapToSource ( index ) )
2023-09-06 13:37:37 +05:00
PageController . goToPage ( PageEnum . PageSetupWizardProtocolSettings )
2023-05-03 19:06:16 +03:00
}
2023-04-14 19:31:10 +03:00
}
2023-05-27 22:46:41 +08:00
DividerType { }
2023-04-14 19:31:10 +03:00
}
}
}
}
}
}