mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Rework the open project dialog to contain only 1 dropdown
With the caveat that the qtQuickControls had to be updated to 2.3, due to a qt bug in 1.x that did not update the dropdown popup list according to the ListModel. This leads to a different look in the dropdowns and in the buttons of the open project dialog, compaired to the rest of the application. CURA-7609
This commit is contained in:
parent
e5d3271698
commit
4e20c7dddc
4 changed files with 98 additions and 67 deletions
43
plugins/3MFReader/UpdatableMachinesModel.py
Normal file
43
plugins/3MFReader/UpdatableMachinesModel.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
# Copyright (c) 2020 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from typing import Dict, List
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
from UM.Qt.ListModel import ListModel
|
||||
from cura.Settings.GlobalStack import GlobalStack
|
||||
|
||||
create_new_list_item = {
|
||||
"id": "new",
|
||||
"name": "Create new",
|
||||
"displayName": "Create new",
|
||||
"type": "default_option" # to make sure we are not mixing the "Create new" option with a printer with id "new"
|
||||
} # type: Dict[str, str]
|
||||
|
||||
|
||||
class UpdatableMachinesModel(ListModel):
|
||||
"""Model that holds cura packages.
|
||||
|
||||
By setting the filter property the instances held by this model can be changed.
|
||||
"""
|
||||
|
||||
def __init__(self, parent = None) -> None:
|
||||
super().__init__(parent)
|
||||
|
||||
self.addRoleName(Qt.UserRole + 1, "id")
|
||||
self.addRoleName(Qt.UserRole + 2, "name")
|
||||
self.addRoleName(Qt.UserRole + 3, "displayName")
|
||||
self.addRoleName(Qt.UserRole + 4, "type") # Either "default_option" or "machine"
|
||||
|
||||
def update(self, machines: List[GlobalStack]) -> None:
|
||||
items = [create_new_list_item] # type: List[Dict[str, str]]
|
||||
|
||||
for machine in sorted(machines, key = lambda printer: printer.name):
|
||||
items.append({
|
||||
"id": machine.id,
|
||||
"name": machine.name,
|
||||
"displayName": "Update " + machine.name,
|
||||
"type": "machine"
|
||||
})
|
||||
self.setItems(items)
|
Loading…
Add table
Add a link
Reference in a new issue