Files
amnezia-client/client/ui/qml/main2.qml
T

250 lines
6.6 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Layouts
2023-09-06 22:20:59 +05:00
import QtQuick.Dialogs
2023-06-01 11:25:33 +08:00
import PageEnum 1.0
2024-07-07 13:42:38 +03:00
import Style 1.0
import "Config"
2023-06-01 11:25:33 +08:00
import "Controls2"
2024-02-16 15:24:06 +05:00
import "Components"
import "Pages2"
Window {
id: root
2023-09-06 22:20:59 +05:00
objectName: "mainWindow"
visible: true
width: GC.screenWidth
height: GC.screenHeight
minimumWidth: GC.isDesktop() ? 360 : 0
minimumHeight: GC.isDesktop() ? 640 : 0
maximumWidth: 600
maximumHeight: 800
color: AmneziaStyle.color.midnightBlack
onClosing: function() {
console.debug("QML onClosing signal")
PageController.closeWindow()
}
title: "AmneziaVPN"
2023-06-01 11:25:33 +08:00
Connections {
target: PageController
function onRaiseMainWindow() {
2023-07-14 13:14:50 +09:00
root.show()
root.raise()
root.requestActivate()
}
function onHideMainWindow() {
root.hide()
}
function onShowErrorMessage(errorMessage) {
popupErrorMessage.text = errorMessage
popupErrorMessage.open()
}
function onShowNotificationMessage(message) {
popupNotificationMessage.text = message
popupNotificationMessage.closeButtonVisible = false
popupNotificationMessage.open()
popupNotificationTimer.start()
}
2023-08-02 20:37:43 +09:00
function onShowPassphraseRequestDrawer() {
privateKeyPassphraseDrawer.open()
}
function onGoToPageSettingsBackup() {
PageController.goToPage(PageEnum.PageSettingsBackup)
}
function onShowBusyIndicator(visible) {
busyIndicator.visible = visible
PageController.disableControls(visible)
}
}
Connections {
target: SettingsController
2024-03-20 21:22:29 +07:00
function onChangeSettingsFinished(finishedMessage) {
PageController.showNotificationMessage(finishedMessage)
}
}
PageStart {
width: root.width
height: root.height
}
Item {
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: parent.bottom
implicitHeight: popupNotificationMessage.height
PopupType {
id: popupNotificationMessage
}
Timer {
id: popupNotificationTimer
interval: 3000
repeat: false
running: false
onTriggered: {
popupNotificationMessage.close()
}
}
}
Item {
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: parent.bottom
implicitHeight: popupErrorMessage.height
PopupType {
id: popupErrorMessage
}
}
2023-08-02 20:37:43 +09:00
Item {
2024-02-16 15:24:06 +05:00
anchors.fill: parent
2023-08-02 20:37:43 +09:00
2024-02-16 15:24:06 +05:00
DrawerType2 {
2023-08-02 20:37:43 +09:00
id: privateKeyPassphraseDrawer
2024-02-16 15:24:06 +05:00
anchors.fill: parent
expandedHeight: root.height * 0.35
2023-08-02 20:37:43 +09:00
2024-02-16 15:24:06 +05:00
expandedContent: ColumnLayout {
2023-08-02 20:37:43 +09:00
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 16
anchors.leftMargin: 16
anchors.rightMargin: 16
2024-02-16 15:24:06 +05:00
Connections {
target: privateKeyPassphraseDrawer
function onOpened() {
passphrase.textFieldText = ""
passphrase.textField.forceActiveFocus()
}
function onAboutToHide() {
if (passphrase.textFieldText !== "") {
PageController.showBusyIndicator(true)
}
}
function onAboutToShow() {
PageController.showBusyIndicator(false)
}
}
2023-08-02 20:37:43 +09:00
TextFieldWithHeaderType {
id: passphrase
property bool hidePassword: true
Layout.fillWidth: true
headerText: qsTr("Private key passphrase")
textField.echoMode: hidePassword ? TextInput.Password : TextInput.Normal
buttonImageSource: hidePassword ? "qrc:/images/controls/eye.svg" : "qrc:/images/controls/eye-off.svg"
clickedFunc: function() {
hidePassword = !hidePassword
}
KeyNavigation.tab: saveButton
2023-08-02 20:37:43 +09:00
}
BasicButtonType {
id: saveButton
2023-08-02 20:37:43 +09:00
Layout.fillWidth: true
2024-07-07 13:42:38 +03:00
defaultColor: AmneziaStyle.color.transparent
hoveredColor: AmneziaStyle.color.translucentWhite
pressedColor: AmneziaStyle.color.sheerWhite
disabledColor: AmneziaStyle.color.mutedGray
textColor: AmneziaStyle.color.paleGray
2023-08-02 20:37:43 +09:00
borderWidth: 1
text: qsTr("Save")
clickedFunc: function() {
2023-08-02 20:37:43 +09:00
privateKeyPassphraseDrawer.close()
PageController.passphraseRequestDrawerClosed(passphrase.textFieldText)
}
}
}
}
}
2023-09-06 22:20:59 +05:00
2024-02-16 15:24:06 +05:00
Item {
anchors.fill: parent
QuestionDrawer {
id: questionDrawer
anchors.fill: parent
}
}
Item {
anchors.fill: parent
BusyIndicatorType {
id: busyIndicator
anchors.centerIn: parent
z: 1
}
}
2024-02-16 15:24:06 +05:00
function showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction) {
questionDrawer.headerText = headerText
questionDrawer.descriptionText = descriptionText
questionDrawer.yesButtonText = yesButtonText
questionDrawer.noButtonText = noButtonText
questionDrawer.yesButtonFunction = function() {
questionDrawer.close()
if (yesButtonFunction && typeof yesButtonFunction === "function") {
yesButtonFunction()
}
}
questionDrawer.noButtonFunction = function() {
questionDrawer.close()
if (noButtonFunction && typeof noButtonFunction === "function") {
noButtonFunction()
}
}
questionDrawer.open()
}
2023-09-06 22:20:59 +05:00
FileDialog {
id: mainFileDialog
property bool isSaveMode: false
2023-09-06 22:20:59 +05:00
objectName: "mainFileDialog"
fileMode: isSaveMode ? FileDialog.SaveFile : FileDialog.OpenFile
2023-09-06 22:20:59 +05:00
onAccepted: SystemController.fileDialogClosed(true)
onRejected: SystemController.fileDialogClosed(false)
2023-09-06 22:20:59 +05:00
}
}