Skip to content

Commit

Permalink
AddonManager: open addon's location directory (FreeCAD#19209)
Browse files Browse the repository at this point in the history
* AddonManager: open addon's location directory
* AddonManager: account for macros when setting addon location
  • Loading branch information
hasecilu authored Jan 24, 2025
1 parent 0768992 commit 9ae7491
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/Mod/AddonManager/Addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ class ResolutionFailed(RuntimeError):
# The location of the Mod directory: overridden by testing code
mod_directory = fci.DataPaths().mod_dir

# The location of the Macro directory: overridden by testing code
macro_directory = fci.DataPaths().macro_dir

def __init__(
self,
name: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def _setup_ui(self):
self.location_label = QtWidgets.QLabel(self)
self.url_label = QtWidgets.QLabel(self)
self.url_label.setOpenExternalLinks(True)
self.location_label.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
self.location_label.setOpenExternalLinks(True)
self.vertical_layout.addWidget(self.button_bar)
self.vertical_layout.addWidget(self.message_label)
self.vertical_layout.addWidget(self.location_label)
Expand All @@ -121,10 +121,10 @@ def _setup_ui(self):

def set_location(self, location: Optional[str]):
if location is not None:
location_path = os.path.normpath(location)
text = (
translate("AddonsInstaller", "Installation location")
+ ": "
+ os.path.normpath(location)
f"{translate('AddonsInstaller', 'Installation location')}: "
f'<a href="file://{location_path}">{location_path}</a>'
)
self.location_label.setText(text)
self.location_label.show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ def show_repo(self, repo: Addon) -> None:
elif repo.macro:
update_info.version = repo.macro.version
self.ui.set_update_available(update_info)
self.ui.set_location(os.path.join(self.addon.mod_directory, self.addon.name))
self.ui.set_location(
self.addon.macro_directory
if repo.repo_type == Addon.Kind.MACRO
else os.path.join(self.addon.mod_directory, self.addon.name)
)
self.ui.set_disabled(self.addon.is_disabled())
self.ui.allow_running(repo.repo_type == Addon.Kind.MACRO)
self.ui.allow_disabling(repo.repo_type != Addon.Kind.MACRO)
Expand All @@ -125,7 +129,7 @@ def show_repo(self, repo: Addon) -> None:
if repo.status() == Addon.Status.UNCHECKED:
self.ui.button_bar.check_for_update.show()
self.ui.button_bar.check_for_update.setText(
translate("AddonsInstaller", "Check for " "update")
translate("AddonsInstaller", "Check for update")
)
self.ui.button_bar.check_for_update.setEnabled(True)
if not self.update_check_thread:
Expand Down

0 comments on commit 9ae7491

Please sign in to comment.