0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-14 03:31:50 +02:00

fix(moduar-toolbar): fix cleanup of modular toolbar and dock_area

This commit is contained in:
2025-04-11 18:02:00 +02:00
committed by perl_d
parent ca45268430
commit de76087c7e
6 changed files with 7 additions and 12 deletions

View File

@ -59,7 +59,7 @@ class SidePanel(QWidget):
self.main_layout.setContentsMargins(0, 0, 0, 0) self.main_layout.setContentsMargins(0, 0, 0, 0)
self.main_layout.setSpacing(0) self.main_layout.setSpacing(0)
self.toolbar = ModularToolBar(target_widget=self, orientation="vertical") self.toolbar = ModularToolBar(parent=self, target_widget=self, orientation="vertical")
self.container = QWidget() self.container = QWidget()
self.container.layout = QVBoxLayout(self.container) self.container.layout = QVBoxLayout(self.container)
@ -89,7 +89,7 @@ class SidePanel(QWidget):
self.main_layout.setContentsMargins(0, 0, 0, 0) self.main_layout.setContentsMargins(0, 0, 0, 0)
self.main_layout.setSpacing(0) self.main_layout.setSpacing(0)
self.toolbar = ModularToolBar(target_widget=self, orientation="horizontal") self.toolbar = ModularToolBar(parent=self, target_widget=self, orientation="horizontal")
self.container = QWidget() self.container = QWidget()
self.container.layout = QVBoxLayout(self.container) self.container.layout = QVBoxLayout(self.container)

View File

@ -521,7 +521,7 @@ class ModularToolBar(QToolBar):
orientation: Literal["horizontal", "vertical"] = "horizontal", orientation: Literal["horizontal", "vertical"] = "horizontal",
background_color: str = "rgba(0, 0, 0, 0)", background_color: str = "rgba(0, 0, 0, 0)",
): ):
super().__init__(parent) super().__init__(parent=parent)
self.widgets = defaultdict(dict) self.widgets = defaultdict(dict)
self.background_color = background_color self.background_color = background_color

View File

@ -102,7 +102,7 @@ class BECDockArea(BECWidget, QWidget):
self._instructions_visible = True self._instructions_visible = True
self.dark_mode_button = DarkModeButton(parent=self, parent_id=self.gui_id, toolbar=True) self.dark_mode_button = DarkModeButton(parent=self, parent_id=self.gui_id, toolbar=True)
self.dock_area = DockArea() self.dock_area = DockArea(parent=self)
self.toolbar = ModularToolBar( self.toolbar = ModularToolBar(
parent=self, parent=self,
actions={ actions={
@ -440,12 +440,6 @@ class BECDockArea(BECWidget, QWidget):
Cleanup the dock area. Cleanup the dock area.
""" """
self.delete_all() self.delete_all()
self.toolbar.close()
self.toolbar.deleteLater()
self.dark_mode_button.close()
self.dark_mode_button.deleteLater()
self.dock_area.close()
self.dock_area.deleteLater()
super().cleanup() super().cleanup()
def show(self): def show(self):

View File

@ -101,7 +101,7 @@ class PlotBase(BECWidget, QWidget):
self.plot_item = pg.PlotItem(viewBox=BECViewBox(enableMenu=True)) self.plot_item = pg.PlotItem(viewBox=BECViewBox(enableMenu=True))
self.plot_widget.addItem(self.plot_item) self.plot_widget.addItem(self.plot_item)
self.side_panel = SidePanel(self, orientation="left", panel_max_width=280) self.side_panel = SidePanel(self, orientation="left", panel_max_width=280)
self.toolbar = ModularToolBar(target_widget=self, orientation="horizontal") self.toolbar = ModularToolBar(parent=self, target_widget=self, orientation="horizontal")
self._init_toolbar() self._init_toolbar()
# PlotItem Addons # PlotItem Addons

View File

@ -386,7 +386,7 @@ class CurveTree(BECWidget, QWidget):
def _init_toolbar(self): def _init_toolbar(self):
"""Initialize the toolbar with actions: add, send, refresh, expand, collapse, renormalize.""" """Initialize the toolbar with actions: add, send, refresh, expand, collapse, renormalize."""
self.toolbar = ModularToolBar(target_widget=self, orientation="horizontal") self.toolbar = ModularToolBar(parent=self, target_widget=self, orientation="horizontal")
add = MaterialIconAction( add = MaterialIconAction(
icon_name="add", tooltip="Add new curve", checkable=False, parent=self icon_name="add", tooltip="Add new curve", checkable=False, parent=self
) )

View File

@ -76,6 +76,7 @@ class BECQueue(BECWidget, CompactPopupWidget):
widget_label = QLabel("Live Queue") widget_label = QLabel("Live Queue")
widget_label.setStyleSheet("font-weight: bold;") widget_label.setStyleSheet("font-weight: bold;")
self.toolbar = ModularToolBar( self.toolbar = ModularToolBar(
parent=self,
actions={ actions={
"widget_label": WidgetAction(widget=widget_label), "widget_label": WidgetAction(widget=widget_label),
"separator_1": SeparatorAction(), "separator_1": SeparatorAction(),