feature/custom-drawer (#563)

Replaced all the DrawerType with DrawerType2
This commit is contained in:
Nethius 2024-02-16 15:24:06 +05:00 committed by GitHub
parent fd030a5fd4
commit 074562b141
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 1331 additions and 1319 deletions

View file

@ -16,19 +16,18 @@ import "../Controls2/TextTypes"
import "../Config"
import "../Components"
DrawerType {
DrawerType2 {
id: root
property alias headerText: header.headerText
property alias configContentHeaderText: configContentHeader.headerText
property alias contentVisible: content.visible
property string headerText
property string configContentHeaderText
property string contentVisible
property string configExtension: ".vpn"
property string configCaption: qsTr("Save AmneziaVPN config")
property string configFileName: "amnezia_config"
width: parent.width
height: parent.height * 0.9
expandedHeight: parent.height * 0.9
onClosed: {
configExtension = ".vpn"
@ -36,8 +35,8 @@ DrawerType {
configFileName = "amnezia_config"
}
Item {
anchors.fill: parent
expandedContent: Item {
implicitHeight: root.expandedHeight
Header2Type {
id: header
@ -47,6 +46,8 @@ DrawerType {
anchors.topMargin: 20
anchors.leftMargin: 16
anchors.rightMargin: 16
headerText: root.headerText
}
FlickableType {
@ -64,6 +65,8 @@ DrawerType {
anchors.leftMargin: 16
anchors.rightMargin: 16
visible: root.contentVisible
BasicButtonType {
Layout.fillWidth: true
Layout.topMargin: 16
@ -91,6 +94,7 @@ DrawerType {
}
BasicButtonType {
id: copyConfigTextButton
Layout.fillWidth: true
Layout.topMargin: 8
@ -103,20 +107,14 @@ DrawerType {
text: qsTr("Copy")
imageSource: "qrc:/images/controls/copy.svg"
onClicked: {
configText.selectAll()
configText.copy()
configText.select(0, 0)
PageController.showNotificationMessage(qsTr("Copied"))
}
}
BasicButtonType {
id: copyNativeConfigStringButton
Layout.fillWidth: true
Layout.topMargin: 8
visible: nativeConfigString.text !== ""
visible: false
defaultColor: "transparent"
hoveredColor: Qt.rgba(1, 1, 1, 0.08)
@ -127,13 +125,6 @@ DrawerType {
text: qsTr("Copy config string")
imageSource: "qrc:/images/controls/copy.svg"
onClicked: {
nativeConfigString.selectAll()
nativeConfigString.copy()
nativeConfigString.select(0, 0)
PageController.showNotificationMessage(qsTr("Copied"))
}
}
BasicButtonType {
@ -150,82 +141,116 @@ DrawerType {
text: qsTr("Show connection settings")
onClicked: {
configContentDrawer.visible = true
configContentDrawer.open()
}
}
DrawerType {
DrawerType2 {
id: configContentDrawer
width: parent.width
height: parent.height * 0.9
parent: root.parent
BackButtonType {
id: backButton
anchors.fill: parent
expandedHeight: parent.height * 0.9
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 16
expandedContent: Item {
id: configContentContainer
backButtonFunction: function() {
configContentDrawer.visible = false
implicitHeight: configContentDrawer.expandedHeight
Connections {
target: copyNativeConfigStringButton
function onClicked() {
nativeConfigString.selectAll()
nativeConfigString.copy()
nativeConfigString.select(0, 0)
PageController.showNotificationMessage(qsTr("Copied"))
}
}
}
FlickableType {
anchors.top: backButton.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
contentHeight: configContent.implicitHeight + configContent.anchors.topMargin + configContent.anchors.bottomMargin
ColumnLayout {
id: configContent
anchors.fill: parent
anchors.rightMargin: 16
anchors.leftMargin: 16
Header2Type {
id: configContentHeader
Layout.fillWidth: true
Layout.topMargin: 16
Connections {
target: copyConfigTextButton
function onClicked() {
configText.selectAll()
configText.copy()
configText.select(0, 0)
PageController.showNotificationMessage(qsTr("Copied"))
}
}
TextField {
id: nativeConfigString
visible: false
text: ExportController.nativeConfigString
BackButtonType {
id: backButton
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 16
backButtonFunction: function() {
configContentDrawer.open()
}
}
TextArea {
id: configText
FlickableType {
anchors.top: backButton.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
contentHeight: configContent.implicitHeight + configContent.anchors.topMargin + configContent.anchors.bottomMargin
Layout.fillWidth: true
Layout.topMargin: 16
Layout.bottomMargin: 16
ColumnLayout {
id: configContent
padding: 0
leftPadding: 0
height: 24
anchors.fill: parent
anchors.rightMargin: 16
anchors.leftMargin: 16
readOnly: true
Header2Type {
id: configContentHeader
Layout.fillWidth: true
Layout.topMargin: 16
color: "#D7D8DB"
selectionColor: "#633303"
selectedTextColor: "#D7D8DB"
headerText: root.configContentHeaderText
}
font.pixelSize: 16
font.weight: Font.Medium
font.family: "PT Root UI VF"
TextField {
id: nativeConfigString
visible: false
text: ExportController.nativeConfigString
text: ExportController.config
onTextChanged: {
copyNativeConfigStringButton.visible = nativeConfigString.text !== ""
}
}
wrapMode: Text.Wrap
TextArea {
id: configText
background: Rectangle {
color: "transparent"
Layout.fillWidth: true
Layout.topMargin: 16
Layout.bottomMargin: 16
padding: 0
leftPadding: 0
height: 24
readOnly: true
color: "#D7D8DB"
selectionColor: "#633303"
selectedTextColor: "#D7D8DB"
font.pixelSize: 16
font.weight: Font.Medium
font.family: "PT Root UI VF"
text: ExportController.config
wrapMode: Text.Wrap
background: Rectangle {
color: "transparent"
}
}
}
}