replace FlickableType with ListViewType in PageShareFullAccess

This commit is contained in:
Cyril Anisimov
2025-07-26 17:26:56 +02:00
parent 53a466d7d7
commit 9d4d493095
+170 -150
View File
@@ -1,150 +1,170 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import QtQuick.Dialogs import QtQuick.Dialogs
import SortFilterProxyModel 0.2 import SortFilterProxyModel 0.2
import PageEnum 1.0 import PageEnum 1.0
import ContainerProps 1.0 import ContainerProps 1.0
import Style 1.0 import Style 1.0
import "./" import "./"
import "../Controls2" import "../Controls2"
import "../Controls2/TextTypes" import "../Controls2/TextTypes"
import "../Components" import "../Components"
import "../Config" import "../Config"
PageType { PageType {
id: root id: root
BackButtonType { BackButtonType {
id: backButton id: backButton
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.topMargin: 20 anchors.topMargin: 20
}
onFocusChanged: {
FlickableType { if (this.activeFocus) {
anchors.top: backButton.bottom listView.positionViewAtBeginning()
anchors.bottom: parent.bottom }
contentHeight: content.height }
}
ColumnLayout {
id: content ListViewType {
id: listView
anchors.top: parent.top
anchors.left: parent.left anchors.top: backButton.bottom
anchors.right: parent.right anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.rightMargin: 16 anchors.left: parent.left
anchors.leftMargin: 16
header: ColumnLayout {
spacing: 0 width: listView.width
BaseHeaderType { BaseHeaderType {
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 24 Layout.leftMargin: 16
Layout.rightMargin: 16
headerText: qsTr("Full access to the server and VPN") Layout.topMargin: 24
}
headerText: qsTr("Full access to the server and VPN")
ParagraphTextType { }
Layout.fillWidth: true
Layout.topMargin: 24 ParagraphTextType {
Layout.bottomMargin: 24 Layout.fillWidth: true
Layout.leftMargin: 16
text: qsTr("We recommend that you use full access to the server only for your own additional devices.\n") + Layout.rightMargin: 16
qsTr("If you share full access with other people, they can remove and add protocols and services to the server, which will cause the VPN to work incorrectly for all users. ") Layout.topMargin: 24
color: AmneziaStyle.color.mutedGray Layout.bottomMargin: 24
}
text: qsTr("We recommend that you use full access to the server only for your own additional devices.\n") +
DropDownType { qsTr("If you share full access with other people, they can remove and add protocols and services to the server, which will cause the VPN to work incorrectly for all users. ")
id: serverSelector color: AmneziaStyle.color.mutedGray
}
signal severSelectorIndexChanged
property int currentIndex: 0 DropDownType {
id: serverSelector
Layout.fillWidth: true objectName: "serverSelector"
Layout.topMargin: 16
signal severSelectorIndexChanged
drawerHeight: 0.4375 property int currentIndex: 0
drawerParent: root
Layout.fillWidth: true
descriptionText: qsTr("Server") Layout.leftMargin: 16
headerText: qsTr("Server") Layout.rightMargin: 16
Layout.topMargin: 16
listView: ListViewWithRadioButtonType {
id: serverSelectorListView drawerHeight: 0.4375
drawerParent: root
rootWidth: root.width
imageSource: "qrc:/images/controls/check.svg" descriptionText: qsTr("Server")
headerText: qsTr("Server")
model: SortFilterProxyModel {
id: proxyServersModel listView: ListViewWithRadioButtonType {
sourceModel: ServersModel id: serverSelectorListView
filters: [
ValueFilter { rootWidth: root.width
roleName: "hasWriteAccess" imageSource: "qrc:/images/controls/check.svg"
value: true
} model: SortFilterProxyModel {
] id: proxyServersModel
} sourceModel: ServersModel
filters: [
clickedFunction: function() { ValueFilter {
handler() roleName: "hasWriteAccess"
value: true
if (serverSelector.currentIndex !== serverSelectorListView.currentIndex) { }
serverSelector.currentIndex = serverSelectorListView.currentIndex ]
} }
shareConnectionPage.headerText = qsTr("Accessing ") + serverSelector.text clickedFunction: function() {
shareConnectionPage.configContentHeaderText = qsTr("File with accessing settings to ") + serverSelector.text handler()
serverSelector.closeTriggered()
} if (serverSelector.currentIndex !== serverSelectorListView.currentIndex) {
serverSelector.currentIndex = serverSelectorListView.currentIndex
Component.onCompleted: { }
serverSelectorListView.currentIndex = ServersModel.isDefaultServerHasWriteAccess() ?
proxyServersModel.mapFromSource(ServersModel.defaultIndex) : 0 shareConnectionPage.headerText = qsTr("Accessing ") + serverSelector.text
serverSelectorListView.triggerCurrentItem() shareConnectionPage.configContentHeaderText = qsTr("File with accessing settings to ") + serverSelector.text
} serverSelector.closeTriggered()
}
function handler() {
serverSelector.text = selectedText Component.onCompleted: {
ServersModel.processedIndex = proxyServersModel.mapToSource(currentIndex) serverSelectorListView.currentIndex = ServersModel.isDefaultServerHasWriteAccess() ?
} proxyServersModel.mapFromSource(ServersModel.defaultIndex) : 0
} serverSelectorListView.triggerCurrentItem()
} }
BasicButtonType { function handler() {
id: shareButton serverSelector.text = selectedText
Layout.fillWidth: true ServersModel.processedIndex = proxyServersModel.mapToSource(currentIndex)
Layout.topMargin: 40 }
}
text: qsTr("Share") }
leftImageSource: "qrc:/images/controls/share-2.svg" }
clickedFunc: function() { model: 1 // fake model to force the ListView to be created without a model
PageController.showBusyIndicator(true) spacing: 0
if (Qt.platform.os === "android" && !SystemController.isAuthenticated()) { delegate: ColumnLayout {
PageController.showBusyIndicator(false) width: listView.width
ExportController.exportErrorOccurred(qsTr("Access error!"))
return BasicButtonType {
} else { id: shareButton
ExportController.generateFullAccessConfig() Layout.fillWidth: true
} Layout.topMargin: 32
Layout.leftMargin: 16
PageController.showBusyIndicator(false) Layout.rightMargin: 16
PageController.goToPage(PageEnum.PageShareConnection) text: qsTr("Share")
} leftImageSource: "qrc:/images/controls/share-2.svg"
}
} clickedFunc: function() {
} PageController.showBusyIndicator(true)
} if (Qt.platform.os === "android" && !SystemController.isAuthenticated()) {
PageController.showBusyIndicator(false)
ExportController.exportErrorOccurred(qsTr("Access error!"))
return
} else {
ExportController.generateFullAccessConfig()
}
PageController.showBusyIndicator(false)
PageController.goToPage(PageEnum.PageShareConnection)
}
}
}
}
ShareConnectionDrawer {
id: shareConnectionDrawer
anchors.fill: parent
}
}