Skip to content

Commit

Permalink
Update wallpaper rotation to handle changes from GUI (#25)
Browse files Browse the repository at this point in the history
* Update wallpaper rotation to handle changes from GUI

* Emit Messagebus event directly from QML instead of via GUI event handler

* Troubleshoot errors
Refactor and note changes to deprecate GUI bus event

* Add context to GUI events

* Remove `wallpaper_rotation` session data that is handled in Qt already

* Remove unused import

* Remove unused GUI event

---------

Co-authored-by: Daniel McKnight <[email protected]>
  • Loading branch information
NeonDaniel and NeonDaniel authored Jun 13, 2024
1 parent feacd67 commit 9867c0c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
13 changes: 3 additions & 10 deletions ovos_gui_plugin_shell_companion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ 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.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)

Expand Down Expand Up @@ -142,7 +141,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'
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)
Expand All @@ -155,12 +154,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):
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"))

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -161,7 +161,12 @@ Item {
onClicked: {
console.log(autoWallpaperRotationSwitch.checked)
Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("../snd/clicked.wav"))
triggerGuiEvent("speaker.extension.display.set.wallpaper.rotation", {"wallpaper_rotation": autoWallpaperRotationSwitch.checked})
if (autoWallpaperRotationSwitch.checked === true) {
Mycroft.MycroftController.sendRequest("ovos.wallpaper.manager.enable.auto.rotation", {}, {"session": {"session_id": "default"}})
}
else {
Mycroft.MycroftController.sendRequest("ovos.wallpaper.manager.disable.auto.rotation", {}, {"session": {"session_id": "default"}})
}
}
}
}
Expand Down Expand Up @@ -365,7 +370,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"}})
}
}
}
Expand Down

0 comments on commit 9867c0c

Please sign in to comment.