added PageSettingsAbout, PageSettingsApplication, PageSettingsBackup, PageSettingsConnection, PageSettingsDns

- added SettingsController
This commit is contained in:
vladimir.kuznetsov 2023-06-16 13:43:55 +09:00
parent be7386f0d7
commit 7b14ad9616
28 changed files with 1054 additions and 63 deletions

View file

@ -59,8 +59,6 @@ Item {
Layout.fillWidth: true
implicitHeight: 74
rootButtonBorderWidth: 0
descriptionText: qsTr("Hash")
headerText: qsTr("Hash")
@ -97,8 +95,6 @@ Item {
Layout.fillWidth: true
implicitHeight: 74
rootButtonBorderWidth: 0
descriptionText: qsTr("Cipher")
headerText: qsTr("Cipher")

View file

@ -15,8 +15,6 @@ import "../Controls2/TextTypes"
DrawerType {
id: root
property var qrCodes: []
property alias configText: configContent.text
property alias headerText: header.headerText
width: parent.width
@ -120,6 +118,8 @@ DrawerType {
font.weight: Font.Medium
font.family: "PT Root UI VF"
text: ExportController.amneziaCode
wrapMode: Text.Wrap
enabled: false
@ -135,6 +135,8 @@ DrawerType {
Layout.preferredHeight: width
Layout.topMargin: 20
visible: ExportController.qrCodesCount > 0
color: "white"
Image {
@ -144,22 +146,20 @@ DrawerType {
Timer {
property int idx: 0
interval: 1000
running: qrCodes.length > 0
running: ExportController.qrCodesCount > 0
repeat: true
onTriggered: {
idx++
if (idx >= qrCodes.length) {
if (idx >= ExportController.qrCodesCount) {
idx = 0
}
parent.source = qrCodes[idx]
parent.source = ExportController.qrCodes[idx]
}
}
Behavior on source {
PropertyAnimation { duration: 200 }
}
visible: qrCodes.length > 0
}
}

View file

@ -15,13 +15,15 @@ Item {
property string headerText
property string headerBackButtonImage
property var onRootButtonClicked
property var rootButtonClickedFunction
property string rootButtonImage: "qrc:/images/controls/chevron-down.svg"
property string rootButtonImageColor: "#494B50"
property string rootButtonDefaultColor: "#1C1D21"
property string rootButtonImageColor: "#D7D8DB"
property string rootButtonBackgroundColor: "#1C1D21"
property int rootButtonMaximumWidth: 0
property string rootButtonBorderColor: "#494B50"
property string rootButtonHoveredBorderColor: "#494B50"
property string rootButtonDefaultBorderColor: "transparent"
property string rootButtonPressedBorderColor: "#D7D8DB"
property int rootButtonBorderWidth: 1
property real drawerHeight: 0.9
@ -32,18 +34,31 @@ Item {
implicitWidth: rootButtonContent.implicitWidth
implicitHeight: rootButtonContent.implicitHeight
onMenuVisibleChanged: {
if (menuVisible) {
rootButtonBackground.border.color = rootButtonPressedBorderColor
rootButtonBackground.border.width = rootButtonBorderWidth
} else {
rootButtonBackground.border.color = rootButtonDefaultBorderColor
rootButtonBackground.border.width = 0
}
}
Rectangle {
id: rootButtonBackground
anchors.fill: rootButtonContent
radius: 16
color: rootButtonDefaultColor
border.color: rootButtonBorderColor
border.width: rootButtonBorderWidth
color: rootButtonBackgroundColor
border.color: rootButtonDefaultBorderColor
border.width: 0
Behavior on border.width {
PropertyAnimation { duration: 200 }
}
Behavior on border.color {
PropertyAnimation { duration: 200 }
}
}
RowLayout {
@ -83,7 +98,6 @@ Item {
}
}
//todo change to image type
ImageButtonType {
Layout.leftMargin: 4
Layout.rightMargin: 16
@ -100,16 +114,22 @@ Item {
hoverEnabled: true
onEntered: {
rootButtonBackground.border.width = rootButtonBorderWidth
if (menu.visible === false) {
rootButtonBackground.border.width = rootButtonBorderWidth
rootButtonBackground.border.color = rootButtonHoveredBorderColor
}
}
onExited: {
rootButtonBackground.border.width = 0
if (menu.visible === false) {
rootButtonBackground.border.width = 0
rootButtonBackground.border.color = rootButtonDefaultBorderColor
}
}
onClicked: {
if (onRootButtonClicked && typeof onRootButtonClicked === "function") {
onRootButtonClicked()
if (rootButtonClickedFunction && typeof rootButtonClickedFunction === "function") {
rootButtonClickedFunction()
} else {
menu.visible = true
}

View file

@ -10,8 +10,10 @@ Button {
property string hoveredColor: Qt.rgba(1, 1, 1, 0.08)
property string defaultColor: "transparent"
property string pressedColor: Qt.rgba(1, 1, 1, 0.12)
property string disableColor: "#2C2D30"
property string imageColor: "#878B91"
property string disableImageColor: "#2C2D30"
implicitWidth: 40
implicitHeight: 40
@ -19,7 +21,11 @@ Button {
hoverEnabled: true
icon.source: image
icon.color: imageColor
icon.color: root.enabled ? imageColor : disableImageColor
Behavior on icon.color {
PropertyAnimation { duration: 200 }
}
background: Rectangle {
id: background
@ -33,6 +39,7 @@ Button {
}
return hovered ? hoveredColor : defaultColor
}
return defaultColor
}
Behavior on color {
PropertyAnimation { duration: 200 }

View file

@ -2,9 +2,13 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import "TextTypes"
Switch {
id: root
property alias descriptionText: description.text
property string checkedIndicatorColor: "#412102"
property string defaultIndicatorColor: "transparent"
property string checkedIndicatorBorderColor: "#412102"
@ -16,10 +20,18 @@ Switch {
property string hoveredIndicatorBackgroundColor: Qt.rgba(1, 1, 1, 0.08)
property string defaultIndicatorBackgroundColor: "transparent"
implicitWidth: content.implicitWidth + switcher.implicitWidth
implicitHeight: content.implicitHeight
indicator: Rectangle {
id: switcher
anchors.left: content.right
anchors.verticalCenter: parent.verticalCenter
implicitWidth: 52
implicitHeight: 32
x: content.width - width
radius: 16
color: root.checked ? checkedIndicatorColor : defaultIndicatorColor
border.color: root.checked ? checkedIndicatorBorderColor : defaultIndicatorBorderColor
@ -62,16 +74,23 @@ Switch {
contentItem: ColumnLayout {
id: content
Text {
text: root.text
color: "#D7D8DB"
font.pixelSize: 18
font.weight: 400
font.family: "PT Root UI VF"
anchors.fill: parent
anchors.rightMargin: switcher.implicitWidth
height: 22
ListItemTitleType {
Layout.fillWidth: true
Layout.bottomMargin: 16
text: root.text
}
CaptionTextType {
id: description
Layout.fillWidth: true
color: "#878B91"
visible: text !== ""
}
}

View file

@ -145,14 +145,14 @@ PageType {
rootButtonBorderWidth: 0
rootButtonImageColor: "#0E0E11"
rootButtonMaximumWidth: 150 //todo make it dynamic
rootButtonDefaultColor: "#D7D8DB"
rootButtonBackgroundColor: "#D7D8DB"
text: root.currentContainerName
textColor: "#0E0E11"
headerText: qsTr("Протокол подключения")
headerBackButtonImage: "qrc:/images/controls/arrow-left.svg"
onRootButtonClicked: function() {
rootButtonClickedFunction: function() {
ServersModel.setCurrentlyProcessedServerIndex(serversMenuContent.currentIndex)
ContainersModel.setCurrentlyProcessedServerIndex(serversMenuContent.currentIndex)
containersDropDown.menuVisible = true

View file

@ -58,6 +58,7 @@ PageType {
iconImage: "qrc:/images/controls/radio.svg"
clickedFunction: function() {
goToPage(PageEnum.PageSettingsConnection)
}
}
@ -71,6 +72,7 @@ PageType {
iconImage: "qrc:/images/controls/app.svg"
clickedFunction: function() {
goToPage(PageEnum.PageSettingsApplication)
}
}
@ -84,6 +86,7 @@ PageType {
iconImage: "qrc:/images/controls/save.svg"
clickedFunction: function() {
goToPage(PageEnum.PageSettingsBackup)
}
}
@ -97,6 +100,7 @@ PageType {
iconImage: "qrc:/images/controls/amnezia.svg"
clickedFunction: function() {
goToPage(PageEnum.PageSettingsAbout)
}
}

View file

@ -0,0 +1,207 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0
import "./"
import "../Controls2"
import "../Config"
import "../Controls2/TextTypes"
import "../Components"
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: backButton.bottom
anchors.bottom: root.bottom
contentHeight: content.height
ColumnLayout {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
Image {
id: image
source: "qrc:/images/amneziaBigLogo.png"
Layout.alignment: Qt.AlignCenter
Layout.topMargin: 16
Layout.leftMargin: 16
Layout.rightMargin: 16
Layout.preferredWidth: 344
Layout.preferredHeight: 279
}
Header2TextType {
Layout.fillWidth: true
Layout.topMargin: 16
Layout.leftMargin: 16
Layout.rightMargin: 16
text: qsTr("Support the project with a donation")
horizontalAlignment: Text.AlignHCenter
}
ParagraphTextType {
Layout.fillWidth: true
Layout.topMargin: 16
Layout.leftMargin: 16
Layout.rightMargin: 16
horizontalAlignment: Text.AlignHCenter
height: 20
font.pixelSize: 14
text: qsTr("This is a free and open source application. If you like it, support the developers with a donation.
And if you don't like the app, all the more support it - the donation will be used to improve the app.")
color: "#CCCAC8"
}
BasicButtonType {
Layout.fillWidth: true
Layout.topMargin: 24
Layout.leftMargin: 16
Layout.rightMargin: 16
text: qsTr("Card on Patreon")
onClicked: {
}
}
BasicButtonType {
Layout.fillWidth: true
Layout.topMargin: 8
Layout.leftMargin: 16
Layout.rightMargin: 16
defaultColor: "transparent"
hoveredColor: Qt.rgba(1, 1, 1, 0.08)
pressedColor: Qt.rgba(1, 1, 1, 0.12)
disabledColor: "#878B91"
textColor: "#D7D8DB"
borderWidth: 1
text: qsTr("Show other methods on Github")
onClicked: {
}
}
ParagraphTextType {
Layout.fillWidth: true
Layout.topMargin: 32
Layout.leftMargin: 16
Layout.rightMargin: 16
text: qsTr("Contacts")
}
LabelWithButtonType {
Layout.fillWidth: true
Layout.topMargin: 16
text: qsTr("Telegram group")
descriptionText: qsTr("To discuss features")
buttonImage: "qrc:/images/controls/chevron-right.svg"
iconImage: "qrc:/images/controls/telegram.svg"
clickedFunction: function() {
goToPage(PageEnum.PageSettingsAbout)
}
}
DividerType {}
LabelWithButtonType {
Layout.fillWidth: true
text: qsTr("Mail")
descriptionText: qsTr("For reviews and bug reports")
buttonImage: "qrc:/images/controls/chevron-right.svg"
iconImage: "qrc:/images/controls/mail.svg"
clickedFunction: function() {
goToPage(PageEnum.PageSettingsAbout)
}
}
DividerType {}
LabelWithButtonType {
Layout.fillWidth: true
text: qsTr("Github")
buttonImage: "qrc:/images/controls/chevron-right.svg"
iconImage: "qrc:/images/controls/github.svg"
clickedFunction: function() {
goToPage(PageEnum.PageSettingsAbout)
}
}
DividerType {}
LabelWithButtonType {
Layout.fillWidth: true
text: qsTr("Website")
buttonImage: "qrc:/images/controls/chevron-right.svg"
iconImage: "qrc:/images/controls/amnezia.svg"
clickedFunction: function() {
goToPage(PageEnum.PageSettingsAbout)
}
}
DividerType {}
CaptionTextType {
Layout.fillWidth: true
Layout.topMargin: 40
horizontalAlignment: Text.AlignHCenter
text: SettingsController.getAppVersion()
color: "#878B91"
}
BasicButtonType {
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: 8
Layout.bottomMargin: 16
implicitHeight: 32
defaultColor: "transparent"
hoveredColor: Qt.rgba(1, 1, 1, 0.08)
pressedColor: Qt.rgba(1, 1, 1, 0.12)
disabledColor: "#878B91"
textColor: "#FBB26A"
text: qsTr("Check for updates")
onClicked: {
Qt.openUrlExternally("https://github.com/amnezia-vpn/desktop-client/releases/latest")
}
}
}
}
}

View file

@ -0,0 +1,74 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0
import "./"
import "../Controls2"
import "../Config"
import "../Controls2/TextTypes"
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: backButton.bottom
anchors.bottom: root.bottom
contentHeight: content.height
ColumnLayout {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 16
anchors.rightMargin: 16
spacing: 16
HeaderType {
Layout.fillWidth: true
headerText: qsTr("Application")
}
LabelWithButtonType {
Layout.fillWidth: true
text: qsTr("Language")
buttonImage: "qrc:/images/controls/chevron-right.svg"
clickedFunction: function() {
}
}
DividerType {}
LabelWithButtonType {
Layout.fillWidth: true
text: qsTr("Reset settings and remove all data from the application")
buttonImage: "qrc:/images/controls/chevron-right.svg"
clickedFunction: function() {
}
}
DividerType {}
}
}
}

View file

@ -0,0 +1,184 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0
import "./"
import "../Controls2"
import "../Config"
import "../Controls2/TextTypes"
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: backButton.bottom
anchors.bottom: root.bottom
contentHeight: content.height
ColumnLayout {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 16
anchors.rightMargin: 16
spacing: 16
HeaderType {
Layout.fillWidth: true
headerText: qsTr("Backup")
}
SwitcherType {
Layout.fillWidth: true
Layout.topMargin: 16
text: qsTr("Save logs")
checked: SettingsController.isSaveLogsEnabled()
onCheckedChanged: {
if (checked !== SettingsController.isSaveLogsEnabled()) {
SettingsController.setSaveLogs(checked)
}
}
}
RowLayout {
Layout.fillWidth: true
ColumnLayout {
Layout.alignment: Qt.AlignBaseline
Layout.preferredWidth: root.width / 3
ImageButtonType {
Layout.alignment: Qt.AlignHCenter
implicitWidth: 56
implicitHeight: 56
image: "qrc:/images/controls/folder-open.svg"
onClicked: SettingsController.openLogsFolder()
}
CaptionTextType {
horizontalAlignment: Text.AlignHCenter
Layout.fillWidth: true
text: qsTr("Open folder with logs")
color: "#D7D8DB"
}
}
ColumnLayout {
Layout.alignment: Qt.AlignBaseline
Layout.preferredWidth: root.width / 3
ImageButtonType {
Layout.alignment: Qt.AlignHCenter
implicitWidth: 56
implicitHeight: 56
image: "qrc:/images/controls/save.svg"
onClicked: SettingsController.exportLogsFile()
}
CaptionTextType {
horizontalAlignment: Text.AlignHCenter
Layout.fillWidth: true
text: qsTr("Save logs to file")
color: "#D7D8DB"
}
}
ColumnLayout {
Layout.alignment: Qt.AlignBaseline
Layout.preferredWidth: root.width / 3
ImageButtonType {
Layout.alignment: Qt.AlignHCenter
implicitWidth: 56
implicitHeight: 56
image: "qrc:/images/controls/delete.svg"
onClicked: SettingsController.clearLogs()
}
CaptionTextType {
horizontalAlignment: Text.AlignHCenter
Layout.fillWidth: true
text: qsTr("Clear logs")
color: "#D7D8DB"
}
}
}
ListItemTitleType {
Layout.fillWidth: true
Layout.topMargin: 10
text: qsTr("Configuration backup")
}
CaptionTextType {
Layout.fillWidth: true
Layout.topMargin: -12
text: qsTr("It will help you instantly restore connection settings at the next installation")
color: "#878B91"
}
BasicButtonType {
Layout.fillWidth: true
Layout.topMargin: 14
text: qsTr("Make a backup")
onClicked: {
SettingsController.backupAppConfig()
}
}
BasicButtonType {
Layout.fillWidth: true
Layout.topMargin: -8
defaultColor: "transparent"
hoveredColor: Qt.rgba(1, 1, 1, 0.08)
pressedColor: Qt.rgba(1, 1, 1, 0.12)
disabledColor: "#878B91"
textColor: "#D7D8DB"
borderWidth: 1
text: qsTr("Restore from backup")
onClicked: {
SettingsController.restoreAppConfig()
}
}
}
}
}

View file

@ -0,0 +1,107 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0
import "./"
import "../Controls2"
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: backButton.bottom
anchors.bottom: root.bottom
contentHeight: content.height
ColumnLayout {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
spacing: 16
HeaderType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
headerText: qsTr("Connection")
}
SwitcherType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
text: qsTr("Use AmnesiaDNS if installed on the server")
descriptionText: qsTr("Internal IP address 172.29.172.254")
checked: SettingsController.isAmneziaDnsEnabled()
onCheckedChanged: {
if (checked !== SettingsController.isAmneziaDnsEnabled()) {
SettingsController.setAmneziaDns(checked)
}
}
}
DividerType {}
LabelWithButtonType {
Layout.fillWidth: true
text: qsTr("DNS servers")
descriptionText: qsTr("If AmneziaDNS is not used or installed")
buttonImage: "qrc:/images/controls/chevron-right.svg"
clickedFunction: function() {
goToPage(PageEnum.PageSettingsDns)
}
}
DividerType {}
LabelWithButtonType {
Layout.fillWidth: true
text: qsTr("Split site tunneling")
descriptionText: qsTr("Allows you to connect to some sites through a secure connection, and to others bypassing it")
buttonImage: "qrc:/images/controls/chevron-right.svg"
clickedFunction: function() {
}
}
DividerType {}
LabelWithButtonType {
Layout.fillWidth: true
text: qsTr("Separate application tunneling")
descriptionText: qsTr("Allows you to use the VPN only for certain applications")
buttonImage: "qrc:/images/controls/chevron-right.svg"
clickedFunction: function() {
}
}
DividerType {}
}
}
}

View file

@ -0,0 +1,87 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0
import "./"
import "../Controls2"
import "../Config"
import "../Controls2/TextTypes"
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: backButton.bottom
anchors.bottom: root.bottom
contentHeight: content.height
ColumnLayout {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 16
anchors.rightMargin: 16
spacing: 16
HeaderType {
Layout.fillWidth: true
headerText: qsTr("DNS servers")
}
ParagraphTextType {
text: qsTr("If AmneziaDNS is not used or installed")
}
TextFieldWithHeaderType {
id: primaryDns
Layout.fillWidth: true
headerText: "Primary DNS"
textFieldText: SettingsController.primaryDns
}
TextFieldWithHeaderType {
id: secondaryDns
Layout.fillWidth: true
headerText: "Secondary DNS"
textFieldText: SettingsController.secondaryDns
}
BasicButtonType {
Layout.fillWidth: true
text: qsTr("Save")
onClicked: function() {
if (primaryDns.textFieldText !== SettingsController.primaryDns) {
SettingsController.primaryDns = primaryDns.textFieldText
}
if (secondaryDns.textFieldText !== SettingsController.secondaryDns) {
SettingsController.secondaryDns = secondaryDns.textFieldText
}
}
}
}
}
}

View file

@ -25,9 +25,6 @@ PageType {
} else {
ExportController.generateConnectionConfig()
}
shareConnectionDrawer.configText = ExportController.getAmneziaCode()
shareConnectionDrawer.qrCodes = ExportController.getQrCodes()
}
}
@ -125,7 +122,8 @@ PageType {
ParagraphTextType {
Layout.fillWidth: true
text: qsTr("VPN access without the ability to manage the server")
text: accessTypeSelector.currentIndex === 0 ? qsTr("VPN access without the ability to manage the server") :
qsTr("Full access to server")
color: "#878B91"
}
@ -137,7 +135,6 @@ PageType {
implicitHeight: 74
rootButtonBorderWidth: 0
drawerHeight: 0.4375
descriptionText: qsTr("Server and service")
@ -234,6 +231,7 @@ PageType {
clickedFunction: function () {
serverSelector.text += ", " + selectedText
shareConnectionDrawer.headerText = qsTr("Connection to ") + serverSelector.text
ContainersModel.setCurrentlyProcessedContainerIndex(proxyContainersModel.mapToSource(currentIndex))
protocolSelector.visible = false
serverSelector.menuVisible = false
@ -244,6 +242,7 @@ PageType {
Component.onCompleted: {
serverSelector.text += ", " + selectedText
shareConnectionDrawer.headerText = qsTr("Connection to ") + serverSelector.text
ContainersModel.setCurrentlyProcessedContainerIndex(proxyContainersModel.mapToSource(currentIndex))
fillConnectionTypeModel()
}
@ -273,7 +272,6 @@ PageType {
implicitHeight: 74
rootButtonBorderWidth: 0
drawerHeight: 0.4375
visible: accessTypeSelector.currentIndex === 0