Files
amnezia-client/client/ui/qml/Components/HomeContainersListView.qml
T

91 lines
2.7 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import SortFilterProxyModel 0.2
import PageEnum 1.0
import ProtocolEnum 1.0
import "../Controls2"
import "../Controls2/TextTypes"
ListView {
id: menuContent
property var rootWidth
width: rootWidth
height: menuContent.contentItem.height
clip: true
interactive: false
ButtonGroup {
id: containersRadioButtonGroup
}
delegate: Item {
implicitWidth: rootWidth
2023-06-05 15:49:10 +08:00
implicitHeight: content.implicitHeight
2023-06-05 15:49:10 +08:00
ColumnLayout {
id: content
2023-06-01 11:25:33 +08:00
anchors.fill: parent
anchors.rightMargin: 16
anchors.leftMargin: 16
2023-06-05 15:49:10 +08:00
VerticalRadioButton {
id: containerRadioButton
2023-06-05 15:49:10 +08:00
Layout.fillWidth: true
2023-06-05 15:49:10 +08:00
text: name
descriptionText: description
2023-06-05 15:49:10 +08:00
ButtonGroup.group: containersRadioButtonGroup
2023-06-05 15:49:10 +08:00
imageSource: "qrc:/images/controls/download.svg"
showImage: !isInstalled
checkable: isInstalled && !ConnectionController.isConnected && isSupported
2024-02-13 20:20:13 +05:00
checked: proxyContainersModel.mapToSource(index) === ServersModel.getDefaultContainer(ServersModel.defaultIndex)
2023-06-05 15:49:10 +08:00
onClicked: {
if (ConnectionController.isConnected && isInstalled) {
PageController.showNotificationMessage(qsTr("Unable change protocol while there is an active connection"))
return
}
2023-06-05 15:49:10 +08:00
if (checked) {
2024-02-16 15:24:06 +05:00
containersDropDown.close()
2024-02-13 20:20:13 +05:00
ServersModel.setDefaultContainer(ServersModel.defaultIndex, proxyContainersModel.mapToSource(index))
2023-06-05 15:49:10 +08:00
} else {
if (!isSupported && isInstalled) {
PageController.showErrorMessage(qsTr("The selected protocol is not supported on the current platform"))
return
}
2023-06-13 20:03:20 +09:00
ContainersModel.setCurrentlyProcessedContainerIndex(proxyContainersModel.mapToSource(index))
2023-06-05 15:49:10 +08:00
InstallController.setShouldCreateServer(false)
2023-09-06 13:37:37 +05:00
PageController.goToPage(PageEnum.PageSetupWizardProtocolSettings)
2024-02-16 15:24:06 +05:00
containersDropDown.close()
2023-06-05 15:49:10 +08:00
}
}
MouseArea {
anchors.fill: containerRadioButton
cursorShape: Qt.PointingHandCursor
enabled: false
}
}
2023-06-05 15:49:10 +08:00
DividerType {
Layout.fillWidth: true
}
}
}
}