mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 23:17:32 -06:00
Fix The toolbox license dialog
CURA-6983
This commit is contained in:
parent
317061029c
commit
88d210d12d
7 changed files with 35 additions and 32 deletions
|
@ -96,17 +96,12 @@ Window
|
|||
visible: toolbox.restartRequired
|
||||
height: visible ? UM.Theme.getSize("toolbox_footer").height : 0
|
||||
}
|
||||
// TODO: Clean this up:
|
||||
|
||||
Connections
|
||||
{
|
||||
target: toolbox
|
||||
onShowLicenseDialog:
|
||||
{
|
||||
licenseDialog.pluginName = toolbox.getLicenseDialogPluginName();
|
||||
licenseDialog.licenseContent = toolbox.getLicenseDialogLicenseContent();
|
||||
licenseDialog.pluginFileLocation = toolbox.getLicenseDialogPluginFileLocation();
|
||||
licenseDialog.show();
|
||||
}
|
||||
onShowLicenseDialog: { licenseDialog.show() }
|
||||
onCloseLicenseDialog: { licenseDialog.close() }
|
||||
}
|
||||
|
||||
ToolboxLicenseDialog
|
||||
|
|
|
@ -19,9 +19,6 @@ UM.Dialog
|
|||
minimumHeight: UM.Theme.getSize("license_window_minimum").height
|
||||
width: minimumWidth
|
||||
height: minimumHeight
|
||||
property var pluginName;
|
||||
property var licenseContent;
|
||||
property var pluginFileLocation;
|
||||
|
||||
Item
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@ from typing import Optional
|
|||
from PyQt5.QtCore import QObject
|
||||
from PyQt5.QtNetwork import QNetworkReply, QNetworkRequest
|
||||
|
||||
from UM import i18nCatalog
|
||||
from UM.Logger import Logger
|
||||
from UM.Message import Message
|
||||
from UM.Signal import Signal
|
||||
|
@ -11,7 +12,6 @@ from plugins.Toolbox.src.UltimakerCloudScope import UltimakerCloudScope
|
|||
from cura.CuraApplication import CuraApplication
|
||||
from plugins.Toolbox.src.CloudApiModel import CloudApiModel
|
||||
from plugins.Toolbox.src.CloudSync.SubscribedPackagesModel import SubscribedPackagesModel
|
||||
from plugins.Toolbox.src.Toolbox import i18n_catalog
|
||||
|
||||
|
||||
class CloudPackageChecker(QObject):
|
||||
|
@ -25,6 +25,7 @@ class CloudPackageChecker(QObject):
|
|||
self._model = SubscribedPackagesModel()
|
||||
|
||||
self._application.initializationFinished.connect(self._onAppInitialized)
|
||||
self._i18n_catalog = i18nCatalog("cura")
|
||||
|
||||
# This is a plugin, so most of the components required are not ready when
|
||||
# this is initialized. Therefore, we wait until the application is ready.
|
||||
|
@ -56,13 +57,13 @@ class CloudPackageChecker(QObject):
|
|||
|
||||
def _handlePackageDiscrepancies(self):
|
||||
Logger.log("d", "Discrepancy found between Cloud subscribed packages and Cura installed packages")
|
||||
sync_message = Message(i18n_catalog.i18nc(
|
||||
sync_message = Message(self._i18n_catalog.i18nc(
|
||||
"@info:generic",
|
||||
"\nDo you want to sync material and software packages with your account?"),
|
||||
lifetime=0,
|
||||
title=i18n_catalog.i18nc("@info:title", "Changes detected from your Ultimaker account", ))
|
||||
title=self._i18n_catalog.i18nc("@info:title", "Changes detected from your Ultimaker account", ))
|
||||
sync_message.addAction("sync",
|
||||
name=i18n_catalog.i18nc("@action:button", "Sync"),
|
||||
name=self._i18n_catalog.i18nc("@action:button", "Sync"),
|
||||
icon="",
|
||||
description="Sync your Cloud subscribed packages to your local environment.",
|
||||
button_align=Message.ActionButtonAlignment.ALIGN_RIGHT)
|
||||
|
|
|
@ -40,7 +40,7 @@ class LicenseModel(QObject):
|
|||
self._license_text = license_text
|
||||
self.licenseTextChanged.emit()
|
||||
|
||||
def setCurrentPageNumber(self, idx: int) -> None:
|
||||
def setCurrentPageIdx(self, idx: int) -> None:
|
||||
self._current_page_idx = idx
|
||||
self._updateDialogTitle()
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ class LicensePresenter(QObject):
|
|||
self.onLicenseAccepted()
|
||||
return
|
||||
|
||||
self._license_model.setCurrentPageNumber(self._current_package_idx)
|
||||
self._license_model.setCurrentPageIdx(self._current_package_idx)
|
||||
self._license_model.setPackageName(package_model["package_id"])
|
||||
self._license_model.setLicenseText(license_content)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ from UM.Extension import Extension
|
|||
from UM.Logger import Logger
|
||||
from UM.PluginRegistry import PluginRegistry
|
||||
from cura.CuraApplication import CuraApplication
|
||||
from plugins.Toolbox import CloudPackageChecker
|
||||
from plugins.Toolbox.src.CloudSync.CloudPackageChecker import CloudPackageChecker
|
||||
from plugins.Toolbox.src.CloudSync.DiscrepanciesPresenter import DiscrepanciesPresenter
|
||||
from plugins.Toolbox.src.CloudSync.DownloadPresenter import DownloadPresenter
|
||||
from plugins.Toolbox.src.CloudSync.LicensePresenter import LicensePresenter
|
||||
|
|
|
@ -22,6 +22,7 @@ from cura.Machines.ContainerTree import ContainerTree
|
|||
from plugins.Toolbox.src.CloudApiModel import CloudApiModel
|
||||
|
||||
from .AuthorsModel import AuthorsModel
|
||||
from .CloudSync.LicenseModel import LicenseModel
|
||||
from .PackagesModel import PackagesModel
|
||||
from .CloudSync.SubscribedPackagesModel import SubscribedPackagesModel
|
||||
from .UltimakerCloudScope import UltimakerCloudScope
|
||||
|
@ -77,6 +78,8 @@ class Toolbox(QObject, Extension):
|
|||
self._materials_installed_model = PackagesModel(self)
|
||||
self._materials_generic_model = PackagesModel(self)
|
||||
|
||||
self._license_model = LicenseModel()
|
||||
|
||||
# These properties are for keeping track of the UI state:
|
||||
# ----------------------------------------------------------------------
|
||||
# View category defines which filter to use, and therefore effectively
|
||||
|
@ -99,8 +102,6 @@ class Toolbox(QObject, Extension):
|
|||
self._restart_required = False # type: bool
|
||||
|
||||
# variables for the license agreement dialog
|
||||
self._license_dialog_plugin_name = "" # type: str
|
||||
self._license_dialog_license_content = "" # type: str
|
||||
self._license_dialog_plugin_file_location = "" # type: str
|
||||
self._restart_dialog_message = "" # type: str
|
||||
|
||||
|
@ -122,6 +123,7 @@ class Toolbox(QObject, Extension):
|
|||
filterChanged = pyqtSignal()
|
||||
metadataChanged = pyqtSignal()
|
||||
showLicenseDialog = pyqtSignal()
|
||||
closeLicenseDialog = pyqtSignal()
|
||||
uninstallVariablesChanged = pyqtSignal()
|
||||
|
||||
## Go back to the start state (welcome screen or loading if no login required)
|
||||
|
@ -155,21 +157,16 @@ class Toolbox(QObject, Extension):
|
|||
data=data.encode()
|
||||
)
|
||||
|
||||
@pyqtSlot(result = str)
|
||||
def getLicenseDialogPluginName(self) -> str:
|
||||
return self._license_dialog_plugin_name
|
||||
|
||||
@pyqtSlot(result = str)
|
||||
def getLicenseDialogPluginFileLocation(self) -> str:
|
||||
return self._license_dialog_plugin_file_location
|
||||
|
||||
@pyqtSlot(result = str)
|
||||
def getLicenseDialogLicenseContent(self) -> str:
|
||||
return self._license_dialog_license_content
|
||||
|
||||
def openLicenseDialog(self, plugin_name: str, license_content: str, plugin_file_location: str) -> None:
|
||||
self._license_dialog_plugin_name = plugin_name
|
||||
self._license_dialog_license_content = license_content
|
||||
# Set page 1/1 when opening the dialog for a single package
|
||||
self._license_model.setCurrentPageIdx(0)
|
||||
self._license_model.setPageCount(1)
|
||||
|
||||
self._license_model.setPackageName(plugin_name)
|
||||
self._license_model.setLicenseText(license_content)
|
||||
self._license_dialog_plugin_file_location = plugin_file_location
|
||||
self.showLicenseDialog.emit()
|
||||
|
||||
|
@ -227,7 +224,11 @@ class Toolbox(QObject, Extension):
|
|||
return None
|
||||
path = os.path.join(plugin_path, "resources", "qml", qml_name)
|
||||
|
||||
dialog = self._application.createQmlComponent(path, {"toolbox": self})
|
||||
dialog = self._application.createQmlComponent(path, {
|
||||
"toolbox": self,
|
||||
"handler": self,
|
||||
"licenseModel": self._license_model
|
||||
})
|
||||
if not dialog:
|
||||
raise Exception("Failed to create Marketplace dialog")
|
||||
return dialog
|
||||
|
@ -376,6 +377,15 @@ class Toolbox(QObject, Extension):
|
|||
self._resetUninstallVariables()
|
||||
self.closeConfirmResetDialog()
|
||||
|
||||
@pyqtSlot()
|
||||
def onLicenseAccepted(self):
|
||||
self.closeLicenseDialog.emit()
|
||||
self.install(self.getLicenseDialogPluginFileLocation())
|
||||
|
||||
@pyqtSlot()
|
||||
def onLicenseDeclined(self):
|
||||
self.closeLicenseDialog.emit()
|
||||
|
||||
def _markPackageMaterialsAsToBeUninstalled(self, package_id: str) -> None:
|
||||
container_registry = self._application.getContainerRegistry()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue