added PageSettings and PageSettingsServersList.

- replaced PageLoader with PageType with stackView property.
- added error handling when installing a server/container
This commit is contained in:
vladimir.kuznetsov 2023-05-25 15:40:17 +08:00
parent ca6b7fbeb2
commit e00656d757
31 changed files with 486 additions and 142 deletions

View file

@ -57,8 +57,8 @@ Drawer {
text: "IP, логин и пароль от сервера"
buttonImage: "qrc:/images/controls/chevron-right.svg"
onClickedFunc: function() {
PageController.goToPage(PageEnum.PageSetupWizardCredentials)
clickedFunction: function() {
goToPage(PageEnum.PageSetupWizardCredentials)
root.visible = false
}
}
@ -73,8 +73,8 @@ Drawer {
text: "QR-код, ключ или файл настроек"
buttonImage: "qrc:/images/controls/chevron-right.svg"
onClickedFunc: function() {
PageController.goToPage(PageEnum.PageSetupWizardConfigSource)
clickedFunction: function() {
goToPage(PageEnum.PageSetupWizardConfigSource)
root.visible = false
}
}

View file

@ -96,7 +96,7 @@ ListView {
} else {
ContainersModel.setCurrentlyInstalledContainerIndex(proxyContainersModel.mapToSource(index))
InstallController.setShouldCreateServer(false)
PageController.goToPage(PageEnum.PageSetupWizardProtocolSettings)
goToPage(PageEnum.PageSetupWizardProtocolSettings)
containersDropDown.menuVisible = false
menu.visible = false
}

View file

@ -36,7 +36,7 @@ Item {
if (backButtonFunction && typeof backButtonFunction === "function") {
backButtonFunction()
} else {
PageController.closePage()
closePage()
}
}
}

View file

@ -36,7 +36,7 @@ Item {
if (backButtonFunction && typeof backButtonFunction === "function") {
backButtonFunction()
} else {
PageController.closePage()
closePage()
}
}
}
@ -61,8 +61,8 @@ Item {
visible: image ? true : false
onClicked: {
if (actionButtonImage && typeof actionButtonImage === "function") {
actionButtonImage()
if (actionButtonFunction && typeof actionButtonFunction === "function") {
actionButtonFunction()
}
}
}

View file

@ -8,7 +8,7 @@ Item {
property string text
property string descriptionText
property var onClickedFunc
property var clickedFunction
property alias buttonImage: button.image
property string iconImage
@ -68,8 +68,8 @@ Item {
hoverEnabled: false
image: buttonImage
onClicked: {
if (onClickedFunc && typeof onClickedFunc === "function") {
onClickedFunc()
if (clickedFunction && typeof clickedFunction === "function") {
clickedFunction()
}
}

View file

@ -0,0 +1,31 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Item {
id: root
property StackView stackView: StackView.view
function goToPage(page, slide = true) {
if (slide) {
root.stackView.push(PageController.getPagePath(page), {}, StackView.PushTransition)
} else {
root.stackView.push(PageController.getPagePath(page), {}, StackView.Immediate)
}
}
function closePage() {
if (root.stackView.depth <= 1) {
return
}
root.stackView.pop()
}
function goToStartPage() {
while (root.stackView.depth > 1) {
root.stackView.pop()
}
}
}

View file

@ -0,0 +1,61 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import "TextTypes"
Popup {
id: root
property string popupErrorMessageText
property bool closeButtonVisible: true
leftMargin: 25
rightMargin: 25
bottomMargin: 70
width: parent.width - leftMargin - rightMargin
anchors.centerIn: parent
modal: true
closePolicy: Popup.CloseOnEscape
Overlay.modal: Rectangle {
color: Qt.rgba(14/255, 14/255, 17/255, 0.8)
}
background: Rectangle {
anchors.fill: parent
color: Qt.rgba(215/255, 216/255, 219/255, 0.95)
radius: 4
}
contentItem: RowLayout {
width: parent.width
CaptionTextType {
horizontalAlignment: Text.AlignHCenter
Layout.fillWidth: true
text: root.popupErrorMessageText
}
BasicButtonType {
visible: closeButtonVisible
defaultColor: Qt.rgba(215/255, 216/255, 219/255, 0.95)
hoveredColor: "#C1C2C5"
pressedColor: "#AEB0B7"
disabledColor: "#494B50"
textColor: "#0E0E11"
borderWidth: 0
text: "Close"
onClicked: {
root.close()
}
}
}
}

View file

@ -0,0 +1,13 @@
import QtQuick
Text {
height: 16
color: "#0E0E11"
font.pixelSize: 13
font.weight: Font.Normal
font.family: "PT Root UI VF"
font.letterSpacing: 0.02
wrapMode: Text.WordWrap
}

View file

@ -1,37 +0,0 @@
import QtQuick
import QtQuick.Controls
StackView {
id: stackView
function gotoPage(page, slide) {
if (slide) {
stackView.push(PageController.getPagePath(page), {}, StackView.PushTransition)
} else {
stackView.push(PageController.getPagePath(page), {}, StackView.Immediate)
}
}
function closePage() {
if (stackView.depth <= 1) {
return
}
stackView.pop()
}
Connections {
target: PageController
function onGoToPage(page, slide) {
stackView.gotoPage(page, slide)
}
function onClosePage() {
stackView.closePage()
}
}
Component.onCompleted: {
PageController.setStartPage()
}
}

View file

@ -14,7 +14,7 @@ import "../Controls2/TextTypes"
import "../Config"
import "../Components"
Item {
PageType {
id: root
property string defaultColor: "#1C1D21"
@ -37,6 +37,21 @@ Item {
}
}
Connections {
target: InstallController
function onInstallContainerFinished() {
goToStartPage()
menu.visible = true
containersDropDown.menuVisible = true
}
function onInstallServerFinished() {
goToStartPage()
menu.visible = true
}
}
Rectangle {
id: buttonBackground
anchors.fill: buttonContent
@ -279,6 +294,15 @@ Item {
z: 1
Image {
source: "qrc:/images/controls/check.svg"
visible: serverRadioButton.checked
width: 24
height: 24
Layout.rightMargin: 8
}
Text {
id: serverRadioButtonText
@ -295,13 +319,10 @@ Item {
Layout.bottomMargin: 20
}
Image {
source: "qrc:/images/controls/check.svg"
visible: serverRadioButton.checked
width: 24
height: 24
ImageButtonType {
image: "qrc:/images/controls/settings.svg"
Layout.rightMargin: 8
// onClicked:
}
}

View file

@ -1,5 +1,71 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Item {
import SortFilterProxyModel 0.2
import PageEnum 1.0
import ContainerProps 1.0
import ProtocolProps 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
ColumnLayout {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
spacing: 16
Repeater {
model: proxyServersModel
delegate: HeaderType {
id: header
Layout.fillWidth: true
Layout.topMargin: 20
Layout.leftMargin: 16
Layout.rightMargin: 16
actionButtonImage: "qrc:/images/controls/plus.svg"
backButtonImage: "qrc:/images/controls/arrow-left.svg"
headerText: name
actionButtonFunction: function() {
connectionTypeSelection.visible = true
}
backButtonFunction: function() {
closePage()
}
}
}
}
}
}

View file

@ -0,0 +1,111 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import SortFilterProxyModel 0.2
import PageEnum 1.0
import ProtocolEnum 1.0
import ContainerProps 1.0
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
import "../Components"
PageType {
id: root
HeaderType {
id: header
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.leftMargin: 16
anchors.rightMargin: 16
actionButtonImage: "qrc:/images/controls/plus.svg"
backButtonImage: "qrc:/images/controls/arrow-left.svg"
headerText: "Серверы"
actionButtonFunction: function() {
connectionTypeSelection.visible = true
}
backButtonFunction: function() {
PageController.goToPageHome()
}
}
ConnectionTypeSelectionDrawer {
id: connectionTypeSelection
}
FlickableType {
anchors.top: header.bottom
anchors.topMargin: 16
contentHeight: col.implicitHeight
Column {
id: col
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 16
anchors.rightMargin: 16
spacing: 16
ListView {
id: servers
width: parent.width
height: servers.contentItem.height
model: ServersModel
clip: true
delegate: Item {
implicitWidth: servers.width
implicitHeight: delegateContent.implicitHeight
ColumnLayout {
id: delegateContent
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
LabelWithButtonType {
id: server
Layout.fillWidth: true
Layout.topMargin: 16
Layout.bottomMargin: 16
text: name
descriptionText: hostName
buttonImage: "qrc:/images/controls/chevron-right.svg"
clickedFunction: function() {
ServersModel.setCurrentlyProcessedServerIndex(index)
goToPage(PageEnum.PageSettings)
}
}
Rectangle {
Layout.fillWidth: true
height: 1
color: "#2C2D30"
}
}
}
}
}
}
}

View file

@ -10,7 +10,7 @@ import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
Item {
PageType {
id: root
Connections {
@ -44,7 +44,7 @@ Item {
backButtonImage: "qrc:/images/controls/arrow-left.svg"
headerText: "Подключение к серверу"
headerText: "Подключение к серверу"
descriptionText: "Не используйте код подключения из публичных источников. Его могли создать, чтобы перехватывать ваши данные.\n
Всё в порядке, если код передал друг."
}
@ -64,7 +64,7 @@ Item {
buttonImage: "qrc:/images/controls/chevron-right.svg"
iconImage: "qrc:/images/controls/folder-open.svg"
onClickedFunc: function() {
clickedFunction: function() {
onClicked: fileDialog.open()
}
@ -89,7 +89,7 @@ Item {
buttonImage: "qrc:/images/controls/chevron-right.svg"
iconImage: "qrc:/images/controls/qr-code.svg"
onClickedFunc: function() {
clickedFunction: function() {
}
}
@ -106,8 +106,8 @@ Item {
buttonImage: "qrc:/images/controls/chevron-right.svg"
iconImage: "qrc:/images/controls/text-cursor.svg"
onClickedFunc: function() {
PageController.goToPage(PageEnum.PageSetupWizardTextKey)
clickedFunction: function() {
goToPage(PageEnum.PageSetupWizardTextKey)
}
}

View file

@ -8,7 +8,7 @@ import "./"
import "../Controls2"
import "../Config"
Item {
PageType {
id: root
FlickableType {
@ -69,7 +69,7 @@ Item {
InstallController.setShouldCreateServer(true)
InstallController.setCurrentlyInstalledServerCredentials(hostname.textField.text, username.textField.text, secretData.textField.text)
PageController.goToPage(PageEnum.PageSetupWizardEasy)
goToPage(PageEnum.PageSetupWizardEasy)
}
}
@ -90,7 +90,7 @@ Item {
InstallController.setShouldCreateServer(true)
InstallController.setCurrentlyInstalledServerCredentials(hostname.textField.text, username.textField.text, secretData.textField.text)
PageController.goToPage(PageEnum.PageSetupWizardProtocols)
goToPage(PageEnum.PageSetupWizardProtocols)
}
}
}

View file

@ -12,7 +12,7 @@ import "./"
import "../Controls2"
import "../Config"
Item {
PageType {
id: root
SortFilterProxyModel {
@ -34,7 +34,7 @@ Item {
id: fl
anchors.top: root.top
anchors.bottom: root.bottom
contentHeight: content.height
contentHeight: content.implicitHeight + buttonContinue.anchors.bottomMargin
Column {
id: content
@ -49,8 +49,9 @@ Item {
spacing: 16
HeaderType {
id: header
implicitWidth: parent.width
anchors.topMargin: 20
backButtonImage: "qrc:/images/controls/arrow-left.svg"
@ -117,6 +118,8 @@ Item {
}
BasicButtonType {
id: buttonContinue
implicitWidth: parent.width
anchors.topMargin: 24
anchors.bottomMargin: 32
@ -125,7 +128,7 @@ Item {
onClicked: function() {
ContainersModel.setCurrentlyInstalledContainerIndex(containers.dockerContainer)
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
goToPage(PageEnum.PageSetupWizardInstalling);
InstallController.install(containers.dockerContainer,
containers.containerDefaultPort,
containers.containerDefaultTransportProto)

View file

@ -11,11 +11,20 @@ import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
Item {
PageType {
id: root
property real progressBarValue: 0
Connections {
target: InstallController
function onInstallationErrorOccurred(errorMessage) {
closePage()
PageController.showErrorMessage(errorMessage)
}
}
SortFilterProxyModel {
id: proxyContainersModel
sourceModel: ContainersModel
@ -100,26 +109,5 @@ Item {
}
}
}
Timer {
id: closePageTimer
interval: 1000
repeat: false
running: false
onTriggered: {
// todo go to root installing page
PageController.goToPage(PageEnum.PageStart)
}
}
Connections {
target: InstallController
function onInstallContainerFinished() {
progressBarValue = 1
closePageTimer.start()
}
}
}
}

View file

@ -13,7 +13,7 @@ import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
Item {
PageType {
id: root
SortFilterProxyModel {
@ -156,7 +156,7 @@ Item {
text: qsTr("Установить")
onClicked: function() {
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
goToPage(PageEnum.PageSetupWizardInstalling);
InstallController.install(dockerContainer, port.textFieldText, transportProtoButtonGroup.currentIndex)
}
}

View file

@ -11,7 +11,7 @@ import "./"
import "../Controls2"
import "../Config"
Item {
PageType {
id: root
SortFilterProxyModel {
@ -86,9 +86,9 @@ Item {
descriptionText: description
buttonImage: "qrc:/images/controls/chevron-right.svg"
onClickedFunc: function() {
clickedFunction: function() {
ContainersModel.setCurrentlyInstalledContainerIndex(proxyContainersModel.mapToSource(index))
PageController.goToPage(PageEnum.PageSetupWizardProtocolSettings)
goToPage(PageEnum.PageSetupWizardProtocolSettings)
}
}

View file

@ -10,9 +10,27 @@ import "../Config"
import "../Controls2/TextTypes"
import "../Components"
Item {
PageType {
id: root
Connections {
target: PageController
function onShowErrorMessage(errorMessage) {
popupErrorMessage.popupErrorMessageText = errorMessage
popupErrorMessage.open()
}
}
Connections {
target: InstallController
function onInstallServerFinished() {
goToStartPage()
// goToPage(PageEnum.PageStart)
}
}
FlickableType {
id: fl
anchors.top: root.top
@ -44,7 +62,7 @@ Item {
Layout.leftMargin: 16
Layout.rightMargin: 16
text: "Бесплатный сервис для создания личного VPN на вашем сервере. Помогаем получать доступ к заблокированному контенту, не раскрывая конфиденциальность даже провайдерам VPN."
text: "Бесплатный сервис для создания личного VPN на вашем сервере. Помогаем получать доступ к заблокированному контенту, не раскрывая конфиденциальность даже провайдерам VPN."
}
BasicButtonType {
@ -76,7 +94,7 @@ Item {
text: qsTr("У меня ничего нет")
onClicked: {
PageController.goToPage(PageEnum.PageTest)
goToPage(PageEnum.PageTest)
}
}
}
@ -85,4 +103,16 @@ Item {
id: connectionTypeSelection
}
}
Item {
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: parent.bottom
implicitHeight: popupErrorMessage.height
PopupType {
id: popupErrorMessage
}
}
}

View file

@ -9,7 +9,7 @@ import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
Item {
PageType {
id: root
FlickableType {
@ -66,7 +66,7 @@ Item {
text: qsTr("Подключиться")
onClicked: function() {
// PageController.goToPage(PageEnum.PageSetupWizardInstalling)
// goToPage(PageEnum.PageSetupWizardInstalling)
}
}
}

View file

@ -9,9 +9,22 @@ import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
Item {
PageType {
id: root
Connections {
target: PageController
function onGoToPageHome() {
tabBar.currentIndex = 0
}
function onShowErrorMessage(errorMessage) {
popupErrorMessage.popupErrorMessageText = errorMessage
popupErrorMessage.open()
}
}
StackLayout {
id: stackLayout
currentIndex: tabBar.currentIndex
@ -24,10 +37,18 @@ Item {
width: parent.width
height: root.height - tabBar.implicitHeight
PageHome {
StackView {
id: homeStackView
initialItem: "PageHome.qml" //PageController.getPagePath(PageEnum.PageSettingsServersList)
}
PageSetupWizardEasy {
Item {
}
StackView {
id: settingsStackView
initialItem: "PageSettingsServersList.qml" //PageController.getPagePath(PageEnum.PageSettingsServersList)
}
}
@ -69,4 +90,16 @@ Item {
cursorShape: Qt.PointingHandCursor
enabled: false
}
Item {
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: parent.bottom
implicitHeight: popupErrorMessage.height
PopupType {
id: popupErrorMessage
}
}
}

View file

@ -27,9 +27,9 @@ Window {
color: "#0E0E11"
}
PageLoader {
id: pageLoader
StackView {
anchors.fill: parent
focus: true
initialItem: PageController.getInitialPage()
}
}