diff --git a/laserstudio/laserstudio.py b/laserstudio/laserstudio.py index dfa15eb..1118ab3 100644 --- a/laserstudio/laserstudio.py +++ b/laserstudio/laserstudio.py @@ -23,7 +23,6 @@ CameraToolbar, MainToolbar, MarkersToolbar, - MarkersListToolbar, PDMToolbar, LaserDriverToolbar, CameraNITToolBar, @@ -86,10 +85,7 @@ def __init__(self, config: Optional[dict]): # Toolbar: Markers toolbar = MarkersToolbar(self.viewer) self.addToolBar(Qt.ToolBarArea.TopToolBarArea, toolbar) - - # Toolbar: Markers' List - toolbar = MarkersListToolbar(self.viewer) - self.addToolBar(Qt.ToolBarArea.LeftToolBarArea, toolbar) + self.addToolBar(Qt.ToolBarArea.RightToolBarArea, toolbar.markers_list_toolbar) # Toolbar: Stage positioning if self.instruments.stage is not None: diff --git a/laserstudio/widgets/toolbars/__init__.py b/laserstudio/widgets/toolbars/__init__.py index 46b7160..c17a6b1 100644 --- a/laserstudio/widgets/toolbars/__init__.py +++ b/laserstudio/widgets/toolbars/__init__.py @@ -4,7 +4,6 @@ from .laserdrivertoolbar import LaserDriverToolbar from .maintoolbar import MainToolbar from .markerstoolbar import MarkersToolbar -from .markerslisttoolbar import MarkersListToolbar from .scantoolbar import ScanToolbar from .picturetoolbar import PictureToolbar from .stagetoolbar import StageToolbar @@ -22,5 +21,4 @@ "LaserDriverToolbar", "PDMToolbar", "MarkersToolbar", - "MarkersListToolbar", ] diff --git a/laserstudio/widgets/toolbars/markerslisttoolbar.py b/laserstudio/widgets/toolbars/markerslisttoolbar.py index 4799fa8..0ea827c 100644 --- a/laserstudio/widgets/toolbars/markerslisttoolbar.py +++ b/laserstudio/widgets/toolbars/markerslisttoolbar.py @@ -20,9 +20,11 @@ def __init__(self, parent: QTreeWidget): def update_checked_state(self): # To prevent the itemChanged signal from being emitted - self.treeWidget().blockSignals(True) + tw = self.treeWidget() + assert tw is not None + tw.blockSignals(True) self.setToolTip(0, f"{self.number_of_checked} shown over {self.childCount()}") - self.treeWidget().blockSignals(False) + tw.blockSignals(False) if self.number_of_checked == 0: self.setCheckState(0, Qt.CheckState.Unchecked) elif self.number_of_checked == self.childCount(): diff --git a/laserstudio/widgets/toolbars/markerstoolbar.py b/laserstudio/widgets/toolbars/markerstoolbar.py index 2638e12..180eabe 100644 --- a/laserstudio/widgets/toolbars/markerstoolbar.py +++ b/laserstudio/widgets/toolbars/markerstoolbar.py @@ -1,6 +1,6 @@ from PyQt6.QtCore import Qt, QSize from PyQt6.QtGui import QIcon -from PyQt6.QtWidgets import QToolBar, QPushButton +from PyQt6.QtWidgets import QToolBar, QPushButton, QMainWindow from ..return_line_edit import ReturnSpinBox from ...utils.util import colored_image from ..viewer import Viewer @@ -30,6 +30,14 @@ def __init__(self, viewer: Viewer): w.clicked.connect(viewer.clear_markers) self.addWidget(w) + # Show list of all markers + w = QPushButton(parent=self) + w.setText("Show list") + w.setToolTip("Show a list of all markers") + w.setCheckable(True) + w.clicked.connect(self.show_markers_list) + self.addWidget(w) + # Markers' size self.marker_size_sp = w = ReturnSpinBox() self.marker_size_sp.setSuffix("\xa0µm") @@ -43,3 +51,13 @@ def __init__(self, viewer: Viewer): lambda: viewer.marker_size(float(self.marker_size_sp.value())) ) self.addWidget(self.marker_size_sp) + + # Toolbar: Markers' List + self.markers_list_toolbar = MarkersListToolbar(viewer) + + def show_markers_list(self, state: bool): + if state: + self.markers_list_toolbar.refresh_list() + self.markers_list_toolbar.show() + else: + self.markers_list_toolbar.hide()