mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 23:46:22 -06:00
CURA-5035 Don't show authors with 0 packages
This commit is contained in:
parent
523518020c
commit
85ebe741a8
4 changed files with 36 additions and 19 deletions
|
@ -69,6 +69,7 @@ class CuraPackageManager(QObject):
|
|||
|
||||
# (for initialize) Removes all packages that have been scheduled to be removed.
|
||||
def _removeAllScheduledPackages(self) -> None:
|
||||
print("Will purge", self._to_remove_package_set)
|
||||
for package_id in self._to_remove_package_set:
|
||||
self._purgePackage(package_id)
|
||||
self._to_remove_package_set.clear()
|
||||
|
@ -223,7 +224,10 @@ class CuraPackageManager(QObject):
|
|||
del self._to_install_package_dict[package_id]
|
||||
|
||||
# If the package has already been installed, schedule for a delayed removal
|
||||
if package_id in self._installed_package_dict:
|
||||
# if package_id in self._installed_package_dict:
|
||||
# self._to_remove_package_set.add(package_id)
|
||||
# "Or rather don't because sometimes packages are not making it into the
|
||||
# dict I guess." - Ian
|
||||
self._to_remove_package_set.add(package_id)
|
||||
|
||||
self._saveManagementData()
|
||||
|
@ -231,6 +235,7 @@ class CuraPackageManager(QObject):
|
|||
|
||||
# Removes everything associated with the given package ID.
|
||||
def _purgePackage(self, package_id: str) -> None:
|
||||
print("Purging",package_id)
|
||||
# Get all folders that need to be checked for installed packages, including:
|
||||
# - materials
|
||||
# - qualities
|
||||
|
@ -244,6 +249,7 @@ class CuraPackageManager(QObject):
|
|||
|
||||
for root_dir in dirs_to_check:
|
||||
package_dir = os.path.join(root_dir, package_id)
|
||||
print(package_dir)
|
||||
if os.path.exists(package_dir):
|
||||
Logger.log("i", "Removing '%s' for package [%s]", package_dir, package_id)
|
||||
shutil.rmtree(package_dir)
|
||||
|
|
|
@ -12,6 +12,18 @@ Item
|
|||
{
|
||||
width: UM.Theme.getSize("toolbox_thumbnail_large").width
|
||||
height: UM.Theme.getSize("toolbox_thumbnail_large").width
|
||||
visible:
|
||||
{
|
||||
if (toolbox.viewCategory == "material" && model.packages_count)
|
||||
{
|
||||
console.log(model)
|
||||
return model.packages_count > 0
|
||||
}
|
||||
else
|
||||
{
|
||||
return true
|
||||
}
|
||||
}
|
||||
Rectangle
|
||||
{
|
||||
color: "white"
|
||||
|
|
|
@ -10,20 +10,16 @@ from UM.Qt.ListModel import ListModel
|
|||
|
||||
## Model that holds cura packages. By setting the filter property the instances held by this model can be changed.
|
||||
class AuthorsModel(ListModel):
|
||||
NameRole = Qt.UserRole + 1
|
||||
EmailRole = Qt.UserRole + 2
|
||||
WebsiteRole = Qt.UserRole + 3
|
||||
TypeRole = Qt.UserRole + 4
|
||||
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
|
||||
self._metadata = None
|
||||
|
||||
self.addRoleName(AuthorsModel.NameRole, "name")
|
||||
self.addRoleName(AuthorsModel.EmailRole, "email")
|
||||
self.addRoleName(AuthorsModel.WebsiteRole, "website")
|
||||
self.addRoleName(AuthorsModel.TypeRole, "type")
|
||||
self.addRoleName(Qt.UserRole + 1, "name")
|
||||
self.addRoleName(Qt.UserRole + 2, "email")
|
||||
self.addRoleName(Qt.UserRole + 3, "website")
|
||||
self.addRoleName(Qt.UserRole + 4, "type")
|
||||
self.addRoleName(Qt.UserRole + 5, "packages_count")
|
||||
|
||||
# List of filters for queries. The result is the union of the each list of results.
|
||||
self._filter = {} # type: Dict[str,str]
|
||||
|
@ -40,7 +36,8 @@ class AuthorsModel(ListModel):
|
|||
"name": author["name"],
|
||||
"email": author["email"],
|
||||
"website": author["website"],
|
||||
"type": author["type"]
|
||||
"type": author["type"],
|
||||
"packages_count": author["packages_count"]
|
||||
})
|
||||
|
||||
# Filter on all the key-word arguments.
|
||||
|
|
|
@ -74,19 +74,22 @@ class Toolbox(QObject, Extension):
|
|||
"name": "Ultimaker",
|
||||
"email": "ian.paschal@gmail.com",
|
||||
"website": "ultimaker.com",
|
||||
"type": "material"
|
||||
"type": "material",
|
||||
"packages_count": 7
|
||||
},
|
||||
{
|
||||
"name": "DSM",
|
||||
"email": "contact@dsm.nl",
|
||||
"website": "www.dsm.nl",
|
||||
"type": "material"
|
||||
"type": "material",
|
||||
"packages_count": 0
|
||||
},
|
||||
{
|
||||
"name": "BASF",
|
||||
"email": "contact@basf.de",
|
||||
"website": "www.basf.de",
|
||||
"type": "material"
|
||||
"type": "material",
|
||||
"packages_count": 0
|
||||
}
|
||||
],
|
||||
"materials_installed": []
|
||||
|
@ -225,19 +228,16 @@ class Toolbox(QObject, Extension):
|
|||
self._package_manager.installPackage(file_path)
|
||||
self.installChanged.emit()
|
||||
self.metadataChanged.emit()
|
||||
# TODO: Stuff
|
||||
self.openRestartDialog("TODO")
|
||||
self._restart_required = True
|
||||
self.restartRequiredChanged.emit()
|
||||
|
||||
@pyqtSlot(str)
|
||||
def uninstall(self, plugin_id):
|
||||
self._package_manager.removePackage(plugin_id)
|
||||
self.installChanged.emit()
|
||||
self.metadataChanged.emit()
|
||||
self._restart_required = True
|
||||
self.restartRequiredChanged.emit()
|
||||
# TODO: Stuff
|
||||
Application.getInstance().messageBox(i18n_catalog.i18nc("@window:title", "Plugin browser"), "TODO")
|
||||
|
||||
@pyqtSlot(str)
|
||||
def enable(self, plugin_id):
|
||||
|
@ -261,6 +261,7 @@ class Toolbox(QObject, Extension):
|
|||
|
||||
@pyqtSlot()
|
||||
def restart(self):
|
||||
self._package_manager._removeAllScheduledPackages()
|
||||
CuraApplication.getInstance().windowClosed()
|
||||
|
||||
|
||||
|
@ -394,6 +395,7 @@ class Toolbox(QObject, Extension):
|
|||
# TODO: Replace this with a proper API call:
|
||||
for package in self._metadata["packages"]:
|
||||
package["author"]["type"] = package["package_type"]
|
||||
package["author"]["packages_count"] = 1
|
||||
if package["author"] not in self._metadata["authors"]:
|
||||
self._metadata["authors"].append(package["author"])
|
||||
self._models["authors"].setMetadata(self._metadata["authors"])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue