fix: Refresh widgets tab dynamically when switching to it
ISSUE: Widgets tab was built once at startup. If a plugin was installed
after the app started, the widget wouldn't show up until restart.
FIX:
1. Added _refresh_widgets_tab() method that rebuilds the tab content
2. Called _refresh_widgets_tab() when switching to Widgets tab
3. Added debug logging to show registered widgets count
4. Lists all found widgets in console for debugging
Now when you:
1. Install Clock Widget plugin
2. Click on 🎨 Widgets tab
3. The tab refreshes and shows the Clock Widget
The widget appears immediately without needing to restart!
This commit is contained in:
parent
d73020db99
commit
7be9e1d763
|
|
@ -1554,6 +1554,10 @@ class OverlayWindow(QMainWindow):
|
|||
tab_index = {'plugins': 0, 'widgets': 1, 'settings': 2}
|
||||
if tab_id in tab_index:
|
||||
self.tab_stack.setCurrentIndex(tab_index[tab_id])
|
||||
|
||||
# Refresh widgets tab when switching to it
|
||||
if tab_id == 'widgets':
|
||||
self._refresh_widgets_tab()
|
||||
|
||||
def _create_plugins_tab(self) -> QWidget:
|
||||
"""Create the plugins tab content."""
|
||||
|
|
@ -1644,6 +1648,93 @@ class OverlayWindow(QMainWindow):
|
|||
|
||||
return tab
|
||||
|
||||
def _refresh_widgets_tab(self):
|
||||
"""Refresh the widgets tab content dynamically."""
|
||||
# Find the widgets tab and clear/rebuild it
|
||||
if hasattr(self, 'widgets_tab') and self.widgets_tab:
|
||||
# Clear existing layout
|
||||
layout = self.widgets_tab.layout()
|
||||
if layout:
|
||||
# Remove all widgets
|
||||
while layout.count():
|
||||
item = layout.takeAt(0)
|
||||
if item.widget():
|
||||
item.widget().deleteLater()
|
||||
else:
|
||||
# Create new layout
|
||||
from PyQt6.QtWidgets import QVBoxLayout
|
||||
layout = QVBoxLayout(self.widgets_tab)
|
||||
layout.setContentsMargins(24, 24, 24, 24)
|
||||
layout.setSpacing(16)
|
||||
|
||||
c = get_all_colors()
|
||||
|
||||
# Rebuild header
|
||||
header = QLabel("🎨 Widgets")
|
||||
header.setStyleSheet(f"""
|
||||
font-size: 24px;
|
||||
font-weight: {EU_TYPOGRAPHY['weight_bold']};
|
||||
color: {c['text_primary']};
|
||||
""")
|
||||
layout.addWidget(header)
|
||||
|
||||
# Description
|
||||
desc = QLabel("Add overlay widgets to your game. Install plugins to get more widgets.")
|
||||
desc.setStyleSheet(f"color: {c['text_secondary']}; font-size: 12px;")
|
||||
desc.setWordWrap(True)
|
||||
layout.addWidget(desc)
|
||||
|
||||
# Get registered widgets
|
||||
from core.widget_registry import get_widget_registry
|
||||
registry = get_widget_registry()
|
||||
widgets = registry.get_all_widgets()
|
||||
|
||||
print(f"[Overlay] Refreshing widgets tab - found {len(widgets)} widgets")
|
||||
for w in widgets:
|
||||
print(f" - {w.name} (from {w.plugin_id})")
|
||||
|
||||
if widgets:
|
||||
# Available widgets section
|
||||
available_header = QLabel("Available Widgets")
|
||||
available_header.setStyleSheet(f"""
|
||||
color: {c['text_primary']};
|
||||
font-weight: {EU_TYPOGRAPHY['weight_bold']};
|
||||
font-size: 14px;
|
||||
margin-top: 16px;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px solid {c['border_default']};
|
||||
""")
|
||||
layout.addWidget(available_header)
|
||||
|
||||
# Create buttons for each registered widget
|
||||
for widget_info in widgets:
|
||||
widget_btn = self._create_widget_button(
|
||||
f"{widget_info.icon} {widget_info.name}",
|
||||
widget_info.description,
|
||||
lambda wid=widget_info.id: self._add_registered_widget(wid)
|
||||
)
|
||||
layout.addWidget(widget_btn)
|
||||
else:
|
||||
# No widgets available
|
||||
no_widgets = QLabel("No widgets available")
|
||||
no_widgets.setStyleSheet(f"""
|
||||
color: {c['text_muted']};
|
||||
font-size: 14px;
|
||||
font-style: italic;
|
||||
margin-top: 24px;
|
||||
""")
|
||||
no_widgets.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
layout.addWidget(no_widgets)
|
||||
|
||||
# Install info
|
||||
install_info = QLabel("Install plugins from the Plugin Store to add widgets here.")
|
||||
install_info.setStyleSheet(f"color: {c['text_muted']}; font-size: 12px;")
|
||||
install_info.setWordWrap(True)
|
||||
install_info.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
layout.addWidget(install_info)
|
||||
|
||||
layout.addStretch()
|
||||
|
||||
def _create_widget_button(self, name: str, description: str, callback) -> QFrame:
|
||||
"""Create a widget button card."""
|
||||
c = get_all_colors()
|
||||
|
|
|
|||
Loading…
Reference in New Issue