feat: Menu active status (#1482)
* feat: menu active status, now used to show if homed and leveled * style: menu_active class
This commit is contained in:
1 parent
f4c6801a8c
commit
4172d59dbe
10 files changed
+69
-3
No files matched your search
@@ -7,30 +7,35 @@ name: {{ gettext('Home X') }}
|
||||
icon: home-x
|
||||
method: printer.gcode.script
|
||||
params: {"script":"G28 X"}
|
||||
active: {{ 'x' in printer.homed_axes }}
|
||||
|
||||
[menu move homing homey]
|
||||
name: {{ gettext('Home Y') }}
|
||||
icon: home-y
|
||||
method: printer.gcode.script
|
||||
params: {"script":"G28 Y"}
|
||||
active: {{ 'y' in printer.homed_axes }}
|
||||
|
||||
[menu move homing homez]
|
||||
name: {{ gettext('Home Z') }}
|
||||
icon: home-z
|
||||
method: printer.gcode.script
|
||||
params: {"script":"G28 Z"}
|
||||
active: {{ 'z' in printer.homed_axes }}
|
||||
|
||||
[menu move homing homeall]
|
||||
name: {{ gettext('Home All') }}
|
||||
icon: home
|
||||
method: printer.gcode.script
|
||||
params: {"script":"G28"}
|
||||
active: {{ 'xyz' in printer.homed_axes }}
|
||||
|
||||
[menu move homing homexy]
|
||||
name: {{ gettext('Home XY') }}
|
||||
icon: home
|
||||
method: printer.gcode.script
|
||||
params: {"script":"G28 X Y"}
|
||||
active: {{ 'xy' in printer.homed_axes }}
|
||||
|
||||
[menu move homing quad_gantry_level]
|
||||
name: {{ gettext('Quad Gantry Level') }}
|
||||
@@ -38,6 +43,7 @@ icon: home-z
|
||||
method: printer.gcode.script
|
||||
params: {"script":"QUAD_GANTRY_LEVEL"}
|
||||
enable: {{ 'quad_gantry_level' in printer.config_sections }}
|
||||
active: {{ printer.quad_gantry_level.applied }}
|
||||
|
||||
[menu move homing Z-Tilt]
|
||||
name: {{ gettext('Z Tilt') }}
|
||||
@@ -45,3 +51,4 @@ icon: z-tilt
|
||||
method: printer.gcode.script
|
||||
params: {"script":"Z_TILT_ADJUST"}
|
||||
enable: {{ 'z_tilt' in printer.config_sections }}
|
||||
active: {{ printer.z_tilt.applied }}
|
||||
@@ -191,7 +191,7 @@ class KlipperScreenConfig:
|
||||
strs = ('gcode', '')
|
||||
numbers = [f'{option}' for option in config[section] if option != 'gcode']
|
||||
elif section.startswith('menu '):
|
||||
strs = ('name', 'icon', 'panel', 'method', 'params', 'enable', 'confirm', 'style')
|
||||
strs = ('name', 'icon', 'panel', 'method', 'params', 'enable', 'confirm', 'style', 'active')
|
||||
elif section.startswith('graph')\
|
||||
or section.startswith('displayed_macros')\
|
||||
or section.startswith('spoolman'):
|
||||
@@ -618,7 +618,8 @@ class KlipperScreenConfig:
|
||||
"confirm": cfg.get("confirm", None),
|
||||
"enable": cfg.get("enable", "True"),
|
||||
"params": cfg.get("params", "{}"),
|
||||
"style": cfg.get("style", None)
|
||||
"style": cfg.get("style", None),
|
||||
"active": cfg.get("active", None)
|
||||
}
|
||||
|
||||
return {name[(len(menu) + 6):]: item}
|
||||
@@ -257,6 +257,9 @@ class Printer:
|
||||
"gcode_macros": {"count": len(self.get_gcode_macros()), "list": self.get_gcode_macros()},
|
||||
"leds": {"count": self.ledcount},
|
||||
"config_sections": list(self.config.keys()),
|
||||
"homed_axes": self.get_stat("toolhead", "homed_axes"),
|
||||
"quad_gantry_level": self.get_stat("quad_gantry_level"),
|
||||
"z_tilt": self.get_stat("z_tilt"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+17
-1
@@ -83,15 +83,31 @@ class Panel(ScreenPanel):
|
||||
b.connect("clicked", self._screen._send_action, item['method'], params)
|
||||
else:
|
||||
b.connect("clicked", self._screen._go_to_submenu, key)
|
||||
b.set_name(key)
|
||||
self.labels[key] = b
|
||||
|
||||
def evaluate_enable(self, enable):
|
||||
if enable is None:
|
||||
return False
|
||||
if enable == "{{ moonraker_connected }}":
|
||||
logging.info(f"moonraker connected {self._screen._ws.connected}")
|
||||
return self._screen._ws.connected
|
||||
try:
|
||||
j2_temp = Template(enable, autoescape=True)
|
||||
return j2_temp.render(self.j2_data) == 'True'
|
||||
return j2_temp.render(self._printer.get_printer_status_data()) == 'True'
|
||||
except Exception as e:
|
||||
logging.debug(f"Error evaluating enable statement: {enable}\n{e}")
|
||||
return False
|
||||
|
||||
def process_update(self, action, data):
|
||||
if action != "notify_status_update":
|
||||
return
|
||||
for item in self.autogrid:
|
||||
key = item.get_name()
|
||||
for item_dict in self.items:
|
||||
if key in item_dict and 'active' in item_dict[key]:
|
||||
if self.evaluate_enable(item_dict[key]['active']):
|
||||
item.get_style_context().add_class("menu_active")
|
||||
else:
|
||||
item.get_style_context().remove_class("menu_active")
|
||||
break
|
||||
@@ -80,6 +80,13 @@ button.active {
|
||||
background-color: @active;
|
||||
}
|
||||
|
||||
|
||||
button.menu_active {
|
||||
border-width: 0.25em;
|
||||
border-style: dashed;
|
||||
border-color: @active;
|
||||
}
|
||||
|
||||
button:disabled,
|
||||
button.color1:disabled,
|
||||
button.color2:disabled,
|
||||
|
||||
@@ -110,6 +110,12 @@ popover button {
|
||||
border-color: @solarized-base03;
|
||||
}
|
||||
|
||||
button.menu_active {
|
||||
border-width: 0.25em;
|
||||
border-style: dashed;
|
||||
border-color: @solarized-green;
|
||||
}
|
||||
|
||||
switch {
|
||||
background-color: @solarized-base02;
|
||||
}
|
||||
|
||||
@@ -94,6 +94,12 @@ combobox menuitem {
|
||||
border-color: @bg;
|
||||
}
|
||||
|
||||
button.menu_active {
|
||||
border-width: 0.25em;
|
||||
border-style: dashed;
|
||||
border-color: @echo;
|
||||
}
|
||||
|
||||
treeview.view check,
|
||||
switch {
|
||||
background-color: @active-dark;
|
||||
|
||||
@@ -92,6 +92,12 @@ combobox menuitem {
|
||||
border-color: #121212;
|
||||
}
|
||||
|
||||
button.menu_active {
|
||||
border-width: 0.25em;
|
||||
border-style: solid;
|
||||
border-color: #006412;
|
||||
}
|
||||
|
||||
treeview.view check,
|
||||
switch {
|
||||
background-color: #1c1c1c;
|
||||
|
||||
@@ -149,6 +149,15 @@ menu {
|
||||
border-color: @border;
|
||||
}
|
||||
|
||||
button.menu_active {
|
||||
border-color: @border;
|
||||
border-style: solid;
|
||||
border-width: .25em;
|
||||
background-color: @bg;
|
||||
box-shadow: .1em .1em @border;
|
||||
border-radius: 1em;
|
||||
}
|
||||
|
||||
menuitem {
|
||||
background-color: @bg;
|
||||
border-color: @border;
|
||||
|
||||
@@ -101,6 +101,11 @@ menu {
|
||||
border-color: @lines;
|
||||
}
|
||||
|
||||
button.menu_active {
|
||||
border-width: 0;
|
||||
background-color: @active;
|
||||
}
|
||||
|
||||
menuitem {
|
||||
background-color: @bg;
|
||||
border-color: @lines;
|
||||
|
||||
Reference in new issue
Block a user