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"
|
2020-06-19 18:06:58 +00:00
|
|
|
import "../../../../shared"
|
2020-09-17 15:55:09 +00:00
|
|
|
import "../../../../shared/status"
|
2020-05-27 21:28:25 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: syncContainer
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-05-27 21:28:25 +00:00
|
|
|
id: element4
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Sync settings"
|
|
|
|
text: qsTrId("sync-settings")
|
2020-05-27 21:28:25 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 24
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 24
|
|
|
|
font.weight: Font.Bold
|
|
|
|
font.pixelSize: 20
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: mailserversList
|
2020-09-15 11:21:23 +00:00
|
|
|
|
2020-09-17 15:55:09 +00:00
|
|
|
StatusRadioButton {
|
|
|
|
text: name
|
2021-01-07 17:41:20 +00:00
|
|
|
checked: name == profileModel.mailservers.activeMailserver
|
|
|
|
onClicked: {
|
|
|
|
if (checked) {
|
|
|
|
profileModel.mailservers.setMailserver(name);
|
|
|
|
}
|
|
|
|
}
|
2020-05-27 21:28:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-11 19:31:47 +00:00
|
|
|
Item {
|
|
|
|
id: addMailserver
|
|
|
|
width: parent.width
|
|
|
|
height: addButton.height
|
|
|
|
anchors.top: element4.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 24
|
|
|
|
|
|
|
|
StatusRoundButton {
|
|
|
|
id: addButton
|
|
|
|
icon.name: "plusSign"
|
|
|
|
size: "medium"
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: usernameText
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Add mailserver"
|
|
|
|
text: qsTrId("add-mailserver")
|
2021-01-11 19:31:47 +00:00
|
|
|
color: Style.current.blue
|
|
|
|
anchors.left: addButton.right
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.verticalCenter: addButton.verticalCenter
|
|
|
|
font.pixelSize: 15
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: addMailserverPopup.open()
|
|
|
|
}
|
|
|
|
|
|
|
|
ModalPopup {
|
|
|
|
id: addMailserverPopup
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Add mailserver"
|
|
|
|
title: qsTrId("add-mailserver")
|
2021-01-11 19:31:47 +00:00
|
|
|
|
|
|
|
property string nameValidationError: ""
|
|
|
|
property string enodeValidationError: ""
|
|
|
|
|
|
|
|
function validate() {
|
|
|
|
nameValidationError = ""
|
|
|
|
enodeValidationError = ""
|
|
|
|
|
|
|
|
if (nameInput.text === "") {
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "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 === "") {
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "You need to enter the enode address"
|
|
|
|
enodeValidationError = qsTrId("you-need-to-enter-the-enode-address")
|
2021-01-11 19:31:47 +00:00
|
|
|
}
|
|
|
|
return !nameValidationError && !enodeValidationError
|
|
|
|
}
|
|
|
|
|
|
|
|
onOpened: {
|
|
|
|
nameInput.text = "";
|
|
|
|
enodeInput.text = "";
|
|
|
|
|
|
|
|
nameValidationError = "";
|
|
|
|
enodeValidationError = "";
|
|
|
|
}
|
|
|
|
|
2021-01-28 11:04:10 +00:00
|
|
|
footer: StatusButton {
|
2021-01-11 19:31:47 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.smallPadding
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Save"
|
|
|
|
text: qsTrId("save")
|
2021-01-11 19:31:47 +00:00
|
|
|
anchors.bottom: parent.bottom
|
2021-01-28 11:04:10 +00:00
|
|
|
enabled: nameInput.text !== "" && enodeInput.text !== ""
|
2021-01-11 19:31:47 +00:00
|
|
|
onClicked: {
|
|
|
|
if (!addMailserverPopup.validate()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
profileModel.mailservers.save(nameInput.text, enodeInput.text)
|
|
|
|
addMailserverPopup.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Input {
|
|
|
|
id: nameInput
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Name"
|
|
|
|
label: qsTrId("name")
|
|
|
|
//% "Specify a name"
|
|
|
|
placeholderText: qsTrId("specify-name")
|
2021-01-11 19:31:47 +00:00
|
|
|
validationError: addMailserverPopup.nameValidationError
|
|
|
|
}
|
|
|
|
|
|
|
|
Input {
|
|
|
|
id: enodeInput
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "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-")
|
2021-01-11 19:31:47 +00:00
|
|
|
validationError: addMailserverPopup.enodeValidationError
|
|
|
|
anchors.top: nameInput.bottom
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: switchLbl
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Automatic mailserver selection"
|
|
|
|
text: qsTrId("automatic-mailserver-selection")
|
2021-01-11 19:31:47 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 24
|
|
|
|
anchors.top: addMailserver.bottom
|
|
|
|
anchors.topMargin: 24
|
|
|
|
}
|
|
|
|
|
2021-01-07 17:41:20 +00:00
|
|
|
StatusSwitch {
|
|
|
|
id: automaticSelectionSwitch
|
|
|
|
checked: profileModel.mailservers.automaticSelection
|
|
|
|
onCheckedChanged: profileModel.mailservers.enableAutomaticSelection(checked)
|
2021-01-11 19:31:47 +00:00
|
|
|
anchors.top: addMailserver.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
anchors.left: switchLbl.right
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
|
2021-01-07 17:41:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "..."
|
|
|
|
text: profileModel.mailservers.activeMailserver || qsTrId("---")
|
2021-01-07 17:41:20 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 24
|
2021-01-11 19:31:47 +00:00
|
|
|
anchors.top: switchLbl.bottom
|
2021-01-07 17:41:20 +00:00
|
|
|
anchors.topMargin: 24
|
|
|
|
visible: automaticSelectionSwitch.checked
|
|
|
|
}
|
|
|
|
|
2020-05-27 21:28:25 +00:00
|
|
|
ListView {
|
|
|
|
id: mailServersListView
|
2021-01-11 19:31:47 +00:00
|
|
|
anchors.topMargin: 200
|
|
|
|
anchors.top: automaticSelectionSwitch.bottom
|
2020-05-27 21:28:25 +00:00
|
|
|
anchors.fill: parent
|
2020-12-06 22:15:51 +00:00
|
|
|
model: profileModel.mailservers.list
|
2020-05-27 21:28:25 +00:00
|
|
|
delegate: mailserversList
|
2021-01-07 17:41:20 +00:00
|
|
|
visible: !automaticSelectionSwitch.checked
|
2020-05-27 21:28:25 +00:00
|
|
|
}
|
|
|
|
}
|