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

@ -69,4 +69,4 @@ method setProfilePicturesVisibility*(self: AccessInterface, value: int) {.base.}
raise newException(ValueError, "No implementation available")
method getPasswordStrengthScore*(self: AccessInterface, password: string): int {.base.} =
raise newException(ValueError, "No implementation available")
raise newException(ValueError, "No implementation available")

View File

@ -98,4 +98,4 @@ method setProfilePicturesVisibility*(self: Module, value: int) =
self.view.profilePicturesVisibilityChanged()
method getPasswordStrengthScore*(self: Module, password: string): int =
return self.controller.getPasswordStrengthScore(password, singletonInstance.userProfile.getUsername())
return self.controller.getPasswordStrengthScore(password, singletonInstance.userProfile.getUsername())

View File

@ -82,4 +82,4 @@ QtObject:
self.delegate.setProfilePicturesVisibility(value)
proc getPasswordStrengthScore*(self: View, password: string): int {.slot.} =
return self.delegate.getPasswordStrengthScore(password)
return self.delegate.getPasswordStrengthScore(password)

View File

@ -50,3 +50,9 @@ proc saveNewMailserver*(self: Controller, name: string, nodeAddress: string) =
proc enableAutomaticSelection*(self: Controller, value: bool) =
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.} =
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) =
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.} =
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.rightMargin: Style.current.padding
// TODO re-add that when the status-go API to disconnect from the mailserver is added
// StatusListItem {
// anchors.left: parent.left
// anchors.leftMargin: -Style.current.padding
// anchors.right: parent.right
// anchors.rightMargin: -Style.current.padding
// title: qsTr("Use Waku nodes")
// components: [
// StatusSwitch {
// // TODO find what this is
// checked: true
// }
// ]
// }
StatusListItem {
anchors.left: parent.left
anchors.leftMargin: -Style.current.padding
anchors.right: parent.right
anchors.rightMargin: -Style.current.padding
title: qsTr("Use Waku nodes")
components: [
StatusSwitch {
checked: root.messagingStore.useMailservers
onCheckedChanged: root.messagingStore.toggleUseMailservers(checked)
}
]
sensor.onClicked: {
root.messagingStore.toggleUseMailservers(!root.messagingStore.useMailservers)
}
}
Separator {
anchors.left: parent.left

View File

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