diff --git a/src/simudator/gui/cpu_graphics_scene.py b/src/simudator/gui/cpu_graphics_scene.py index 60a5072200e9cee55cc295990f1ed7204e181cdf..3fd687b550c1f953dbc5974f53f6f27d02f32efb 100644 --- a/src/simudator/gui/cpu_graphics_scene.py +++ b/src/simudator/gui/cpu_graphics_scene.py @@ -132,7 +132,7 @@ class CpuGraphicsScene(QGraphicsScene): item.setVisible(value) @Slot(bool) - def show_port_names(self, value: bool) -> None: + def show_port_labels(self, value: bool) -> None: """ Set the visibility of the names of all ports of graphical modules in the scene. @@ -142,9 +142,8 @@ class CpuGraphicsScene(QGraphicsScene): value : bool ``True`` to show the port names, ``False`` to hide them. """ - for item in self._modules.values(): - for port in item.ports: - port.setNameVisibility(value) + for widget in self._modules.values(): + widget.set_port_label_visibility(value) def toggle_layout_lock(self, value: bool) -> None: """ diff --git a/src/simudator/gui/gui.py b/src/simudator/gui/gui.py index 75885705fb35e823c1c3f032e5fb147fa8d5b922..cb49dabcc800e80ba28cadb85b6810da01142817 100644 --- a/src/simudator/gui/gui.py +++ b/src/simudator/gui/gui.py @@ -96,7 +96,7 @@ class GUI(QMainWindow): self._menu_bar.save_layout.connect(self._graphics_scene.save_layout) self._menu_bar.lock_layout.connect(self._graphics_scene.toggle_layout_lock) self._menu_bar.show_all_signals.connect(self._graphics_scene.show_all_signals) - self._menu_bar.show_port_names.connect(self._graphics_scene.show_port_names) + self._menu_bar.show_port_labels.connect(self._graphics_scene.show_port_labels) # Connect signal for managing breakpoints self._menu_bar.show_breakpoints.connect(self.openBreakpointWindow) diff --git a/src/simudator/gui/menu_bar.py b/src/simudator/gui/menu_bar.py index 29183a9df0ef1db0a99dd035a3407b83e93eead9..9018b643c1c3cdb0b0a6991d53e3dd33a3dea684 100644 --- a/src/simudator/gui/menu_bar.py +++ b/src/simudator/gui/menu_bar.py @@ -67,10 +67,10 @@ class MainMenuBar(QMenuBar): processor signals. """ - show_port_names = pyqtSignal(bool) + show_port_labels = pyqtSignal(bool) """ - QT signal emitted when the user has requested to toggle showing the names - of processor module ports. + QT signal emitted when the user has requested to toggle showing the labels + of signal ports of module widgets. """ update_all_values = pyqtSignal(bool) @@ -138,7 +138,7 @@ class MainMenuBar(QMenuBar): self._port_vis_action = QAction("Show port names", self, checkable=True) self._port_vis_action.setChecked(True) self._port_vis_action.setStatusTip("Toggle the visibility of port names.") - self._port_vis_action.triggered.connect(self.show_port_names) + self._port_vis_action.triggered.connect(self.show_port_labels) # Create Layout menu for layout actions layout_menu = self.addMenu("&Layout") diff --git a/src/simudator/gui/module_graphics_item/module_widget.py b/src/simudator/gui/module_graphics_item/module_widget.py index 37a6e26bb54221fc24a0696c8e21e1257a4cf980..c7ae14b705f02fd917a3c01a79cd6e47d206645d 100644 --- a/src/simudator/gui/module_graphics_item/module_widget.py +++ b/src/simudator/gui/module_graphics_item/module_widget.py @@ -261,6 +261,18 @@ class ModuleWidget(QGraphicsWidget): self.locked.emit(value) + def set_port_label_visibility(self, value: bool) -> None: + """ + Set the visibility of the labels of the ports of this module widget. + + Parameter + --------- + value: bool + Sets the labels as visible if ``True``, invisible if ``False``. + """ + for port in self._port_widgets: + port.set_label_visible(value) + @Slot() def set_format(self, state_var: str, format: Format) -> None: """ diff --git a/src/simudator/gui/port_widget.py b/src/simudator/gui/port_widget.py index d087eb3eba156da3f43b99b3a9f5e300a1d78d2d..d4bdd08df298619f22699be8ca3b5fed62cc2118 100644 --- a/src/simudator/gui/port_widget.py +++ b/src/simudator/gui/port_widget.py @@ -404,9 +404,10 @@ class PortWidget(QGraphicsWidget): Parameter --------- value: bool - Sets the label as visible if value is `True`, `False` otherwise. + Sets the label as visible if ``True``, invisible if ``False``. """ self._label_visible = value + self.update() def orientation(self) -> Orientation: """