feat(nodes): Add toggle to WakuNodesModal

Closes: #5000
This commit is contained in:
Boris Melnik 2022-03-29 15:04:56 +03:00 committed by Iuri Matias
parent 7a89781c38
commit 2a27aa17a7
9 changed files with 54 additions and 17 deletions

View File

@ -50,3 +50,9 @@ proc saveNewMailserver*(self: Controller, name: string, nodeAddress: string) =
proc enableAutomaticSelection*(self: Controller, value: bool) = proc enableAutomaticSelection*(self: Controller, value: bool) =
self.mailserversService.enableAutomaticSelection(value) self.mailserversService.enableAutomaticSelection(value)
method getUseMailservers*(self: Controller): bool =
return self.settingsService.getUseMailservers()
method setUseMailservers*(self: Controller, value: bool): bool =
return self.settingsService.saveUseMailservers(value)

View File

@ -35,3 +35,9 @@ method saveNewMailserver*(self: AccessInterface, name: string, nodeAddress: stri
method enableAutomaticSelection*(self: AccessInterface, value: bool) {.base.} = method enableAutomaticSelection*(self: AccessInterface, value: bool) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method getUseMailservers*(self: AccessInterface): bool {.base.} =
raise newException(ValueError, "No implementation available")
method setUseMailservers*(self: AccessInterface, value: bool) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -83,3 +83,10 @@ method saveNewMailserver*(self: Module, name: string, nodeAddress: string) =
method enableAutomaticSelection*(self: Module, value: bool) = method enableAutomaticSelection*(self: Module, value: bool) =
self.controller.enableAutomaticSelection(value) self.controller.enableAutomaticSelection(value)
method getUseMailservers*(self: Module): bool =
return self.controller.getUseMailservers()
method setUseMailservers*(self: Module, value: bool) =
if (self.controller.setUseMailservers(value)):
self.view.useMailserversChanged()

View File

@ -64,3 +64,13 @@ QtObject:
proc enableAutomaticSelection(self: View, value: bool) {.slot.} = proc enableAutomaticSelection(self: View, value: bool) {.slot.} =
self.delegate.enableAutomaticSelection(value) self.delegate.enableAutomaticSelection(value)
proc useMailserversChanged*(self: View) {.signal.}
proc getUseMailservers*(self: View): bool {.slot.} =
return self.delegate.getUseMailservers()
QtProperty[bool] useMailservers:
read = getUseMailservers
notify = useMailserversChanged
proc setUseMailservers*(self: View, value: bool) {.slot.} =
self.delegate.setUseMailservers(value)

View File

@ -45,20 +45,22 @@ StatusModal {
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: Style.current.padding anchors.rightMargin: Style.current.padding
// TODO re-add that when the status-go API to disconnect from the mailserver is added StatusListItem {
// StatusListItem { anchors.left: parent.left
// anchors.left: parent.left anchors.leftMargin: -Style.current.padding
// anchors.leftMargin: -Style.current.padding anchors.right: parent.right
// anchors.right: parent.right anchors.rightMargin: -Style.current.padding
// anchors.rightMargin: -Style.current.padding title: qsTr("Use Waku nodes")
// title: qsTr("Use Waku nodes") components: [
// components: [ StatusSwitch {
// StatusSwitch { checked: root.messagingStore.useMailservers
// // TODO find what this is onCheckedChanged: root.messagingStore.toggleUseMailservers(checked)
// checked: true }
// } ]
// ] sensor.onClicked: {
// } root.messagingStore.toggleUseMailservers(!root.messagingStore.useMailservers)
}
}
Separator { Separator {
anchors.left: parent.left anchors.left: parent.left

View File

@ -17,6 +17,12 @@ QtObject {
property var mailservers: syncModule.model property var mailservers: syncModule.model
property bool useMailservers: syncModule.useMailservers
function toggleUseMailservers(value) {
root.syncModule.useMailservers = value
}
// Module Properties // Module Properties
property bool automaticMailserverSelection: syncModule.automaticSelection property bool automaticMailserverSelection: syncModule.automaticSelection
property string activeMailserver: syncModule.activeMailserver property string activeMailserver: syncModule.activeMailserver