Added bomb spinner

Thanks to @EraOSBeta
This commit is contained in:
brostos 2025-02-07 14:39:46 +03:00 committed by GitHub
parent d6210689a2
commit 2cf1e83eb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1675,6 +1675,7 @@ class PluginManagerWindow(bui.MainWindow):
self.selected_alphabet_order = 'a_z' self.selected_alphabet_order = 'a_z'
self.alphabet_order_selection_button = None self.alphabet_order_selection_button = None
loop.create_task(self.draw_index()) loop.create_task(self.draw_index())
self._width = (700 if _uiscale is babase.UIScale.SMALL self._width = (700 if _uiscale is babase.UIScale.SMALL
@ -1746,21 +1747,27 @@ class PluginManagerWindow(bui.MainWindow):
parent=self._root_widget, parent=self._root_widget,
position=(-5, loading_pos_y), position=(-5, loading_pos_y),
size=(self._width, 25), size=(self._width, 25),
text="Loading", text="",
color=bui.app.ui_v1.title_color, color=bui.app.ui_v1.title_color,
scale=0.7, scale=0.7,
h_align="center", h_align="center",
v_align="center", v_align="center",
maxwidth=400, maxwidth=400,
) )
self._dot_timer = babase.AppTimer(0.5, self._update_dots, repeat=True) self._loading_spinner = bui.spinnerwidget(
parent=self._root_widget,
position=(self._width * 0.5, loading_pos_y),
style='bomb',
size=48,
)
@contextlib.contextmanager @contextlib.contextmanager
def exception_handler(self): def exception_handler(self):
try: try:
yield yield
except urllib.error.URLError: except urllib.error.URLError:
self._dot_timer = None bui.spinnerwidget(edit=self._loading_spinner, visible=False)
try: try:
bui.textwidget( bui.textwidget(
edit=self._plugin_manager_status_text, edit=self._plugin_manager_status_text,
@ -1773,21 +1780,13 @@ 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:
self._dot_timer = None bui.spinnerwidget(edit=self._loading_spinner, visible=False)
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:
pass pass
raise raise
def _update_dots(self):
try:
text = cast(str, bui.textwidget(query=self._plugin_manager_status_text))
if text.endswith('....'):
text = text[0:len(text)-4]
bui.textwidget(edit=self._plugin_manager_status_text, text=(text + '.'))
except:
pass
async def draw_index(self): async def draw_index(self):
self.draw_search_bar() self.draw_search_bar()
@ -1798,7 +1797,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()
self._dot_timer = None bui.spinnerwidget(edit=self._loading_spinner, visible=False)
try: try:
bui.textwidget(edit=self._plugin_manager_status_text, text="") bui.textwidget(edit=self._plugin_manager_status_text, text="")
except: except:
@ -2115,18 +2114,18 @@ class PluginManagerWindow(bui.MainWindow):
async def refresh(self): async def refresh(self):
self.cleanup() self.cleanup()
try: # try:
bui.textwidget(edit=self._plugin_manager_status_text, text="Refreshing") # bui.textwidget(edit=self._plugin_manager_status_text, text="Refreshing")
except: # except:
pass # pass
if self._dot_timer is None:
self._dot_timer = babase.AppTimer(0.5, self._update_dots, repeat=True) bui.spinnerwidget(edit=self._loading_spinner, visible=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()
self._dot_timer = None bui.spinnerwidget(edit=self._loading_spinner, visible=False)
try: try:
bui.textwidget(edit=self._plugin_manager_status_text, text="") bui.textwidget(edit=self._plugin_manager_status_text, text="")
except: except: