added PageLoader and pageController
This commit is contained in:
parent
116fa6777b
commit
03a0e2084a
27 changed files with 265 additions and 193 deletions
|
|
@ -7,15 +7,8 @@ import ConnectionState 1.0
|
|||
Button {
|
||||
id: root
|
||||
|
||||
property var isConnected: ConnectionController.isConnected
|
||||
|
||||
text: "Подключиться"
|
||||
|
||||
// implicitHeight: 190
|
||||
// implicitWidth: 190
|
||||
|
||||
// color: "transparent"
|
||||
|
||||
background: Image {
|
||||
id: border
|
||||
|
||||
|
|
@ -54,56 +47,55 @@ Button {
|
|||
|
||||
onClicked: {
|
||||
ConnectionController.onConnectionButtonClicked()
|
||||
console.log(connectionProccess.from)
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: ConnectionController
|
||||
function onConnectionStateChanged(state) {
|
||||
switch(state) {
|
||||
case ConnectionState.Unknown: {
|
||||
console.log("Unknown")
|
||||
break
|
||||
}
|
||||
case ConnectionState.Disconnected: {
|
||||
console.log("Disconnected")
|
||||
connectionProccess.running = false
|
||||
root.text = "Подключиться"
|
||||
break
|
||||
}
|
||||
case ConnectionState.Preparing: {
|
||||
console.log("Preparing")
|
||||
break
|
||||
}
|
||||
case ConnectionState.Connecting: {
|
||||
console.log("Connecting")
|
||||
connectionProccess.running = true
|
||||
root.text = "Подключение..."
|
||||
break
|
||||
}
|
||||
case ConnectionState.Connected: {
|
||||
console.log("Connected")
|
||||
connectionProccess.running = false
|
||||
root.text = "Подключено"
|
||||
break
|
||||
}
|
||||
case ConnectionState.Disconnecting: {
|
||||
console.log("Disconnecting")
|
||||
connectionProccess.running = true
|
||||
root.text = "Отключение..."
|
||||
break
|
||||
}
|
||||
case ConnectionState.Reconnecting: {
|
||||
console.log("Reconnecting")
|
||||
connectionProccess.running = true
|
||||
root.text = "Переподключение..."
|
||||
break
|
||||
}
|
||||
case ConnectionState.Error: {
|
||||
console.log("Error")
|
||||
connectionProccess.running = false
|
||||
break
|
||||
}
|
||||
case ConnectionState.Unknown: {
|
||||
console.log("Unknown")
|
||||
break
|
||||
}
|
||||
case ConnectionState.Disconnected: {
|
||||
console.log("Disconnected")
|
||||
connectionProccess.running = false
|
||||
root.text = "Подключиться"
|
||||
break
|
||||
}
|
||||
case ConnectionState.Preparing: {
|
||||
console.log("Preparing")
|
||||
break
|
||||
}
|
||||
case ConnectionState.Connecting: {
|
||||
console.log("Connecting")
|
||||
connectionProccess.running = true
|
||||
root.text = "Подключение..."
|
||||
break
|
||||
}
|
||||
case ConnectionState.Connected: {
|
||||
console.log("Connected")
|
||||
connectionProccess.running = false
|
||||
root.text = "Подключено"
|
||||
break
|
||||
}
|
||||
case ConnectionState.Disconnecting: {
|
||||
console.log("Disconnecting")
|
||||
connectionProccess.running = true
|
||||
root.text = "Отключение..."
|
||||
break
|
||||
}
|
||||
case ConnectionState.Reconnecting: {
|
||||
console.log("Reconnecting")
|
||||
connectionProccess.running = true
|
||||
root.text = "Переподключение..."
|
||||
break
|
||||
}
|
||||
case ConnectionState.Error: {
|
||||
console.log("Error")
|
||||
connectionProccess.running = false
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,6 +154,10 @@ Item {
|
|||
anchors.topMargin: 16
|
||||
anchors.leftMargin: 16
|
||||
anchors.rightMargin: 16
|
||||
|
||||
backButtonFunction: function() {
|
||||
root.menuVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
FlickableType {
|
||||
|
|
@ -190,6 +194,7 @@ Item {
|
|||
id: loader
|
||||
sourceComponent: root.menuDelegate
|
||||
property QtObject modelData: model
|
||||
property var delegateIndex: index
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ Item {
|
|||
onClicked: {
|
||||
if (backButtonFunction && typeof backButtonFunction === "function") {
|
||||
backButtonFunction()
|
||||
} else {
|
||||
PageController.closePage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ Item {
|
|||
onClicked: {
|
||||
if (backButtonFunction && typeof backButtonFunction === "function") {
|
||||
backButtonFunction()
|
||||
} else {
|
||||
PageController.closePage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,5 +3,35 @@ import QtQuick.Controls
|
|||
|
||||
StackView {
|
||||
id: stackView
|
||||
initialItem: "PageSetupWizardStart"
|
||||
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,15 +8,13 @@ import PageEnum 1.0
|
|||
import ProtocolEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Controls2/TextTypes"
|
||||
import "../Config"
|
||||
import "../Components"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageHome
|
||||
|
||||
property string defaultColor: "#1C1D21"
|
||||
|
||||
|
|
@ -143,10 +141,6 @@ PageBase {
|
|||
ValueFilter {
|
||||
roleName: "serviceType"
|
||||
value: ProtocolEnum.Vpn
|
||||
},
|
||||
ValueFilter {
|
||||
roleName: "isInstalled"
|
||||
value: true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -196,6 +190,19 @@ PageBase {
|
|||
indicator: Rectangle {
|
||||
anchors.fill: parent
|
||||
color: containerRadioButton.hovered ? "#2C2D30" : "#1C1D21"
|
||||
|
||||
Behavior on color {
|
||||
PropertyAnimation { duration: 200 }
|
||||
}
|
||||
}
|
||||
|
||||
checkable: {
|
||||
if (modelData !== null) {
|
||||
if (modelData.isInstalled) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
|
|
@ -207,10 +214,33 @@ PageBase {
|
|||
|
||||
z: 1
|
||||
|
||||
Image {
|
||||
source: {
|
||||
if (modelData !== null) {
|
||||
if (modelData.isInstalled) {
|
||||
return "qrc:/images/controls/check.svg"
|
||||
}
|
||||
}
|
||||
return "qrc:/images/controls/download.svg"
|
||||
}
|
||||
visible: {
|
||||
if (modelData !== null) {
|
||||
if (modelData.isInstalled) {
|
||||
return containerRadioButton.checked
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
width: 24
|
||||
height: 24
|
||||
|
||||
Layout.rightMargin: 8
|
||||
}
|
||||
|
||||
Text {
|
||||
id: containerRadioButtonText
|
||||
|
||||
// todo remove dirty hack?
|
||||
text: {
|
||||
if (modelData !== null) {
|
||||
return modelData.name
|
||||
|
|
@ -228,22 +258,26 @@ PageBase {
|
|||
Layout.topMargin: 20
|
||||
Layout.bottomMargin: 20
|
||||
}
|
||||
|
||||
Image {
|
||||
source: "qrc:/images/controls/check.svg"
|
||||
visible: containerRadioButton.checked
|
||||
width: 24
|
||||
height: 24
|
||||
|
||||
Layout.rightMargin: 8
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
modelData.isDefault = true
|
||||
if (checked) {
|
||||
modelData.isDefault = true
|
||||
|
||||
containersDropDown.text = containerRadioButtonText.text
|
||||
containersDropDown.menuVisible = false
|
||||
containersDropDown.text = containerRadioButtonText.text
|
||||
containersDropDown.menuVisible = false
|
||||
} else {
|
||||
ContainersModel.setCurrentlyInstalledContainerIndex(proxyContainersModel.mapToSource(delegateIndex))
|
||||
PageController.goToPage(PageEnum.PageSetupWizardProtocolSettings)
|
||||
containersDropDown.menuVisible = false
|
||||
menu.visible = false
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: containerRadioButton
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -326,6 +360,10 @@ PageBase {
|
|||
indicator: Rectangle {
|
||||
anchors.fill: parent
|
||||
color: serverRadioButton.hovered ? "#2C2D30" : "#1C1D21"
|
||||
|
||||
Behavior on color {
|
||||
PropertyAnimation { duration: 200 }
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
|
|
@ -370,6 +408,12 @@ PageBase {
|
|||
ServersModel.setDefaultServerIndex(index)
|
||||
ContainersModel.setSelectedServerIndex(index)
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: serverRadioButton
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,14 +6,12 @@ import QtQuick.Dialogs
|
|||
import PageEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Controls2/TextTypes"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageSetupWizardInstalling
|
||||
|
||||
FlickableType {
|
||||
id: fl
|
||||
|
|
@ -100,7 +98,7 @@ PageBase {
|
|||
iconImage: "qrc:/images/controls/text-cursor.svg"
|
||||
|
||||
onClickedFunc: function() {
|
||||
UiLogic.goToPage(PageEnum.PageSetupWizardTextKey)
|
||||
PageController.goToPage(PageEnum.PageSetupWizardTextKey)
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
|
|
|
|||
|
|
@ -5,13 +5,11 @@ import QtQuick.Layouts
|
|||
import PageEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageSetupWizardCredentials
|
||||
|
||||
FlickableType {
|
||||
id: fl
|
||||
|
|
@ -61,7 +59,7 @@ PageBase {
|
|||
text: qsTr("Настроить сервер простым образом")
|
||||
|
||||
onClicked: function() {
|
||||
UiLogic.goToPage(PageEnum.PageSetupWizardEasy)
|
||||
PageController.goToPage(PageEnum.PageSetupWizardEasy)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +77,7 @@ PageBase {
|
|||
text: qsTr("Выбрать протокол для установки")
|
||||
|
||||
onClicked: function() {
|
||||
UiLogic.goToPage(PageEnum.PageSetupWizardProtocols)
|
||||
PageController.goToPage(PageEnum.PageSetupWizardProtocols)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,13 +5,11 @@ import QtQuick.Layouts
|
|||
import PageEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageSetupWizardEasy
|
||||
|
||||
FlickableType {
|
||||
id: fl
|
||||
|
|
|
|||
|
|
@ -5,14 +5,12 @@ import QtQuick.Layouts
|
|||
import PageEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Controls2/TextTypes"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageSetupWizardInstalling
|
||||
|
||||
FlickableType {
|
||||
id: fl
|
||||
|
|
|
|||
|
|
@ -5,14 +5,12 @@ import QtQuick.Layouts
|
|||
import PageEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Controls2/TextTypes"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageSetupWizardProtocolSettings
|
||||
|
||||
FlickableType {
|
||||
id: fl
|
||||
|
|
@ -90,7 +88,7 @@ PageBase {
|
|||
text: qsTr("Установить")
|
||||
|
||||
onClicked: function() {
|
||||
UiLogic.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,13 +8,11 @@ import PageEnum 1.0
|
|||
import ProtocolEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageSetupWizardProtocols
|
||||
|
||||
SortFilterProxyModel {
|
||||
id: proxyContainersModel
|
||||
|
|
@ -89,7 +87,7 @@ PageBase {
|
|||
|
||||
onClickedFunc: function() {
|
||||
ContainersModel.setCurrentlyInstalledContainerIndex(proxyContainersModel.mapToSource(index))
|
||||
UiLogic.goToPage(PageEnum.PageSetupWizardProtocolSettings)
|
||||
PageController.goToPage(PageEnum.PageSetupWizardProtocolSettings)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,14 +5,12 @@ import QtQuick.Layouts
|
|||
import PageEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Config"
|
||||
import "../Controls2/TextTypes"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageSetupWizardStart
|
||||
|
||||
FlickableType {
|
||||
id: fl
|
||||
|
|
@ -77,7 +75,7 @@ PageBase {
|
|||
text: qsTr("У меня ничего нет")
|
||||
|
||||
onClicked: {
|
||||
UiLogic.goToPage(PageEnum.PageTest)
|
||||
PageController.goToPage(PageEnum.PageTest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -132,7 +130,7 @@ PageBase {
|
|||
buttonImage: "qrc:/images/controls/chevron-right.svg"
|
||||
|
||||
onClickedFunc: function() {
|
||||
UiLogic.goToPage(PageEnum.PageSetupWizardCredentials)
|
||||
PageController.goToPage(PageEnum.PageSetupWizardCredentials)
|
||||
drawer.visible = false
|
||||
}
|
||||
}
|
||||
|
|
@ -148,7 +146,7 @@ PageBase {
|
|||
buttonImage: "qrc:/images/controls/chevron-right.svg"
|
||||
|
||||
onClickedFunc: function() {
|
||||
UiLogic.goToPage(PageEnum.PageSetupWizardConfigSource)
|
||||
PageController.goToPage(PageEnum.PageSetupWizardConfigSource)
|
||||
drawer.visible = false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,14 +5,12 @@ import QtQuick.Layouts
|
|||
import PageEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Controls2/TextTypes"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageSetupWizardInstalling
|
||||
|
||||
FlickableType {
|
||||
id: fl
|
||||
|
|
@ -68,7 +66,7 @@ PageBase {
|
|||
text: qsTr("Подключиться")
|
||||
|
||||
onClicked: function() {
|
||||
// UiLogic.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||
// PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,14 +5,12 @@ import QtQuick.Layouts
|
|||
import PageEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Controls2/TextTypes"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageStart
|
||||
|
||||
StackLayout {
|
||||
id: stackLayout
|
||||
|
|
|
|||
|
|
@ -4,15 +4,12 @@ import QtQuick.Layouts
|
|||
import PageEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Config"
|
||||
import "../Controls2/TextTypes"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.Test
|
||||
logic: ViewConfigLogic
|
||||
|
||||
ColumnLayout {
|
||||
id: content
|
||||
|
|
|
|||
|
|
@ -22,83 +22,14 @@ Window {
|
|||
|
||||
title: "AmneziaVPN"
|
||||
|
||||
function gotoPage(page, reset, slide) {
|
||||
if (pageStackView.depth > 0) {
|
||||
pageStackView.currentItem.deactivated()
|
||||
}
|
||||
|
||||
if (slide) {
|
||||
pageStackView.push(UiLogic.pageEnumToString(page), {}, StackView.PushTransition)
|
||||
} else {
|
||||
pageStackView.push(UiLogic.pageEnumToString(page), {}, StackView.Immediate)
|
||||
}
|
||||
|
||||
pageStackView.currentItem.activated(reset)
|
||||
}
|
||||
|
||||
function closePage() {
|
||||
if (pageStackView.depth <= 1) {
|
||||
return
|
||||
}
|
||||
pageStackView.currentItem.deactivated()
|
||||
pageStackView.pop()
|
||||
}
|
||||
|
||||
function setStartPage(page, slide) {
|
||||
if (pageStackView.depth > 0) {
|
||||
pageStackView.currentItem.deactivated()
|
||||
}
|
||||
|
||||
pageStackView.clear()
|
||||
if (slide) {
|
||||
pageStackView.push(UiLogic.pageEnumToString(page), {}, StackView.PushTransition)
|
||||
} else {
|
||||
pageStackView.push(UiLogic.pageEnumToString(page), {}, StackView.Immediate)
|
||||
}
|
||||
if (page === PageEnum.Start) {
|
||||
UiLogic.pushButtonBackFromStartVisible = !pageStackView.empty
|
||||
UiLogic.onUpdatePage();
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "#0E0E11"
|
||||
}
|
||||
|
||||
StackView {
|
||||
id: pageStackView
|
||||
PageLoader {
|
||||
id: pageLoader
|
||||
anchors.fill: parent
|
||||
focus: true
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: UiLogic
|
||||
function onGoToPage(page, reset, slide) {
|
||||
root.gotoPage(page, reset, slide)
|
||||
}
|
||||
|
||||
function onClosePage() {
|
||||
root.closePage()
|
||||
}
|
||||
|
||||
function onSetStartPage(page, slide) {
|
||||
root.setStartPage(page, slide)
|
||||
}
|
||||
|
||||
function onShow() {
|
||||
root.show()
|
||||
UiLogic.initializeUiLogic()
|
||||
}
|
||||
|
||||
function onHide() {
|
||||
root.hide()
|
||||
}
|
||||
|
||||
function onRaise() {
|
||||
root.show()
|
||||
root.raise()
|
||||
root.requestActivate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue