mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-22 02:01:08 +07:00
replace FlickableType with ListViewType in PageSetupWizardProtocolSettings
This commit is contained in:
@@ -29,256 +29,239 @@ PageType {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
FlickableType {
|
BackButtonType {
|
||||||
anchors.fill: parent
|
id: backButton
|
||||||
contentHeight: content.height
|
|
||||||
|
|
||||||
Column {
|
anchors.top: parent.top
|
||||||
id: content
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.topMargin: 20
|
||||||
|
|
||||||
anchors.top: parent.top
|
onFocusChanged: {
|
||||||
anchors.left: parent.left
|
if (this.activeFocus) {
|
||||||
anchors.right: parent.right
|
listView.positionViewAtBeginning()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ListView {
|
ListViewType {
|
||||||
id: processedContainerListView
|
id: listView
|
||||||
width: parent.width
|
|
||||||
height: contentItem.height
|
|
||||||
currentIndex: -1
|
|
||||||
clip: true
|
|
||||||
interactive: false
|
|
||||||
model: proxyContainersModel
|
|
||||||
|
|
||||||
property bool isFocusable: true
|
anchors.top: backButton.bottom
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.left: parent.left
|
||||||
|
|
||||||
Keys.onTabPressed: {
|
currentIndex: -1
|
||||||
FocusController.nextKeyTabItem()
|
|
||||||
|
model: proxyContainersModel
|
||||||
|
|
||||||
|
delegate: ColumnLayout {
|
||||||
|
width: listView.width
|
||||||
|
|
||||||
|
BaseHeaderType {
|
||||||
|
id: header
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
|
||||||
|
headerText: qsTr("Installing %1").arg(name)
|
||||||
|
descriptionText: description
|
||||||
|
}
|
||||||
|
|
||||||
|
BasicButtonType {
|
||||||
|
id: showDetailsButton
|
||||||
|
|
||||||
|
Layout.topMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
|
||||||
|
implicitHeight: 32
|
||||||
|
|
||||||
|
defaultColor: AmneziaStyle.color.transparent
|
||||||
|
hoveredColor: AmneziaStyle.color.translucentWhite
|
||||||
|
pressedColor: AmneziaStyle.color.sheerWhite
|
||||||
|
disabledColor: AmneziaStyle.color.mutedGray
|
||||||
|
textColor: AmneziaStyle.color.goldenApricot
|
||||||
|
|
||||||
|
text: qsTr("More detailed")
|
||||||
|
|
||||||
|
clickedFunc: function() {
|
||||||
|
showDetailsDrawer.openTriggered()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Keys.onBacktabPressed: {
|
DrawerType2 {
|
||||||
FocusController.previousKeyTabItem()
|
id: showDetailsDrawer
|
||||||
}
|
parent: root
|
||||||
|
|
||||||
Keys.onUpPressed: {
|
anchors.fill: parent
|
||||||
FocusController.nextKeyUpItem()
|
expandedHeight: parent.height * 0.9
|
||||||
}
|
expandedStateContent: Item {
|
||||||
|
implicitHeight: showDetailsDrawer.expandedHeight
|
||||||
|
|
||||||
Keys.onDownPressed: {
|
BackButtonType {
|
||||||
FocusController.nextKeyDownItem()
|
id: showDetailsBackButton
|
||||||
}
|
|
||||||
|
|
||||||
Keys.onLeftPressed: {
|
anchors.top: parent.top
|
||||||
FocusController.nextKeyLeftItem()
|
anchors.left: parent.left
|
||||||
}
|
anchors.right: parent.right
|
||||||
|
anchors.topMargin: 16
|
||||||
|
|
||||||
Keys.onRightPressed: {
|
backButtonFunction: function() {
|
||||||
FocusController.nextKeyRightItem()
|
showDetailsDrawer.closeTriggered()
|
||||||
}
|
|
||||||
|
|
||||||
delegate: Item {
|
|
||||||
implicitWidth: processedContainerListView.width
|
|
||||||
implicitHeight: (delegateContent.implicitHeight > root.height) ? delegateContent.implicitHeight : root.height
|
|
||||||
|
|
||||||
property alias port:port
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
id: delegateContent
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.rightMargin: 16
|
|
||||||
anchors.leftMargin: 16
|
|
||||||
|
|
||||||
BackButtonType {
|
|
||||||
id: backButton
|
|
||||||
|
|
||||||
Layout.topMargin: 20
|
|
||||||
Layout.rightMargin: -16
|
|
||||||
Layout.leftMargin: -16
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BaseHeaderType {
|
ListViewType {
|
||||||
id: header
|
id: showDetailsListView
|
||||||
|
|
||||||
Layout.fillWidth: true
|
anchors.top: showDetailsBackButton.bottom
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
|
||||||
headerText: qsTr("Installing %1").arg(name)
|
header: ColumnLayout {
|
||||||
descriptionText: description
|
width: showDetailsListView.width
|
||||||
}
|
|
||||||
|
|
||||||
BasicButtonType {
|
Header2Type {
|
||||||
id: showDetailsButton
|
id: showDetailsDrawerHeader
|
||||||
|
|
||||||
Layout.topMargin: 16
|
Layout.fillWidth: true
|
||||||
Layout.leftMargin: -8
|
Layout.topMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
|
||||||
implicitHeight: 32
|
headerText: name
|
||||||
|
|
||||||
defaultColor: AmneziaStyle.color.transparent
|
|
||||||
hoveredColor: AmneziaStyle.color.translucentWhite
|
|
||||||
pressedColor: AmneziaStyle.color.sheerWhite
|
|
||||||
disabledColor: AmneziaStyle.color.mutedGray
|
|
||||||
textColor: AmneziaStyle.color.goldenApricot
|
|
||||||
|
|
||||||
text: qsTr("More detailed")
|
|
||||||
KeyNavigation.tab: transportProtoSelector
|
|
||||||
|
|
||||||
clickedFunc: function() {
|
|
||||||
showDetailsDrawer.openTriggered()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawerType2 {
|
model: 1 // fake model to force the ListView to be created without a model
|
||||||
id: showDetailsDrawer
|
|
||||||
parent: root
|
|
||||||
|
|
||||||
anchors.fill: parent
|
delegate: ColumnLayout {
|
||||||
expandedHeight: parent.height * 0.9
|
width: showDetailsListView.width
|
||||||
expandedStateContent: Item {
|
|
||||||
implicitHeight: showDetailsDrawer.expandedHeight
|
|
||||||
|
|
||||||
BackButtonType {
|
ParagraphTextType {
|
||||||
id: showDetailsBackButton
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 16
|
||||||
|
Layout.bottomMargin: 16
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
anchors.top: parent.top
|
text: detailedDescription
|
||||||
anchors.left: parent.left
|
textFormat: Text.MarkdownText
|
||||||
anchors.right: parent.right
|
}
|
||||||
anchors.topMargin: 16
|
|
||||||
|
|
||||||
backButtonFunction: function() {
|
Rectangle {
|
||||||
showDetailsDrawer.closeTriggered()
|
Layout.fillHeight: true
|
||||||
}
|
Layout.leftMargin: 16
|
||||||
}
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
FlickableType {
|
color: AmneziaStyle.color.transparent
|
||||||
id: fl
|
}
|
||||||
anchors.top: showDetailsBackButton.bottom
|
}
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
contentHeight: {
|
|
||||||
var emptySpaceHeight = parent.height - showDetailsBackButton.implicitHeight - showDetailsBackButton.anchors.topMargin
|
|
||||||
return (showDetailsDrawerContent.height > emptySpaceHeight) ?
|
|
||||||
showDetailsDrawerContent.height : emptySpaceHeight
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
footer: ColumnLayout {
|
||||||
id: showDetailsDrawerContent
|
width: showDetailsListView.width
|
||||||
|
|
||||||
anchors.top: parent.top
|
BasicButtonType {
|
||||||
anchors.left: parent.left
|
id: showDetailsCloseButton
|
||||||
anchors.right: parent.right
|
Layout.fillWidth: true
|
||||||
anchors.rightMargin: 16
|
Layout.bottomMargin: 32
|
||||||
anchors.leftMargin: 16
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
Header2Type {
|
text: qsTr("Close")
|
||||||
id: showDetailsDrawerHeader
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 16
|
|
||||||
|
|
||||||
headerText: name
|
clickedFunc: function() {
|
||||||
}
|
showDetailsDrawer.closeTriggered()
|
||||||
|
|
||||||
ParagraphTextType {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 16
|
|
||||||
Layout.bottomMargin: 16
|
|
||||||
|
|
||||||
text: detailedDescription
|
|
||||||
textFormat: Text.MarkdownText
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
Layout.fillHeight: true
|
|
||||||
color: AmneziaStyle.color.transparent
|
|
||||||
}
|
|
||||||
|
|
||||||
BasicButtonType {
|
|
||||||
id: showDetailsCloseButton
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.bottomMargin: 32
|
|
||||||
parentFlickable: fl
|
|
||||||
|
|
||||||
text: qsTr("Close")
|
|
||||||
|
|
||||||
clickedFunc: function() {
|
|
||||||
showDetailsDrawer.closeTriggered()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ParagraphTextType {
|
|
||||||
id: transportProtoHeader
|
|
||||||
|
|
||||||
Layout.topMargin: 16
|
|
||||||
|
|
||||||
text: qsTr("Network protocol")
|
|
||||||
}
|
|
||||||
|
|
||||||
TransportProtoSelector {
|
|
||||||
id: transportProtoSelector
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
|
||||||
rootWidth: root.width
|
|
||||||
}
|
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
|
||||||
id: port
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 16
|
|
||||||
|
|
||||||
headerText: qsTr("Port")
|
|
||||||
textField.maximumLength: 5
|
|
||||||
textField.validator: IntValidator { bottom: 1; top: 65535 }
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
Layout.fillHeight: true
|
|
||||||
color: AmneziaStyle.color.transparent
|
|
||||||
}
|
|
||||||
|
|
||||||
BasicButtonType {
|
|
||||||
id: installButton
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.bottomMargin: 32
|
|
||||||
|
|
||||||
text: qsTr("Install")
|
|
||||||
|
|
||||||
clickedFunc: function() {
|
|
||||||
if (!port.textField.acceptableInput &&
|
|
||||||
ContainerProps.containerTypeToString(dockerContainer) !== "torwebsite" &&
|
|
||||||
ContainerProps.containerTypeToString(dockerContainer) !== "ikev2") {
|
|
||||||
port.errorText = qsTr("The port must be in the range of 1 to 65535")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
|
||||||
InstallController.install(dockerContainer, port.textField.text, transportProtoSelector.currentIndex)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
var defaultContainerProto = ContainerProps.defaultProtocol(dockerContainer)
|
|
||||||
|
|
||||||
if (ProtocolProps.defaultPort(defaultContainerProto) < 0) {
|
|
||||||
port.visible = false
|
|
||||||
} else {
|
|
||||||
port.textField.text = ProtocolProps.getPortForInstall(defaultContainerProto)
|
|
||||||
}
|
|
||||||
transportProtoSelector.currentIndex = ProtocolProps.defaultTransportProto(defaultContainerProto)
|
|
||||||
|
|
||||||
port.enabled = ProtocolProps.defaultPortChangeable(defaultContainerProto)
|
|
||||||
var protocolSelectorVisible = ProtocolProps.defaultTransportProtoChangeable(defaultContainerProto)
|
|
||||||
transportProtoSelector.visible = protocolSelectorVisible
|
|
||||||
transportProtoHeader.visible = protocolSelectorVisible
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ParagraphTextType {
|
||||||
|
id: transportProtoHeader
|
||||||
|
|
||||||
|
Layout.topMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
|
||||||
|
text: qsTr("Network protocol")
|
||||||
|
}
|
||||||
|
|
||||||
|
TransportProtoSelector {
|
||||||
|
id: transportProtoSelector
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
|
||||||
|
rootWidth: root.width
|
||||||
|
}
|
||||||
|
|
||||||
|
TextFieldWithHeaderType {
|
||||||
|
id: port
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
|
||||||
|
headerText: qsTr("Port")
|
||||||
|
textField.maximumLength: 5
|
||||||
|
textField.validator: IntValidator { bottom: 1; top: 65535 }
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
|
||||||
|
color: AmneziaStyle.color.transparent
|
||||||
|
}
|
||||||
|
|
||||||
|
BasicButtonType {
|
||||||
|
id: installButton
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.bottomMargin: 32
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
|
||||||
|
text: qsTr("Install")
|
||||||
|
|
||||||
|
clickedFunc: function() {
|
||||||
|
if (!port.textField.acceptableInput &&
|
||||||
|
ContainerProps.containerTypeToString(dockerContainer) !== "torwebsite" &&
|
||||||
|
ContainerProps.containerTypeToString(dockerContainer) !== "ikev2") {
|
||||||
|
port.errorText = qsTr("The port must be in the range of 1 to 65535")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
||||||
|
InstallController.install(dockerContainer, port.textField.text, transportProtoSelector.currentIndex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
var defaultContainerProto = ContainerProps.defaultProtocol(dockerContainer)
|
||||||
|
|
||||||
|
if (ProtocolProps.defaultPort(defaultContainerProto) < 0) {
|
||||||
|
port.visible = false
|
||||||
|
} else {
|
||||||
|
port.textField.text = ProtocolProps.getPortForInstall(defaultContainerProto)
|
||||||
|
}
|
||||||
|
transportProtoSelector.currentIndex = ProtocolProps.defaultTransportProto(defaultContainerProto)
|
||||||
|
|
||||||
|
port.enabled = ProtocolProps.defaultPortChangeable(defaultContainerProto)
|
||||||
|
var protocolSelectorVisible = ProtocolProps.defaultTransportProtoChangeable(defaultContainerProto)
|
||||||
|
transportProtoSelector.visible = protocolSelectorVisible
|
||||||
|
transportProtoHeader.visible = protocolSelectorVisible
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user