feat: Allow to enable auto message

This commit is contained in:
Anthony Laibe 2021-11-24 15:20:05 +01:00
parent 30d1866ee6
commit 2d49da7331
9 changed files with 80 additions and 1 deletions

View File

@ -44,6 +44,12 @@ method toggleTelemetry*[T](self: Controller[T]) =
method isTelemetryEnabled*[T](self: Controller[T]): bool =
return self.settingsService.isTelemetryEnabled()
method toggleAutoMessage*[T](self: Controller[T]) =
self.settingsService.toggleAutoMessage()
method isAutoMessageEnabled*[T](self: Controller[T]): bool =
return self.settingsService.isAutoMessageEnabled()
method toggleDebug*[T](self: Controller[T]) =
self.settingsService.toggleDebug()

View File

@ -15,6 +15,12 @@ method toggleTelemetry*(self: AccessInterface) {.base.} =
method isTelemetryEnabled*(self: AccessInterface): bool {.base.} =
raise newException(ValueError, "No implementation available")
method toggleAutoMessage*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method isAutoMessageEnabled*(self: AccessInterface): bool {.base.} =
raise newException(ValueError, "No implementation available")
method toggleDebug*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -14,6 +14,9 @@ method isLoaded*(self: AccessInterface): bool {.base.} =
method toggleTelemetry*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method toggleAutoMessage*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method toggleDebug*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -87,6 +87,7 @@ method load*[T](self: Module[T]) =
self.view.setIsTelemetryEnabled(self.controller.isTelemetryEnabled())
self.view.setIsDebugEnabled(self.controller.isDebugEnabled())
self.view.setIsAutoMessageEnabled(self.controller.isAutoMessageEnabled())
self.moduleLoaded = true
self.delegate.profileSectionDidLoad()
@ -100,5 +101,8 @@ method viewDidLoad*(self: Module) =
method toggleTelemetry*[T](self: Module[T]) =
self.controller.toggleTelemetry()
method toggleAutoMessage*[T](self: Module[T]) =
self.controller.toggleAutoMessage()
method toggleDebug*[T](self: Module[T]) =
self.controller.toggleDebug()

View File

@ -9,6 +9,7 @@ QtObject:
# TODO: move to the correct module once all have been merged
isTelemetryEnabled: bool
isDebugEnabled: bool
isAutoMessageEnabled: bool
proc setup(self: View) =
self.QObject.setup
@ -54,3 +55,20 @@ QtObject:
proc toggleDebug*(self: View) {.slot.} =
self.delegate.toggleDebug()
self.setIsDebugEnabled(not self.isDebugEnabled)
proc isAutoMessageEnabledChanged*(self: View) {.signal.}
proc setIsAutoMessageEnabled*(self: View, isAutoMessageEnabled: bool) =
self.isAutoMessageEnabled = isAutoMessageEnabled
self.isAutoMessageEnabledChanged()
proc getIsAutoMessageEnabled*(self: View): QVariant {.slot.} =
return newQVariant(self.isAutoMessageEnabled)
QtProperty[QVariant] isAutoMessageEnabled:
read = getIsAutoMessageEnabled
notify = isAutoMessageEnabledChanged
proc toggleAutoMessage*(self: View) {.slot.} =
self.delegate.toggleAutoMessage()
self.setIsAutoMessageEnabled(not self.isAutoMessageEnabled)

View File

@ -93,6 +93,13 @@ method isTelemetryEnabled*(self: Service): bool =
let telemetryServerUrl = status_go_settings.getSetting[string](Setting.TelemetryServerUrl)
return telemetryServerUrl != ""
method toggleAutoMessage*(self: Service) =
let enabled = status_go_settings.getSetting[bool](Setting.AutoMessageEnabled)
discard status_go_settings.saveSetting(Setting.AutoMessageEnabled, not enabled)
method isAutoMessageEnabled*(self: Service): bool =
return status_go_settings.getSetting[bool](Setting.AutoMessageEnabled)
method toggleDebug*(self: Service) =
var nodeConfig = status_go_settings.getNodeConfig()
if nodeConfig["LogLevel"].getStr() == $LogLevel.INFO:

View File

@ -57,6 +57,12 @@ method toggleTelemetry*(self: ServiceInterface) {.base.} =
method isTelemetryEnabled*(self: ServiceInterface): bool {.base.} =
raise newException(ValueError, "No implementation available")
method toggleAutoMessage*(self: ServiceInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method isAutoMessageEnabled*(self: ServiceInterface): bool {.base.} =
raise newException(ValueError, "No implementation available")
method toggleDebug*(self: ServiceInterface) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -417,6 +417,7 @@ ScrollView {
}
}
// TODO: replace with StatusQ component
StatusSettingsLineButton {
text: qsTr("Debug")
isSwitch: true
@ -425,6 +426,16 @@ ScrollView {
openPopup(enableDebugComponent)
}
}
// TODO: replace with StatusQ component
StatusSettingsLineButton {
text: qsTr("Enable Auto message")
isSwitch: true
switchChecked: root.store.profileModuleInst.isAutoMessageEnabled
onClicked: {
openPopup(enableAutoMessageConfirmationDialogComponent, {light: false})
}
}
}
NetworksModal {
@ -453,6 +464,24 @@ ScrollView {
}
}
Component {
id: enableAutoMessageConfirmationDialogComponent
ConfirmationDialog {
property bool mode: false
id: confirmDialog
showCancelButton: true
confirmationText: qsTr("Are you sure you want to enable auto message? You need to restart the app for this change to take effect.")
onConfirmButtonClicked: {
root.store.profileModuleInst.toggleAutoMessage()
close()
}
onCancelButtonClicked: {
close()
}
}
}
Component {
id: enableDebugComponent
ConfirmationDialog {

2
vendor/status-lib vendored

@ -1 +1 @@
Subproject commit c7a7bdc0df39ee25e2fe77cb7a0a362b74247aa2
Subproject commit cd5412823a8727e2decc3be430818309c57b3a92