Add files via upload

This commit is contained in:
BroBordd 2025-04-08 18:24:09 +02:00 committed by GitHub
parent 656e59ab0b
commit 4eea3ca298
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -29,7 +29,7 @@ from datetime import datetime
# Modules used for overriding AllSettingsWindow # Modules used for overriding AllSettingsWindow
import logging import logging
PLUGIN_MANAGER_VERSION = "1.1.2" PLUGIN_MANAGER_VERSION = "1.1.1"
REPOSITORY_URL = "https://github.com/bombsquad-community/plugin-manager" REPOSITORY_URL = "https://github.com/bombsquad-community/plugin-manager"
# Current tag can be changed to "staging" or any other branch in # Current tag can be changed to "staging" or any other branch in
# plugin manager repo for testing purpose. # plugin manager repo for testing purpose.
@ -1760,12 +1760,17 @@ class PluginManagerWindow(bui.MainWindow):
size=48, size=48,
) )
def spin(self,show=False):
w = self._loading_spinner
p = self._root_widget
bui.spinnerwidget(w,visible=show) if w.exists() and p.exists() and not p.transitioning_out else None
@contextlib.contextmanager @contextlib.contextmanager
def exception_handler(self): def exception_handler(self):
try: try:
yield yield
except urllib.error.URLError: except urllib.error.URLError:
bui.spinnerwidget(edit=self._loading_spinner, visible=False) self.spin()
try: try:
bui.textwidget( bui.textwidget(
edit=self._plugin_manager_status_text, edit=self._plugin_manager_status_text,
@ -1778,7 +1783,7 @@ class PluginManagerWindow(bui.MainWindow):
# User probably went back before a bui.Window could finish loading. # User probably went back before a bui.Window could finish loading.
pass pass
except Exception as e: except Exception as e:
bui.spinnerwidget(edit=self._loading_spinner, visible=False) self.spin()
try: try:
bui.textwidget(edit=self._plugin_manager_status_text, text=str(e)) bui.textwidget(edit=self._plugin_manager_status_text, text=str(e))
except: except:
@ -1794,7 +1799,7 @@ class PluginManagerWindow(bui.MainWindow):
with self.exception_handler(): with self.exception_handler():
await self.plugin_manager.setup_changelog() await self.plugin_manager.setup_changelog()
await self.plugin_manager.setup_index() await self.plugin_manager.setup_index()
bui.spinnerwidget(edit=self._loading_spinner, visible=False) self.spin()
try: try:
bui.textwidget(edit=self._plugin_manager_status_text, text="") bui.textwidget(edit=self._plugin_manager_status_text, text="")
except: except:
@ -1840,25 +1845,30 @@ class PluginManagerWindow(bui.MainWindow):
textcolor=b_textcolor, textcolor=b_textcolor,
text_scale=0.6) text_scale=0.6)
else: else:
bui.buttonwidget(edit=self.alphabet_order_selection_button, b = self.alphabet_order_selection_button
label=('Z - A' if self.selected_alphabet_order == 'z_a' else 'A - Z') bui.buttonwidget(
) edit=b,
label=('Z - A' if self.selected_alphabet_order == 'z_a' else 'A - Z')
) if b.exists() else None
label = f"Category: {post_label}" label = f"Category: {post_label}"
if self.category_selection_button is None: if self.category_selection_button is None:
self.category_selection_button = b = bui.buttonwidget(parent=self._root_widget, self.category_selection_button = b = bui.buttonwidget(parent=self._root_widget,
position=(category_pos_x, position=(category_pos_x,
category_pos_y), category_pos_y),
size=b_size, size=b_size,
label=label, label=label,
button_type="square", button_type="square",
textcolor=b_textcolor, textcolor=b_textcolor,
text_scale=0.6) text_scale=0.6)
bui.buttonwidget(b, on_activate_call=lambda: self.show_categories_window(source=b)), bui.buttonwidget(b,on_activate_call=lambda: self.show_categories_window(source=b)),
else: else:
self.category_selection_button = bui.buttonwidget(edit=self.category_selection_button, b = self.category_selection_button
label=label) bui.buttonwidget(
edit=b,
label=label
) if b.exists() else None
async def _on_order_button_press(self) -> None: async def _on_order_button_press(self) -> None:
self.selected_alphabet_order = ('a_z' if self.selected_alphabet_order == 'z_a' else 'z_a') self.selected_alphabet_order = ('a_z' if self.selected_alphabet_order == 'z_a' else 'z_a')
@ -1965,19 +1975,22 @@ class PluginManagerWindow(bui.MainWindow):
refresh_pos_y = (180 if _uiscale is babase.UIScale.SMALL else refresh_pos_y = (180 if _uiscale is babase.UIScale.SMALL else
108 if _uiscale is babase.UIScale.MEDIUM else 120) 108 if _uiscale is babase.UIScale.MEDIUM else 120)
controller_button = bui.buttonwidget(parent=self._root_widget, controller_button = bui.buttonwidget(
position=(refresh_pos_x, refresh_pos_y), parent=self._root_widget,
size=(30, 30), position=(refresh_pos_x, refresh_pos_y),
button_type="square", size=(30, 30),
label="", button_type="square",
on_activate_call=lambda: label="",
loop.create_task(self.refresh())) on_activate_call=lambda: loop.create_task(self.refresh())
bui.imagewidget(parent=self._root_widget, )
position=(refresh_pos_x, refresh_pos_y), bui.imagewidget(
size=(30, 30), parent=self._root_widget,
color=(0.8, 0.95, 1), position=(refresh_pos_x, refresh_pos_y),
texture=bui.gettexture("replayIcon"), size=(30, 30),
draw_controller=controller_button) color=(0.8, 0.95, 1),
texture=bui.gettexture("replayIcon"),
draw_controller=controller_button
)
def search_term_filterer(self, plugin, search_term): def search_term_filterer(self, plugin, search_term):
# This helps resolve "plugin name" to "plugin_name". # This helps resolve "plugin name" to "plugin_name".
@ -2033,17 +2046,18 @@ class PluginManagerWindow(bui.MainWindow):
self._last_filter_text = search_term self._last_filter_text = search_term
self._last_filter_plugins = plugins self._last_filter_plugins = plugins
if not self._columnwidget.exists(): return
if category == 'Installed': if category == 'Installed':
plugin_names_to_draw = tuple(self.draw_plugin_name(plugin) plugin_names_to_draw = tuple(
for plugin in plugins if plugin.is_installed) self.draw_plugin_name(plugin) for plugin in plugins if plugin.is_installed
)
else: else:
plugin_names_to_draw = tuple(self.draw_plugin_name(plugin) for plugin in plugins) plugin_names_to_draw = tuple(self.draw_plugin_name(plugin) for plugin in plugins)
for plugin in self._columnwidget.get_children(): [plugin.delete() for plugin in self._columnwidget.get_children()]
plugin.delete()
text_widget = bui.textwidget(parent=self._columnwidget) text_widget = bui.textwidget(parent=self._columnwidget)
text_widget.delete() text_widget.delete()
await asyncio.gather(*plugin_names_to_draw) await asyncio.gather(*plugin_names_to_draw)
async def draw_plugin_name(self, plugin): async def draw_plugin_name(self, plugin):
@ -2069,20 +2083,24 @@ class PluginManagerWindow(bui.MainWindow):
plugin_name_widget_to_update = self.plugins_in_current_view.get(plugin.name) plugin_name_widget_to_update = self.plugins_in_current_view.get(plugin.name)
if plugin_name_widget_to_update: if plugin_name_widget_to_update:
bui.textwidget(edit=plugin_name_widget_to_update, bui.textwidget(
color=color) edit=plugin_name_widget_to_update,
color=color
)
else: else:
text_widget = bui.textwidget(parent=self._columnwidget, text_widget = bui.textwidget(
size=(410, 30), parent=self._columnwidget,
selectable=True, size=(410, 30),
always_highlight=True, selectable=True,
color=color, always_highlight=True,
text=plugin.name.replace('_', ' ').title(), color=color,
click_activate=True, text=plugin.name.replace('_', ' ').title(),
on_activate_call=lambda: self.show_plugin_window(plugin), click_activate=True,
h_align='left', on_activate_call=lambda: self.show_plugin_window(plugin),
v_align='center', h_align='left',
maxwidth=420) v_align='center',
maxwidth=420
)
self.plugins_in_current_view[plugin.name] = text_widget self.plugins_in_current_view[plugin.name] = text_widget
# XXX: This seems nicer. Might wanna use this in future. # XXX: This seems nicer. Might wanna use this in future.
# text_widget.add_delete_callback(lambda: self.plugins_in_current_view.pop(plugin.name)) # text_widget.add_delete_callback(lambda: self.plugins_in_current_view.pop(plugin.name))
@ -2090,7 +2108,7 @@ class PluginManagerWindow(bui.MainWindow):
def show_plugin_window(self, plugin): def show_plugin_window(self, plugin):
PluginWindow(plugin, self._root_widget, lambda: self.draw_plugin_name(plugin)) PluginWindow(plugin, self._root_widget, lambda: self.draw_plugin_name(plugin))
def show_categories_window(self, source): def show_categories_window(self,source):
PluginCategoryWindow( PluginCategoryWindow(
self.plugin_manager.categories.keys(), self.plugin_manager.categories.keys(),
self.selected_category, self.selected_category,
@ -2120,13 +2138,13 @@ class PluginManagerWindow(bui.MainWindow):
# except: # except:
# pass # pass
bui.spinnerwidget(edit=self._loading_spinner, visible=True) self.spin(True)
with self.exception_handler(): with self.exception_handler():
await self.plugin_manager.refresh() await self.plugin_manager.refresh()
await self.plugin_manager.setup_changelog() await self.plugin_manager.setup_changelog()
await self.plugin_manager.setup_index() await self.plugin_manager.setup_index()
bui.spinnerwidget(edit=self._loading_spinner, visible=False) self.spin()
try: try:
bui.textwidget(edit=self._plugin_manager_status_text, text="") bui.textwidget(edit=self._plugin_manager_status_text, text="")
except: except:
@ -2182,13 +2200,13 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
pos -= 20 pos -= 20
self._changelog_button = b = bui.buttonwidget(parent=self._root_widget, self._changelog_button = b = bui.buttonwidget(parent=self._root_widget,
position=((width * 0.2) - button_size[0] / 2 - 5, position=((width * 0.2) - button_size[0] / 2 - 5,
pos), pos),
size=(80, 30), size=(80, 30),
textcolor=b_text_color, textcolor=b_text_color,
button_type='square', button_type='square',
label='') label='')
bui.buttonwidget(b, on_activate_call=lambda: ChangelogWindow(b)) bui.buttonwidget(b,on_activate_call=lambda:ChangelogWindow(b))
bui.textwidget(parent=self._root_widget, bui.textwidget(parent=self._root_widget,
position=((width * 0.2) - button_size[0] / 2, pos), position=((width * 0.2) - button_size[0] / 2, pos),
size=(70, 30), size=(70, 30),