Implement UX design for maketplace license dialog

cura 8587
This commit is contained in:
casper 2021-12-06 17:10:13 +01:00
parent 0cc9d8db68
commit 4848c474e8
5 changed files with 17 additions and 46 deletions

View file

@ -11,7 +11,6 @@ class LicenseModel(QObject):
dialogTitleChanged = pyqtSignal()
packageNameChanged = pyqtSignal()
licenseTextChanged = pyqtSignal()
iconChanged = pyqtSignal()
def __init__(self, decline_button_text: str = DEFAULT_DECLINE_BUTTON_TEXT) -> None:
super().__init__()
@ -19,7 +18,6 @@ class LicenseModel(QObject):
self._dialogTitle = ""
self._license_text = ""
self._package_name = ""
self._icon_url = ""
self._decline_button_text = decline_button_text
@pyqtProperty(str, constant = True)
@ -42,14 +40,6 @@ class LicenseModel(QObject):
self._package_name = name
self.packageNameChanged.emit()
@pyqtProperty(str, notify=iconChanged)
def iconUrl(self) -> str:
return self._icon_url
def setIconUrl(self, url: str):
self._icon_url = url
self.iconChanged.emit()
@pyqtProperty(str, notify=licenseTextChanged)
def licenseText(self) -> str:
return self._license_text

View file

@ -136,9 +136,8 @@ class PackageList(ListModel):
canInstallChanged = pyqtSignal(str, bool)
def _openLicenseDialog(self, plugin_name: str, license_content: str, icon_url: str) -> None:
def _openLicenseDialog(self, plugin_name: str, license_content: str) -> None:
Logger.debug(f"Prompting license for {plugin_name}")
self._license_model.setIconUrl(icon_url)
self._license_model.setPackageName(plugin_name)
self._license_model.setLicenseText(license_content)
self._license_dialog.show()
@ -180,8 +179,7 @@ class PackageList(ListModel):
# Open actual dialog
package = self.getPackageModel(package_id)
plugin_name = package.displayName
icon_url = package.iconUrl
self._openLicenseDialog(plugin_name, license_content, icon_url)
self._openLicenseDialog(plugin_name, license_content)
else:
# Otherwise continue the installation
self._install(package_id, package_path, update)

View file

@ -20,7 +20,6 @@ UM.Dialog
width: minimumWidth
height: minimumHeight
backgroundColor: UM.Theme.getColor("main_background")
margin: screenScaleFactor * 10
ColumnLayout
{
@ -29,49 +28,32 @@ UM.Dialog
UM.I18nCatalog{id: catalog; name: "cura"}
Label
{
id: licenseHeader
Layout.fillWidth: true
text: catalog.i18nc("@label", "You need to accept the license to install the package")
color: UM.Theme.getColor("text")
wrapMode: Text.Wrap
renderType: Text.NativeRendering
}
Row {
id: packageRow
Layout.fillWidth: true
height: childrenRect.height
spacing: UM.Theme.getSize("default_margin").width
leftPadding: UM.Theme.getSize("narrow_margin").width
Image
UM.RecolorImage
{
id: icon
width: 30 * screenScaleFactor
height: width
sourceSize.width: width
sourceSize.height: height
fillMode: Image.PreserveAspectFit
source: licenseModel.iconUrl || "../../images/placeholder.svg"
mipmap: true
width: UM.Theme.getSize("marketplace_large_icon").width
height: UM.Theme.getSize("marketplace_large_icon").height
color: UM.Theme.getColor("text")
source: UM.Theme.getIcon("Certificate", "high")
}
Label
{
id: packageName
text: licenseModel.packageName
text: catalog.i18nc("@text", "Please read and agree with the plugin licence.")
color: UM.Theme.getColor("text")
font.bold: true
font: UM.Theme.getFont("large")
anchors.verticalCenter: icon.verticalCenter
height: contentHeight
height: UM.Theme.getSize("marketplace_large_icon").height
verticalAlignment: Qt.AlignVCenter
wrapMode: Text.Wrap
renderType: Text.NativeRendering
}
}
Cura.ScrollableTextArea
@ -90,9 +72,6 @@ UM.Dialog
[
Cura.PrimaryButton
{
leftPadding: UM.Theme.getSize("dialog_primary_button_padding").width
rightPadding: UM.Theme.getSize("dialog_primary_button_padding").width
text: licenseModel.acceptButtonText
onClicked: { handler.onLicenseAccepted() }
}
@ -102,7 +81,6 @@ UM.Dialog
[
Cura.SecondaryButton
{
id: declineButton
text: licenseModel.declineButtonText
onClicked: { handler.onLicenseDeclined() }
}