mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-19 04:37:29 +08:00
Only show formatted description in detail page
We can't show rich text in the package list, because the we use the onLineLaidOut signal there, which doesn't work with Rich Text. So for the package list we should NOT use the formatted version of the description because that will contain ugly HTML tags that the user wouldn't want to see. Show the original description there. Use the formatted description only in the detail page where we don't use onLineLaidOut. Contributes to issue CURA-8565.
This commit is contained in:
parent
b5c7dfe9a2
commit
d96284ee3e
@ -34,7 +34,8 @@ class PackageModel(QObject):
|
||||
self._package_version = package_data.get("package_version", "") # Display purpose, no need for 'UM.Version'.
|
||||
self._package_info_url = package_data.get("website", "") # Not to be confused with 'download_url'.
|
||||
self._download_count = package_data.get("download_count", 0)
|
||||
self._description = self._format(package_data.get("description", ""))
|
||||
self._description = package_data.get("description", "")
|
||||
self._formatted_description = self._format(self._description)
|
||||
|
||||
self._download_url = package_data.get("download_url", "")
|
||||
self._release_notes = package_data.get("release_notes", "") # Not used yet, propose to add to description?
|
||||
@ -48,7 +49,7 @@ class PackageModel(QObject):
|
||||
self._section_title = section_title
|
||||
# Note that there's a lot more info in the package_data than just these specified here.
|
||||
|
||||
def _format(self, text):
|
||||
def _format(self, text: str) -> str:
|
||||
"""
|
||||
Formats a user-readable block of text for display.
|
||||
:return: A block of rich text with formatting embedded.
|
||||
@ -95,6 +96,10 @@ class PackageModel(QObject):
|
||||
def description(self):
|
||||
return self._description
|
||||
|
||||
@pyqtProperty(str, constant = True)
|
||||
def formattedDescription(self) -> str:
|
||||
return self._formatted_description
|
||||
|
||||
@pyqtProperty(str, constant=True)
|
||||
def authorName(self):
|
||||
return self._author_name
|
||||
|
@ -233,6 +233,7 @@ Rectangle
|
||||
property real lastLineWidth: 0; //Store the width of the last line, to properly position the elision.
|
||||
|
||||
text: packageData.description
|
||||
textFormat: Text.PlainText //Must be plain text, or we won't get onLineLaidOut signals. Don't auto-detect!
|
||||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("text")
|
||||
maximumLineCount: 2
|
||||
@ -401,7 +402,7 @@ Rectangle
|
||||
{
|
||||
width: parent.width - parent.padding * 2
|
||||
|
||||
text: packageData.description
|
||||
text: packageData.formattedDescription
|
||||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("text")
|
||||
linkColor: UM.Theme.getColor("text_link")
|
||||
|
Loading…
x
Reference in New Issue
Block a user