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

fix: gui pages #40

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Changes from all 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
19 changes: 7 additions & 12 deletions ovos_PHAL_plugin_system/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class SystemEventsPlugin(PHALPlugin):
def __init__(self, bus=None, config=None):
super().__init__(bus=bus, name="ovos-PHAL-plugin-system", config=config)
self.gui = GUIInterface(bus=self.bus, skill_id=self.name,
ui_directories={"qt5": join(dirname(__file__), "ui")},
config=self.config_core.get('gui'))
self.bus.on("system.ssh.status", self.handle_ssh_status)
self.bus.on("system.ssh.enable", self.handle_ssh_enable_request)
Expand Down Expand Up @@ -201,28 +202,25 @@ def handle_ssh_enable_request(self, message):
subprocess.call(f"systemctl start {self.ssh_service}", shell=True)
# ovos-shell does not want to display
if message.data.get("display", True):
page = join(dirname(__file__), "ui", "Status.qml")
self.gui["status"] = "Enabled"
self.gui["label"] = "SSH Enabled"
self.gui.show_page(page)
self.gui.show_page("Status")

def handle_ssh_disable_request(self, message):
subprocess.call(f"systemctl stop {self.ssh_service}", shell=True)
subprocess.call(f"systemctl disable {self.ssh_service}", shell=True)
# ovos-shell does not want to display
if message.data.get("display", True):
page = join(dirname(__file__), "ui", "Status.qml")
self.gui["status"] = "Disabled"
self.gui["label"] = "SSH Disabled"
self.gui.show_page(page)
self.gui.show_page("Status")

def handle_reboot_request(self, message):
"""
Shut down and restart the system
"""
if message.data.get("display", True):
page = join(dirname(__file__), "ui", "Reboot.qml")
self.gui.show_page(page, override_animations=True,
self.gui.show_page("Reboot", override_animations=True,
override_idle=True)

script = os.path.expanduser(self.config.get("reboot_script") or "")
Expand All @@ -237,8 +235,7 @@ def handle_shutdown_request(self, message):
Turn the system completely off (with no option to inhibit it)
"""
if message.data.get("display", True):
page = join(dirname(__file__), "ui", "Shutdown.qml")
self.gui.show_page(page, override_animations=True,
self.gui.show_page("Shutdown", override_animations=True,
override_idle=True)
script = os.path.expanduser(self.config.get("shutdown_script") or "")
LOG.info(f"Shutdown requested. script={script}")
Expand All @@ -261,18 +258,16 @@ def handle_configure_language_request(self, message):
# it is usually part of other groups of actions that may
# provide their own UI
if message.data.get("display", False):
page = join(dirname(__file__), "ui", "Status.qml")
self.gui["status"] = "Enabled"
self.gui["label"] = f"Language changed to {language_code}"
self.gui.show_page(page)
self.gui.show_page("Status")

self.bus.emit(Message('system.configure.language.complete',
{"lang": language_code}))

def handle_mycroft_restart_request(self, message):
if message.data.get("display", True):
page = join(dirname(__file__), "ui", "Restart.qml")
self.gui.show_page(page, override_animations=True,
self.gui.show_page("Restart", override_animations=True,
override_idle=True)
service = self.core_service_name
# TODO - clean up this mess
Expand Down
Loading