settings: remove options that are directly on the panels
This commit is contained in:
parent
48860159e9
commit
fd2a717ece
@ -103,20 +103,14 @@ class KlipperScreenConfig:
|
||||
_n = self.lang.ngettext
|
||||
|
||||
self.configurable_options = [
|
||||
{"invert_x": {"section": "main", "name": _("Invert X"), "type": "binary", "value": "False"}},
|
||||
{"invert_y": {"section": "main", "name": _("Invert Y"), "type": "binary", "value": "False"}},
|
||||
{"invert_z": {"section": "main", "name": _("Invert Z"), "type": "binary", "value": "False"}},
|
||||
{"language": {"section": "main", "name": _("Language"), "type": "dropdown", "value": "system_lang",
|
||||
"callback": screen.restart_warning, "options": [
|
||||
{"name": _("System") + " " + _("(default)"), "value": "system_lang"}
|
||||
]}},
|
||||
{"move_speed_xy": {
|
||||
"section": "main", "name": _("XY Move Speed (mm/s)"), "type": "scale", "value": "20",
|
||||
"range": [5, 200], "step": 1}},
|
||||
{"move_speed_z": {
|
||||
"section": "main", "name": _("Z Move Speed (mm/s)"), "type": "scale", "value": "20",
|
||||
"range": [5, 200], "step": 1}},
|
||||
{"print_sort_dir": {"section": "main", "type": None, "value": "name_asc"}},
|
||||
{"theme": {
|
||||
"section": "main", "name": _("Icon Theme"), "type": "dropdown",
|
||||
"value": "z-bolt", "callback": screen.restart_warning, "options": [
|
||||
{"name": "Z-bolt" + " " + _("(default)"), "value": "z-bolt"}]}},
|
||||
{"print_estimate_method": {
|
||||
"section": "main", "name": _("Estimated Time Method"), "type": "dropdown",
|
||||
"value": "auto", "options": [
|
||||
@ -129,10 +123,6 @@ class KlipperScreenConfig:
|
||||
"value": "3600", "callback": screen.set_screenblanking_timeout, "options": [
|
||||
{"name": _("Off"), "value": "off"}]
|
||||
}},
|
||||
{"theme": {
|
||||
"section": "main", "name": _("Icon Theme"), "type": "dropdown",
|
||||
"value": "z-bolt", "callback": screen.restart_warning, "options": [
|
||||
{"name": "Z-bolt" + " " + _("(default)"), "value": "z-bolt"}]}},
|
||||
{"24htime": {"section": "main", "name": _("24 Hour Time"), "type": "binary", "value": "True"}},
|
||||
{"side_macro_shortcut": {
|
||||
"section": "main", "name": _("Macro shortcut on sidebar"), "type": "binary",
|
||||
@ -152,13 +142,26 @@ class KlipperScreenConfig:
|
||||
{"print_estimate_compensation": {
|
||||
"section": "main", "name": _("Slicer Time correction (%)"), "type": "scale", "value": "100",
|
||||
"range": [50, 150], "step": 1}},
|
||||
|
||||
# {"": {"section": "main", "name": _(""), "type": ""}}
|
||||
]
|
||||
|
||||
# Options that are in panels and shouldn't be added to the main settings
|
||||
panel_options = [
|
||||
{"invert_x": {"section": "main", "name": _("Invert X"), "type": None, "value": "False"}},
|
||||
{"invert_y": {"section": "main", "name": _("Invert Y"), "type": None, "value": "False"}},
|
||||
{"invert_z": {"section": "main", "name": _("Invert Z"), "type": None, "value": "False"}},
|
||||
{"move_speed_xy": {"section": "main", "name": _("XY Move Speed (mm/s)"), "type": None, "value": "50"}},
|
||||
{"move_speed_z": {"section": "main", "name": _("Z Move Speed (mm/s)"), "type": None, "value": "10"}},
|
||||
{"print_sort_dir": {"section": "main", "type": None, "value": "name_asc"}},
|
||||
]
|
||||
|
||||
self.configurable_options.extend(panel_options)
|
||||
|
||||
lang_path = os.path.join(klipperscreendir, "ks_includes", "locales")
|
||||
langs = [d for d in os.listdir(lang_path) if not os.path.isfile(os.path.join(lang_path, d))]
|
||||
langs.sort()
|
||||
lang_opt = self.configurable_options[3]['language']['options']
|
||||
lang_opt = self.configurable_options[0]['language']['options']
|
||||
|
||||
for lang in langs:
|
||||
lang_opt.append({"name": lang, "value": lang})
|
||||
@ -166,7 +169,7 @@ class KlipperScreenConfig:
|
||||
t_path = os.path.join(klipperscreendir, 'styles')
|
||||
themes = [d for d in os.listdir(t_path) if (not os.path.isfile(os.path.join(t_path, d)) and d != "z-bolt")]
|
||||
themes.sort()
|
||||
theme_opt = self.configurable_options[9]['theme']['options']
|
||||
theme_opt = self.configurable_options[1]['theme']['options']
|
||||
|
||||
for theme in themes:
|
||||
theme_opt.append({"name": theme, "value": theme})
|
||||
|
@ -13,12 +13,10 @@ class SettingsPanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
self.settings = {}
|
||||
self.macros = {}
|
||||
self.menu_cur = 'main_box'
|
||||
self.menu = ['main_box']
|
||||
|
||||
self.labels['main_box'] = self.create_box('main')
|
||||
self.labels['macros_box'] = self.create_box('macros')
|
||||
|
||||
printbox = Gtk.Box(spacing=0)
|
||||
printbox.set_vexpand(False)
|
||||
@ -26,11 +24,6 @@ class SettingsPanel(ScreenPanel):
|
||||
self.labels['printers_box'] = self.create_box('printers', printbox)
|
||||
|
||||
options = self._config.get_configurable_options().copy()
|
||||
options.append({"macros": {
|
||||
"name": _("Displayed Macros"),
|
||||
"type": "menu",
|
||||
"menu": "macros"}
|
||||
})
|
||||
options.append({"printers": {
|
||||
"name": _("Printer Connections"),
|
||||
"type": "menu",
|
||||
@ -41,20 +34,6 @@ class SettingsPanel(ScreenPanel):
|
||||
name = list(option)[0]
|
||||
self.add_option('main', self.settings, name, option[name])
|
||||
|
||||
for macro in self._printer.get_config_section_list("gcode_macro "):
|
||||
macro = macro[12:]
|
||||
# Support for hiding macros by name
|
||||
if macro.startswith("_"):
|
||||
continue
|
||||
self.macros[macro] = {
|
||||
"name": macro,
|
||||
"section": "displayed_macros %s" % self._screen.connected_printer,
|
||||
"type": "macro"
|
||||
}
|
||||
|
||||
for macro in list(self.macros):
|
||||
self.add_option('macros', self.macros, macro, self.macros[macro])
|
||||
|
||||
self.printers = {}
|
||||
for printer in self._config.get_printers():
|
||||
logging.debug("Printer: %s" % printer)
|
||||
@ -81,14 +60,14 @@ class SettingsPanel(ScreenPanel):
|
||||
return False
|
||||
|
||||
def create_box(self, name, insert=None):
|
||||
# Create a scroll window for the macros
|
||||
# Create a scroll window for the options
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_vexpand(True)
|
||||
scroll.add_events(Gdk.EventMask.TOUCH_MASK)
|
||||
scroll.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
|
||||
|
||||
# Create a grid for all macros
|
||||
# Create a grid for all options
|
||||
self.labels[name] = Gtk.Grid()
|
||||
scroll.add(self.labels[name])
|
||||
|
||||
@ -125,15 +104,12 @@ class SettingsPanel(ScreenPanel):
|
||||
dev.set_valign(Gtk.Align.CENTER)
|
||||
|
||||
dev.add(labels)
|
||||
if option['type'] == "binary" or option['type'] == "macro":
|
||||
if option['type'] == "binary":
|
||||
box = Gtk.Box()
|
||||
box.set_vexpand(False)
|
||||
switch = Gtk.Switch()
|
||||
switch.set_hexpand(False)
|
||||
switch.set_vexpand(False)
|
||||
if option['type'] == "macro":
|
||||
switch.set_active(self._config.get_config().getboolean(option['section'], opt_name, fallback=True))
|
||||
else:
|
||||
switch.set_active(self._config.get_config().getboolean(option['section'], opt_name))
|
||||
switch.connect("notify::active", self.switch_config_option, option['section'], opt_name,
|
||||
option['callback'] if "callback" in option else None)
|
||||
@ -242,14 +218,3 @@ class SettingsPanel(ScreenPanel):
|
||||
self._config.save_user_config_options()
|
||||
if callback is not None:
|
||||
callback(switch.get_active())
|
||||
|
||||
def add_gcode_option(self):
|
||||
macros = self._screen.printer.get_gcode_macros()
|
||||
for x in macros:
|
||||
self.add_gcode_macro("macros", self.macros, x, {
|
||||
"name": x[12:],
|
||||
"type": binary
|
||||
})
|
||||
|
||||
def run_gcode_macro(self, widget, macro):
|
||||
self._screen._ws.klippy.gcode_script(macro)
|
||||
|
Loading…
x
Reference in New Issue
Block a user