diff --git a/src/app/modules/main/profile_section/advanced/controller.nim b/src/app/modules/main/profile_section/advanced/controller.nim index 52f6f01b7f..d1b6e79247 100644 --- a/src/app/modules/main/profile_section/advanced/controller.nim +++ b/src/app/modules/main/profile_section/advanced/controller.nim @@ -100,6 +100,13 @@ method setWakuV2LightClientEnabled*(self: Controller, enabled: bool) = self.delegate.onWakuV2LightClientSet() +method enableDeveloperFeatures*(self: Controller) = + discard self.settingsService.saveTelemetryServerUrl(DEFAULT_TELEMETRY_SERVER_URL) + discard self.settingsService.saveAutoMessageEnabled(true) + discard self.nodeConfigurationService.setDebugLevel(LogLevel.DEBUG) + + quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported + method toggleTelemetry*(self: Controller) = var value = "" if(not self.isTelemetryEnabled()): diff --git a/src/app/modules/main/profile_section/advanced/controller_interface.nim b/src/app/modules/main/profile_section/advanced/controller_interface.nim index b49ec122ab..377e0ba862 100644 --- a/src/app/modules/main/profile_section/advanced/controller_interface.nim +++ b/src/app/modules/main/profile_section/advanced/controller_interface.nim @@ -34,6 +34,9 @@ method getWakuV2LightClientEnabled*(self: AccessInterface): bool {.base.} = method setWakuV2LightClientEnabled*(self: AccessInterface, enabled: bool) {.base.} = raise newException(ValueError, "No implementation available") +method enableDeveloperFeatures*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + method toggleTelemetry*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/profile_section/advanced/module.nim b/src/app/modules/main/profile_section/advanced/module.nim index 61faa1fb93..277a8d03ce 100644 --- a/src/app/modules/main/profile_section/advanced/module.nim +++ b/src/app/modules/main/profile_section/advanced/module.nim @@ -103,6 +103,9 @@ method onWakuV2LightClientSet*(self: Module) = method isTelemetryEnabled*(self: Module): bool = self.controller.isTelemetryEnabled() + +method enableDeveloperFeatures*(self: Module) = + self.controller.enableDeveloperFeatures() method toggleTelemetry*(self: Module) = self.controller.toggleTelemetry() @@ -126,8 +129,7 @@ method toggleDebug*(self: Module) = self.controller.toggleDebug() method onDebugToggled*(self: Module) = - info "quit the app because of successful debug level changed" - quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported + self.view.isDebugEnabledChanged() method addCustomNetwork*(self: Module, name: string, endpoint: string, networkId: int, networkType: string) = var network: settings_service.Network diff --git a/src/app/modules/main/profile_section/advanced/private_interfaces/module_view_delegate_interface.nim b/src/app/modules/main/profile_section/advanced/private_interfaces/module_view_delegate_interface.nim index 144c43a4cd..aebab80dc1 100644 --- a/src/app/modules/main/profile_section/advanced/private_interfaces/module_view_delegate_interface.nim +++ b/src/app/modules/main/profile_section/advanced/private_interfaces/module_view_delegate_interface.nim @@ -63,4 +63,7 @@ method toggleCommunitySection*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") method toggleNodeManagementSection*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + +method enableDeveloperFeatures*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") \ No newline at end of file diff --git a/src/app/modules/main/profile_section/advanced/view.nim b/src/app/modules/main/profile_section/advanced/view.nim index 7bf3f33cb7..11fdd4e41f 100644 --- a/src/app/modules/main/profile_section/advanced/view.nim +++ b/src/app/modules/main/profile_section/advanced/view.nim @@ -152,4 +152,7 @@ QtObject: self.delegate.toggleCommunitySection() proc toggleNodeManagementSection*(self: View) {.slot.} = - self.delegate.toggleNodeManagementSection() \ No newline at end of file + self.delegate.toggleNodeManagementSection() + + proc enableDeveloperFeatures*(self: View) {.slot.} = + self.delegate.enableDeveloperFeatures() \ No newline at end of file diff --git a/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml b/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml index 3e29869eda..e4e832c874 100644 --- a/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml +++ b/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml @@ -98,6 +98,13 @@ QtObject { root.advancedModule.toggleDebug() } + function enableDeveloperFeatures() { + if(!root.advancedModule) + return + + root.advancedModule.enableDeveloperFeatures() + } + function addCustomNetwork(name, endpoint, networkId, networkType) { if(!root.advancedModule) return diff --git a/ui/app/AppLayouts/Profile/views/AdvancedView.qml b/ui/app/AppLayouts/Profile/views/AdvancedView.qml index 378150f903..6b7359f738 100644 --- a/ui/app/AppLayouts/Profile/views/AdvancedView.qml +++ b/ui/app/AppLayouts/Profile/views/AdvancedView.qml @@ -374,6 +374,41 @@ ScrollView { } } + StatusSectionHeadline { + text: qsTr("Developer features") + topPadding: Style.current.bigPadding + bottomPadding: Style.current.padding + } + + Separator { + anchors.topMargin: Style.current.bigPadding + anchors.left: parent.left + anchors.leftMargin: -Style.current.padding + anchors.right: parent.right + anchors.rightMargin: -Style.current.padding + } + + StatusSettingsLineButton { + text: qsTr("Full developer mode") + isEnabled: { + return !localAccountSensitiveSettings.downloadChannelMessagesEnabled || + !root.advancedStore.isTelemetryEnabled || + !root.advancedStore.isDebugEnabled || + !root.advancedStore.isAutoMessageEnabled + } + onClicked: { + Global.openPopup(enableDeveloperFeaturesConfirmationDialogComponent) + } + } + + Separator { + anchors.topMargin: Style.current.bigPadding + anchors.left: parent.left + anchors.leftMargin: -Style.current.padding + anchors.right: parent.right + anchors.rightMargin: -Style.current.padding + } + // TODO: replace with StatusQ component StatusSettingsLineButton { text: qsTr("Download messages") @@ -386,22 +421,11 @@ ScrollView { // TODO: replace with StatusQ component StatusSettingsLineButton { - text: qsTr("Stickers/ENS on ropsten") - visible: root.advancedStore.currentNetworkId === Constants.networkRopsten - isSwitch: true - switchChecked: localAccountSensitiveSettings.stickersEnsRopsten - onClicked: { - localAccountSensitiveSettings.stickersEnsRopsten = !localAccountSensitiveSettings.stickersEnsRopsten - } - } - - // TODO: replace with StatusQ component - StatusSettingsLineButton { - text: qsTr("Enable Telemetry") + text: qsTr("Telemetry") isSwitch: true switchChecked: root.advancedStore.isTelemetryEnabled onClicked: { - Global.openPopup(enableTelemetryConfirmationDialogComponent, {light: false}) + Global.openPopup(enableTelemetryConfirmationDialogComponent) } } @@ -417,11 +441,22 @@ ScrollView { // TODO: replace with StatusQ component StatusSettingsLineButton { - text: qsTr("Enable Auto message") + text: qsTr("Auto message") isSwitch: true switchChecked: root.advancedStore.isAutoMessageEnabled onClicked: { - Global.openPopup(enableAutoMessageConfirmationDialogComponent, {light: false}) + Global.openPopup(enableAutoMessageConfirmationDialogComponent) + } + } + + // TODO: replace with StatusQ component + StatusSettingsLineButton { + text: qsTr("Stickers/ENS on ropsten") + visible: root.advancedStore.currentNetworkId === Constants.networkRopsten + isSwitch: true + switchChecked: localAccountSensitiveSettings.stickersEnsRopsten + onClicked: { + localAccountSensitiveSettings.stickersEnsRopsten = !localAccountSensitiveSettings.stickersEnsRopsten } } } @@ -436,6 +471,25 @@ ScrollView { advancedStore: root.advancedStore } + Component { + id: enableDeveloperFeaturesConfirmationDialogComponent + ConfirmationDialog { + property bool mode: false + + id: confirmDialog + showCancelButton: true + confirmationText: qsTr("Are you sure you want to enable all the develoer features? The app will be restarted.") + onConfirmButtonClicked: { + localAccountSensitiveSettings.downloadChannelMessagesEnabled = true + Qt.callLater(root.advancedStore.enableDeveloperFeatures) + close() + } + onCancelButtonClicked: { + close() + } + } + } + Component { id: enableTelemetryConfirmationDialogComponent ConfirmationDialog { @@ -479,7 +533,7 @@ ScrollView { id: confirmDialog showCancelButton: true - confirmationText: qsTr("Are you sure you want to %1 debug mode? The app will be restarted for this change to take effect.").arg(root.advancedStore.isDebugEnabled ? + confirmationText: qsTr("Are you sure you want to %1 debug mode? You need to restart the app for this change to take effect.").arg(root.advancedStore.isDebugEnabled ? qsTr("disable") : qsTr("enable")) onConfirmButtonClicked: {