Skip to content

Commit 3174686

Browse files
authored
Merge f7e7aff into 20bdb39
2 parents 20bdb39 + f7e7aff commit 3174686

6 files changed

Lines changed: 71 additions & 2 deletions

File tree

include/liblouis

Submodule liblouis updated 66 files

source/gui/addonStoreGui/controls/storeDialog.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,19 @@ def _createFilterControls(self, filterCtrlHelper: guiHelper.BoxSizerHelper) -> N
155155
filterCtrlsLine1.sizer.AddSpacer(FILTER_MARGIN_PADDING)
156156
filterCtrlHelper.addItem(filterCtrlsLine1.sizer, flag=wx.EXPAND, proportion=1)
157157

158+
self._storeVM.listVM.setColumnChoices()
159+
self.columnFilterCtrl = cast(
160+
wx.Choice,
161+
filterCtrlsLine0.addLabeledControl(
162+
# Translators: The label of a selection field to sort the list of add-ons in the add-on store dialog.
163+
labelText=pgettext("addonStore", "Sort by colu&mn:"),
164+
wxCtrlClass=wx.Choice,
165+
choices=self._storeVM.listVM._columnChoices,
166+
),
167+
)
168+
self.columnFilterCtrl.Bind(wx.EVT_CHOICE, self.onColumnFilterChange, self.columnFilterCtrl)
169+
self.bindHelpEvent("AddonStoreSortByColumn", self.columnFilterCtrl)
170+
158171
self.channelFilterCtrl = cast(
159172
wx.Choice,
160173
filterCtrlsLine0.addLabeledControl(
@@ -323,6 +336,10 @@ def _setListLabels(self):
323336
self.SetTitle(self._titleText)
324337

325338
def _toggleFilterControls(self):
339+
self.columnFilterCtrl.Clear()
340+
self._storeVM.listVM.setColumnChoices()
341+
for c in self._storeVM.listVM._columnChoices:
342+
self.columnFilterCtrl.Append(c)
326343
self.channelFilterCtrl.Clear()
327344
for c in _channelFilters:
328345
if c != Channel.EXTERNAL:
@@ -358,6 +375,9 @@ def onListTabPageChange(self, evt: wx.EVT_CHOICE):
358375
self._storeVM._filteredStatusKey = self._statusFilterKey
359376
self.addonListView._refreshColumns()
360377
self._toggleFilterControls()
378+
self.columnFilterCtrl.SetSelection(0)
379+
self._storeVM.listVM.setSortField(self._storeVM.listVM.presentedFields[0])
380+
self._storeVM.listVM.setReverse(False)
361381

362382
channelFilterIndex = list(_channelFilters.keys()).index(self._storeVM._filterChannelKey)
363383
self.channelFilterCtrl.SetSelection(channelFilterIndex)
@@ -370,6 +390,20 @@ def onListTabPageChange(self, evt: wx.EVT_CHOICE):
370390
if not self.addonListTabs.HasFocus():
371391
self.addonListTabs.SetFocus()
372392

393+
def onColumnFilterChange(self, evt: wx.EVT_CHOICE):
394+
# Each col index will correspond to 2 choices in the combo box (ascending and descending)
395+
colIndex = evt.GetSelection() // 2
396+
self._storeVM.listVM.setSortField(self._storeVM.listVM.presentedFields[colIndex])
397+
# Descending sort should be applied for odd choices of the combo box
398+
reverse = evt.GetSelection() % 2
399+
self._storeVM.listVM.setReverse(reverse)
400+
log.debug(f"sortered by: {colIndex}; reversed: {reverse}")
401+
self._storeVM.refresh()
402+
403+
def onDescendingOrderFilterChange(self, evt: wx.EVT_CHECKBOX):
404+
self._storeVM.listVM.setReverse(self.descendingOrderFilterCtrl.GetValue())
405+
self._storeVM.refresh()
406+
373407
def onChannelFilterChange(self, evt: wx.EVT_CHOICE):
374408
self._storeVM._filterChannelKey = self._channelFilterKey
375409
self._storeVM.listVM.setSelection(None)

source/gui/addonStoreGui/viewModels/addonList.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ def __init__(
220220
self.lastSelectedAddonId = self.selectedAddonId
221221
self._sortByModelField: AddonListField = AddonListField.displayName
222222
self._filterString: Optional[str] = None
223+
self._columnChoices: list[str] = []
224+
self._reverse: bool = False
223225

224226
self._setSelectionPending = False
225227
self._addonsFilteredOrdered: List[str] = self._getFilteredSortedIds()
@@ -349,6 +351,20 @@ def setSortField(self, modelField: AddonListField):
349351
# ensure calling on the main thread.
350352
core.callLater(delay=0, callable=self.updated.notify)
351353

354+
def setColumnChoices(self) -> None:
355+
# Translators: Presented when a list will be sorted in ascending order.
356+
ascendingOrderLabel = pgettext("addonStore", "Ascending")
357+
# Translators: Presented when a list will be sorted in descending order.
358+
descendingOrderLabel = pgettext("addonStore", "Descending")
359+
columnChoices = []
360+
for c in self.presentedFields:
361+
columnChoices.append(f"{c.displayString} ({ascendingOrderLabel})")
362+
columnChoices.append(f"{c.displayString} ({descendingOrderLabel})")
363+
self._columnChoices = columnChoices
364+
365+
def setReverse(self, reverse: bool) -> None:
366+
self._reverse = reverse
367+
352368
def _getFilteredSortedIds(self) -> List[str]:
353369
def _getSortFieldData(listItemVM: AddonListItemVM) -> "SupportsLessThan":
354370
return strxfrm(self._getAddonFieldText(listItemVM, self._sortByModelField))
@@ -371,7 +387,9 @@ def _containsTerm(detailsVM: AddonListItemVM, term: str) -> bool:
371387
for vm in self._addons.values()
372388
if self._filterString is None or _containsTerm(vm, self._filterString)
373389
)
374-
filteredSorted = list([vm.Id for vm in sorted(filtered, key=_getSortFieldData)])
390+
filteredSorted = list(
391+
[vm.Id for vm in sorted(filtered, key=_getSortFieldData, reverse=self._reverse)],
392+
)
375393
return filteredSorted
376394

377395
def _tryPersistSelection(

tests/manual/addonStore.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ Add-ons can be filtered by display name, publisher and description.
3030
1. Enable the "Include incompatible add-ons" filter
3131
1. Ensure add-ons with status "incompatible" are included in the list with the available add-ons.
3232

33+
### Sorting the add-ons list by column
34+
1. Open the Add-on Store
35+
1. Jump to the sort by column field (`alt+m`)
36+
1. Select different columns, and ensure that the add-ons list is sorted accordingly
37+
1. Alternatively, perform a left mouse click on different columns
38+
1. Check and uncheck the descending order checkbox (`alt+d`), and ensure that add-ons are sorted in descending order only when the checkbox is checked.
39+
1. Change to different tabs, and repeat the previous steps.
40+
3341
### Failure to fetch add-ons available for download
3442
1. Disable your internet connection
3543
1. Go to your [NVDA user configuration folder](#editing-user-configuration)

user_docs/en/changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ In order to use this feature, the application volume adjuster needs to be enable
1515
* Added an action in the Add-on Store to cancel the install of add-ons. (#15578, @hwf1324)
1616
* Added an action in the Add-on Store to retry the installation if the download/installation of an add-on fails. (#17090, @hwf1324)
1717
* It is now possible to specify a mirror URL to use for the Add-on Store. (#14974)
18+
* The add-ons lists in the Add-on Store can be sorted by columns. (#15277, @nvdaes)
1819
* When decreasing or increasing the font size in LibreOffice Writer using the corresponding keyboard shortcuts, NVDA announces the new font size. (#6915, @michaelweghorn)
1920

2021
### Changes

user_docs/en/userGuide.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3637,6 +3637,14 @@ You can reach it by pressing `shift+tab` from the list of add-ons.
36373637
Type a keyword or two for the kind of add-on you're looking for, then `tab` to the list of add-ons.
36383638
Add-ons will be listed if the search text can be found in the add-on ID, display name, publisher, author or description.
36393639

3640+
#### Sorting the add-ons list by column {#AddonStoreSortByColumn}
3641+
3642+
By default, the add-ons list is sorted by the add-ons' display name.
3643+
The "Sort by column" combo box can be used to sort the list by the available columns for each tab.
3644+
For example, you may wish to sort add-ons by publisher, available version, etc.
3645+
3646+
Add-ons can be sortered in ascending or descending order.
3647+
36403648
### Add-on actions {#AddonStoreActions}
36413649

36423650
Add-ons have associated actions, such as install, help, disable, and remove.

0 commit comments

Comments
 (0)