Files
amnezia-client/client/ui/qml/Pages2/PageHome.qml
T

311 lines
9.2 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
2023-05-11 14:50:50 +08:00
import SortFilterProxyModel 0.2
import PageEnum 1.0
2023-05-11 14:50:50 +08:00
import ProtocolEnum 1.0
import ContainerProps 1.0
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
import "../Components"
PageType {
id: root
property string defaultColor: "#1C1D21"
property string borderColor: "#2C2D30"
property string currentServerName: serversMenuContent.currentItem.delegateData.name
property string currentServerHostName: serversMenuContent.currentItem.delegateData.hostName
property string currentContainerName
ConnectButton {
anchors.centerIn: parent
}
Connections {
target: ContainersModel
function onDefaultContainerChanged() {
root.currentContainerName = ContainersModel.getDefaultContainerName()
}
}
2023-06-01 11:25:33 +08:00
Connections {
target: PageController
function onRestorePageHomeState(isContainerInstalled) {
menu.visible = true
if (isContainerInstalled) {
containersDropDown.menuVisible = true
}
}
}
Rectangle {
id: buttonBackground
anchors.fill: buttonContent
anchors.bottomMargin: -radius
radius: 16
color: root.defaultColor
border.color: root.borderColor
border.width: 1
Rectangle {
width: parent.width
height: 1
y: parent.height - height - parent.radius
color: root.borderColor
}
}
ColumnLayout {
id: buttonContent
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: parent.bottom
RowLayout {
Layout.topMargin: 24
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
Header1TextType {
text: root.currentServerName
}
Image {
Layout.preferredWidth: 18
Layout.preferredHeight: 18
source: "qrc:/images/controls/chevron-down.svg"
}
}
LabelTextType {
Layout.bottomMargin: 44
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
text: root.currentContainerName + " | " + root.currentServerHostName
}
}
MouseArea {
anchors.fill: buttonBackground
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked: {
menu.visible = true
}
}
2023-06-01 11:25:33 +08:00
DrawerType {
id: menu
width: parent.width
height: parent.height * 0.90
ColumnLayout {
id: serversMenuHeader
anchors.top: parent.top
anchors.right: parent.right
anchors.left: parent.left
Header1TextType {
Layout.topMargin: 24
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
text: root.currentServerName
}
LabelTextType {
Layout.bottomMargin: 24
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
text: root.currentServerHostName
}
RowLayout {
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
spacing: 8
DropDownType {
id: containersDropDown
2023-05-11 14:50:50 +08:00
implicitHeight: 40
rootButtonBorderWidth: 0
rootButtonImageColor: "#0E0E11"
rootButtonMaximumWidth: 150 //todo make it dynamic
rootButtonDefaultColor: "#D7D8DB"
text: root.currentContainerName
textColor: "#0E0E11"
headerText: qsTr("Протокол подключения")
2023-05-11 14:50:50 +08:00
headerBackButtonImage: "qrc:/images/controls/arrow-left.svg"
onRootButtonClicked: function() {
ServersModel.setCurrentlyProcessedServerIndex(serversMenuContent.currentIndex)
ContainersModel.setCurrentlyProcessedServerIndex(serversMenuContent.currentIndex)
containersDropDown.menuVisible = true
}
2023-06-01 11:25:33 +08:00
listView: HomeContainersListView {
rootWidth: root.width
2023-05-11 14:50:50 +08:00
model: SortFilterProxyModel {
id: proxyContainersModel
sourceModel: ContainersModel
filters: [
ValueFilter {
roleName: "serviceType"
value: ProtocolEnum.Vpn
},
ValueFilter {
roleName: "isSupported"
value: true
}
]
}
currentIndex: ContainersModel.getDefaultContainer()
2023-05-11 14:50:50 +08:00
}
}
BasicButtonType {
id: dnsButton
implicitHeight: 40
text: "Amnezia DNS"
}
}
Header2Type {
2023-05-11 14:50:50 +08:00
Layout.fillWidth: true
Layout.topMargin: 48
Layout.leftMargin: 16
Layout.rightMargin: 16
2023-05-11 14:50:50 +08:00
actionButtonImage: "qrc:/images/controls/plus.svg"
headerText: qsTr("Servers")
actionButtonFunction: function() {
menu.visible = false
connectionTypeSelection.visible = true
}
}
ConnectionTypeSelectionDrawer {
id: connectionTypeSelection
}
}
FlickableType {
anchors.top: serversMenuHeader.bottom
anchors.topMargin: 16
contentHeight: col.implicitHeight
Column {
id: col
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
spacing: 16
ButtonGroup {
id: serversRadioButtonGroup
}
ListView {
id: serversMenuContent
width: parent.width
height: serversMenuContent.contentItem.height
model: ServersModel
currentIndex: ServersModel.getDefaultServerIndex()
clip: true
interactive: false
delegate: Item {
id: menuContentDelegate
property variant delegateData: model
implicitWidth: serversMenuContent.width
2023-06-01 11:25:33 +08:00
implicitHeight: serverRadioButtonContent.implicitHeight
2023-06-01 11:25:33 +08:00
ColumnLayout {
id: serverRadioButtonContent
anchors.fill: parent
2023-06-01 11:25:33 +08:00
anchors.rightMargin: 16
anchors.leftMargin: 16
2023-06-01 11:25:33 +08:00
spacing: 0
RowLayout {
2023-06-01 11:25:33 +08:00
VerticalRadioButton {
id: serverRadioButton
2023-06-01 11:25:33 +08:00
Layout.fillWidth: true
2023-06-01 11:25:33 +08:00
text: name
2023-06-05 22:40:35 +08:00
descriptionText: hostName
2023-06-01 11:25:33 +08:00
checked: index === serversMenuContent.currentIndex
2023-06-01 11:25:33 +08:00
ButtonGroup.group: serversRadioButtonGroup
2023-06-01 11:25:33 +08:00
onClicked: {
serversMenuContent.currentIndex = index
2023-06-01 11:25:33 +08:00
isDefault = true
ContainersModel.setCurrentlyProcessedServerIndex(index)
}
2023-06-01 11:25:33 +08:00
MouseArea {
anchors.fill: serverRadioButton
cursorShape: Qt.PointingHandCursor
enabled: false
}
}
ImageButtonType {
image: "qrc:/images/controls/settings.svg"
2023-06-01 11:25:33 +08:00
implicitWidth: 56
implicitHeight: 56
2023-05-11 14:50:50 +08:00
2023-06-01 11:25:33 +08:00
z: 1
2023-06-01 11:25:33 +08:00
onClicked: function() {
ServersModel.setCurrentlyProcessedServerIndex(index)
ContainersModel.setCurrentlyProcessedServerIndex(index)
goToPage(PageEnum.PageSettingsServerInfo)
menu.visible = false
}
}
2023-05-11 14:50:50 +08:00
}
2023-05-15 13:38:17 +08:00
2023-06-01 11:25:33 +08:00
DividerType {
Layout.fillWidth: true
2023-05-15 13:38:17 +08:00
}
}
}
}
}
}
}
}