Fix vendor/model selector on create printer dialog (#9344)

* Make sure printer vendor matches

* Handle cases where some vendor do not have printers (such as `OrcaFilamentLibrary`)

* Ignore vendor `custom printer` from create printer vendor list

* Fix missing end bracket

* Update printer vendor and model list on create printer dialog
This commit is contained in:
Noisyfox 2025-05-01 17:12:03 +08:00 committed by GitHub
parent a9d426a3dc
commit 8c4b7456c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 93 additions and 49 deletions

View file

@ -18,8 +18,10 @@ for entry in profiles_dir.glob('*.json'):
if entry.is_file():
entry_info = json.loads(entry.read_text())
vendor_name = entry_info.get('name', None)
if vendor_name:
if vendor_name and vendor_name != 'Custom Printer':
models = [machine.get('name', None) for machine in entry_info.get('machine_model_list', []) if machine.get('name', None)]
if not models:
continue
printers[vendor_name] = models
vendor_names = [f'"{vendor_name}",' for vendor_name in sorted(printers.keys(), key=str.casefold)]
@ -43,7 +45,7 @@ for vendor_name in sorted(printers.keys(), key=str.casefold):
models_formatted += '},\n '
models_formatted = models_formatted.rstrip()[:-1]
models_formatted = models_formatted.rstrip()[:-1] + '}'
print(models_formatted)