added PageSetupWizardViewConfig

- added a popup with a question when deleting containers/servers
- added import from code and import error handling
This commit is contained in:
vladimir.kuznetsov 2023-06-05 15:49:10 +08:00
parent de0cd976de
commit 420c33d3ba
37 changed files with 701 additions and 312 deletions

View file

@ -0,0 +1,91 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import SortFilterProxyModel 0.2
import PageEnum 1.0
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
PageType {
id: root
SortFilterProxyModel {
id: proxyServersModel
sourceModel: ServersModel
filters: [
ValueFilter {
roleName: "isCurrentlyProcessed"
value: true
}
]
}
FlickableType {
id: fl
anchors.fill: parent
contentHeight: content.height
Column {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
spacing: 16
Repeater {
model: proxyServersModel
delegate: Item {
implicitWidth: parent.width
implicitHeight: delegateContent.implicitHeight
ColumnLayout {
id: delegateContent
anchors.fill: parent
anchors.rightMargin: 16
anchors.leftMargin: 16
HeaderType {
Layout.fillWidth: true
Layout.topMargin: 20
headerText: qsTr("Removing services from ") + name
}
ProgressBarType {
id: progressBar
Layout.fillWidth: true
Layout.topMargin: 32
Timer {
id: timer
interval: 300
repeat: true
running: true
onTriggered: {
progressBar.value += 0.001
}
}
}
ParagraphTextType {
Layout.fillWidth: true
Layout.topMargin: 8
text: "Обычно это занимает не больше 5 минут"
}
}
}
}
}
}
}

View file

