fix: Fix widget not appearing - store reference and set proper position
ISSUE: Clock and System Monitor widgets were created but not visible. The widgets were being garbage collected because they weren't stored. FIX: 1. Store widget in self._active_widgets list to prevent GC 2. Set parent=self to keep widget alive with overlay 3. Position widget at center of screen (visible location) 4. Call raise_() and activateWindow() to bring to front 5. Added debug output showing widget position WIDGET CREATION NOW: - Creates widget with parent - Positions at center of screen - Shows, raises, activates - Stores reference in list - Prints position for debugging
This commit is contained in:
parent
71a205bc18
commit
3ee405475f
|
|
@ -1736,18 +1736,58 @@ class OverlayWindow(QMainWindow):
|
||||||
"""Add a clock widget to the overlay."""
|
"""Add a clock widget to the overlay."""
|
||||||
try:
|
try:
|
||||||
from core.widget_system import ClockWidget
|
from core.widget_system import ClockWidget
|
||||||
widget = ClockWidget()
|
|
||||||
|
# Create widget with self as parent
|
||||||
|
widget = ClockWidget(parent=self)
|
||||||
|
|
||||||
|
# Position near center of screen
|
||||||
|
screen = QApplication.primaryScreen().geometry()
|
||||||
|
x = (screen.width() - 200) // 2
|
||||||
|
y = (screen.height() - 100) // 2
|
||||||
|
widget.move(x, y)
|
||||||
|
|
||||||
|
# Show and raise
|
||||||
widget.show()
|
widget.show()
|
||||||
print("[Overlay] Clock widget added")
|
widget.raise_()
|
||||||
|
widget.activateWindow()
|
||||||
|
|
||||||
|
# Store reference to prevent garbage collection
|
||||||
|
if not hasattr(self, '_active_widgets'):
|
||||||
|
self._active_widgets = []
|
||||||
|
self._active_widgets.append(widget)
|
||||||
|
|
||||||
|
print(f"[Overlay] Clock widget added at ({x}, {y})")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[Overlay] Error adding clock widget: {e}")
|
print(f"[Overlay] Error adding clock widget: {e}")
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
def _add_system_monitor_widget(self):
|
def _add_system_monitor_widget(self):
|
||||||
"""Add a system monitor widget to the overlay."""
|
"""Add a system monitor widget to the overlay."""
|
||||||
try:
|
try:
|
||||||
from core.widget_system import SystemMonitorWidget
|
from core.widget_system import SystemMonitorWidget
|
||||||
widget = SystemMonitorWidget()
|
|
||||||
|
# Create widget with self as parent
|
||||||
|
widget = SystemMonitorWidget(parent=self)
|
||||||
|
|
||||||
|
# Position below the clock
|
||||||
|
screen = QApplication.primaryScreen().geometry()
|
||||||
|
x = (screen.width() - 200) // 2
|
||||||
|
y = (screen.height() - 100) // 2 + 120
|
||||||
|
widget.move(x, y)
|
||||||
|
|
||||||
|
# Show and raise
|
||||||
widget.show()
|
widget.show()
|
||||||
print("[Overlay] System monitor widget added")
|
widget.raise_()
|
||||||
|
widget.activateWindow()
|
||||||
|
|
||||||
|
# Store reference to prevent garbage collection
|
||||||
|
if not hasattr(self, '_active_widgets'):
|
||||||
|
self._active_widgets = []
|
||||||
|
self._active_widgets.append(widget)
|
||||||
|
|
||||||
|
print(f"[Overlay] System monitor widget added at ({x}, {y})")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[Overlay] Error adding system monitor widget: {e}")
|
print(f"[Overlay] Error adding system monitor widget: {e}")
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue