Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update wallpaper rotation to handle changes from GUI #25

Merged
merged 7 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions ovos_gui_plugin_shell_companion/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import platform

from os.path import join, dirname

from ovos_bus_client.message import GUIMessage
NeonDaniel marked this conversation as resolved.
Show resolved Hide resolved

from ovos_bus_client.client import MessageBusClient
from ovos_bus_client import Message
from ovos_utils import network_utils
Expand Down Expand Up @@ -75,9 +78,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 +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'
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 +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):
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,6 +161,13 @@ Item {
onClicked: {
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", {}, {"session": {"session_id": "default"}})
}
else {
Mycroft.MycroftController.sendRequest("ovos.wallpaper.manager.disable.auto.rotation", {}, {"session": {"session_id": "default"}})
}
// TODO: deprecate this event?
NeonDaniel marked this conversation as resolved.
Show resolved Hide resolved
triggerGuiEvent("speaker.extension.display.set.wallpaper.rotation", {"wallpaper_rotation": autoWallpaperRotationSwitch.checked})
}
}
Expand Down Expand Up @@ -365,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"}})
}
}
}
Expand Down
Loading