mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-17 03:37:48 -06:00
Persistent handled state across Package Lists
Contributes to: CURA-8587
This commit is contained in:
parent
2d9c557a13
commit
325783ca46
5 changed files with 26 additions and 13 deletions
|
@ -57,10 +57,13 @@ class LocalPackageList(PackageList):
|
||||||
|
|
||||||
def _makePackageModel(self, package_info: Dict[str, Any]) -> PackageModel:
|
def _makePackageModel(self, package_info: Dict[str, Any]) -> PackageModel:
|
||||||
""" Create a PackageModel from the package_info and determine its section_title"""
|
""" Create a PackageModel from the package_info and determine its section_title"""
|
||||||
bundled_or_installed = "installed" if self._manager.isUserInstalledPackage(package_info["package_id"]) else "bundled"
|
|
||||||
|
bundled_or_installed = "bundled" if self._manager.isBundledPackage(package_info["package_id"]) else "installed"
|
||||||
package_type = package_info["package_type"]
|
package_type = package_info["package_type"]
|
||||||
section_title = self.PACKAGE_CATEGORIES[bundled_or_installed][package_type]
|
section_title = self.PACKAGE_CATEGORIES[bundled_or_installed][package_type]
|
||||||
package = PackageModel(package_info, section_title = section_title, parent = self)
|
package = PackageModel(package_info, section_title = section_title, parent = self)
|
||||||
|
if package_info["package_id"] in self._manager.getPackagesToRemove() or package_info["package_id"] in self._manager.getPackagesToInstall():
|
||||||
|
package.is_recently_managed = True
|
||||||
self._connectManageButtonSignals(package)
|
self._connectManageButtonSignals(package)
|
||||||
return package
|
return package
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import tempfile
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, Qt
|
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, Qt
|
||||||
from typing import Dict, Optional, TYPE_CHECKING
|
from typing import Dict, Optional, Set, TYPE_CHECKING
|
||||||
|
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
from UM.Qt.ListModel import ListModel
|
from UM.Qt.ListModel import ListModel
|
||||||
|
@ -43,6 +43,7 @@ class PackageList(ListModel):
|
||||||
self._has_footer = True
|
self._has_footer = True
|
||||||
self._to_install: Dict[str, str] = {}
|
self._to_install: Dict[str, str] = {}
|
||||||
self.canInstallChanged.connect(self._install)
|
self.canInstallChanged.connect(self._install)
|
||||||
|
self._local_packages: Set[str] = {p["package_id"] for p in self._manager.local_packages}
|
||||||
|
|
||||||
self._ongoing_request: Optional[HttpRequestData] = None
|
self._ongoing_request: Optional[HttpRequestData] = None
|
||||||
self._scope = JsonDecoratorScope(UltimakerCloudScope(CuraApplication.getInstance()))
|
self._scope = JsonDecoratorScope(UltimakerCloudScope(CuraApplication.getInstance()))
|
||||||
|
@ -128,7 +129,8 @@ class PackageList(ListModel):
|
||||||
if update:
|
if update:
|
||||||
package.is_updating = False
|
package.is_updating = False
|
||||||
else:
|
else:
|
||||||
package.is_recently_installed = True
|
Logger.debug(f"Setting recently installed for package: {package_id}")
|
||||||
|
package.is_recently_managed = True
|
||||||
package.is_installing = False
|
package.is_installing = False
|
||||||
self.subscribeUserToPackage(package_id, str(package.sdk_version))
|
self.subscribeUserToPackage(package_id, str(package.sdk_version))
|
||||||
|
|
||||||
|
@ -201,7 +203,7 @@ class PackageList(ListModel):
|
||||||
package.is_installing = True
|
package.is_installing = True
|
||||||
url = package.download_url
|
url = package.download_url
|
||||||
Logger.debug(f"Trying to download and install {package_id} from {url}")
|
Logger.debug(f"Trying to download and install {package_id} from {url}")
|
||||||
self.download(package_id, url)
|
self.download(package_id, url, False)
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def uninstallPackage(self, package_id: str) -> None:
|
def uninstallPackage(self, package_id: str) -> None:
|
||||||
|
@ -209,8 +211,9 @@ class PackageList(ListModel):
|
||||||
package = self.getPackageModel(package_id)
|
package = self.getPackageModel(package_id)
|
||||||
package.is_installing = True
|
package.is_installing = True
|
||||||
self._manager.removePackage(package_id)
|
self._manager.removePackage(package_id)
|
||||||
package.is_installing = False
|
|
||||||
self.unsunscribeUserFromPackage(package_id)
|
self.unsunscribeUserFromPackage(package_id)
|
||||||
|
package.is_installing = False
|
||||||
|
package.is_recently_managed = True
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def updatePackage(self, package_id: str) -> None:
|
def updatePackage(self, package_id: str) -> None:
|
||||||
|
|
|
@ -62,7 +62,7 @@ class PackageModel(QObject):
|
||||||
self._icon_url = author_data.get("icon_url", "")
|
self._icon_url = author_data.get("icon_url", "")
|
||||||
|
|
||||||
self._is_installing = False
|
self._is_installing = False
|
||||||
self.is_recently_installed = False
|
self._is_recently_managed = False
|
||||||
self._can_update = False
|
self._can_update = False
|
||||||
self._is_updating = False
|
self._is_updating = False
|
||||||
self._is_enabling = False
|
self._is_enabling = False
|
||||||
|
@ -284,7 +284,7 @@ class PackageModel(QObject):
|
||||||
def stateManageEnableButton(self) -> str:
|
def stateManageEnableButton(self) -> str:
|
||||||
if self._is_enabling:
|
if self._is_enabling:
|
||||||
return "busy"
|
return "busy"
|
||||||
if self.is_recently_installed:
|
if self._is_recently_managed:
|
||||||
return "hidden"
|
return "hidden"
|
||||||
if self._package_type == "material":
|
if self._package_type == "material":
|
||||||
if self._is_bundled: # TODO: Check if a bundled material can/should be un-/install en-/disabled
|
if self._is_bundled: # TODO: Check if a bundled material can/should be un-/install en-/disabled
|
||||||
|
@ -312,8 +312,8 @@ class PackageModel(QObject):
|
||||||
def stateManageInstallButton(self) -> str:
|
def stateManageInstallButton(self) -> str:
|
||||||
if self._is_installing:
|
if self._is_installing:
|
||||||
return "busy"
|
return "busy"
|
||||||
if self.is_recently_installed:
|
if self._is_recently_managed:
|
||||||
return "secondary"
|
return "hidden"
|
||||||
if self._is_installed:
|
if self._is_installed:
|
||||||
if self._is_bundled:
|
if self._is_bundled:
|
||||||
return "hidden"
|
return "hidden"
|
||||||
|
@ -322,6 +322,16 @@ class PackageModel(QObject):
|
||||||
else:
|
else:
|
||||||
return "primary"
|
return "primary"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_recently_managed(self) -> bool:
|
||||||
|
return self._is_recently_managed
|
||||||
|
|
||||||
|
@is_recently_managed.setter
|
||||||
|
def is_recently_managed(self, value: bool) -> None:
|
||||||
|
if value != self._is_recently_managed:
|
||||||
|
self._is_recently_managed = value
|
||||||
|
self.stateManageButtonChanged.emit()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_installing(self) -> bool:
|
def is_installing(self) -> bool:
|
||||||
return self._is_installing
|
return self._is_installing
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot
|
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot
|
||||||
from PyQt5.QtNetwork import QNetworkReply
|
from PyQt5.QtNetwork import QNetworkReply
|
||||||
from typing import Optional, Set, TYPE_CHECKING
|
from typing import Optional, TYPE_CHECKING
|
||||||
|
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
|
@ -31,7 +31,6 @@ class RemotePackageList(PackageList):
|
||||||
self._request_url = self._initialRequestUrl()
|
self._request_url = self._initialRequestUrl()
|
||||||
self.isLoadingChanged.connect(self._onLoadingChanged)
|
self.isLoadingChanged.connect(self._onLoadingChanged)
|
||||||
self.isLoadingChanged.emit()
|
self.isLoadingChanged.emit()
|
||||||
self._local_packages: Set[str] = { p["package_id"] for p in self._manager.local_packages }
|
|
||||||
|
|
||||||
def __del__(self) -> None:
|
def __del__(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -21,8 +21,6 @@ RowLayout
|
||||||
|
|
||||||
signal clicked(bool primary_action)
|
signal clicked(bool primary_action)
|
||||||
|
|
||||||
state: busy ? "busy" : mainState
|
|
||||||
|
|
||||||
Cura.PrimaryButton
|
Cura.PrimaryButton
|
||||||
{
|
{
|
||||||
id: primaryButton
|
id: primaryButton
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue