feat: Add power_devices to the power screen close #1475

This commit is contained in:
Alfredo Monclus committed 2026-02-28 11:49:10 -03:00
1 parent e0675137fc
commit fbaa1e1fd8
2 files changed
+20 -1

No files matched your search

+1
View File
@@ -4,6 +4,7 @@ Probably all versions contain changes regarding documentation, translation, fixe
## Current master
* if printer power_devices in ks config add shortcut to shutdown panel
* change default value on macro shortcut to false
* rotate the move buttons according to screw_rotation
* add caching of some resources for perfomance
+19 -1
View File
@@ -16,6 +16,12 @@ class Panel(ScreenPanel):
estop = self._gtk.Button("emergency", _("Emergency Stop"), "color2")
estop.connect("clicked", self.emergency_stop)
power_panel = {
"panel": "power",
}
power_shortcut = self._gtk.Button("shutdown", _("Power"), "color2")
power_shortcut.connect("clicked", self.menu_item_clicked, power_panel)
poweroff = self._gtk.Button("shutdown", _("Shutdown"), "color1")
poweroff.connect("clicked", self.reboot_poweroff, "shutdown")
@@ -29,8 +35,20 @@ class Panel(ScreenPanel):
lock_screen.connect("clicked", self._screen.lock_screen.lock)
self.main = Gtk.Grid(row_homogeneous=True, column_homogeneous=True)
if self._printer and self._printer.state not in {'disconnected', 'startup', 'shutdown', 'error'}:
show_estop = self._printer and self._printer.state not in {'disconnected', 'startup', 'shutdown', 'error'}
show_power_shortcut = False
if self.ks_printer_cfg is not None and self._screen._ws.connected:
power_devices = self.ks_printer_cfg.get("power_devices", "")
if power_devices and self._printer.get_power_devices():
show_power_shortcut = True
if show_estop and show_power_shortcut:
self.main.attach(estop, 0, 0, 1, 1)
self.main.attach(power_shortcut, 0, 1, 1, 1)
elif show_estop:
self.main.attach(estop, 0, 0, 1, 2)
elif show_power_shortcut:
self.main.attach(power_shortcut, 0, 0, 1, 2)
self.main.attach(restart_ks, 1, 0, 1, 1)
self.main.attach(lock_screen, 2, 0, 1, 1)
self.main.attach(poweroff, 1, 1, 1, 1)