few fixes
This commit is contained in:
parent
02752c7e4a
commit
cb32a00ea5
@ -9,27 +9,27 @@ from app.core.main_manager import MainManager, NotificationType
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
class MenuDirection(Enum):
|
||||
HORIZONTAL = 0
|
||||
VERTICAL = 1
|
||||
HORIZONTAL = 0 # Barre en haut ou en bas
|
||||
VERTICAL = 1 # Barre à gauche ou à droite
|
||||
|
||||
class ButtonPosition(Enum):
|
||||
START = 0 # Au début (aligné à gauche/haut)
|
||||
END = 1 # À la fin (aligné à droite/bas)
|
||||
CENTER = 2 # Au centre
|
||||
AFTER = 3 # Après un bouton spécifique
|
||||
START = 0 # Au début (aligné à gauche/haut)
|
||||
END = 1 # À la fin (aligné à droite/bas)
|
||||
CENTER = 2 # Au centre
|
||||
AFTER = 3 # Après un bouton spécifique
|
||||
|
||||
class BorderSide(Enum):
|
||||
LEFT = "left"
|
||||
RIGHT = "right"
|
||||
TOP = "top"
|
||||
BOTTOM = "bottom"
|
||||
LEFT = "left" # Bord gauche
|
||||
RIGHT = "right" # Bord droit
|
||||
TOP = "top" # Bord supérieur
|
||||
BOTTOM = "bottom" # Bord inférieur
|
||||
NONE = None
|
||||
|
||||
class TabSide(Enum):
|
||||
LEFT = 0 # Barre à gauche (pour VERTICAL)
|
||||
RIGHT = 1 # Barre à droite (pour VERTICAL)
|
||||
TOP = 0 # Barre en haut (pour HORIZONTAL)
|
||||
BOTTOM = 1 # Barre en bas (pour HORIZONTAL)
|
||||
LEFT = 0 # Barre à gauche (pour VERTICAL)
|
||||
RIGHT = 1 # Barre à droite (pour VERTICAL)
|
||||
TOP = 0 # Barre en haut (pour HORIZONTAL)
|
||||
BOTTOM = 1 # Barre en bas (pour HORIZONTAL)
|
||||
|
||||
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):
|
||||
@ -53,7 +53,6 @@ class TabsWidget(QWidget):
|
||||
|
||||
# Déterminer le côté de la barre d'onglets
|
||||
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
|
||||
else:
|
||||
self.tab_side = tab_side
|
||||
@ -62,12 +61,13 @@ class TabsWidget(QWidget):
|
||||
self.widgets = []
|
||||
self.button_positions = []
|
||||
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
|
||||
self.start_buttons = []
|
||||
self.center_buttons = []
|
||||
self.end_buttons = []
|
||||
|
||||
# Icon Colors
|
||||
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")
|
||||
@ -151,12 +151,9 @@ class TabsWidget(QWidget):
|
||||
container_widget = QWidget()
|
||||
container_widget.setLayout(widget)
|
||||
container_widget.setContentsMargins(0, 0, 0, 0)
|
||||
self._insert_widget_with_alignment(container_widget, position)
|
||||
return container_widget
|
||||
else:
|
||||
# If it's already a widget, insert it directly
|
||||
self._insert_widget_with_alignment(widget, position)
|
||||
return widget
|
||||
widget = container_widget
|
||||
self._insert_widget_with_alignment(widget, position)
|
||||
return widget
|
||||
|
||||
def add_random_layout(self, layout, position=ButtonPosition.END):
|
||||
"""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):
|
||||
"""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
|
||||
if icon_path:
|
||||
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)
|
||||
self._original_icon_paths.append(None)
|
||||
|
||||
button.setObjectName("menu_button")
|
||||
button.setCheckable(True)
|
||||
|
||||
# Store button size ratio (use provided ratio or default)
|
||||
@ -248,8 +240,6 @@ class TabsWidget(QWidget):
|
||||
self._update_button_size(button)
|
||||
|
||||
# Store reference for resize updates
|
||||
if not hasattr(self, '_square_buttons'):
|
||||
self._square_buttons = []
|
||||
self._square_buttons.append(button)
|
||||
|
||||
def eventFilter(self, obj : QPushButton, event):
|
||||
|
Loading…
x
Reference in New Issue
Block a user