Merge branch 'feature/new-gui' into bugfix/scroll_stuck_on_fl_textarea

This commit is contained in:
ronoaer 2023-09-18 07:36:01 +08:00 committed by GitHub
commit 29e8f8f5fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
99 changed files with 5221 additions and 715 deletions

View file

@ -61,9 +61,24 @@ ListView {
onClicked: {
if (checked) {
var needReconnected = false
if (!isDefault) {
needReconnected = true
}
isDefault = true
menuContent.currentIndex = index
containersDropDown.menuVisible = false
if (needReconnected &&
(ConnectionController.isConnected || ConnectionController.isConnectionInProgress)) {
PageController.showNotificationMessage(qsTr("Reconnect via VPN Procotol: ") + name)
PageController.goToPageHome()
menu.visible = false
ConnectionController.openConnection()
}
} else {
ContainersModel.setCurrentlyProcessedContainerIndex(proxyContainersModel.mapToSource(index))
InstallController.setShouldCreateServer(false)

View file

@ -33,7 +33,7 @@ DrawerType {
onClosed: {
configExtension = ".vpn"
configCaption = qsTr("Save AmneziaVPN config")
configFileName = "amnezia_config.vpn"
configFileName = "amnezia_config"
}
Item {
@ -74,7 +74,7 @@ DrawerType {
onClicked: {
var fileName = ""
if (GC.isMobile()) {
fileName = configFileName
fileName = configFileName + configExtension
} else {
fileName = SystemController.getFileName(configCaption,
qsTr("Config files (*" + configExtension + ")"),
@ -169,7 +169,7 @@ DrawerType {
Layout.topMargin: 16
}
TextArea {
TextField {
id: configText
Layout.fillWidth: true
@ -180,6 +180,8 @@ DrawerType {
leftPadding: 0
height: 24
readOnly: true
color: "#D7D8DB"
selectionColor: "#633303"
selectedTextColor: "#D7D8DB"

View file

@ -10,6 +10,8 @@ Item {
property string text
property string textColor: "#d7d8db"
property string textDisabledColor: "#878B91"
property int textMaximumLineCount: 2
property int textElide: Qt.ElideRight
property string descriptionText
property string descriptionTextColor: "#878B91"
@ -102,6 +104,8 @@ Item {
color: root.enabled ? root.textColor : root.textDisabledColor
text: root.text
maximumLineCount: root.textMaximumLineCount
elide: root.textElide
}
}

View file

@ -10,6 +10,9 @@ Item {
property var actionButtonFunction
property string headerText
property int headerTextMaximumLineCount: 2
property int headerTextElide: Qt.ElideRight
property string descriptionText
implicitWidth: content.implicitWidth
@ -26,6 +29,8 @@ Item {
Layout.fillWidth: true
text: root.headerText
maximumLineCount: root.headerTextMaximumLineCount
elide: root.headerTextElide
}
ImageButtonType {

View file

@ -8,6 +8,9 @@ Item {
id: root
property string text
property int textMaximumLineCount: 2
property int textElide: Qt.ElideRight
property string descriptionText
property var clickedFunction
@ -68,6 +71,8 @@ Item {
ListItemTitleType {
text: root.text
color: root.descriptionOnTop ? root.descriptionColor : root.textColor
maximumLineCount: root.textMaximumLineCount
elide: root.textElide
opacity: root.textOpacity

View file

@ -5,12 +5,15 @@ import QtQuick.Layouts
import "TextTypes"
ListView {
id: menuContent
id: root
property var rootWidth
property var selectedText
property int textMaximumLineCount: 2
property int textElide: Qt.ElideRight
property string imageSource: "qrc:/images/controls/check.svg"
property var clickedFunction
@ -18,7 +21,7 @@ ListView {
currentIndex: 0
width: rootWidth
height: menuContent.contentItem.height
height: root.contentItem.height
clip: true
interactive: false
@ -27,6 +30,12 @@ ListView {
id: buttonGroup
}
function triggerCurrentItem() {
var item = root.itemAtIndex(currentIndex)
var radioButton = item.children[0].children[0]
radioButton.clicked()
}
delegate: Item {
implicitWidth: rootWidth
implicitHeight: content.implicitHeight
@ -74,6 +83,9 @@ ListView {
Layout.bottomMargin: 20
text: name
maximumLineCount: root.textMaximumLineCount
elide: root.textElide
}
Image {
@ -88,11 +100,11 @@ ListView {
}
ButtonGroup.group: buttonGroup
checked: menuContent.currentIndex === index
checked: root.currentIndex === index
onClicked: {
menuContent.currentIndex = index
menuContent.selectedText = name
root.currentIndex = index
root.selectedText = name
if (clickedFunction && typeof clickedFunction === "function") {
clickedFunction()
}
@ -101,8 +113,8 @@ ListView {
}
Component.onCompleted: {
if (menuContent.currentIndex === index) {
menuContent.selectedText = name
if (root.currentIndex === index) {
root.selectedText = name
}
}
}

View file

@ -6,7 +6,8 @@ Rectangle {
property string placeholderText
property string text
property var onEditingFinished
property alias textArea: textArea
property alias textAreaText: textArea.text
height: 148
color: "#1C1D21"
@ -43,12 +44,6 @@ Rectangle {
placeholderText: root.placeholderText
text: root.text
onEditingFinished: {
if (root.onEditingFinished && typeof root.onEditingFinished === "function") {
root.onEditingFinished()
}
}
onCursorVisibleChanged: {
if (textArea.cursorVisible) {
fl.interactive = true

View file

@ -8,6 +8,8 @@ import "TextTypes"
RadioButton {
id: root
property int textMaximumLineCount: 2
property int textElide: Qt.ElideRight
property string descriptionText
property string hoveredColor: Qt.rgba(1, 1, 1, 0.05)
@ -104,6 +106,8 @@ RadioButton {
ListItemTitleType {
text: root.text
maximumLineCount: root.textMaximumLineCount
elide: root.textElide
color: {
if (root.checked) {

View file

@ -75,12 +75,20 @@ PageType {
RowLayout {
Layout.topMargin: 24
Layout.leftMargin: 24
Layout.rightMargin: 24
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
spacing: 0
Header1TextType {
Layout.maximumWidth: buttonContent.width - 48 - 18 - 12 // todo
maximumLineCount: 2
elide: Qt.ElideRight
text: root.defaultServerName
horizontalAlignment: Qt.AlignHCenter
}
Image {
@ -148,10 +156,15 @@ PageType {
anchors.left: parent.left
Header1TextType {
Layout.fillWidth: true
Layout.topMargin: 24
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
Layout.leftMargin: 16
Layout.rightMargin: 16
text: root.defaultServerName
horizontalAlignment: Qt.AlignHCenter
maximumLineCount: 2
elide: Qt.ElideRight
}
LabelTextType {
@ -210,7 +223,6 @@ PageType {
}
Component.onCompleted: updateContainersModelFilters()
currentIndex: ContainersModel.getDefaultContainer()
}
}
}

View file

@ -13,14 +13,6 @@ import "../Components"
PageType {
id: root
Connections {
target: InstallController
function onUpdateContainerFinished() {
PageController.showNotificationMessage(qsTr("Settings updated successfully"))
}
}
ColumnLayout {
id: backButton

View file

@ -15,14 +15,6 @@ import "../Components"
PageType {
id: root
Connections {
target: InstallController
function onUpdateContainerFinished() {
PageController.showNotificationMessage(qsTr("Settings updated successfully"))
}
}
ColumnLayout {
id: backButton
@ -312,12 +304,12 @@ PageType {
visible: additionalClientCommandsSwitcher.checked
text: additionalClientCommands
textAreaText: additionalClientCommands
placeholderText: qsTr("Commands:")
onEditingFinished: {
if (additionalClientCommands !== text) {
additionalClientCommands = text
textArea.onEditingFinished: {
if (additionalClientCommands !== textAreaText) {
additionalClientCommands = textAreaText
}
}
}
@ -330,6 +322,12 @@ PageType {
checked: additionalServerCommands !== ""
text: qsTr("Additional server configuration commands")
onCheckedChanged: {
if (!checked) {
additionalServerCommands = ""
}
}
}
TextAreaType {
@ -338,12 +336,12 @@ PageType {
visible: additionalServerCommandsSwitcher.checked
text: additionalServerCommands
textAreaText: additionalServerCommands
placeholderText: qsTr("Commands:")
onEditingFinished: {
if (additionalServerCommands !== text) {
additionalServerCommands = text
textArea.onEditingFinished: {
if (additionalServerCommands !== textAreaText) {
additionalServerCommands = textAreaText
}
}
}

View file

@ -13,14 +13,6 @@ import "../Components"
PageType {
id: root
Connections {
target: InstallController
function onUpdateContainerFinished() {
PageController.showNotificationMessage(qsTr("Settings updated successfully"))
}
}
ColumnLayout {
id: backButton

View file

@ -165,6 +165,8 @@ PageType {
}
BasicButtonType {
visible: !GC.isMobile()
Layout.fillWidth: true
Layout.topMargin: 24
Layout.bottomMargin: 24
@ -218,6 +220,11 @@ PageType {
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
}
}
BasicButtonType {

View file

@ -10,6 +10,7 @@ import PageEnum 1.0
import "./"
import "../Controls2"
import "../Config"
import "../Components"
import "../Controls2/TextTypes"
PageType {
@ -27,6 +28,10 @@ PageType {
//goToStartPage()
PageController.goToPageHome()
}
function onImportBackupFromOutside(filePath) {
restoreBackup(filePath)
}
}
BackButtonType {
@ -116,15 +121,35 @@ PageType {
text: qsTr("Restore from backup")
onClicked: {
var fileName = SystemController.getFileName(qsTr("Open backup file"),
var filePath = SystemController.getFileName(qsTr("Open backup file"),
qsTr("Backup files (*.backup)"))
if (fileName !== "") {
PageController.showBusyIndicator(true)
SettingsController.restoreAppConfig(fileName)
PageController.showBusyIndicator(false)
if (filePath !== "") {
restoreBackup(filePath)
}
}
}
}
}
function restoreBackup(filePath) {
questionDrawer.headerText = qsTr("Import settings from a backup file?")
questionDrawer.descriptionText = qsTr("All current settings will be reset");
questionDrawer.yesButtonText = qsTr("Continue")
questionDrawer.noButtonText = qsTr("Cancel")
questionDrawer.yesButtonFunction = function() {
questionDrawer.visible = false
PageController.showBusyIndicator(true)
SettingsController.restoreAppConfig(filePath)
PageController.showBusyIndicator(false)
}
questionDrawer.noButtonFunction = function() {
questionDrawer.visible = false
}
questionDrawer.visible = true
}
QuestionDrawer {
id: questionDrawer
}
}

View file

@ -101,7 +101,7 @@ PageType {
Layout.fillWidth: true
headerText: qsTr("Server name")
textFieldText: name
textField.maximumLength: 20
textField.maximumLength: 30
}
BasicButtonType {

View file

@ -56,6 +56,20 @@ PageType {
}
}
Connections {
target: InstallController
function onInstallationErrorOccurred(errorMessage) {
PageController.showErrorMessage(errorMessage)
var currentPageName = tabBarStackView.currentItem.objectName
if (currentPageName === PageController.getPagePath(PageEnum.PageSetupWizardInstalling)) {
PageController.closePage()
}
}
}
FlickableType {
id: fl
anchors.top: parent.top

View file

@ -173,19 +173,22 @@ PageType {
DropDownType {
id: serverSelector
signal severSelectorIndexChanged
property int currentIndex: 0
Layout.fillWidth: true
Layout.topMargin: 16
drawerHeight: 0.4375
descriptionText: accessTypeSelector.currentIndex === 0 ? qsTr("Server and service") : qsTr("Server")
descriptionText: qsTr("Servers")
headerText: qsTr("Server")
listView: ListViewWithLabelsType {
rootWidth: root.width
dividerVisible: true
listView: ListViewWithRadioButtonType {
id: serverSelectorListView
imageSource: "qrc:/images/controls/chevron-right.svg"
rootWidth: root.width
imageSource: "qrc:/images/controls/check.svg"
model: SortFilterProxyModel {
id: proxyServersModel
@ -203,14 +206,16 @@ PageType {
clickedFunction: function() {
handler()
if (accessTypeSelector.currentIndex === 0) {
protocolSelector.visible = true
root.shareButtonEnabled = false
} else {
if (serverSelector.currentIndex !== serverSelectorListView.currentIndex) {
serverSelector.currentIndex = serverSelectorListView.currentIndex
serverSelector.severSelectorIndexChanged()
}
if (accessTypeSelector.currentIndex !== 0) {
shareConnectionDrawer.headerText = qsTr("Accessing ") + serverSelector.text
shareConnectionDrawer.configContentHeaderText = qsTr("File with connection settings to ") + serverSelector.text
serverSelector.menuVisible = false
}
serverSelector.menuVisible = false
}
Component.onCompleted: {
@ -224,117 +229,90 @@ PageType {
ServersModel.currentlyProcessedIndex = proxyServersModel.mapToSource(currentIndex)
}
}
}
DrawerType {
id: protocolSelector
DropDownType {
id: protocolSelector
width: parent.width
height: parent.height * 0.5
Layout.fillWidth: true
Layout.topMargin: 16
ColumnLayout {
id: protocolSelectorHeader
drawerHeight: 0.5
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 16
descriptionText: qsTr("Protocols")
headerText: qsTr("Protocol")
BackButtonType {
backButtonImage: "qrc:/images/controls/arrow-left.svg"
backButtonFunction: function() {
protocolSelector.visible = false
listView: ListViewWithRadioButtonType {
id: protocolSelectorListView
rootWidth: root.width
imageSource: "qrc:/images/controls/check.svg"
model: SortFilterProxyModel {
id: proxyContainersModel
sourceModel: ContainersModel
filters: [
ValueFilter {
roleName: "isInstalled"
value: true
},
ValueFilter {
roleName: "isShareable"
value: true
}
]
}
currentIndex: 0
clickedFunction: function() {
handler()
protocolSelector.menuVisible = false
}
Component.onCompleted: {
if (accessTypeSelector.currentIndex === 0) {
handler()
}
}
FlickableType {
anchors.top: protocolSelectorHeader.bottom
anchors.topMargin: 16
contentHeight: protocolSelectorContent.implicitHeight
Connections {
target: serverSelector
Column {
id: protocolSelectorContent
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
function onSeverSelectorIndexChanged() {
protocolSelectorListView.currentIndex = 0
protocolSelectorListView.triggerCurrentItem()
}
}
spacing: 16
function handler() {
if (!proxyContainersModel.count) {
root.shareButtonEnabled = false
return
} else {
root.shareButtonEnabled = true
}
Header2TextType {
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 16
anchors.rightMargin: 16
protocolSelector.text = selectedText
root.connectionServerSelectorText = serverSelector.text
text: qsTr("Protocols and services")
wrapMode: Text.WordWrap
}
shareConnectionDrawer.headerText = qsTr("Connection to ") + serverSelector.text
shareConnectionDrawer.configContentHeaderText = qsTr("File with connection settings to ") + serverSelector.text
ContainersModel.setCurrentlyProcessedContainerIndex(proxyContainersModel.mapToSource(currentIndex))
ListViewWithRadioButtonType {
rootWidth: root.width
fillConnectionTypeModel()
}
imageSource: "qrc:/images/controls/check.svg"
function fillConnectionTypeModel() {
root.connectionTypesModel = [amneziaConnectionFormat]
model: SortFilterProxyModel {
id: proxyContainersModel
sourceModel: ContainersModel
filters: [
ValueFilter {
roleName: "isInstalled"
value: true
},
ValueFilter {
roleName: "isShareable"
value: true
}
]
}
var index = proxyContainersModel.mapToSource(currentIndex)
currentIndex: 0
clickedFunction: function() {
handler()
protocolSelector.visible = false
serverSelector.menuVisible = false
}
Component.onCompleted: {
if (accessTypeSelector.currentIndex === 0) {
handler()
}
}
function handler() {
if (!proxyContainersModel.count) {
root.shareButtonEnabled = false
return
} else {
root.shareButtonEnabled = true
}
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))
fillConnectionTypeModel()
}
function fillConnectionTypeModel() {
root.connectionTypesModel = [amneziaConnectionFormat]
var index = proxyContainersModel.mapToSource(currentIndex)
if (index === ContainerProps.containerFromString("amnezia-openvpn")) {
root.connectionTypesModel.push(openVpnConnectionFormat)
} else if (index === ContainerProps.containerFromString("amnezia-wireguard")) {
root.connectionTypesModel.push(wireGuardConnectionFormat)
}
}
}
if (index === ContainerProps.containerFromString("amnezia-openvpn")) {
root.connectionTypesModel.push(openVpnConnectionFormat)
} else if (index === ContainerProps.containerFromString("amnezia-wireguard")) {
root.connectionTypesModel.push(wireGuardConnectionFormat)
}
}
}

View file

@ -82,6 +82,18 @@ PageType {
PageController.closePage()
}
}
function onUpdateContainerFinished(message) {
PageController.showNotificationMessage(message)
}
}
Connections {
target: ConnectionController
function onReconnectWithUpdatedContainer(message) {
PageController.showNotificationMessage(message)
}
}
StackViewType {
@ -97,8 +109,8 @@ PageType {
function goToTabBarPage(page) {
var pagePath = PageController.getPagePath(page)
tabBarStackView.clear(StackView.PopTransition)
tabBarStackView.replace(pagePath, { "objectName" : pagePath })
tabBarStackView.clear(StackView.Immediate)
tabBarStackView.replace(pagePath, { "objectName" : pagePath }, StackView.Immediate)
}
Component.onCompleted: {

View file

@ -81,6 +81,10 @@ Window {
function onShowPassphraseRequestDrawer() {
privateKeyPassphraseDrawer.open()
}
function onGoToPageSettingsBackup() {
PageController.goToPage(PageEnum.PageSettingsBackup)
}
}
Connections {