DarkMode ist existent yeah
Dieser Commit ist enthalten in:
@ -27,7 +27,6 @@ class MainWindow(QMainWindow):
|
||||
# Signale
|
||||
platform_selected = pyqtSignal(str)
|
||||
back_to_selector_requested = pyqtSignal()
|
||||
theme_toggled = pyqtSignal()
|
||||
|
||||
def __init__(self, theme_manager=None, language_manager=None, db_manager=None):
|
||||
super().__init__()
|
||||
@ -143,32 +142,53 @@ class MainWindow(QMainWindow):
|
||||
self.add_platform_tabs(platform_controller)
|
||||
|
||||
def _create_menus(self):
|
||||
"""Erstellt die Menüeinträge."""
|
||||
"""Erstellt die Menüeinträge und Dark Mode Toggle."""
|
||||
# Erstelle ein Logo-Button anstelle des Text-Menüs
|
||||
logo_widget = QPushButton()
|
||||
logo_widget.setIcon(QIcon(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
|
||||
"resources", "icons", "intelsight-logo.svg")))
|
||||
logo_widget.setIconSize(QSize(120, 40))
|
||||
logo_widget.setFlat(True)
|
||||
logo_widget.setCursor(Qt.PointingHandCursor)
|
||||
logo_widget.setStyleSheet("""
|
||||
QPushButton {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
padding: 5px;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background-color: rgba(0, 0, 0, 0.05);
|
||||
border-radius: 4px;
|
||||
}
|
||||
""")
|
||||
logo_widget.clicked.connect(self._show_about_dialog)
|
||||
self.logo_widget = QPushButton() # Store as instance variable for easier access
|
||||
|
||||
# Add logo to menu bar
|
||||
self.menuBar().setCornerWidget(logo_widget, Qt.TopLeftCorner)
|
||||
# Get the correct logo based on current theme
|
||||
if self.theme_manager:
|
||||
logo_path = self.theme_manager.get_icon_path("intelsight-logo")
|
||||
else:
|
||||
# Fallback if no theme manager
|
||||
logo_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
|
||||
"resources", "icons", "intelsight-logo.svg")
|
||||
|
||||
self.logo_widget.setIcon(QIcon(logo_path))
|
||||
self.logo_widget.setIconSize(QSize(120, 40))
|
||||
self.logo_widget.setFlat(True)
|
||||
self.logo_widget.setCursor(Qt.PointingHandCursor)
|
||||
self.logo_widget.setObjectName("logo_button") # For QSS targeting
|
||||
self.logo_widget.clicked.connect(self._show_about_dialog)
|
||||
|
||||
# Add logo to menu bar (left side)
|
||||
self.menuBar().setCornerWidget(self.logo_widget, Qt.TopLeftCorner)
|
||||
|
||||
# Create container for dark mode toggle (right side)
|
||||
right_container = QWidget()
|
||||
right_container.setObjectName("menubar_right_container") # For QSS targeting
|
||||
right_layout = QHBoxLayout(right_container)
|
||||
right_layout.setContentsMargins(0, 5, 10, 5) # Add some right margin
|
||||
|
||||
# Import and create Dark Mode Toggle
|
||||
from views.widgets.dark_mode_toggle import DarkModeToggle
|
||||
self.dark_mode_toggle = DarkModeToggle(self)
|
||||
|
||||
# Set initial state based on current theme
|
||||
if self.theme_manager:
|
||||
initial_dark = self.theme_manager.is_dark_mode()
|
||||
self.dark_mode_toggle.setChecked(initial_dark)
|
||||
|
||||
# Connect toggle to theme manager
|
||||
self.dark_mode_toggle.toggled.connect(self._on_theme_toggled)
|
||||
|
||||
right_layout.addWidget(self.dark_mode_toggle)
|
||||
|
||||
# Add dark mode toggle to menu bar (right side)
|
||||
self.menuBar().setCornerWidget(right_container, Qt.TopRightCorner)
|
||||
|
||||
# Store reference for language updates
|
||||
self.about_action = logo_widget
|
||||
self.about_action = self.logo_widget
|
||||
|
||||
|
||||
def _show_about_dialog(self):
|
||||
@ -177,6 +197,17 @@ class MainWindow(QMainWindow):
|
||||
dialog.exec_()
|
||||
|
||||
|
||||
def _on_theme_toggled(self, is_dark):
|
||||
"""Handle theme toggle from the dark mode switch."""
|
||||
if self.theme_manager:
|
||||
if is_dark:
|
||||
self.theme_manager.apply_theme(self.theme_manager.DARK_THEME)
|
||||
else:
|
||||
self.theme_manager.apply_theme(self.theme_manager.LIGHT_THEME)
|
||||
|
||||
# Explicitly update logo after theme change
|
||||
self.update_logo()
|
||||
|
||||
def refresh_language_ui(self):
|
||||
"""
|
||||
Aktualisiert alle UI-Texte nach einem Sprachwechsel.
|
||||
@ -238,4 +269,43 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def add_log_widget(self, text_widget):
|
||||
"""Fügt einen GUI-Handler zum Logger hinzu."""
|
||||
add_gui_handler(logger, text_widget)
|
||||
add_gui_handler(logger, text_widget)
|
||||
|
||||
def update_logo(self, theme_name: str = None):
|
||||
"""
|
||||
Updates the logo based on the current theme.
|
||||
|
||||
Args:
|
||||
theme_name: Name of the theme ("light" or "dark") - not used, kept for compatibility
|
||||
"""
|
||||
try:
|
||||
# Use stored reference to logo widget
|
||||
if hasattr(self, 'logo_widget') and self.logo_widget and self.theme_manager:
|
||||
# Get the new logo path from theme manager based on current theme
|
||||
current_theme = self.theme_manager.get_current_theme()
|
||||
logo_path = self.theme_manager.get_icon_path("intelsight-logo")
|
||||
|
||||
print(f"DEBUG: Updating logo for theme '{current_theme}'")
|
||||
print(f"DEBUG: Logo path: {logo_path}")
|
||||
print(f"DEBUG: File exists: {os.path.exists(logo_path)}")
|
||||
|
||||
if os.path.exists(logo_path):
|
||||
icon = QIcon(logo_path)
|
||||
self.logo_widget.setIcon(icon)
|
||||
# Force update
|
||||
self.logo_widget.update()
|
||||
self.logo_widget.repaint()
|
||||
|
||||
logger.info(f"Logo updated to {logo_path} for theme {current_theme}")
|
||||
print(f"DEBUG: Logo icon set successfully")
|
||||
else:
|
||||
logger.warning(f"Logo file not found: {logo_path}")
|
||||
print(f"DEBUG: Logo file not found!")
|
||||
else:
|
||||
print(f"DEBUG: Cannot update logo - missing components:")
|
||||
print(f" - has logo_widget: {hasattr(self, 'logo_widget')}")
|
||||
print(f" - logo_widget exists: {hasattr(self, 'logo_widget') and self.logo_widget}")
|
||||
print(f" - theme_manager exists: {self.theme_manager is not None}")
|
||||
except Exception as e:
|
||||
logger.error(f"Could not update logo: {e}")
|
||||
print(f"DEBUG: Exception updating logo: {e}")
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren