moved the platform-specific android code for the new ui

This commit is contained in:
vladimir.kuznetsov 2023-07-24 16:31:04 +09:00
parent 5b8a0881b7
commit 0a1359ed16
31 changed files with 854 additions and 764 deletions

View file

@ -54,10 +54,10 @@ DrawerType {
Layout.fillWidth: true
Layout.topMargin: 16
text: qsTr("Save connection code")
text: Qt.platform.os === "android" ? qsTr("Share") : qsTr("Save connection code")
onClicked: {
ExportController.saveFile()
Qt.platform.os === "android" ? ExportController.shareFile() : ExportController.saveFile()
}
}

View file

@ -26,7 +26,7 @@ CheckBox {
hoverEnabled: true
indicator: Rectangle {
id: checkBoxBackground
id: background
anchors.verticalCenter: parent.verticalCenter
@ -57,7 +57,6 @@ CheckBox {
radius: 4
Image {
id: indicator
anchors.centerIn: parent
source: root.pressed ? imageSource : root.checked ? imageSource : ""
@ -71,31 +70,38 @@ CheckBox {
}
}
contentItem: ColumnLayout {
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 8 + checkBoxBackground.width
contentItem: Item {
implicitWidth: content.implicitWidth
implicitHeight: content.implicitHeight
spacing: 4
anchors.fill: parent
anchors.leftMargin: 8 + background.width
ListItemTitleType {
Layout.fillWidth: true
// Layout.topMargin: 16
// Layout.bottomMargin: description.visible ? 0 : 16
ColumnLayout {
id: content
text: root.text
}
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
CaptionTextType {
id: description
spacing: 4
Layout.fillWidth: true
Layout.bottomMargin: 16
ListItemTitleType {
Layout.fillWidth: true
text: root.descriptionText
color: "#878b91"
text: root.text
}
visible: root.descriptionText !== ""
CaptionTextType {
id: description
Layout.fillWidth: true
text: root.descriptionText
color: "#878b91"
visible: root.descriptionText !== ""
}
}
}

View file

@ -20,7 +20,6 @@ Item {
if (root.stackView.depth <= 1) {
return
}
root.stackView.pop()
}

View file

@ -85,44 +85,50 @@ RadioButton {
}
}
contentItem: ColumnLayout {
id: content
anchors.left: parent.left
anchors.right: parent.right
contentItem: Item {
implicitWidth: content.implicitWidth
implicitHeight: content.implicitHeight
anchors.fill: parent
anchors.leftMargin: 8 + background.width
spacing: 4
ColumnLayout {
id: content
ListItemTitleType {
text: root.text
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
color: {
if (root.checked) {
return selectedTextColor
spacing: 4
ListItemTitleType {
text: root.text
color: {
if (root.checked) {
return selectedTextColor
}
return textColor
}
Layout.fillWidth: true
Behavior on color {
PropertyAnimation { duration: 200 }
}
return textColor
}
Layout.fillWidth: true
Layout.topMargin: 16
Layout.bottomMargin: description.visible ? 0 : 16
CaptionTextType {
id: description
Behavior on color {
PropertyAnimation { duration: 200 }
color: "#878B91"
text: root.descriptionText
visible: root.descriptionText !== ""
Layout.fillWidth: true
}
}
CaptionTextType {
id: description
color: "#878B91"
text: root.descriptionText
visible: root.descriptionText !== ""
Layout.fillWidth: true
Layout.bottomMargin: 16
}
}
MouseArea {

View file

@ -43,8 +43,8 @@ PageType {
Layout.topMargin: 16
Layout.leftMargin: 16
Layout.rightMargin: 16
Layout.preferredWidth: 344
Layout.preferredHeight: 279
Layout.preferredWidth: 291
Layout.preferredHeight: 224
}
Header2TextType {
@ -100,7 +100,7 @@ And if you don't like the app, all the more support it - the donation will be us
text: qsTr("Show other methods on Github")
onClicked: Qt.openUrlExternally("https://github.com/amnezia-vpn/amnezia-client")
onClicked: Qt.openUrlExternally("https://github.com/amnezia-vpn/amnezia-client#donate")
}
ParagraphTextType {

View file

@ -61,16 +61,18 @@ PageType {
leftImageSource: "qrc:/images/controls/folder-open.svg"
clickedFunction: function() {
onClicked: fileDialog.open()
// onClicked: fileDialog.open()
ImportController.extractConfigFromFile()
goToPage(PageEnum.PageSetupWizardViewConfig)
}
FileDialog {
id: fileDialog
onAccepted: {
ImportController.extractConfigFromFile(selectedFile)
goToPage(PageEnum.PageSetupWizardViewConfig)
}
}
// FileDialog {
// id: fileDialog
// onAccepted: {
// ImportController.extractConfigFromFile(selectedFile)
// goToPage(PageEnum.PageSetupWizardViewConfig)
// }
// }
}
DividerType {}
@ -84,6 +86,8 @@ PageType {
leftImageSource: "qrc:/images/controls/qr-code.svg"
clickedFunction: function() {
ImportController.extractConfigFromQr()
// goToPage(PageEnum.PageSetupWizardQrReader)
}
}

View file

@ -0,0 +1,52 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Dialogs
import PageEnum 1.0
import QRCodeReader 1.0
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
PageType {
id: root
ColumnLayout {
anchors.fill: parent
spacing: 0
BackButtonType {
Layout.topMargin: 20
}
ParagraphTextType {
Layout.fillWidth: true
text: qsTr("Point the camera at the QR code and hold for a couple of seconds.")
}
ProgressBarType {
}
Item {
Layout.fillHeight: true
Layout.fillWidth: true
QRCodeReader {
id: qrCodeReader
Component.onCompleted: {
qrCodeReader.setCameraSize(Qt.rect(parent.x,
parent.y,
parent.width,
parent.height))
qrCodeReader.startReading()
}
}
}
}
}

View file

@ -20,6 +20,10 @@ PageType {
popupErrorMessage.popupErrorMessageText = errorMessage
popupErrorMessage.open()
}
function onGoToPageViewConfig() {
goToPage(PageEnum.PageSetupWizardViewConfig)
}
}
FlickableType {

View file

@ -18,7 +18,7 @@ PageType {
enum ConfigType {
AmneziaConnection,
AmenziaFullAccess,
AmneziaFullAccess,
OpenVpn,
WireGuard
}
@ -33,7 +33,14 @@ PageType {
switch (type) {
case PageShare.ConfigType.AmneziaConnection: ExportController.generateConnectionConfig(); break;
case PageShare.ConfigType.AmenziaFullAccess: ExportController.generateFullAccessConfig(); break;
case PageShare.ConfigType.AmneziaFullAccess: {
if (Qt.platform.os === "android") {
ExportController.generateFullAccessConfigAndroid();
} else {
ExportController.generateFullAccessConfig();
}
break;
}
case PageShare.ConfigType.OpenVpn: ExportController.generateOpenVpnConfig(); break;
case PageShare.ConfigType.WireGuard: ExportController.generateWireGuardConfig(); break;
}
@ -48,6 +55,8 @@ PageType {
}
}
property string fullConfigServerSelectorText
property string connectionServerSelectorText
property bool showContent: false
property bool shareButtonEnabled: false
property list<QtObject> connectionTypesModel: [
@ -118,6 +127,7 @@ PageType {
onClicked: {
accessTypeSelector.currentIndex = 0
serverSelector.text = root.connectionServerSelectorText
}
}
@ -129,6 +139,7 @@ PageType {
onClicked: {
accessTypeSelector.currentIndex = 1
serverSelector.text = root.fullConfigServerSelectorText
}
}
}
@ -176,14 +187,24 @@ PageType {
currentIndex: 0
clickedFunction: function() {
serverSelector.text = selectedText
ServersModel.currentlyProcessedIndex = currentIndex
protocolSelector.visible = true
root.shareButtonEnabled = false
handler()
if (accessTypeSelector.currentIndex === 0) {
protocolSelector.visible = true
root.shareButtonEnabled = false
} else {
serverSelector.menuVisible = false
}
}
Component.onCompleted: {
handler()
}
function handler() {
serverSelector.text = selectedText
root.fullConfigServerSelectorText = selectedText
root.connectionServerSelectorText = selectedText
ServersModel.currentlyProcessedIndex = currentIndex
}
}
@ -260,7 +281,9 @@ PageType {
}
Component.onCompleted: {
handler()
if (accessTypeSelector.currentIndex === 0) {
handler()
}
}
function handler() {
@ -272,6 +295,8 @@ PageType {
}
serverSelector.text += ", " + selectedText
root.connectionServerSelectorText = serverSelector.text
shareConnectionDrawer.headerText = qsTr("Connection to ") + serverSelector.text
shareConnectionDrawer.configContentHeaderText = qsTr("File with connection settings to ") + serverSelector.text
ContainersModel.setCurrentlyProcessedContainerIndex(proxyContainersModel.mapToSource(currentIndex))

View file

@ -25,6 +25,11 @@ PageType {
tabBarStackView.goToTabBarPage(PageController.getPagePath(PageEnum.PageSettings))
}
function onGoToPageViewConfig() {
var pagePath = PageController.getPagePath(PageEnum.PageSetupWizardViewConfig)
tabBarStackView.push(pagePath, { "objectName" : pagePath }, StackView.PushTransition)
}
function onShowErrorMessage(errorMessage) {
popupErrorMessage.popupErrorMessageText = errorMessage
popupErrorMessage.open()
@ -35,6 +40,13 @@ PageType {
tabBarStackView.enabled = !visible
tabBar.enabled = !visible
}
function onClosePage() {
if (tabBarStackView.depth <= 1) {
return
}
tabBarStackView.pop()
}
}
StackViewType {

View file

@ -1,282 +0,0 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0
import "./"
import "../Controls2"
import "../Config"
import "../Controls2/TextTypes"
Item {
id: root
ColumnLayout {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
HeaderType {
id: header
Layout.rightMargin: 16
Layout.leftMargin: 16
Layout.topMargin: 20
Layout.bottomMargin: 32
Layout.fillWidth: true
backButtonImage: "qrc:/images/controls/arrow-left.svg"
headerText: "Server 1"
descriptionText: "root 192.168.111.111"
}
Item {
Layout.fillWidth: true
TabBar {
id: tabBar
anchors {
top: parent.top
right: parent.right
left: parent.left
}
background: Rectangle {
color: "transparent"
}
TabButtonType {
id: bb
isSelected: tabBar.currentIndex === 0
text: qsTr("Протоколы")
}
TabButtonType {
isSelected: tabBar.currentIndex === 1
text: qsTr("Сервисы")
}
TabButtonType {
isSelected: tabBar.currentIndex === 2
text: qsTr("Данные")
}
}
StackLayout {
id: stackLayout
currentIndex: tabBar.currentIndex
anchors.top: tabBar.bottom
anchors.topMargin: 16
width: parent.width
height: root.height - header.implicitHeight - tabBar.implicitHeight - 100
Item {
id: protocolsTab
FlickableType {
anchors.top: parent.top
anchors.bottom: parent.bottom
contentHeight: protocolsTabContent.height
ColumnLayout {
id: protocolsTabContent
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
BasicButtonType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
text: qsTr("Forget this server")
}
BasicButtonType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
defaultColor: "transparent"
hoveredColor: Qt.rgba(255, 255, 255, 0.08)
pressedColor: Qt.rgba(255, 255, 255, 0.12)
disabledColor: "#878B91"
textColor: "#D7D8DB"
borderWidth: 1
text: qsTr("Forget this server")
}
TextFieldWithHeaderType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
headerText: "Server IP adress [:port]"
}
LabelWithButtonType {
id: ip
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
text: "IP, логин и пароль от сервера"
rightImageSource: "qrc:/images/controls/chevron-right.svg"
}
Rectangle {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
height: 1
color: "#2C2D30"
}
LabelWithButtonType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
text: "QR-код, ключ или файл настроек"
rightImageSource: "qrc:/images/controls/chevron-right.svg"
}
Rectangle {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
height: 1
color: "#2C2D30"
}
CardType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
headerText: "Высокий"
bodyText: "Многие иностранные сайты и VPN-провайдеры заблокированы"
footerText: "футер"
}
CardType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
headerText: "Высокий"
bodyText: "Многие иностранные сайты и VPN-провайдеры заблокированы"
footerText: "футер"
}
DropDownType {
Layout.fillWidth: true
text: "IP, логин и пароль от сервера"
descriptionText: "IP, логин и пароль от сервера"
menuModel: [
qsTr("SHA512"),
qsTr("SHA384"),
qsTr("SHA256"),
qsTr("SHA3-512"),
qsTr("SHA3-384"),
qsTr("SHA3-256"),
qsTr("whirlpool"),
qsTr("BLAKE2b512"),
qsTr("BLAKE2s256"),
qsTr("SHA1")
]
}
}
}
}
Item {
id: servicesTab
FlickableType {
anchors.top: parent.top
anchors.bottom: parent.bottom
contentHeight: servicesTabContent.height
ColumnLayout {
id: servicesTabContent
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
CheckBoxType {
Layout.leftMargin: 16
Layout.rightMargin: 16
Layout.fillWidth: true
text: qsTr("Auto-negotiate encryption")
}
CheckBoxType {
Layout.leftMargin: 16
Layout.rightMargin: 16
Layout.fillWidth: true
text: qsTr("Auto-negotiate encryption")
descriptionText: qsTr("Auto-negotiate encryption")
}
Rectangle {
implicitWidth: buttonGroup.implicitWidth
implicitHeight: buttonGroup.implicitHeight
Layout.leftMargin: 16
Layout.rightMargin: 16
color: "#1C1D21"
radius: 16
RowLayout {
id: buttonGroup
spacing: 0
HorizontalRadioButton {
implicitWidth: (root.width - 32) / 2
text: "UDP"
}
HorizontalRadioButton {
implicitWidth: (root.width - 32) / 2
text: "TCP"
}
}
}
VerticalRadioButton {
text: "Раздельное туннелирование"
descriptionText: "Позволяет подключаться к одним сайтам через защищенное соединение, а к другим в обход него"
checked: true
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
}
VerticalRadioButton {
text: "Раздельное туннелирование"
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
}
SwitcherType {
text: "Auto-negotiate encryption"
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
}
}
}
}
}
}
}
}

View file

@ -18,10 +18,9 @@ Window {
color: "#0E0E11"
// todo
onClosing: function() {
console.debug("QML onClosing signal")
UiLogic.onCloseWindow()
PageController.closeWindow()
}
title: "AmneziaVPN"
@ -36,6 +35,11 @@ Window {
var pagePath = PageController.getInitialPage()
rootStackView.push(pagePath, { "objectName" : pagePath })
}
Keys.onPressed: function(event) {
PageController.keyPressEvent(event.key)
event.accepted = true
}
}
Connections {
@ -49,10 +53,14 @@ Window {
rootStackView.replace(pagePath, { "objectName" : pagePath })
}
function onRaise() {
function onRaiseMainWindow() {
root.show()
root.raise()
root.requestActivate()
}
function onHideMainWindow() {
root.hide()
}
}
}