diff --git a/source/gui/addonStoreGui/viewModels/action.py b/source/gui/addonStoreGui/viewModels/action.py index 1bf4c7694aa..8ec76fcf718 100644 --- a/source/gui/addonStoreGui/viewModels/action.py +++ b/source/gui/addonStoreGui/viewModels/action.py @@ -10,6 +10,7 @@ Iterable, Optional, TypeVar, + Union, TYPE_CHECKING, ) @@ -29,24 +30,29 @@ class _AddonAction(Generic[ActionTargetT], ABC): def __init__( self, - displayName: str, + displayName: Union[str, Callable[[], str]], actionHandler: Callable[[ActionTargetT], None], validCheck: Callable[[ActionTargetT], bool], actionTarget: ActionTargetT, ): """ - @param displayName: Translated string, to be displayed to the user. Should describe the action / behaviour. + @param displayName: Translated string, or callable returning one, to be displayed to the user. + Should describe the action / behaviour. @param actionHandler: Call when the action is triggered. @param validCheck: Is the action valid for the current target @param actionTarget: The target this action will be applied to. L{updated} notifies of modification. """ - self.displayName = displayName + self._displayName = displayName if callable(displayName) else lambda: displayName self.actionHandler = actionHandler self._validCheck = validCheck self._actionTarget = actionTarget self.updated = extensionPoints.Action() """Notify of changes to the action""" + @property + def displayName(self) -> str: + return self._displayName() + @abstractmethod def _listItemChanged(self, addonListItemVM: "AddonListItemVM"): ... diff --git a/source/gui/addonStoreGui/viewModels/store.py b/source/gui/addonStoreGui/viewModels/store.py index 6adc3f4e861..da56394e7b8 100644 --- a/source/gui/addonStoreGui/viewModels/store.py +++ b/source/gui/addonStoreGui/viewModels/store.py @@ -129,8 +129,13 @@ def _makeActionsList(self): actionTarget=selectedListItem, ), AddonActionVM( - # Translators: Label for an action that updates the selected addon - displayName=pgettext("addonStore", "&Update"), + displayName=lambda: ( + # Translators: Label for an action that enables and updates the selected disabled addon + pgettext("addonStore", "&Enable and update") + if selectedListItem is not None and selectedListItem.model.isDisabled + # Translators: Label for an action that updates the selected addon + else pgettext("addonStore", "&Update") + ), actionHandler=self.getAddon, validCheck=lambda aVM: aVM.canUseUpdateAction(), actionTarget=selectedListItem, diff --git a/user_docs/en/changes.md b/user_docs/en/changes.md index 5d53a5bafa0..29b188912a1 100644 --- a/user_docs/en/changes.md +++ b/user_docs/en/changes.md @@ -26,6 +26,7 @@ The triple-press keyboard shortcut (`NVDA+ctrl+r`) is not affected, as it is int ### Changes +* In the Add-on Store, the "Update" action for disabled add-ons is now labelled "Enable and update" to clarify that the add-on will be enabled as part of the update process. (#17624) * It is now possible to open the log viewer with `NVDA+f1`, even when the log level is set to "disabled". (#19318, @CyrilleB79) * Improved search algorithm for filtering add-ons in the Add-on Store. (#19309) * NVDA can now be configured to not play error sounds, even in test versions. (#13021, @CyrilleB79)