status-desktop/ui/app/AppLayouts/Profile/Sections/SyncContainer.qml

192 lines
6.3 KiB
QML
Raw Normal View History

2020-06-17 19:18:31 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
2020-05-27 21:28:25 +00:00
import "../../../../imports"
import "../../../../shared"
import "../../../../shared/status"
2020-05-27 21:28:25 +00:00
Item {
id: syncContainer
Layout.fillHeight: true
Layout.fillWidth: true
property string activeMailserver: ""
Connections {
target: profileModel.mailservers
onActiveMailserverChanged: (activeMailserver) => {
syncContainer.activeMailserver = activeMailserver
}
}
2020-05-27 21:28:25 +00:00
Item {
width: profileContainer.profileContentWidth
anchors.horizontalCenter: parent.horizontalCenter
2020-05-27 21:28:25 +00:00
Component {
id: mailserversList
StatusRadioButton {
id: rbSetMailsever
text: name
checked: name === activeMailserver.activeMailserver
onClicked: {
if (checked) {
profileModel.mailservers.setMailserver(name);
}
2021-01-07 17:41:20 +00:00
}
}
2020-05-27 21:28:25 +00:00
}
Item {
id: addMailserver
width: parent.width
height: addButton.height
anchors.top: parent.top
anchors.topMargin: 24
anchors.left: parent.left
anchors.leftMargin: 24
StatusRoundButton {
id: addButton
icon.name: "plusSign"
size: "medium"
type: "secondary"
anchors.verticalCenter: parent.verticalCenter
}
2021-01-11 19:31:47 +00:00
StyledText {
id: usernameText
//% "Add mailserver"
text: qsTrId("add-mailserver")
color: Style.current.blue
anchors.left: addButton.right
anchors.leftMargin: Style.current.padding
anchors.verticalCenter: addButton.verticalCenter
font.pixelSize: 15
}
2021-01-11 19:31:47 +00:00
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: addMailserverPopup.open()
}
2021-01-11 19:31:47 +00:00
ModalPopup {
id: addMailserverPopup
//% "Add mailserver"
title: qsTrId("add-mailserver")
2021-01-11 19:31:47 +00:00
property string nameValidationError: ""
property string enodeValidationError: ""
2021-01-11 19:31:47 +00:00
function validate() {
nameValidationError = ""
enodeValidationError = ""
if (nameInput.text === "") {
//% "You need to enter a name"
nameValidationError = qsTrId("you-need-to-enter-a-name")
}
2021-01-11 19:31:47 +00:00
if (enodeInput.text === "") {
//% "You need to enter the enode address"
enodeValidationError = qsTrId("you-need-to-enter-the-enode-address")
}
return !nameValidationError && !enodeValidationError
2021-01-11 19:31:47 +00:00
}
onOpened: {
nameInput.text = "";
enodeInput.text = "";
nameValidationError = "";
enodeValidationError = "";
}
2021-01-11 19:31:47 +00:00
footer: StatusButton {
anchors.right: parent.right
anchors.rightMargin: Style.current.smallPadding
//% "Save"
text: qsTrId("save")
anchors.bottom: parent.bottom
enabled: nameInput.text !== "" && enodeInput.text !== ""
onClicked: {
if (!addMailserverPopup.validate()) {
return;
}
profileModel.mailservers.save(nameInput.text, enodeInput.text)
addMailserverPopup.close()
2021-01-11 19:31:47 +00:00
}
}
Input {
id: nameInput
//% "Name"
label: qsTrId("name")
//% "Specify a name"
placeholderText: qsTrId("specify-name")
validationError: addMailserverPopup.nameValidationError
}
2021-01-11 19:31:47 +00:00
Input {
id: enodeInput
//% "History node address"
label: qsTrId("history-node-address")
//% "enode://{enode-id}:{password}@{ip-address}:{port-number}"
placeholderText: qsTrId("enode----enode-id---password---ip-address---port-number-")
validationError: addMailserverPopup.enodeValidationError
anchors.top: nameInput.bottom
anchors.topMargin: Style.current.bigPadding
}
2021-01-11 19:31:47 +00:00
}
2021-01-11 19:31:47 +00:00
}
StyledText {
id: switchLbl
//% "Automatic mailserver selection"
text: qsTrId("automatic-mailserver-selection")
anchors.left: parent.left
anchors.leftMargin: 24
anchors.top: addMailserver.bottom
anchors.topMargin: 24
}
2021-01-11 19:31:47 +00:00
StatusSwitch {
id: automaticSelectionSwitch
checked: profileModel.mailservers.automaticSelection
onCheckedChanged: profileModel.mailservers.enableAutomaticSelection(checked)
anchors.top: addMailserver.bottom
anchors.topMargin: Style.current.padding
anchors.left: switchLbl.right
anchors.leftMargin: Style.current.padding
2021-01-11 19:31:47 +00:00
}
2021-01-07 17:41:20 +00:00
StyledText {
//% "..."
text: profileModel.mailservers.activeMailserver || qsTrId("---")
anchors.left: parent.left
anchors.leftMargin: 24
anchors.top: switchLbl.bottom
anchors.topMargin: 24
visible: automaticSelectionSwitch.checked
}
2021-01-07 17:41:20 +00:00
ListView {
id: mailServersListView
anchors.topMargin: 200
anchors.top: automaticSelectionSwitch.bottom
anchors.fill: parent
model: profileModel.mailservers.list
delegate: mailserversList
visible: !automaticSelectionSwitch.checked
Component.onCompleted: {
profileModel.mailservers.getActiveMailserver()
}
}
2020-05-27 21:28:25 +00:00
}
}