Share pages refactoring
This commit is contained in:
parent
396af917b5
commit
836075de10
15 changed files with 222 additions and 622 deletions
|
@ -11,6 +11,11 @@ PageShareProtocolBase {
|
|||
protocol: ProtocolEnum.Any
|
||||
logic: ShareConnectionLogic
|
||||
|
||||
readonly property string generateConfigText: qsTr("Generate config")
|
||||
readonly property string generatingConfigText: qsTr("Generating config...")
|
||||
readonly property string showConfigText: qsTr("Show config")
|
||||
property bool genConfigProcess: false
|
||||
|
||||
BackButton {
|
||||
id: back
|
||||
}
|
||||
|
@ -19,72 +24,113 @@ PageShareProtocolBase {
|
|||
text: qsTr("Share for Amnezia")
|
||||
}
|
||||
|
||||
Text {
|
||||
id: lb_desc
|
||||
Flickable {
|
||||
id: fl
|
||||
width: root.width
|
||||
anchors.top: caption.bottom
|
||||
anchors.topMargin: 20
|
||||
width: parent.width - 60
|
||||
anchors.horizontalCenter: root.horizontalCenter
|
||||
|
||||
font.family: "Lato"
|
||||
font.styleName: "normal"
|
||||
font.pixelSize: 16
|
||||
color: "#181922"
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
wrapMode: Text.Wrap
|
||||
text: qsTr("Anyone who logs in with this code will be able to connect to this VPN server. \nThis code does not include server credentials.")
|
||||
}
|
||||
|
||||
TextAreaType {
|
||||
anchors.top: lb_desc.bottom
|
||||
anchors.topMargin: 20
|
||||
anchors.bottom: pb_gen.top
|
||||
anchors.bottomMargin: 20
|
||||
|
||||
anchors.horizontalCenter: root.horizontalCenter
|
||||
width: parent.width - 60
|
||||
|
||||
textArea.readOnly: true
|
||||
textArea.wrapMode: TextEdit.WrapAnywhere
|
||||
textArea.verticalAlignment: Text.AlignTop
|
||||
textArea.text: ShareConnectionLogic.textEditShareAmneziaCodeText
|
||||
}
|
||||
|
||||
|
||||
ShareConnectionButtonType {
|
||||
id: pb_gen
|
||||
anchors.bottom: pb_copy.top
|
||||
anchors.bottomMargin: 10
|
||||
anchors.horizontalCenter: root.horizontalCenter
|
||||
width: parent.width - 60
|
||||
text: ShareConnectionLogic.pushButtonShareAmneziaGenerateText
|
||||
enabled: ShareConnectionLogic.pushButtonShareAmneziaGenerateEnabled
|
||||
onClicked: {
|
||||
ShareConnectionLogic.onPushButtonShareAmneziaGenerateClicked()
|
||||
}
|
||||
}
|
||||
ShareConnectionButtonType {
|
||||
id: pb_copy
|
||||
anchors.bottom: pb_save.top
|
||||
anchors.bottomMargin: 10
|
||||
anchors.horizontalCenter: root.horizontalCenter
|
||||
width: parent.width - 60
|
||||
text: ShareConnectionLogic.pushButtonShareAmneziaCopyText
|
||||
onClicked: {
|
||||
ShareConnectionLogic.onPushButtonShareAmneziaCopyClicked()
|
||||
}
|
||||
enabled: ShareConnectionLogic.pushButtonShareAmneziaCopyEnabled
|
||||
}
|
||||
ShareConnectionButtonType {
|
||||
id: pb_save
|
||||
anchors.bottom: root.bottom
|
||||
anchors.bottomMargin: 10
|
||||
anchors.horizontalCenter: root.horizontalCenter
|
||||
width: parent.width - 60
|
||||
text: qsTr("Save file")
|
||||
onClicked: {
|
||||
ShareConnectionLogic.onPushButtonShareAmneziaSaveClicked()
|
||||
anchors.bottomMargin: 20
|
||||
anchors.left: root.left
|
||||
anchors.leftMargin: 30
|
||||
anchors.right: root.right
|
||||
anchors.rightMargin: 30
|
||||
|
||||
contentHeight: content.height + 20
|
||||
clip: true
|
||||
|
||||
ColumnLayout {
|
||||
id: content
|
||||
enabled: logic.pageEnabled
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
Text {
|
||||
id: lb_desc
|
||||
Layout.fillWidth: true
|
||||
font.family: "Lato"
|
||||
font.styleName: "normal"
|
||||
font.pixelSize: 16
|
||||
color: "#181922"
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
wrapMode: Text.Wrap
|
||||
text: ShareConnectionLogic.shareFullAccess
|
||||
? qsTr("Anyone who logs in with this code will have the same permissions to use VPN and YOUR SERVER as you. \n
|
||||
This code includes your server credentials!\n
|
||||
Provide this code only to TRUSTED users.")
|
||||
: qsTr("Anyone who logs in with this code will be able to connect to this VPN server. \n
|
||||
This code does not include server credentials.")
|
||||
|
||||
}
|
||||
|
||||
ShareConnectionButtonType {
|
||||
id: pb_gen
|
||||
Layout.topMargin: 20
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 40
|
||||
|
||||
text: ShareConnectionLogic.shareFullAccess
|
||||
? showConfigText
|
||||
: (genConfigProcess ? generatingConfigText : generateConfigText)
|
||||
onClicked: {
|
||||
enabled = false
|
||||
genConfigProcess = true
|
||||
ShareConnectionLogic.onPushButtonShareAmneziaGenerateClicked()
|
||||
enabled = true
|
||||
genConfigProcess = false
|
||||
}
|
||||
}
|
||||
|
||||
TextAreaType {
|
||||
id: tfShareCode
|
||||
|
||||
Layout.topMargin: 20
|
||||
Layout.bottomMargin: 20
|
||||
Layout.preferredHeight: 200
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
textArea.readOnly: true
|
||||
textArea.wrapMode: TextEdit.WrapAnywhere
|
||||
textArea.verticalAlignment: Text.AlignTop
|
||||
textArea.text: ShareConnectionLogic.textEditShareAmneziaCodeText
|
||||
|
||||
visible: tfShareCode.textArea.length > 0
|
||||
}
|
||||
|
||||
|
||||
ShareConnectionButtonCopyType {
|
||||
id: pb_copy
|
||||
Layout.bottomMargin: 10
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 40
|
||||
enabled: tfShareCode.textArea.length > 0
|
||||
visible: tfShareCode.textArea.length > 0
|
||||
}
|
||||
ShareConnectionButtonType {
|
||||
id: pb_save
|
||||
Layout.bottomMargin: 10
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 40
|
||||
text: qsTr("Save to file")
|
||||
enabled: tfShareCode.textArea.length > 0
|
||||
visible: tfShareCode.textArea.length > 0
|
||||
|
||||
onClicked: {
|
||||
UiLogic.saveTextFile(qsTr("Save AmneziaVPN config"), "*.vpn", tfShareCode.textArea.text)
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
id: label_share_code
|
||||
Layout.topMargin: 20
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: width
|
||||
smooth: false
|
||||
source: ShareConnectionLogic.shareAmneziaQrCodeText
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,22 +29,15 @@ PageShareProtocolBase {
|
|||
width: parent.width - 60
|
||||
|
||||
textArea.readOnly: true
|
||||
|
||||
textArea.text: ShareConnectionLogic.plainTextEditShareCloakText
|
||||
textArea.text: ShareConnectionLogic.textEditShareCloakText
|
||||
}
|
||||
|
||||
ShareConnectionButtonType {
|
||||
ShareConnectionButtonCopyType {
|
||||
id: pb_save
|
||||
anchors.bottom: root.bottom
|
||||
anchors.bottomMargin: 10
|
||||
anchors.horizontalCenter: root.horizontalCenter
|
||||
width: parent.width - 60
|
||||
text: ShareConnectionLogic.pushButtonShareCloakCopyText
|
||||
//enabled: ShareConnectionLogic.pushButtonShareCloakCopyEnabled
|
||||
onClicked: {
|
||||
ShareConnectionLogic.onPushButtonShareCloakCopyClicked()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ PageShareProtocolBase {
|
|||
}
|
||||
|
||||
TextAreaType {
|
||||
id: tfShareCode
|
||||
anchors.top: caption.bottom
|
||||
anchors.topMargin: 20
|
||||
anchors.bottom: pb_gen.top
|
||||
|
@ -44,22 +45,19 @@ PageShareProtocolBase {
|
|||
|
||||
text: ShareConnectionLogic.pushButtonShareOpenVpnGenerateText
|
||||
onClicked: {
|
||||
enabled = false
|
||||
ShareConnectionLogic.onPushButtonShareOpenVpnGenerateClicked()
|
||||
enabled = true
|
||||
}
|
||||
enabled: ShareConnectionLogic.pushButtonShareOpenVpnGenerateEnabled
|
||||
}
|
||||
ShareConnectionButtonType {
|
||||
ShareConnectionButtonCopyType {
|
||||
id: pb_copy
|
||||
anchors.bottom: pb_save.top
|
||||
anchors.bottomMargin: 10
|
||||
anchors.horizontalCenter: root.horizontalCenter
|
||||
width: parent.width - 60
|
||||
|
||||
text: ShareConnectionLogic.pushButtonShareOpenVpnCopyText
|
||||
enabled: ShareConnectionLogic.pushButtonShareOpenVpnCopyEnabled
|
||||
onClicked: {
|
||||
ShareConnectionLogic.onPushButtonShareOpenVpnCopyClicked()
|
||||
}
|
||||
enabled: tfShareCode.textArea.length > 0
|
||||
}
|
||||
ShareConnectionButtonType {
|
||||
id: pb_save
|
||||
|
@ -68,10 +66,11 @@ PageShareProtocolBase {
|
|||
anchors.horizontalCenter: root.horizontalCenter
|
||||
width: parent.width - 60
|
||||
|
||||
text: qsTr("Save file")
|
||||
enabled: ShareConnectionLogic.pushButtonShareOpenVpnSaveEnabled
|
||||
text: qsTr("Save to file")
|
||||
enabled: tfShareCode.textArea.length > 0
|
||||
|
||||
onClicked: {
|
||||
ShareConnectionLogic.onPushButtonShareOpenVpnSaveClicked()
|
||||
UiLogic.saveTextFile(qsTr("Save OpenVPN config"), "*.ovpn", tfShareCode.textArea.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ PageShareProtocolBase {
|
|||
width: root.width
|
||||
anchors.top: caption.bottom
|
||||
anchors.topMargin: 20
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottom: root.bottom
|
||||
anchors.bottomMargin: 20
|
||||
anchors.left: root.left
|
||||
anchors.leftMargin: 30
|
||||
|
@ -108,14 +108,10 @@ PageShareProtocolBase {
|
|||
text: ShareConnectionLogic.lineEditShareShadowSocksStringText
|
||||
readOnly: true
|
||||
}
|
||||
ShareConnectionButtonType {
|
||||
height: 40
|
||||
ShareConnectionButtonCopyType {
|
||||
Layout.preferredHeight: 40
|
||||
Layout.fillWidth: true
|
||||
text: ShareConnectionLogic.pushButtonShareShadowSocksCopyText
|
||||
enabled: tfConnString.length > 0
|
||||
onClicked: {
|
||||
ShareConnectionLogic.onPushButtonShareShadowSocksCopyClicked()
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
|
@ -124,7 +120,7 @@ PageShareProtocolBase {
|
|||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: width
|
||||
smooth: false
|
||||
source: ShareConnectionLogic.labelShareShadowSocksQrCodeText
|
||||
source: ShareConnectionLogic.shareShadowSocksQrCodeText
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue