Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions source/gui/addonStoreGui/viewModels/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Iterable,
Optional,
TypeVar,
Union,
TYPE_CHECKING,
)

Expand All @@ -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"): ...

Expand Down
9 changes: 7 additions & 2 deletions source/gui/addonStoreGui/viewModels/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading