few fixes

This commit is contained in:
Louis Mazin 2025-09-09 18:27:24 +02:00
parent 02752c7e4a
commit cb32a00ea5

View File

@ -9,27 +9,27 @@ from app.core.main_manager import MainManager, NotificationType
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
class MenuDirection(Enum): class MenuDirection(Enum):
HORIZONTAL = 0 HORIZONTAL = 0 # Barre en haut ou en bas
VERTICAL = 1 VERTICAL = 1 # Barre à gauche ou à droite
class ButtonPosition(Enum): class ButtonPosition(Enum):
START = 0 # Au début (aligné à gauche/haut) START = 0 # Au début (aligné à gauche/haut)
END = 1 # À la fin (aligné à droite/bas) END = 1 # À la fin (aligné à droite/bas)
CENTER = 2 # Au centre CENTER = 2 # Au centre
AFTER = 3 # Après un bouton spécifique AFTER = 3 # Après un bouton spécifique
class BorderSide(Enum): class BorderSide(Enum):
LEFT = "left" LEFT = "left" # Bord gauche
RIGHT = "right" RIGHT = "right" # Bord droit
TOP = "top" TOP = "top" # Bord supérieur
BOTTOM = "bottom" BOTTOM = "bottom" # Bord inférieur
NONE = None NONE = None
class TabSide(Enum): class TabSide(Enum):
LEFT = 0 # Barre à gauche (pour VERTICAL) LEFT = 0 # Barre à gauche (pour VERTICAL)
RIGHT = 1 # Barre à droite (pour VERTICAL) RIGHT = 1 # Barre à droite (pour VERTICAL)
TOP = 0 # Barre en haut (pour HORIZONTAL) TOP = 0 # Barre en haut (pour HORIZONTAL)
BOTTOM = 1 # Barre en bas (pour HORIZONTAL) BOTTOM = 1 # Barre en bas (pour HORIZONTAL)
class TabsWidget(QWidget): class TabsWidget(QWidget):
def __init__(self, parent=None, direction=MenuDirection.VERTICAL, menu_width=80, onTabChange=None, spacing=10, button_size_ratio=0.8, border_side=BorderSide.LEFT, tab_side=None): def __init__(self, parent=None, direction=MenuDirection.VERTICAL, menu_width=80, onTabChange=None, spacing=10, button_size_ratio=0.8, border_side=BorderSide.LEFT, tab_side=None):
@ -53,7 +53,6 @@ class TabsWidget(QWidget):
# Déterminer le côté de la barre d'onglets # Déterminer le côté de la barre d'onglets
if tab_side is None: if tab_side is None:
# Valeurs par défaut basées sur la direction
self.tab_side = TabSide.LEFT if direction == MenuDirection.VERTICAL else TabSide.TOP self.tab_side = TabSide.LEFT if direction == MenuDirection.VERTICAL else TabSide.TOP
else: else:
self.tab_side = tab_side self.tab_side = tab_side
@ -63,11 +62,12 @@ class TabsWidget(QWidget):
self.button_positions = [] self.button_positions = []
self.button_size_ratios = [] # Individual ratios for each button self.button_size_ratios = [] # Individual ratios for each button
self._icon_cache = {} self._icon_cache = {}
self._original_icon_paths = []
self._square_buttons = []
# Track alignment zones # Track alignment zones
self.start_buttons = [] self.start_buttons = []
self.center_buttons = [] self.center_buttons = []
self.end_buttons = [] self.end_buttons = []
# Icon Colors # Icon Colors
self.selected_icon_color = self.theme_manager.current_theme.get_color("icon_selected_color") self.selected_icon_color = self.theme_manager.current_theme.get_color("icon_selected_color")
self.unselected_icon_color = self.theme_manager.current_theme.get_color("icon_unselected_color") self.unselected_icon_color = self.theme_manager.current_theme.get_color("icon_unselected_color")
@ -151,12 +151,9 @@ class TabsWidget(QWidget):
container_widget = QWidget() container_widget = QWidget()
container_widget.setLayout(widget) container_widget.setLayout(widget)
container_widget.setContentsMargins(0, 0, 0, 0) container_widget.setContentsMargins(0, 0, 0, 0)
self._insert_widget_with_alignment(container_widget, position) widget = container_widget
return container_widget self._insert_widget_with_alignment(widget, position)
else: return widget
# If it's already a widget, insert it directly
self._insert_widget_with_alignment(widget, position)
return widget
def add_random_layout(self, layout, position=ButtonPosition.END): def add_random_layout(self, layout, position=ButtonPosition.END):
"""Add a layout at the specified position in the button layout""" """Add a layout at the specified position in the button layout"""
@ -189,10 +186,6 @@ class TabsWidget(QWidget):
def add_widget(self, widget, button_text, icon_path=None, position=ButtonPosition.END, after_button_index=None, button_size_ratio=None): def add_widget(self, widget, button_text, icon_path=None, position=ButtonPosition.END, after_button_index=None, button_size_ratio=None):
"""Add a widget with its corresponding button at specified position""" """Add a widget with its corresponding button at specified position"""
# Store original icon path for theme updates
if not hasattr(self, '_original_icon_paths'):
self._original_icon_paths = []
# Create button # Create button
if icon_path: if icon_path:
colored_icon = self.apply_color_to_svg_icon(icon_path, self.unselected_icon_color) colored_icon = self.apply_color_to_svg_icon(icon_path, self.unselected_icon_color)
@ -202,7 +195,6 @@ class TabsWidget(QWidget):
button = QPushButton(button_text) button = QPushButton(button_text)
self._original_icon_paths.append(None) self._original_icon_paths.append(None)
button.setObjectName("menu_button")
button.setCheckable(True) button.setCheckable(True)
# Store button size ratio (use provided ratio or default) # Store button size ratio (use provided ratio or default)
@ -248,8 +240,6 @@ class TabsWidget(QWidget):
self._update_button_size(button) self._update_button_size(button)
# Store reference for resize updates # Store reference for resize updates
if not hasattr(self, '_square_buttons'):
self._square_buttons = []
self._square_buttons.append(button) self._square_buttons.append(button)
def eventFilter(self, obj : QPushButton, event): def eventFilter(self, obj : QPushButton, event):