@ -113,20 +113,6 @@ PageType {
width: parent.width
height: parent.height * 0.90
background: Rectangle {
anchors.fill: parent
anchors.bottomMargin: -radius
radius: 16
color: "#1C1D21"
border.color: root.borderColor
border.width: 1
}
Overlay.modal: Rectangle {
color: Qt.rgba(14/255, 14/255, 17/255, 0.8)
}
ColumnLayout {
id: serversMenuHeader
anchors.top: parent.top

View file

@ -71,7 +71,6 @@ PageType {
iconImage: "qrc:/images/controls/app.svg"
clickedFunction: function() {
goToPage(PageEnum.PageSetupWizardTextKey)
}
}
@ -85,7 +84,6 @@ PageType {
iconImage: "qrc:/images/controls/save.svg"
clickedFunction: function() {
goToPage(PageEnum.PageSetupWizardTextKey)
}
}
@ -99,7 +97,6 @@ PageType {
iconImage: "qrc:/images/controls/amnezia.svg"
clickedFunction: function() {
goToPage(PageEnum.PageSetupWizardTextKey)
}
}

View file

@ -9,6 +9,7 @@ import ProtocolEnum 1.0
import "../Controls2"
import "../Controls2/TextTypes"
import "../Components"
PageType {
id: root
@ -33,7 +34,19 @@ PageType {
descriptionText: "May be needed when changing other settings"
clickedFunction: function() {
ContainersModel.clearCachedProfiles()
questionDrawer.headerText = qsTr("Clear cached profiles?")
questionDrawer.descriptionText = qsTr("some description")
questionDrawer.yesButtonText = qsTr("Continue")
questionDrawer.noButtonText = qsTr("Cancel")
questionDrawer.yesButtonFunction = function() {
questionDrawer.visible = false
ContainersModel.clearCachedProfiles()
}
questionDrawer.noButtonFunction = function() {
questionDrawer.visible = false
}
questionDrawer.visible = true
}
}
@ -46,15 +59,27 @@ PageType {
textColor: "#EB5757"
clickedFunction: function() {
if (ServersModel.isDefaultServerCurrentlyProcessed && ConnectionController.isConnected()) {
ConnectionController.closeVpnConnection()
questionDrawer.headerText = qsTr("Remove server?")
questionDrawer.descriptionText = qsTr("All installed AmneziaVPN services will still remain on the server.")
questionDrawer.yesButtonText = qsTr("Continue")
questionDrawer.noButtonText = qsTr("Cancel")
questionDrawer.yesButtonFunction = function() {
questionDrawer.visible = false
if (ServersModel.isDefaultServerCurrentlyProcessed && ConnectionController.isConnected) {
ConnectionController.closeConnection()
}
ServersModel.removeServer()
if (!ServersModel.getServersCount()) {
PageController.replaceStartPage()
} else {
goToStartPage()
}
}
ServersModel.removeServer()
if (!ServersModel.getServersCount()) {
PageController.replaceStartPage()
} else {
goToStartPage()
questionDrawer.noButtonFunction = function() {
questionDrawer.visible = false
}
questionDrawer.visible = true
}
}
@ -67,14 +92,32 @@ PageType {
textColor: "#EB5757"
clickedFunction: function() {
if (ServersModel.isDefaultServerCurrentlyProcessed && ConnectionController.isConnected()) {
ConnectionController.closeVpnConnection()
questionDrawer.headerText = qsTr("Clear server from Amnezia software?")
questionDrawer.descriptionText = qsTr(" All containers will be deleted on the server. This means that configuration files, keys and certificates will be deleted.")
questionDrawer.yesButtonText = qsTr("Continue")
questionDrawer.noButtonText = qsTr("Cancel")
questionDrawer.yesButtonFunction = function() {
questionDrawer.visible = false
goToPage(PageEnum.PageDeinstalling)
if (ServersModel.isDefaultServerCurrentlyProcessed && ConnectionController.isConnected) {
ConnectionController.closeVpnConnection()
}
ContainersModel.removeAllContainers()
closePage()
}
ContainersModel.removeAllContainers()
questionDrawer.noButtonFunction = function() {
questionDrawer.visible = false
}
questionDrawer.visible = true
}
}
DividerType {}
QuestionDrawer {
id: questionDrawer
}
}
}
}

View file

@ -30,8 +30,6 @@ PageType {
}
ColumnLayout {
id: content
anchors.fill: parent
spacing: 16
@ -40,24 +38,27 @@ PageType {
id: header
model: proxyServersModel
delegate: HeaderType {
Layout.fillWidth: true
delegate: ColumnLayout {
id: content
Layout.topMargin: 20
Layout.leftMargin: 16
Layout.rightMargin: 16
actionButtonImage: "qrc:/images/controls/edit-3.svg"
backButtonImage: "qrc:/images/controls/arrow-left.svg"
headerText: name
descriptionText: hostName
actionButtonFunction: function() {
connectionTypeSelection.visible = true
BackButtonType {
}
backButtonFunction: function() {
closePage()
HeaderType {
Layout.fillWidth: true
actionButtonImage: "qrc:/images/controls/edit-3.svg"
headerText: name
descriptionText: hostName
actionButtonFunction: function() {
connectionTypeSelection.visible = true
}
}
}
}
@ -74,23 +75,14 @@ PageType {
TabButtonType {
isSelected: tabBar.currentIndex === 0
text: qsTr("Protocols")
// onClicked: {
// tabBarStackView.goToTabBarPage(PageEnum.PageSettingsServerProtocols)
// }
}
TabButtonType {
isSelected: tabBar.currentIndex === 1
text: qsTr("Services")
// onClicked: {
// tabBarStackView.goToTabBarPage(PageEnum.PageSettingsServerServices)
// }
}
TabButtonType {
isSelected: tabBar.currentIndex === 2
text: qsTr("Data")
// onClicked: {
// tabBarStackView.goToTabBarPage(PageEnum.PageSettingsServerData)
// }
}
}
@ -110,25 +102,5 @@ PageType {
stackView: root.stackView
}
}
// StackViewType {
// id: tabBarStackView
// Layout.preferredWidth: root.width
// Layout.preferredHeight: root.height - tabBar.implicitHeight - header.implicitHeight
// function goToTabBarPage(page) {
// var pagePath = PageController.getPagePath(page)
// while (tabBarStackView.depth > 1) {
// tabBarStackView.pop()
// }
// tabBarStackView.replace(pagePath, { "objectName" : pagePath })
// }
// Component.onCompleted: {
// var pagePath = PageController.getPagePath(PageEnum.PageSettingsServerProtocols)
// tabBarStackView.push(pagePath, { "objectName" : pagePath })
// }
// }
}
}

View file

@ -17,7 +17,7 @@ import "../Components"
PageType {
id: root
HeaderType {
ColumnLayout {
id: header
anchors.top: parent.top
@ -28,13 +28,19 @@ PageType {
anchors.leftMargin: 16
anchors.rightMargin: 16
actionButtonImage: "qrc:/images/controls/plus.svg"
backButtonImage: "qrc:/images/controls/arrow-left.svg"
BackButtonType {
}
headerText: "Серверы"
HeaderType {
Layout.fillWidth: true
actionButtonFunction: function() {
connectionTypeSelection.visible = true
actionButtonImage: "qrc:/images/controls/plus.svg"
headerText: "Серверы"
actionButtonFunction: function() {
connectionTypeSelection.visible = true
}
}
}

View file

@ -13,14 +13,6 @@ import "../Config"
PageType {
id: root
Connections {
target: ImportController
function onImportFinished() {
}
}
FlickableType {
id: fl
anchors.top: root.top
@ -34,13 +26,18 @@ PageType {
anchors.left: parent.left
anchors.right: parent.right
BackButtonType {
Layout.topMargin: 20
Layout.rightMargin: 16
Layout.leftMargin: 16
}
HeaderType {
Layout.fillWidth: true
Layout.topMargin: 20
Layout.rightMargin: 16
Layout.leftMargin: 16
backButtonImage: "qrc:/images/controls/arrow-left.svg"
headerText: "Подключение к серверу"
descriptionText: "Не используйте код подключения из публичных источников. Его могли создать, чтобы перехватывать ваши данные.\n
@ -71,7 +68,8 @@ PageType {
FileDialog {
id: fileDialog
onAccepted: {
ImportController.importFromFile(selectedFile)
ImportController.extractConfigFromFile(selectedFile)
goToPage(PageEnum.PageSetupWizardViewConfig)
}
}
}

View file

@ -11,9 +11,20 @@ import "../Config"
PageType {
id: root
BackButtonType {
id: backButton
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 16
anchors.leftMargin: 16
anchors.topMargin: 20
}
FlickableType {
id: fl
anchors.top: root.top
anchors.top: backButton.bottom
anchors.bottom: root.bottom
contentHeight: content.height
@ -30,9 +41,6 @@ PageType {
HeaderType {
Layout.fillWidth: true
Layout.topMargin: 20
backButtonImage: "qrc:/images/controls/arrow-left.svg"
headerText: "Подключение к серверу"
}

View file

@ -30,11 +30,22 @@ PageType {
}
}
BackButtonType {
id: backButton
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 16
anchors.leftMargin: 16
anchors.topMargin: 20
}
FlickableType {
id: fl
anchors.top: root.top
anchors.top: backButton.bottom
anchors.bottom: root.bottom
contentHeight: content.implicitHeight + buttonContinue.anchors.bottomMargin
contentHeight: content.implicitHeight + continueButton.anchors.bottomMargin
Column {
id: content
@ -44,7 +55,6 @@ PageType {
anchors.right: parent.right
anchors.rightMargin: 16
anchors.leftMargin: 16
anchors.topMargin: 20
spacing: 16
@ -53,9 +63,7 @@ PageType {
implicitWidth: parent.width
backButtonImage: "qrc:/images/controls/arrow-left.svg"
headerText: qsTr("What is the level of Internet control in your region?")
headerText: qsTr("What is the level of internet control in your region?")
}
ListView {
@ -118,11 +126,10 @@ PageType {
}
BasicButtonType {
id: buttonContinue
id: continueButton
implicitWidth: parent.width
anchors.topMargin: 24
anchors.bottomMargin: 32
anchors.bottomMargin: 24
text: qsTr("Continue")

View file

@ -109,7 +109,7 @@ PageType {
Layout.fillWidth: true
Layout.topMargin: 32
value: progressBarValue
// value: progressBarValue
Timer {
id: timer
@ -118,7 +118,7 @@ PageType {
repeat: true
running: true
onTriggered: {
progressBarValue += 0.001
progressBar.value += 0.001
}
}
}

View file

@ -62,13 +62,14 @@ PageType {
anchors.rightMargin: 16
anchors.leftMargin: 16
BackButtonType {
Layout.topMargin: 20
}
HeaderType {
id: header
Layout.fillWidth: true
Layout.topMargin: 20
backButtonImage: "qrc:/images/controls/arrow-left.svg"
headerText: "Установка " + name
descriptionText: "Эти настройки можно будет изменить позже"

View file

@ -48,9 +48,12 @@ PageType {
spacing: 16
BackButtonType {
width: parent.width
}
HeaderType {
width: parent.width
backButtonImage: "qrc:/images/controls/arrow-left.svg"
headerText: "Протокол подключения"
descriptionText: "Выберите более приоритетный для вас. Позже можно будет установить остальные протоколы и доп сервисы, вроде DNS-прокси и SFTP."

View file

@ -29,23 +29,26 @@ PageType {
spacing: 16
BackButtonType {
Layout.topMargin: 20
}
HeaderType {
Layout.fillWidth: true
Layout.topMargin: 20
backButtonImage: "qrc:/images/controls/arrow-left.svg"
headerText: "Ключ для подключения"
descriptionText: "Строка, которая начинается с vpn://..."
headerText: qsTr("Connection key")
descriptionText: qsTr("A line that starts with vpn://...")
}
TextFieldWithHeaderType {
id: textKey
Layout.fillWidth: true
Layout.topMargin: 32
headerText: "Ключ"
headerText: qsTr("Key")
textFieldPlaceholderText: "vpn://"
buttonText: "Вставить"
buttonText: qsTr("Insert")
clickedFunc: function() {
textField.text = ""
@ -63,10 +66,11 @@ PageType {
anchors.leftMargin: 16
anchors.bottomMargin: 32
text: qsTr("Подключиться")
text: qsTr("Continue")
onClicked: function() {
// goToPage(PageEnum.PageSetupWizardInstalling)
ImportController.extractConfigFromCode(textKey.textFieldText)
goToPage(PageEnum.PageSetupWizardViewConfig)
}
}
}

View file

@ -0,0 +1,152 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Dialogs
import PageEnum 1.0
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
PageType {
id: root
property bool showContent: false
Connections {
target: ImportController
function onImportErrorOccurred(errorMessage) {
closePage()
PageController.showErrorMessage(errorMessage)
}
function onImportFinished() {
goToStartPage()
if (stackView.currentItem.objectName === PageController.getPagePath(PageEnum.PageHome)) {
PageController.restorePageHomeState()
} else if (stackView.currentItem.objectName === PageController.getPagePath(PageEnum.PageSettings)) {
goToPage(PageEnum.PageSettingsServersList, false)
} else {
var pagePath = PageController.getPagePath(PageEnum.PageStart)
stackView.replace(pagePath, { "objectName" : pagePath })
}
}
}
BackButtonType {
id: backButton
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 16
anchors.leftMargin: 16
anchors.topMargin: 20
}
FlickableType {
id: fl
anchors.top: backButton.bottom
anchors.bottom: root.bottom
contentHeight: content.implicitHeight + connectButton.implicitHeight
ColumnLayout {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 16
anchors.leftMargin: 16
HeaderType {
headerText: qsTr("New connection")
}
RowLayout {
Layout.topMargin: 32
spacing: 8
visible: fileName.text !== ""
Image {
source: "qrc:/images/controls/file-cog-2.svg"
}
Header2TextType {
id: fileName
Layout.fillWidth: true
text: ImportController.getConfigFileName()
}
}
CaptionTextType {
Layout.fillWidth: true
Layout.topMargin: 16
text: qsTr("Do not use connection code from public sources. It could be created to intercept your data.")
color: "#878B91"
}
BasicButtonType {
defaultColor: "transparent"
hoveredColor: Qt.rgba(1, 1, 1, 0.08)
pressedColor: Qt.rgba(1, 1, 1, 0.12)
disabledColor: "#878B91"
textColor: "#D7D8DB"
text: showContent ? qsTr("Collapse content") : qsTr("Show content")
onClicked: {
showContent = !showContent
}
}
Rectangle {
Layout.fillWidth: true
Layout.bottomMargin: 16
implicitHeight: configContent.implicitHeight
radius: 10
color: "#1C1D21"
visible: showContent
ParagraphTextType {
id: configContent
anchors.fill: parent
anchors.margins: 16
text: ImportController.getConfig()
}
}
}
}
ColumnLayout {
id: connectButton
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 16
anchors.leftMargin: 16
BasicButtonType {
Layout.fillWidth: true
Layout.bottomMargin: 32
text: qsTr("Connect")
onClicked: {
ImportController.importConfig()
}
}
}
}

View file

@ -46,6 +46,8 @@ PageType {
Component.onCompleted: {
var pagePath = PageController.getPagePath(PageEnum.PageHome)
tabBarStackView.push(pagePath, { "objectName" : pagePath })
ServersModel.setCurrentlyProcessedServerIndex(ServersModel.getDefaultServerIndex())
ContainersModel.setCurrentlyProcessedServerIndex(ServersModel.getDefaultServerIndex())
}
}