replace ListView with ListViewType in PageSettingsSplitTunneling

This commit is contained in:
Cyril Anisimov
2025-07-26 14:59:32 +02:00
parent 9e30039eaa
commit 7b4a94dd3d
@@ -161,7 +161,7 @@ PageType {
}
}
ListView {
ListViewType {
id: listView
anchors.top: header.bottom
@@ -172,8 +172,6 @@ PageType {
enabled: root.pageEnabled
property bool isFocusable: true
model: SortFilterProxyModel {
id: proxySitesModel
sourceModel: SitesModel
@@ -193,13 +191,7 @@ PageType {
]
}
clip: true
reuseItems: true
delegate: ColumnLayout {
id: delegateContent
width: listView.width
LabelWithButtonType {
@@ -236,7 +228,6 @@ PageType {
}
}
Rectangle {
anchors.fill: addSiteButton
anchors.bottomMargin: -24
@@ -286,8 +277,8 @@ PageType {
moreActionsDrawer.openTriggered()
}
Keys.onReturnPressed: this.clicked()
Keys.onEnterPressed: this.clicked()
Keys.onReturnPressed: addSiteButtonImage.clicked()
Keys.onEnterPressed: addSiteButtonImage.clicked()
}
}
@@ -351,7 +342,7 @@ PageType {
}
DividerType {}
LabelWithButtonType {
id: clearSitesButton
Layout.fillWidth: true
@@ -402,22 +393,24 @@ PageType {
backButtonFunction: function() {
importSitesDrawer.closeTriggered()
}
onFocusChanged: {
if (this.activeFocus) {
importSitesDrawerListView.positionViewAtBeginning()
}
}
}
FlickableType {
ListViewType {
id: importSitesDrawerListView
anchors.top: importSitesDrawerBackButton.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
contentHeight: importSitesDrawerContent.height
ColumnLayout {
id: importSitesDrawerContent
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
header: ColumnLayout {
width: importSitesDrawerListView.width
Header2Type {
Layout.fillWidth: true
@@ -425,49 +418,67 @@ PageType {
headerText: qsTr("Import a list of sites")
}
}
model: importOptions
delegate: ColumnLayout {
width: importSitesDrawerListView.width
LabelWithButtonType {
id: importSitesButton2
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
text: qsTr("Replace site list")
text: title
clickedFunction: function() {
var fileName = SystemController.getFileName(qsTr("Open sites file"),
qsTr("Sites files (*.json)"))
if (fileName !== "") {
importSitesDrawerContent.importSites(fileName, true)
}
clickedHandler()
}
}
DividerType {}
LabelWithButtonType {
id: importSitesButton3
Layout.fillWidth: true
text: qsTr("Add imported sites to existing ones")
clickedFunction: function() {
var fileName = SystemController.getFileName(qsTr("Open sites file"),
qsTr("Sites files (*.json)"))
if (fileName !== "") {
importSitesDrawerContent.importSites(fileName, false)
}
}
}
function importSites(fileName, replaceExistingSites) {
PageController.showBusyIndicator(true)
SitesController.importSites(fileName, replaceExistingSites)
PageController.showBusyIndicator(false)
importSitesDrawer.closeTriggered()
moreActionsDrawer.closeTriggered()
}
DividerType {}
}
}
}
}
property list<QtObject> importOptions: [
replaceOption,
addOption,
]
QtObject {
id: replaceOption
readonly property string title: qsTr("Replace site list")
readonly property var clickedHandler: function() {
var fileName = SystemController.getFileName(qsTr("Open sites file"),
qsTr("Sites files (*.json)"))
if (fileName !== "") {
root.importSites(fileName, true)
}
}
}
QtObject {
id: addOption
readonly property string title: qsTr("Add imported sites to existing ones")
readonly property var clickedHandler: function() {
var fileName = SystemController.getFileName(qsTr("Open sites file"),
qsTr("Sites files (*.json)"))
if (fileName !== "") {
root.importSites(fileName, false)
}
}
}
function importSites(fileName, replaceExistingSites) {
PageController.showBusyIndicator(true)
SitesController.importSites(fileName, replaceExistingSites)
PageController.showBusyIndicator(false)
importSitesDrawer.closeTriggered()
moreActionsDrawer.closeTriggered()
}
}