From 980bb17964ef862634e7fec1fe8836095d144bfc Mon Sep 17 00:00:00 2001 From: Vishal Date: Mon, 22 Apr 2024 15:33:31 +0530 Subject: [PATCH 1/6] Plugins can be now viewed in A-Z or Z-A order. --- plugin_manager.py | 55 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/plugin_manager.py b/plugin_manager.py index 8d7e528..a597073 100644 --- a/plugin_manager.py +++ b/plugin_manager.py @@ -1628,6 +1628,8 @@ class PluginManagerWindow(bui.Window): self.category_selection_button = None self.selected_category = None self.plugins_in_current_view = {} + self.selected_alphabet_order = 'a_z' + self.alphabet_order_selection_button = None loop.create_task(self.draw_index()) @@ -1761,7 +1763,7 @@ class PluginManagerWindow(bui.Window): def draw_category_selection_button(self, post_label): category_pos_x = (440 if _uiscale is babase.UIScale.SMALL else - 340 if _uiscale is babase.UIScale.MEDIUM else 350) + 340 if _uiscale is babase.UIScale.MEDIUM else 370) category_pos_y = self._height - (141 if _uiscale is babase.UIScale.SMALL else 110 if _uiscale is babase.UIScale.MEDIUM else 110) b_size = (140, 30) @@ -1769,6 +1771,25 @@ class PluginManagerWindow(bui.Window): b_textcolor = (0.8, 0.8, 0.85) # b_color = (0.6, 0.53, 0.63) + if self.alphabet_order_selection_button is None: + self.alphabet_order_selection_button = bui.buttonwidget(parent=self._root_widget, + size=(40,30), + position=( + category_pos_x - 47, + category_pos_y), + label=( + 'Z - A' if self.selected_alphabet_order == 'z_a' + else 'A - Z'), + on_activate_call=( + lambda: loop.create_task(self._on_order_button_press())), + button_type="square", + textcolor=b_textcolor, + text_scale=0.6) + else: + bui.buttonwidget(edit=self.alphabet_order_selection_button, + label = ('Z - A' if self.selected_alphabet_order == 'z_a' else 'A - Z') + ) + label = f"Category: {post_label}" if self.category_selection_button is None: @@ -1788,9 +1809,19 @@ class PluginManagerWindow(bui.Window): self.category_selection_button = bui.buttonwidget(edit=self.category_selection_button, label=label) + async def _on_order_button_press(self) -> None: + self.selected_alphabet_order = ('a_z' if self.selected_alphabet_order == 'z_a' else 'z_a') + bui.buttonwidget(edit=self.alphabet_order_selection_button, + label = ('Z - A' if self.selected_alphabet_order == 'z_a' else 'A - Z') + ) + filter_text = bui.textwidget(parent=self._root_widget, query=self._filter_widget) + await self.draw_plugin_names( + self.selected_category, refresh=True, order=self.selected_alphabet_order + ) + def draw_search_bar(self): search_bar_pos_x = (85 if _uiscale is babase.UIScale.SMALL else - 68 if _uiscale is babase.UIScale.MEDIUM else 90) + 68 if _uiscale is babase.UIScale.MEDIUM else 75) search_bar_pos_y = self._height - ( 145 if _uiscale is babase.UIScale.SMALL else 110 if _uiscale is babase.UIScale.MEDIUM else 116) @@ -1802,7 +1833,7 @@ class PluginManagerWindow(bui.Window): 35 if _uiscale is babase.UIScale.MEDIUM else 45) filter_txt_pos_x = (60 if _uiscale is babase.UIScale.SMALL else - 40 if _uiscale is babase.UIScale.MEDIUM else 60) + 40 if _uiscale is babase.UIScale.MEDIUM else 50) filter_txt_pos_y = search_bar_pos_y + (3 if _uiscale is babase.UIScale.SMALL else 4 if _uiscale is babase.UIScale.MEDIUM else 8) @@ -1845,7 +1876,8 @@ class PluginManagerWindow(bui.Window): if self.selected_category is None: continue try: - await self.draw_plugin_names(self.selected_category, search_term=filter_text.lower()) + await self.draw_plugin_names( + self.selected_category, search_term=filter_text.lower(), order=self.selected_alphabet_order) except CategoryDoesNotExist: pass # XXX: This may be more efficient, but we need a way to get a plugin's textwidget @@ -1927,7 +1959,7 @@ class PluginManagerWindow(bui.Window): # await asyncio.gather(*plugin_names_to_draw) # XXX: Not sure if this is the best way to handle search filters. - async def draw_plugin_names(self, category, search_term="", refresh=False): + async def draw_plugin_names(self, category, search_term="", refresh=False, order='a_z'): # Re-draw plugin list UI if either search term or category was switched. to_draw_plugin_names = (search_term, category) != (self._last_filter_text, self.selected_category) @@ -1940,14 +1972,18 @@ class PluginManagerWindow(bui.Window): raise CategoryDoesNotExist(f"{category} does not exist.") if search_term: - plugins = filter( + plugins = list(filter( lambda plugin: self.search_term_filterer(plugin, search_term), category_plugins, - ) + )) else: plugins = category_plugins - if plugins == self._last_filter_plugins: + def return_name(val): + return val.name + plugins.sort(key=return_name, reverse=(True if order == 'z_a' else False)) + + if plugins == self._last_filter_plugins and not refresh: # Plugins names to draw on UI are already drawn. return @@ -2017,7 +2053,8 @@ class PluginManagerWindow(bui.Window): async def select_category(self, category): self.plugins_in_current_view.clear() self.draw_category_selection_button(post_label=category) - await self.draw_plugin_names(category, search_term=self._last_filter_text, refresh=True) + await self.draw_plugin_names( + category, search_term=self._last_filter_text, refresh=True, order=self.selected_alphabet_order) self.selected_category = category def cleanup(self): From 5186033e292d5b2db504d5e331d0bcfa3744a32f Mon Sep 17 00:00:00 2001 From: vishal332008 Date: Mon, 22 Apr 2024 10:03:53 +0000 Subject: [PATCH 2/6] [ci] auto-format --- plugin_manager.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugin_manager.py b/plugin_manager.py index a597073..6c6fd4f 100644 --- a/plugin_manager.py +++ b/plugin_manager.py @@ -1773,7 +1773,7 @@ class PluginManagerWindow(bui.Window): if self.alphabet_order_selection_button is None: self.alphabet_order_selection_button = bui.buttonwidget(parent=self._root_widget, - size=(40,30), + size=(40, 30), position=( category_pos_x - 47, category_pos_y), @@ -1787,8 +1787,8 @@ class PluginManagerWindow(bui.Window): text_scale=0.6) else: bui.buttonwidget(edit=self.alphabet_order_selection_button, - label = ('Z - A' if self.selected_alphabet_order == 'z_a' else 'A - Z') - ) + label=('Z - A' if self.selected_alphabet_order == 'z_a' else 'A - Z') + ) label = f"Category: {post_label}" @@ -1812,8 +1812,8 @@ class PluginManagerWindow(bui.Window): async def _on_order_button_press(self) -> None: self.selected_alphabet_order = ('a_z' if self.selected_alphabet_order == 'z_a' else 'z_a') bui.buttonwidget(edit=self.alphabet_order_selection_button, - label = ('Z - A' if self.selected_alphabet_order == 'z_a' else 'A - Z') - ) + label=('Z - A' if self.selected_alphabet_order == 'z_a' else 'A - Z') + ) filter_text = bui.textwidget(parent=self._root_widget, query=self._filter_widget) await self.draw_plugin_names( self.selected_category, refresh=True, order=self.selected_alphabet_order @@ -1979,8 +1979,8 @@ class PluginManagerWindow(bui.Window): else: plugins = category_plugins - def return_name(val): - return val.name + def return_name(val): + return val.name plugins.sort(key=return_name, reverse=(True if order == 'z_a' else False)) if plugins == self._last_filter_plugins and not refresh: From 2d2a8d673bc0109afa83ef8b5d6c37f4b8ad052d Mon Sep 17 00:00:00 2001 From: Vishal Date: Mon, 22 Apr 2024 16:01:07 +0530 Subject: [PATCH 3/6] Adding 'Installed' category to show Installed plugins. --- index.json | 1 + plugin_manager.py | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/index.json b/index.json index 4996de1..c702c78 100644 --- a/index.json +++ b/index.json @@ -1,6 +1,7 @@ { "plugin_manager_url": "https://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugin_manager.py", "versions": { + "1.0.15": null, "1.0.14": { "api_version": 8, "commit_sha": "fc5a7f1", diff --git a/plugin_manager.py b/plugin_manager.py index 6c6fd4f..8e67fe3 100644 --- a/plugin_manager.py +++ b/plugin_manager.py @@ -31,7 +31,7 @@ from datetime import datetime from threading import Thread import logging -PLUGIN_MANAGER_VERSION = "1.0.14" +PLUGIN_MANAGER_VERSION = "1.0.15" REPOSITORY_URL = "https://github.com/bombsquad-community/plugin-manager" # Current tag can be changed to "staging" or any other branch in # plugin manager repo for testing purpose. @@ -1589,7 +1589,7 @@ class PluginSourcesWindow(popup.PopupWindow): class PluginCategoryWindow(popup.PopupMenuWindow): def __init__(self, choices, current_choice, origin_widget, asyncio_callback): - choices = (*choices, "Custom Sources") + choices = (*choices, "Installed", "Custom Sources") self._asyncio_callback = asyncio_callback self.scale_origin = origin_widget.get_screen_space_center() super().__init__( @@ -1967,7 +1967,7 @@ class PluginManagerWindow(bui.Window): return try: - category_plugins = await self.plugin_manager.categories[category].get_plugins() + category_plugins = await self.plugin_manager.categories[category if category != 'Installed' else 'All'].get_plugins() except (KeyError, AttributeError): raise CategoryDoesNotExist(f"{category} does not exist.") @@ -1990,7 +1990,10 @@ class PluginManagerWindow(bui.Window): self._last_filter_text = search_term self._last_filter_plugins = plugins - plugin_names_to_draw = tuple(self.draw_plugin_name(plugin) for plugin in plugins) + if category == 'Installed': + plugin_names_to_draw = tuple(self.draw_plugin_name(plugin) for plugin in plugins if plugin.is_installed) + else: + plugin_names_to_draw = tuple(self.draw_plugin_name(plugin) for plugin in plugins) for plugin in self._columnwidget.get_children(): plugin.delete() From fd170eb810a4216c54b8030802a26ee8952afe70 Mon Sep 17 00:00:00 2001 From: vishal332008 Date: Mon, 22 Apr 2024 10:31:30 +0000 Subject: [PATCH 4/6] [ci] auto-format --- plugin_manager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin_manager.py b/plugin_manager.py index 8e67fe3..014c890 100644 --- a/plugin_manager.py +++ b/plugin_manager.py @@ -1991,7 +1991,8 @@ class PluginManagerWindow(bui.Window): self._last_filter_plugins = plugins if category == 'Installed': - plugin_names_to_draw = tuple(self.draw_plugin_name(plugin) for plugin in plugins if plugin.is_installed) + plugin_names_to_draw = tuple(self.draw_plugin_name(plugin) + for plugin in plugins if plugin.is_installed) else: plugin_names_to_draw = tuple(self.draw_plugin_name(plugin) for plugin in plugins) From ccaf29a1bb828a9aae212ef3c4de4ecb31a29659 Mon Sep 17 00:00:00 2001 From: vishal332008 Date: Mon, 22 Apr 2024 10:31:31 +0000 Subject: [PATCH 5/6] [ci] apply-version-metadata --- index.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.json b/index.json index c702c78..c5b8ab1 100644 --- a/index.json +++ b/index.json @@ -1,7 +1,12 @@ { "plugin_manager_url": "https://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugin_manager.py", "versions": { - "1.0.15": null, + "1.0.15": { + "api_version": 8, + "commit_sha": "fd170eb", + "released_on": "22-04-2024", + "md5sum": "3666dbb82805bdc4885ebf6b105ebf3b" + }, "1.0.14": { "api_version": 8, "commit_sha": "fc5a7f1", From f4942de9f20deea378d7611e46a38ccc3a098a1f Mon Sep 17 00:00:00 2001 From: Vishal Date: Mon, 22 Apr 2024 16:04:09 +0530 Subject: [PATCH 6/6] Update CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49c5639..54aebec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## Plugin Manager (dd-mm-yyyy) +### 1.0.15 (22-04-2024) + +- Plugins can now be viewed in A-Z and Z-A order. +- Added 'Installed' category to show Installed plugins. + ### 1.0.14 (21-04-2024) - Displaying All Author Names and their Info for plugins.