Files
amnezia-client/client/ui/qml/Pages2/PageSetupWizardEasy.qml
T

219 lines
6.0 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import SortFilterProxyModel 0.2
import PageEnum 1.0
import ContainerProps 1.0
import ProtocolProps 1.0
2024-07-07 13:42:38 +03:00
import Style 1.0
import "./"
import "../Controls2"
import "../Config"
PageType {
id: root
property bool isEasySetup: true
SortFilterProxyModel {
id: proxyContainersModel
sourceModel: ContainersModel
filters: [
ValueFilter {
roleName: "isEasySetupContainer"
value: true
}
]
sorters: RoleSorter {
2023-09-18 21:06:10 +05:00
roleName: "easySetupOrder"
sortOrder: Qt.DescendingOrder
}
}
2023-06-05 15:49:10 +08:00
BackButtonType {
id: backButton
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
2025-11-04 11:43:36 +08:00
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onActiveFocusChanged: {
if(backButton.enabled && backButton.activeFocus) {
listView.positionViewAtBeginning()
}
}
}
ButtonGroup {
id: buttonGroup
2023-06-05 15:49:10 +08:00
}
ListViewType {
id: listView
property int dockerContainer
property int containerDefaultPort
property int containerDefaultTransportProto
2023-06-05 15:49:10 +08:00
anchors.top: backButton.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
spacing: 16
header: ColumnLayout {
width: listView.width
spacing: 16
2025-05-02 23:54:36 -07:00
BaseHeaderType {
id: header
Layout.fillWidth: true
Layout.rightMargin: 16
Layout.leftMargin: 16
Layout.bottomMargin: 16
2023-10-02 16:31:50 +05:00
headerTextMaximumLineCount: 10
2025-02-04 15:53:40 +00:00
headerText: qsTr("Choose Installation Type")
}
}
model: proxyContainersModel
currentIndex: 0
delegate: ColumnLayout {
width: listView.width
CardType {
id: card
Layout.fillWidth: true
Layout.rightMargin: 16
Layout.leftMargin: 16
Layout.bottomMargin: 16
headerText: easySetupHeader
bodyText: easySetupDescription
ButtonGroup.group: buttonGroup
onClicked: function() {
isEasySetup = true
2026-01-30 06:42:29 +02:00
checked = true
var defaultContainerProto = ContainerProps.defaultProtocol(dockerContainer)
listView.dockerContainer = dockerContainer
listView.containerDefaultPort = ProtocolProps.getPortForInstall(defaultContainerProto)
listView.containerDefaultTransportProto = ProtocolProps.defaultTransportProto(defaultContainerProto)
}
Keys.onReturnPressed: this.clicked()
Keys.onEnterPressed: this.clicked()
}
}
footer: ColumnLayout {
width: listView.width
spacing: 16
DividerType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
}
2023-08-20 13:36:54 +05:00
CardType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
2025-02-04 15:53:40 +00:00
headerText: qsTr("Manual")
bodyText: qsTr("Choose a VPN protocol")
ButtonGroup.group: buttonGroup
onClicked: function() {
isEasySetup = false
checked = true
}
Keys.onEnterPressed: this.clicked()
Keys.onReturnPressed: this.clicked()
}
BasicButtonType {
2023-06-05 15:49:10 +08:00
id: continueButton
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
text: qsTr("Continue")
clickedFunc: function() {
if (root.isEasySetup) {
ContainersModel.setProcessedContainerIndex(listView.dockerContainer)
2023-09-06 13:37:37 +05:00
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
InstallController.install(listView.dockerContainer,
listView.containerDefaultPort,
listView.containerDefaultTransportProto)
} else {
2023-09-06 13:37:37 +05:00
PageController.goToPage(PageEnum.PageSetupWizardProtocols)
}
}
}
2023-08-20 13:36:54 +05:00
BasicButtonType {
id: setupLaterButton
Layout.fillWidth: true
Layout.topMargin: 8
Layout.bottomMargin: 24
Layout.leftMargin: 16
Layout.rightMargin: 16
2023-08-20 13:36:54 +05:00
2024-07-07 13:42:38 +03:00
defaultColor: AmneziaStyle.color.transparent
hoveredColor: AmneziaStyle.color.translucentWhite
pressedColor: AmneziaStyle.color.sheerWhite
disabledColor: AmneziaStyle.color.mutedGray
textColor: AmneziaStyle.color.paleGray
2023-08-20 13:36:54 +05:00
borderWidth: 1
visible: {
2023-10-03 22:38:17 +05:00
if (PageController.isTriggeredByConnectButton()) {
PageController.setTriggeredByConnectButton(false)
return false
}
return true
}
2024-03-26 20:05:04 +02:00
text: qsTr("Skip setup")
2023-08-20 13:36:54 +05:00
clickedFunc: function() {
2023-09-06 13:37:37 +05:00
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
2023-08-20 13:36:54 +05:00
InstallController.addEmptyServer()
}
}
}
Component.onCompleted: {
var item = listView.itemAtIndex(listView.currentIndex)
if (item !== null) {
var button = item.children[0]
button.checked = true
button.clicked()
}
}
}
}