main and temp: save visibility of items
This commit is contained in:
parent
38ceea5204
commit
f60a878e7b
@ -421,17 +421,18 @@ class KlipperScreenConfig:
|
|||||||
save_config.add_section(opt['section'])
|
save_config.add_section(opt['section'])
|
||||||
save_config.set(opt['section'], name, str(curval))
|
save_config.set(opt['section'], name, str(curval))
|
||||||
|
|
||||||
macro_sections = [i for i in self.config.sections() if i.startswith("displayed_macros")]
|
extra_sections = [i for i in self.config.sections() if i.startswith("displayed_macros")]
|
||||||
for macro_sec in macro_sections:
|
extra_sections.extend([i for i in self.config.sections() if i.startswith("graph")])
|
||||||
for item in self.config.options(macro_sec):
|
for section in extra_sections:
|
||||||
value = self.config[macro_sec].getboolean(item, fallback=True)
|
for item in self.config.options(section):
|
||||||
|
value = self.config[section].getboolean(item, fallback=True)
|
||||||
if value is False or (self.defined_config is not None and
|
if value is False or (self.defined_config is not None and
|
||||||
macro_sec in self.defined_config.sections() and
|
section in self.defined_config.sections() and
|
||||||
self.defined_config[macro_sec].getboolean(item, fallback=True) is False and
|
self.defined_config[section].getboolean(item, fallback=True) is False and
|
||||||
self.defined_config[macro_sec].getboolean(item, fallback=True) != value):
|
self.defined_config[section].getboolean(item, fallback=True) != value):
|
||||||
if macro_sec not in save_config.sections():
|
if section not in save_config.sections():
|
||||||
save_config.add_section(macro_sec)
|
save_config.add_section(section)
|
||||||
save_config.set(macro_sec, item, str(value))
|
save_config.set(section, item, str(value))
|
||||||
|
|
||||||
save_output = self._build_config_string(save_config).split("\n")
|
save_output = self._build_config_string(save_config).split("\n")
|
||||||
for i in range(len(save_output)):
|
for i in range(len(save_output)):
|
||||||
|
@ -110,7 +110,12 @@ class MainPanel(MenuPanel):
|
|||||||
name = self._gtk.ButtonImage(image, devname.capitalize().replace("_", " "), None, .5, Gtk.PositionType.LEFT, 1)
|
name = self._gtk.ButtonImage(image, devname.capitalize().replace("_", " "), None, .5, Gtk.PositionType.LEFT, 1)
|
||||||
name.connect("clicked", self.toggle_visibility, device)
|
name.connect("clicked", self.toggle_visibility, device)
|
||||||
name.set_alignment(0, .5)
|
name.set_alignment(0, .5)
|
||||||
name.get_style_context().add_class(class_name)
|
visible = self._config.get_config().getboolean(f"graph {self._screen.connected_printer}", device, fallback=True)
|
||||||
|
if visible:
|
||||||
|
name.get_style_context().add_class(class_name)
|
||||||
|
else:
|
||||||
|
name.get_style_context().add_class("graph_label_hidden")
|
||||||
|
self.labels['da'].set_showing(device, visible)
|
||||||
|
|
||||||
temp = self._gtk.Button("")
|
temp = self._gtk.Button("")
|
||||||
if can_target:
|
if can_target:
|
||||||
@ -121,7 +126,7 @@ class MainPanel(MenuPanel):
|
|||||||
"name": name,
|
"name": name,
|
||||||
"temp": temp,
|
"temp": temp,
|
||||||
"can_target": can_target,
|
"can_target": can_target,
|
||||||
"visible_graph": True
|
"visible": visible
|
||||||
}
|
}
|
||||||
|
|
||||||
devices = sorted(self.devices)
|
devices = sorted(self.devices)
|
||||||
@ -134,17 +139,21 @@ class MainPanel(MenuPanel):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def toggle_visibility(self, widget, device):
|
def toggle_visibility(self, widget, device):
|
||||||
self.devices[device]['visible_graph'] ^= True
|
self.devices[device]['visible'] ^= True
|
||||||
logging.info(f"Graph show {self.devices[device]['visible_graph']}: {device}")
|
logging.info(f"Graph show {self.devices[device]['visible']}: {device}")
|
||||||
|
|
||||||
self.labels['da'].set_showing(device, self.devices[device]['visible_graph'])
|
section = f"graph {self._screen.connected_printer}"
|
||||||
if self.devices[device]['visible_graph']:
|
if section not in self._config.get_config().sections():
|
||||||
|
self._config.get_config().add_section(section)
|
||||||
|
self._config.set(section, f"{device}", f"{self.devices[device]['visible']}")
|
||||||
|
self._config.save_user_config_options()
|
||||||
|
|
||||||
|
self.labels['da'].set_showing(device, self.devices[device]['visible'])
|
||||||
|
if self.devices[device]['visible']:
|
||||||
self.devices[device]['name'].get_style_context().remove_class("graph_label_hidden")
|
self.devices[device]['name'].get_style_context().remove_class("graph_label_hidden")
|
||||||
self.devices[device]['name'].get_style_context().add_class(
|
self.devices[device]['name'].get_style_context().add_class(self.devices[device]['class'])
|
||||||
self.devices[device]['class'])
|
|
||||||
else:
|
else:
|
||||||
self.devices[device]['name'].get_style_context().remove_class(
|
self.devices[device]['name'].get_style_context().remove_class(self.devices[device]['class'])
|
||||||
self.devices[device]['class'])
|
|
||||||
self.devices[device]['name'].get_style_context().add_class("graph_label_hidden")
|
self.devices[device]['name'].get_style_context().add_class("graph_label_hidden")
|
||||||
self.labels['da'].queue_draw()
|
self.labels['da'].queue_draw()
|
||||||
|
|
||||||
|
@ -313,25 +313,33 @@ class TemperaturePanel(ScreenPanel):
|
|||||||
|
|
||||||
rgb = self._gtk.get_temp_color(dev_type)
|
rgb = self._gtk.get_temp_color(dev_type)
|
||||||
|
|
||||||
|
name = self._gtk.ButtonImage(image, devname.capitalize().replace("_", " "), None, .5, Gtk.PositionType.LEFT, 1)
|
||||||
|
name.set_alignment(0, .5)
|
||||||
|
visible = self._config.get_config().getboolean(f"graph {self._screen.connected_printer}", device, fallback=True)
|
||||||
|
if visible:
|
||||||
|
name.get_style_context().add_class(class_name)
|
||||||
|
else:
|
||||||
|
name.get_style_context().add_class("graph_label_hidden")
|
||||||
|
|
||||||
can_target = self._printer.get_temp_store_device_has_target(device)
|
can_target = self._printer.get_temp_store_device_has_target(device)
|
||||||
self.labels['da'].add_object(device, "temperatures", rgb, False, True)
|
self.labels['da'].add_object(device, "temperatures", rgb, False, True)
|
||||||
if can_target:
|
if can_target:
|
||||||
self.labels['da'].add_object(device, "targets", rgb, True, False)
|
self.labels['da'].add_object(device, "targets", rgb, True, False)
|
||||||
|
name.connect('clicked', self.select_heater, device)
|
||||||
name = self._gtk.ButtonImage(image, devname.capitalize().replace("_", " "),
|
else:
|
||||||
None, .5, Gtk.PositionType.LEFT, 1)
|
name.connect("clicked", self.toggle_visibility, device)
|
||||||
name.connect('clicked', self.on_popover_clicked, device)
|
self.labels['da'].set_showing(device, visible)
|
||||||
name.set_alignment(0, .5)
|
|
||||||
name.get_style_context().add_class(class_name)
|
|
||||||
|
|
||||||
temp = self._gtk.Button("")
|
temp = self._gtk.Button("")
|
||||||
temp.connect('clicked', self.select_heater, device)
|
if can_target:
|
||||||
|
temp.connect("clicked", self.show_numpad, device)
|
||||||
|
|
||||||
self.devices[device] = {
|
self.devices[device] = {
|
||||||
"class": class_name,
|
"class": class_name,
|
||||||
"name": name,
|
"name": name,
|
||||||
"temp": temp,
|
"temp": temp,
|
||||||
"can_target": can_target
|
"can_target": can_target,
|
||||||
|
"visible": visible
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.devices[device]["can_target"]:
|
if self.devices[device]["can_target"]:
|
||||||
@ -347,6 +355,30 @@ class TemperaturePanel(ScreenPanel):
|
|||||||
self.labels['devices'].show_all()
|
self.labels['devices'].show_all()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def toggle_visibility(self, widget, device=None):
|
||||||
|
if device is None:
|
||||||
|
device = self.popover_device
|
||||||
|
self.devices[device]['visible'] ^= True
|
||||||
|
logging.info(f"Graph show {self.devices[device]['visible']}: {device}")
|
||||||
|
|
||||||
|
section = f"graph {self._screen.connected_printer}"
|
||||||
|
if section not in self._config.get_config().sections():
|
||||||
|
self._config.get_config().add_section(section)
|
||||||
|
self._config.set(section, f"{device}", f"{self.devices[device]['visible']}")
|
||||||
|
self._config.save_user_config_options()
|
||||||
|
|
||||||
|
self.labels['da'].set_showing(device, self.devices[device]['visible'])
|
||||||
|
if self.devices[device]['visible']:
|
||||||
|
self.devices[device]['name'].get_style_context().remove_class("graph_label_hidden")
|
||||||
|
self.devices[device]['name'].get_style_context().add_class(self.devices[device]['class'])
|
||||||
|
else:
|
||||||
|
self.devices[device]['name'].get_style_context().remove_class(self.devices[device]['class'])
|
||||||
|
self.devices[device]['name'].get_style_context().add_class("graph_label_hidden")
|
||||||
|
self.labels['da'].queue_draw()
|
||||||
|
if self.devices[device]['can_target']:
|
||||||
|
self.popover_populate_menu()
|
||||||
|
self.labels['popover'].show_all()
|
||||||
|
|
||||||
def change_target_temp(self, temp):
|
def change_target_temp(self, temp):
|
||||||
name = self.active_heater.split()[1] if len(self.active_heater.split()) > 1 else self.active_heater
|
name = self.active_heater.split()[1] if len(self.active_heater.split()) > 1 else self.active_heater
|
||||||
max_temp = int(float(self._printer.get_config_section(self.active_heater)['max_temp']))
|
max_temp = int(float(self._printer.get_config_section(self.active_heater)['max_temp']))
|
||||||
@ -395,9 +427,9 @@ class TemperaturePanel(ScreenPanel):
|
|||||||
self.labels['graph_settemp'] = self._gtk.Button(label=_("Set Temp"))
|
self.labels['graph_settemp'] = self._gtk.Button(label=_("Set Temp"))
|
||||||
self.labels['graph_settemp'].connect("clicked", self.show_numpad)
|
self.labels['graph_settemp'].connect("clicked", self.show_numpad)
|
||||||
self.labels['graph_hide'] = self._gtk.Button(label=_("Hide"))
|
self.labels['graph_hide'] = self._gtk.Button(label=_("Hide"))
|
||||||
self.labels['graph_hide'].connect("clicked", self.graph_show_device, False)
|
self.labels['graph_hide'].connect("clicked", self.toggle_visibility)
|
||||||
self.labels['graph_show'] = self._gtk.Button(label=_("Show"))
|
self.labels['graph_show'] = self._gtk.Button(label=_("Show"))
|
||||||
self.labels['graph_show'].connect("clicked", self.graph_show_device)
|
self.labels['graph_show'].connect("clicked", self.toggle_visibility)
|
||||||
|
|
||||||
popover = Gtk.Popover()
|
popover = Gtk.Popover()
|
||||||
self.labels['popover_vbox'] = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
self.labels['popover_vbox'] = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||||
@ -410,21 +442,6 @@ class TemperaturePanel(ScreenPanel):
|
|||||||
|
|
||||||
return box
|
return box
|
||||||
|
|
||||||
def graph_show_device(self, widget, show=True):
|
|
||||||
logging.info(f"Graph show: {self.popover_device} {show}")
|
|
||||||
self.labels['da'].set_showing(self.popover_device, show)
|
|
||||||
if show:
|
|
||||||
self.devices[self.popover_device]['name'].get_style_context().remove_class("graph_label_hidden")
|
|
||||||
self.devices[self.popover_device]['name'].get_style_context().add_class(
|
|
||||||
self.devices[self.popover_device]['class'])
|
|
||||||
else:
|
|
||||||
self.devices[self.popover_device]['name'].get_style_context().remove_class(
|
|
||||||
self.devices[self.popover_device]['class'])
|
|
||||||
self.devices[self.popover_device]['name'].get_style_context().add_class("graph_label_hidden")
|
|
||||||
self.labels['da'].queue_draw()
|
|
||||||
self.popover_populate_menu()
|
|
||||||
self.labels['popover'].show_all()
|
|
||||||
|
|
||||||
def hide_numpad(self, widget):
|
def hide_numpad(self, widget):
|
||||||
self.devices[self.active_heater]['name'].get_style_context().remove_class("button_active")
|
self.devices[self.active_heater]['name'].get_style_context().remove_class("button_active")
|
||||||
self.active_heater = None
|
self.active_heater = None
|
||||||
@ -475,11 +492,11 @@ class TemperaturePanel(ScreenPanel):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
def show_numpad(self, widget):
|
def show_numpad(self, widget, device=None):
|
||||||
|
|
||||||
if self.active_heater is not None:
|
if self.active_heater is not None:
|
||||||
self.devices[self.active_heater]['name'].get_style_context().remove_class("button_active")
|
self.devices[self.active_heater]['name'].get_style_context().remove_class("button_active")
|
||||||
self.active_heater = self.popover_device
|
self.active_heater = self.popover_device if device is None else device
|
||||||
self.devices[self.active_heater]['name'].get_style_context().add_class("button_active")
|
self.devices[self.active_heater]['name'].get_style_context().add_class("button_active")
|
||||||
|
|
||||||
if "keypad" not in self.labels:
|
if "keypad" not in self.labels:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user