From ca71de4a2d3bb1e6a3efdd4249732e3053132578 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Wed, 12 Jun 2024 10:41:26 -0700 Subject: [PATCH 1/7] Update wallpaper rotation to handle changes from GUI --- ovos_gui_plugin_shell_companion/__init__.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ovos_gui_plugin_shell_companion/__init__.py b/ovos_gui_plugin_shell_companion/__init__.py index 8908778..ce31afa 100644 --- a/ovos_gui_plugin_shell_companion/__init__.py +++ b/ovos_gui_plugin_shell_companion/__init__.py @@ -1,6 +1,9 @@ import platform from os.path import join, dirname + +from ovos_bus_client.message import GUIMessage + from ovos_bus_client.client import MessageBusClient from ovos_bus_client import Message from ovos_utils import network_utils @@ -155,11 +158,25 @@ def handle_device_about_page(self, message): self.gui['system_info'] = system_information self.gui.show_page("SYSTEM_AdditionalSettings.qml", override_idle=True) - def handle_display_wallpaper_rotation_config_set(self, message): + def handle_display_wallpaper_rotation_config_set(self, message: GUIMessage): + """ + Handle a GUI event requesting a new wallpaper rotation setting + @param message: `speaker.extension.display.set.wallpaper.rotation` + """ wallpaper_rotation = message.data.get("wallpaper_rotation", False) self.local_display_config["wallpaper_rotation"] = wallpaper_rotation self.local_display_config.store() - self.bus.emit(Message("speaker.extension.display.wallpaper.rotation.changed")) + + LOG.info(message.data) + # TODO: Is rotation time defined here? + + if wallpaper_rotation: + msg_type = "ovos.wallpaper.manager.enable.auto.rotation" + else: + msg_type = "ovos.wallpaper.manager.disable.auto.rotation" + self.bus.emit(message.forward(msg_type)) + # TODO Is the below message consumed anywhere? + self.bus.emit(message.forward("speaker.extension.display.wallpaper.rotation.changed")) def handle_display_auto_dim_config_set(self, message): auto_dim = message.data.get("auto_dim", False) From 626b215039e031607823c7b90079c01d51040fed Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Wed, 12 Jun 2024 13:09:26 -0700 Subject: [PATCH 2/7] Emit Messagebus event directly from QML instead of via GUI event handler --- ovos_gui_plugin_shell_companion/__init__.py | 8 -------- .../res/ui/settings/display_settings.qml | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ovos_gui_plugin_shell_companion/__init__.py b/ovos_gui_plugin_shell_companion/__init__.py index ce31afa..1058f9e 100644 --- a/ovos_gui_plugin_shell_companion/__init__.py +++ b/ovos_gui_plugin_shell_companion/__init__.py @@ -167,14 +167,6 @@ def handle_display_wallpaper_rotation_config_set(self, message: GUIMessage): self.local_display_config["wallpaper_rotation"] = wallpaper_rotation self.local_display_config.store() - LOG.info(message.data) - # TODO: Is rotation time defined here? - - if wallpaper_rotation: - msg_type = "ovos.wallpaper.manager.enable.auto.rotation" - else: - msg_type = "ovos.wallpaper.manager.disable.auto.rotation" - self.bus.emit(message.forward(msg_type)) # TODO Is the below message consumed anywhere? self.bus.emit(message.forward("speaker.extension.display.wallpaper.rotation.changed")) diff --git a/ovos_gui_plugin_shell_companion/res/ui/settings/display_settings.qml b/ovos_gui_plugin_shell_companion/res/ui/settings/display_settings.qml index 911b48b..e1c8859 100644 --- a/ovos_gui_plugin_shell_companion/res/ui/settings/display_settings.qml +++ b/ovos_gui_plugin_shell_companion/res/ui/settings/display_settings.qml @@ -161,6 +161,13 @@ Item { onClicked: { console.log(autoWallpaperRotationSwitch.checked) Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("../snd/clicked.wav")) + if (autoWallpaperRotationSwitch.checked) { + Mycroft.MycroftController.sendRequest("ovos.wallpaper.manager.enable.auto.rotation") + } + else { + Mycroft.MycroftController.sendRequest("ovos.wallpaper.manager.disable.auto.rotation") + } + // TODO: deprecate this event? triggerGuiEvent("speaker.extension.display.set.wallpaper.rotation", {"wallpaper_rotation": autoWallpaperRotationSwitch.checked}) } } From 66beebc4e4f9f7e6abfcd91c1b0fe37c44e07726 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Wed, 12 Jun 2024 13:22:06 -0700 Subject: [PATCH 3/7] Troubleshoot errors Refactor and note changes to deprecate GUI bus event --- ovos_gui_plugin_shell_companion/__init__.py | 10 ++++++---- .../res/ui/settings/display_settings.qml | 12 ++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/ovos_gui_plugin_shell_companion/__init__.py b/ovos_gui_plugin_shell_companion/__init__.py index 1058f9e..9f921be 100644 --- a/ovos_gui_plugin_shell_companion/__init__.py +++ b/ovos_gui_plugin_shell_companion/__init__.py @@ -80,7 +80,8 @@ def register_bus_events(self): # Display settings self.gui.register_handler("speaker.extension.display.set.wallpaper.rotation", self.handle_display_wallpaper_rotation_config_set) - self.gui.register_handler("speaker.extension.display.set.auto.dim", self.handle_display_auto_dim_config_set) + self.gui.register_handler("speaker.extension.display.set.auto.dim", + self.handle_display_auto_dim_config_set) self.gui.register_handler("speaker.extension.display.set.auto.nightmode", self.handle_display_auto_nightmode_config_set) @@ -145,7 +146,10 @@ def handle_device_display_factory(self, message): def handle_device_display_settings(self, message): LOG.debug(f"Display settings: {self.local_display_config}") self.gui['state'] = 'settings/display_settings' + + # TODO: Refactor below to query PHAL plugin self.gui['display_wallpaper_rotation'] = self.local_display_config.get("wallpaper_rotation", False) + self.gui['display_auto_dim'] = self.local_display_config.get("auto_dim", False) self.gui['display_auto_nightmode'] = self.local_display_config.get("auto_nightmode", False) self.gui.show_page("SYSTEM_AdditionalSettings.qml", override_idle=True) @@ -163,13 +167,11 @@ def handle_display_wallpaper_rotation_config_set(self, message: GUIMessage): Handle a GUI event requesting a new wallpaper rotation setting @param message: `speaker.extension.display.set.wallpaper.rotation` """ + # TODO: This should come from the PHAL plugin, not a separate config wallpaper_rotation = message.data.get("wallpaper_rotation", False) self.local_display_config["wallpaper_rotation"] = wallpaper_rotation self.local_display_config.store() - # TODO Is the below message consumed anywhere? - self.bus.emit(message.forward("speaker.extension.display.wallpaper.rotation.changed")) - def handle_display_auto_dim_config_set(self, message): auto_dim = message.data.get("auto_dim", False) self.local_display_config["auto_dim"] = auto_dim diff --git a/ovos_gui_plugin_shell_companion/res/ui/settings/display_settings.qml b/ovos_gui_plugin_shell_companion/res/ui/settings/display_settings.qml index e1c8859..0be1f28 100644 --- a/ovos_gui_plugin_shell_companion/res/ui/settings/display_settings.qml +++ b/ovos_gui_plugin_shell_companion/res/ui/settings/display_settings.qml @@ -161,12 +161,12 @@ Item { onClicked: { console.log(autoWallpaperRotationSwitch.checked) Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("../snd/clicked.wav")) - if (autoWallpaperRotationSwitch.checked) { - Mycroft.MycroftController.sendRequest("ovos.wallpaper.manager.enable.auto.rotation") - } - else { - Mycroft.MycroftController.sendRequest("ovos.wallpaper.manager.disable.auto.rotation") - } + if (autoWallpaperRotationSwitch.checked === true) { + Mycroft.MycroftController.sendRequest("ovos.wallpaper.manager.enable.auto.rotation", {}) + } + else { + Mycroft.MycroftController.sendRequest("ovos.wallpaper.manager.disable.auto.rotation", {}) + } // TODO: deprecate this event? triggerGuiEvent("speaker.extension.display.set.wallpaper.rotation", {"wallpaper_rotation": autoWallpaperRotationSwitch.checked}) } From 6c1e1f26df704051fb8f38f529877f678a5da0ba Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Wed, 12 Jun 2024 13:39:19 -0700 Subject: [PATCH 4/7] Add context to GUI events --- .../res/ui/settings/display_settings.qml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ovos_gui_plugin_shell_companion/res/ui/settings/display_settings.qml b/ovos_gui_plugin_shell_companion/res/ui/settings/display_settings.qml index 0be1f28..0ec0b64 100644 --- a/ovos_gui_plugin_shell_companion/res/ui/settings/display_settings.qml +++ b/ovos_gui_plugin_shell_companion/res/ui/settings/display_settings.qml @@ -33,12 +33,12 @@ Item { property bool menuLabelsEnabled: false function getAutoRotation() { - Mycroft.MycroftController.sendRequest("ovos.wallpaper.manager.get.auto.rotation", {}) + Mycroft.MycroftController.sendRequest("ovos.wallpaper.manager.get.auto.rotation", {}, {"session": {"session_id": "default"}}) } Component.onCompleted: { getAutoRotation() - Mycroft.MycroftController.sendRequest("ovos.shell.get.menuLabels.status", {}) + Mycroft.MycroftController.sendRequest("ovos.shell.get.menuLabels.status", {}, {"session": {"session_id": "default"}}) } Connections { @@ -162,10 +162,10 @@ Item { console.log(autoWallpaperRotationSwitch.checked) Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("../snd/clicked.wav")) if (autoWallpaperRotationSwitch.checked === true) { - Mycroft.MycroftController.sendRequest("ovos.wallpaper.manager.enable.auto.rotation", {}) + Mycroft.MycroftController.sendRequest("ovos.wallpaper.manager.enable.auto.rotation", {}, {"session": {"session_id": "default"}}) } else { - Mycroft.MycroftController.sendRequest("ovos.wallpaper.manager.disable.auto.rotation", {}) + Mycroft.MycroftController.sendRequest("ovos.wallpaper.manager.disable.auto.rotation", {}, {"session": {"session_id": "default"}}) } // TODO: deprecate this event? triggerGuiEvent("speaker.extension.display.set.wallpaper.rotation", {"wallpaper_rotation": autoWallpaperRotationSwitch.checked}) @@ -372,7 +372,7 @@ Item { onClicked: { console.log(displayMenuLabelsSwitch.checked) Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("../snd/clicked.wav")) - Mycroft.MycroftController.sendRequest("ovos.shell.set.menuLabels", {"enabled": displayMenuLabelsSwitch.checked}) + Mycroft.MycroftController.sendRequest("ovos.shell.set.menuLabels", {"enabled": displayMenuLabelsSwitch.checked}, {"session": {"session_id": "default"}}) } } } From 5b6a0006009fe1d7951cc288b381f4a3a607ed94 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Wed, 12 Jun 2024 13:40:38 -0700 Subject: [PATCH 5/7] Remove `wallpaper_rotation` session data that is handled in Qt already --- ovos_gui_plugin_shell_companion/__init__.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/ovos_gui_plugin_shell_companion/__init__.py b/ovos_gui_plugin_shell_companion/__init__.py index 9f921be..a86e22a 100644 --- a/ovos_gui_plugin_shell_companion/__init__.py +++ b/ovos_gui_plugin_shell_companion/__init__.py @@ -78,8 +78,6 @@ def register_bus_events(self): self.gui.register_handler("mycroft.device.settings.factory", self.handle_device_display_factory) # Display settings - self.gui.register_handler("speaker.extension.display.set.wallpaper.rotation", - self.handle_display_wallpaper_rotation_config_set) self.gui.register_handler("speaker.extension.display.set.auto.dim", self.handle_display_auto_dim_config_set) self.gui.register_handler("speaker.extension.display.set.auto.nightmode", @@ -146,10 +144,7 @@ def handle_device_display_factory(self, message): def handle_device_display_settings(self, message): LOG.debug(f"Display settings: {self.local_display_config}") self.gui['state'] = 'settings/display_settings' - - # TODO: Refactor below to query PHAL plugin - self.gui['display_wallpaper_rotation'] = self.local_display_config.get("wallpaper_rotation", False) - + # wallpaper_rotation data is determined via Messagebus in Qt directly self.gui['display_auto_dim'] = self.local_display_config.get("auto_dim", False) self.gui['display_auto_nightmode'] = self.local_display_config.get("auto_nightmode", False) self.gui.show_page("SYSTEM_AdditionalSettings.qml", override_idle=True) @@ -162,16 +157,6 @@ def handle_device_about_page(self, message): self.gui['system_info'] = system_information self.gui.show_page("SYSTEM_AdditionalSettings.qml", override_idle=True) - def handle_display_wallpaper_rotation_config_set(self, message: GUIMessage): - """ - Handle a GUI event requesting a new wallpaper rotation setting - @param message: `speaker.extension.display.set.wallpaper.rotation` - """ - # TODO: This should come from the PHAL plugin, not a separate config - wallpaper_rotation = message.data.get("wallpaper_rotation", False) - self.local_display_config["wallpaper_rotation"] = wallpaper_rotation - self.local_display_config.store() - def handle_display_auto_dim_config_set(self, message): auto_dim = message.data.get("auto_dim", False) self.local_display_config["auto_dim"] = auto_dim From 8205546213b28374c6e670e4bc608860e9235fd1 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Wed, 12 Jun 2024 13:49:12 -0700 Subject: [PATCH 6/7] Remove unused import --- ovos_gui_plugin_shell_companion/__init__.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/ovos_gui_plugin_shell_companion/__init__.py b/ovos_gui_plugin_shell_companion/__init__.py index a86e22a..f30b7eb 100644 --- a/ovos_gui_plugin_shell_companion/__init__.py +++ b/ovos_gui_plugin_shell_companion/__init__.py @@ -1,9 +1,6 @@ import platform from os.path import join, dirname - -from ovos_bus_client.message import GUIMessage - from ovos_bus_client.client import MessageBusClient from ovos_bus_client import Message from ovos_utils import network_utils From 5f2be6bb7b73f5be6dcfd689d4d845f1fc4b59de Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Wed, 12 Jun 2024 13:52:13 -0700 Subject: [PATCH 7/7] Remove unused GUI event --- .../res/ui/settings/display_settings.qml | 2 -- 1 file changed, 2 deletions(-) diff --git a/ovos_gui_plugin_shell_companion/res/ui/settings/display_settings.qml b/ovos_gui_plugin_shell_companion/res/ui/settings/display_settings.qml index 0ec0b64..83ea3e6 100644 --- a/ovos_gui_plugin_shell_companion/res/ui/settings/display_settings.qml +++ b/ovos_gui_plugin_shell_companion/res/ui/settings/display_settings.qml @@ -167,8 +167,6 @@ Item { else { Mycroft.MycroftController.sendRequest("ovos.wallpaper.manager.disable.auto.rotation", {}, {"session": {"session_id": "default"}}) } - // TODO: deprecate this event? - triggerGuiEvent("speaker.extension.display.set.wallpaper.rotation", {"wallpaper_rotation": autoWallpaperRotationSwitch.checked}) } } }