Finished LicensePresenter

CURA-6983
This commit is contained in:
Nino van Hooff 2020-01-09 17:44:31 +01:00
parent dda3d0b4eb
commit 89994b92b5
4 changed files with 57 additions and 25 deletions

View file

@ -1,24 +1,35 @@
from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal
from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")
# Model for the ToolboxLicenseDialog
class LicenseModel(QObject):
titleChanged = pyqtSignal()
dialogTitleChanged = pyqtSignal()
headerChanged = pyqtSignal()
licenseTextChanged = pyqtSignal()
def __init__(self, title: str = "", license_text: str = ""):
def __init__(self):
super().__init__()
self._title = title
self._license_text = license_text
@pyqtProperty(str, notify=titleChanged)
def title(self) -> str:
return self._title
self._current_page_idx = 0
self._page_count = 1
self._dialogTitle = ""
self._header_text = ""
self._license_text = ""
self._package_name = ""
def setTitle(self, title: str) -> None:
if self._title != title:
self._title = title
self.titleChanged.emit()
@pyqtProperty(str, notify=dialogTitleChanged)
def dialogTitle(self) -> str:
return self._dialogTitle
@pyqtProperty(str, notify=headerChanged)
def headerText(self) -> str:
return self._header_text
def setPackageName(self, name: str) -> None:
self._header_text = name + ": " + catalog.i18nc("@label", "This plugin contains a license.\nYou need to accept this license to install this plugin.\nDo you agree with the terms below?")
self.headerChanged.emit()
@pyqtProperty(str, notify=licenseTextChanged)
def licenseText(self) -> str:
@ -28,3 +39,16 @@ class LicenseModel(QObject):
if self._license_text != license_text:
self._license_text = license_text
self.licenseTextChanged.emit()
def setCurrentPageNumber(self, idx: int) -> None:
self._current_page_idx = idx
self._updateDialogTitle()
def setPageCount(self, count: int):
self._page_count = count
self._updateDialogTitle()
def _updateDialogTitle(self):
self._dialogTitle = catalog.i18nc("@title:window", "Plugin License Agreement ({}/{})"
.format(self._current_page_idx + 1, self._page_count))
self.dialogTitleChanged.emit()