Addon Manager: Add UI for setting Score source

This commit is contained in:
Chris Hennes
2024-02-25 17:33:07 -06:00
committed by Chris Hennes
parent 7d882ca37f
commit f554750f8e
3 changed files with 37 additions and 7 deletions

View File

@@ -316,6 +316,36 @@ installed addons will be checked for available updates
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayoutScore">
<item>
<widget class="QLabel" name="label_score">
<property name="text">
<string>Score source URL</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefLineEdit" name="guipreflineeditscoresourceurl">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="prefEntry" stdset="0">
<cstring>AddonScoreURL</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Addons</cstring>
</property>
<property name="toolTip">
<string>The URL for the Addon Score data (see documentation for formatting and hosting details).</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">

View File

@@ -23,7 +23,7 @@
# ***************************************************************************
""" Worker thread classes for Addon Manager startup """
import datetime
import hashlib
import json
import os
@@ -966,7 +966,7 @@ class GetAddonScoreWorker(QtCore.QThread):
FreeCAD.Console.PrintError(
translate(
"AddonsInstaller",
"Failed to get Addon score from {} -- sorting by score will fail\n",
"Failed to get Addon score from '{}' -- sorting by score will fail\n",
).format(self.url)
)
return
@@ -976,7 +976,10 @@ class GetAddonScoreWorker(QtCore.QThread):
FreeCAD.Console.PrintWarning("Running score generation in TEST mode...\n")
json_result = {}
for addon in self.addons:
json_result[addon.url] = len(addon.display_name)
if addon.macro:
json_result[addon.name] = len(addon.macro.comment) if addon.macro.comment else 0
else:
json_result[addon.url] = len(addon.description) if addon.description else 0
for addon in self.addons:
score = None

View File

@@ -387,12 +387,9 @@ class PackageListItemDelegate(QtWidgets.QStyledItemDelegate):
return translate("AddonsInstaller", "Updated ") + time_string
return ""
elif self.sort_order == SortOptions.Score:
return translate("AddonsInstaller", "Score: ") + str(len(addon.display_name))
return translate("AddonsInstaller", "Score: ") + str(addon.score)
return ""
def _set_sort_string_expanded(self, addon: Addon, label: QtWidgets.QLabel) -> None:
pass
def _get_compact_description(self, addon: Addon) -> str:
if addon.metadata:
trimmed_text = addon.metadata.description