Addon Manager: Refactor primary view and enable composite (#12693)

* Addon Manager: Refactor primary view and enable composite

This brings back something akin to the original Addon Manager display, with the side-by-side display of the list and details views.
This commit is contained in:
Chris Hennes
2024-03-04 08:56:55 -06:00
committed by GitHub
parent 5834042855
commit 4067cdb672
12 changed files with 242 additions and 119 deletions

View File

@@ -75,6 +75,8 @@ class WidgetAddonButtons(QtWidgets.QWidget):
self.retranslateUi(None)
def _setup_ui(self):
if self.layout():
self.setLayout(None) # TODO: Check this
self.horizontal_layout = QtWidgets.QHBoxLayout()
self.horizontal_layout.setContentsMargins(0, 0, 0, 0)
self.back = QtWidgets.QToolButton(self)
@@ -98,6 +100,9 @@ class WidgetAddonButtons(QtWidgets.QWidget):
self.horizontal_layout.addWidget(self.change_branch)
self.setLayout(self.horizontal_layout)
def set_show_back_button(self, show: bool) -> None:
self.back.setVisible(show)
def _set_icons(self):
self.back.setIcon(QtGui.QIcon.fromTheme("back", QtGui.QIcon(":/icons/button_left.svg")))

View File

@@ -65,6 +65,7 @@ class MessageType(Enum):
@dataclass
class UpdateInformation:
unchecked: bool = True
check_in_progress: bool = False
update_available: bool = False
detached_head: bool = False
@@ -112,6 +113,7 @@ class PackageDetailsView(QtWidgets.QWidget):
self.vertical_layout.addWidget(self.message_label)
self.vertical_layout.addWidget(self.location_label)
self.vertical_layout.addWidget(self.readme_browser)
self.button_bar.hide() # Start with no bar
def set_location(self, location: Optional[str]):
if location is not None:
@@ -274,6 +276,8 @@ class PackageDetailsView(QtWidgets.QWidget):
def _get_update_status_string(self) -> str:
if self.update_info.check_in_progress:
return translate("AddonsInstaller", "Update check in progress") + "."
elif self.update_info.unchecked:
return ""
if self.update_info.detached_head:
return (
translate(

View File

@@ -63,6 +63,7 @@ class WidgetReadmeBrowser(QtWidgets.QTextBrowser):
def setMarkdown(self, md: str):
"""Provides an optional fallback to the markdown library for older versions of Qt (prior to 5.15) that did not
have native markdown support. Lacking that, plaintext is displayed."""
geometry = self.geometry()
if hasattr(super(), "setMarkdown"):
super().setMarkdown(md)
else:
@@ -76,6 +77,7 @@ class WidgetReadmeBrowser(QtWidgets.QTextBrowser):
FreeCAD.Console.Warning(
"Qt < 5.15 and no `import markdown` -- falling back to plain text display\n"
)
self.setGeometry(geometry)
def set_resource(self, resource_url: str, image: Optional[QtGui.QImage]):
"""Once a resource has been fetched (or the fetch has failed), this method should be used to inform the widget

View File

@@ -119,7 +119,6 @@ class WidgetViewSelector(QtWidgets.QWidget):
self.composite_button.setIcon(
QtGui.QIcon.fromTheme("composite_button", QtGui.QIcon(":/icons/composite_view.svg"))
)
self.composite_button.hide() # TODO: Implement this view
self.horizontal_layout.addWidget(self.compact_button)
self.horizontal_layout.addWidget(self.expanded_button)