From 6d2b452e6f79e2cf2fb6e2a75442451d3e730b99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20H=C3=A9riveaux?= Date: Wed, 24 Jul 2024 15:07:09 +0200 Subject: [PATCH] Edits --- laserstudio/widgets/toolbars/laserdrivertoolbar.py | 8 +++++++- laserstudio/widgets/toolbars/lasertoolbar.py | 11 ++++++++--- laserstudio/widgets/toolbars/pdmtoolbar.py | 8 +++++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/laserstudio/widgets/toolbars/laserdrivertoolbar.py b/laserstudio/widgets/toolbars/laserdrivertoolbar.py index 997e5c2..1cf9b20 100644 --- a/laserstudio/widgets/toolbars/laserdrivertoolbar.py +++ b/laserstudio/widgets/toolbars/laserdrivertoolbar.py @@ -13,11 +13,17 @@ class LaserDriverToolbar(LaserToolbar): def __init__(self, laser_studio: "LaserStudio", laser_num: int): + """ + :param laser_studio: Main windows of laserstudio. Can be used for interacting with + other elements of the UI. + :param laser_num: Laser equipment index. + """ assert LaserDriverPanel is not None assert laser_num < len(laser_studio.instruments.lasers) self.laser = laser_studio.instruments.lasers[laser_num] assert isinstance(self.laser, LaserDriverInstrument) - super().__init__(f"Laser {laser_num} (Donjon Driver)", "donjon", laser_num) + super().__init__(f"Laser {laser_num} (Donjon Driver)", laser_studio, laser_num) + super().setObjectName(f"toolbox-laser-donjon-{laser_num}") # For settings save and restore self.setAllowedAreas( Qt.ToolBarArea.LeftToolBarArea | Qt.ToolBarArea.RightToolBarArea ) diff --git a/laserstudio/widgets/toolbars/lasertoolbar.py b/laserstudio/widgets/toolbars/lasertoolbar.py index ec03891..83336d4 100644 --- a/laserstudio/widgets/toolbars/lasertoolbar.py +++ b/laserstudio/widgets/toolbars/lasertoolbar.py @@ -1,11 +1,16 @@ from PyQt6.QtWidgets import QToolBar +from typing import TYPE_CHECKING +if TYPE_CHECKING: + from ...laserstudio import LaserStudio class LaserToolbar(QToolBar): - def __init__(self, title: str, laser_model: str, laser_num: int): + def __init__(self, title: str, laser_studio: "LaserStudio", laser_num: int): """ - :param laser_model: Equipment model, such as "pdm". Used for settings save and restore. + :param laser_studio: Main windows of laserstudio. Can be used for interacting with + other elements of the UI. :param laser_num: Laser equipment index. """ super().__init__(title) - super().setObjectName(f"toolbox-laser-{laser_model}-{laser_num}") # For settings save and restore + self.laser_studio = laser_studio + super().setObjectName(f"toolbox-laser-{laser_num}") # For settings save and restore diff --git a/laserstudio/widgets/toolbars/pdmtoolbar.py b/laserstudio/widgets/toolbars/pdmtoolbar.py index 605a833..431def3 100644 --- a/laserstudio/widgets/toolbars/pdmtoolbar.py +++ b/laserstudio/widgets/toolbars/pdmtoolbar.py @@ -21,10 +21,16 @@ class PDMToolbar(LaserToolbar): def __init__(self, laser_studio: "LaserStudio", laser_num: int): + """ + :param laser_studio: Main windows of laserstudio. Can be used for interacting with + other elements of the UI. + :param laser_num: Laser equipment index. + """ assert laser_num < len(laser_studio.instruments.lasers) self.laser = laser_studio.instruments.lasers[laser_num] assert isinstance(self.laser, PDMInstrument) - super().__init__(f"Laser {laser_num} (PDM)", "pdm", laser_num) + super().__init__(f"Laser {laser_num} (PDM)", laser_studio, laser_num) + super().setObjectName(f"toolbox-laser-pdm-{laser_num}") # For settings save and restore self.setAllowedAreas( Qt.ToolBarArea.LeftToolBarArea | Qt.ToolBarArea.RightToolBarArea )