diff --git a/b_asic/GUI/settings.py b/b_asic/GUI/_preferences.py similarity index 60% rename from b_asic/GUI/settings.py rename to b_asic/GUI/_preferences.py index 1dba5546fe7ca1dac331be07ee3cbdf915390be2..bfcbe8043ddc6256a854fd7402e7bb119024faa0 100644 --- a/b_asic/GUI/settings.py +++ b/b_asic/GUI/_preferences.py @@ -1,3 +1,6 @@ +from qtpy.QtCore import Qt +from qtpy.QtGui import QColor + # Buttons/operations/ports MINBUTTONSIZE = 57 PORTHEIGHT = 19 @@ -7,3 +10,6 @@ GAP = MINBUTTONSIZE - 2 * PORTHEIGHT # Window MIN_WIDTH_SCENE = 600 MIN_HEIGHT_SCENE = 520 + +# Interface +LINECOLOR = QColor(Qt.GlobalColor.black) diff --git a/b_asic/GUI/arrow.py b/b_asic/GUI/arrow.py index 2c43d8d06fdc7086aba71eb8e6e2886267a08696..98c7466bafb5dfd87585cf9155da96a04b3f3058 100644 --- a/b_asic/GUI/arrow.py +++ b/b_asic/GUI/arrow.py @@ -2,6 +2,7 @@ from qtpy.QtCore import QLineF, Qt from qtpy.QtGui import QPen from qtpy.QtWidgets import QGraphicsLineItem, QMenu +from b_asic.GUI._preferences import LINECOLOR from b_asic.signal import Signal @@ -79,7 +80,7 @@ class Arrow(QGraphicsLineItem): """ Draw a line connecting self.source with self.destination. Used as callback when moving operations. """ - self.setPen(QPen(Qt.black, 3)) + self.setPen(QPen(LINECOLOR, 3)) self.setLine( QLineF( self.source.operation.x() + self.source.x() + 14, diff --git a/b_asic/GUI/drag_button.py b/b_asic/GUI/drag_button.py index fc37c729f31fc9e325ca9b60858c96628c989312..3b258c621ca0983fbc9e1c83aefac042be147232 100644 --- a/b_asic/GUI/drag_button.py +++ b/b_asic/GUI/drag_button.py @@ -12,7 +12,7 @@ from qtpy.QtWidgets import QAction, QMenu, QPushButton from b_asic.GUI.properties_window import PropertiesWindow from b_asic.GUI.utils import decorate_class, handle_error -from b_asic.GUI.settings import MINBUTTONSIZE +from b_asic.GUI._preferences import MINBUTTONSIZE @decorate_class(handle_error) @@ -68,7 +68,7 @@ class DragButton(QPushButton): self.label = label def mousePressEvent(self, event): - if event.button() == Qt.LeftButton: + if event.button() == Qt.MouseButton.LeftButton: self._m_press = True self._mouse_press_pos = event.pos() self._mouse_move_pos = event.pos() @@ -76,7 +76,7 @@ class DragButton(QPushButton): super().mousePressEvent(event) def mouseMoveEvent(self, event): - if event.buttons() == Qt.LeftButton and self._m_press: + if event.buttons() == Qt.MouseButton.LeftButton and self._m_press: self._m_drag = True self.move(self.mapToParent(event.pos() - self._mouse_press_pos)) if self in self._window.pressed_operations: @@ -123,7 +123,7 @@ class DragButton(QPushButton): self.setIconSize(QSize(MINBUTTONSIZE, MINBUTTONSIZE)) def select_button(self, modifiers=None): - if modifiers != Qt.ControlModifier: + if modifiers != Qt.KeyboardModifier.ControlModifier: for button in self._window.pressed_operations: button._toggle_button(button.pressed) diff --git a/b_asic/GUI/main_window.py b/b_asic/GUI/main_window.py index d618d62e261d62e7ba824298bf88aa8da3341bb5..ac0ecb687f98d310a32c23ea3de22742abb4623d 100644 --- a/b_asic/GUI/main_window.py +++ b/b_asic/GUI/main_window.py @@ -35,7 +35,7 @@ from b_asic.GUI.drag_button import DragButton from b_asic.GUI.gui_interface import Ui_main_window from b_asic.GUI.port_button import PortButton from b_asic.GUI.select_sfg_window import SelectSFGWindow -from b_asic.GUI.settings import ( +from b_asic.GUI._preferences import ( GAP, MINBUTTONSIZE, PORTHEIGHT, @@ -169,7 +169,7 @@ class MainWindow(QMainWindow): super().resizeEvent(event) def wheelEvent(self, event): - if event.modifiers() == Qt.ControlModifier: + if event.modifiers() == Qt.KeyboardModifier.ControlModifier: old_zoom = self.zoom self.zoom += event.angleDelta().y() / 2500 self.graphic_view.scale(self.zoom, self.zoom) @@ -620,7 +620,7 @@ class MainWindow(QMainWindow): self._create_operation_item(item) def keyPressEvent(self, event): - if event.key() == Qt.Key_Delete: + if event.key() == Qt.Key.Key_Delete: for pressed_op in self.pressed_operations: pressed_op.remove() self.move_button_index -= 1 diff --git a/b_asic/GUI/port_button.py b/b_asic/GUI/port_button.py index 5d46cecb154dcf81394edafcd406822e49ee793c..13e2e2187f4e145a4fe8206eb2b0749f9d2d4a6f 100644 --- a/b_asic/GUI/port_button.py +++ b/b_asic/GUI/port_button.py @@ -25,7 +25,7 @@ class PortButton(QPushButton): menu.exec_(self.cursor().pos()) def mousePressEvent(self, event): - if event.button() == Qt.LeftButton: + if event.button() == Qt.MouseButton.LeftButton: self.select_port(event.modifiers()) super().mousePressEvent(event) @@ -40,7 +40,7 @@ class PortButton(QPushButton): ) def select_port(self, modifiers=None): - if modifiers != Qt.ControlModifier: + if modifiers != Qt.KeyboardModifier.ControlModifier: for port in self._window.pressed_ports: port._toggle_port(port.pressed) diff --git a/b_asic/scheduler_gui/_preferences.py b/b_asic/scheduler_gui/_preferences.py index ac6a8c522bd68fa7c926b52a2f8e3745ec430d93..35ec59230d88991b090c065326674805bb90e76f 100644 --- a/b_asic/scheduler_gui/_preferences.py +++ b/b_asic/scheduler_gui/_preferences.py @@ -1,7 +1,7 @@ from qtpy.QtCore import Qt from qtpy.QtGui import QColor -SIGNAL_INACTIVE = QColor(Qt.black) +SIGNAL_INACTIVE = QColor(Qt.GlobalColor.black) SIGNAL_ACTIVE = QColor(0, 207, 181) SIGNAL_WIDTH = 0.03 diff --git a/b_asic/scheduler_gui/graphics_axes_item.py b/b_asic/scheduler_gui/graphics_axes_item.py index 1dc36e330aadf1cb8d2cd3ca1e20301625e5a1d3..e141993e9a9abd49ab8f11da7c64bb358f134f4f 100644 --- a/b_asic/scheduler_gui/graphics_axes_item.py +++ b/b_asic/scheduler_gui/graphics_axes_item.py @@ -87,12 +87,12 @@ class GraphicsAxesItem(QGraphicsItemGroup): self._base_pen = QPen() self._base_pen.setWidthF(2 / self._scale) - self._base_pen.setJoinStyle(Qt.MiterJoin) - self._ledger_pen = QPen(Qt.lightGray) + self._base_pen.setJoinStyle(Qt.PenJoinStyle.MiterJoin) + self._ledger_pen = QPen(Qt.GlobalColor.lightGray) self._ledger_pen.setWidthF(0) # 0 = cosmetic pen 1px width - self._timeline_pen = QPen(Qt.black) + self._timeline_pen = QPen(Qt.GlobalColor.black) self._timeline_pen.setWidthF(2 / self._scale) - self._timeline_pen.setStyle(Qt.DashLine) + self._timeline_pen.setStyle(Qt.PenStyle.DashLine) self._make_base() diff --git a/b_asic/scheduler_gui/graphics_component_item.py b/b_asic/scheduler_gui/graphics_component_item.py index 4feb0929cf76c7c5ecdfd7f92ddad506b5b96a72..fb9193261baa68eed3ac67ea012b3fbabe3358f2 100644 --- a/b_asic/scheduler_gui/graphics_component_item.py +++ b/b_asic/scheduler_gui/graphics_component_item.py @@ -67,10 +67,10 @@ class GraphicsComponentItem(QGraphicsItemGroup): self.setFlag(QGraphicsItem.ItemIsSelectable) # mouse move events # self.setAcceptHoverEvents(True) # mouse hover events self.setAcceptedMouseButtons( - Qt.LeftButton + Qt.MouseButton.LeftButton ) # accepted buttons for movements self.setCursor( - QCursor(Qt.OpenHandCursor) + QCursor(Qt.CursorShape.OpenHandCursor) ) # default cursor when hovering over object self._make_component() @@ -127,11 +127,11 @@ class GraphicsComponentItem(QGraphicsItemGroup): def set_active(self): self._set_background(OPERATION_LATENCY_ACTIVE) - self.setCursor(QCursor(Qt.ClosedHandCursor)) + self.setCursor(QCursor(Qt.CursorShape.ClosedHandCursor)) def set_inactive(self): self._set_background(OPERATION_LATENCY_INACTIVE) - self.setCursor(QCursor(Qt.OpenHandCursor)) + self.setCursor(QCursor(Qt.CursorShape.OpenHandCursor)) def _set_background(self, color: QColor): brush = QBrush(color) @@ -139,15 +139,15 @@ class GraphicsComponentItem(QGraphicsItemGroup): def _make_component(self) -> None: """Makes a new component out of the stored attributes.""" - pen1 = QPen(Qt.black) # used by component outline + pen1 = QPen(Qt.GlobalColor.black) # used by component outline pen1.setWidthF(2 / self._scale) # pen1.setCapStyle(Qt.RoundCap) # Qt.FlatCap, Qt.SquareCap (default), Qt.RoundCap pen1.setJoinStyle( Qt.RoundJoin ) # Qt.MiterJoin, Qt.BevelJoin (default), Qt.RoundJoin, Qt.SvgMiterJoin - brush2 = QBrush(Qt.black) # used by port filling - pen2 = QPen(Qt.black) # used by port outline + brush2 = QBrush(Qt.GlobalColor.black) # used by port filling + pen2 = QPen(Qt.GlobalColor.black) # used by port outline pen2.setWidthF(0) # pen2.setCosmetic(True) port_size = 7 / self._scale # the diameter of a port @@ -213,7 +213,9 @@ class GraphicsComponentItem(QGraphicsItemGroup): # component item self._component_item = QGraphicsPathItem(component_path) self._component_item.setPen(pen1) - self._set_background(Qt.lightGray) # used by component filling + self._set_background( + Qt.GlobalColor.lightGray + ) # used by component filling # ports item for port_dict in self._ports.values(): diff --git a/b_asic/scheduler_gui/graphics_timeline_item.py b/b_asic/scheduler_gui/graphics_timeline_item.py index fe02ce2aa3604accfaf4efd6fe59e32e3c55101c..826122ab22595c9171d7ae62f0f67bb1dacdf057 100644 --- a/b_asic/scheduler_gui/graphics_timeline_item.py +++ b/b_asic/scheduler_gui/graphics_timeline_item.py @@ -54,10 +54,10 @@ class GraphicsTimelineItem(QGraphicsLineItem): self.setFlag(QGraphicsItem.ItemIsMovable) # mouse move events # self.setAcceptHoverEvents(True) # mouse hover events self.setAcceptedMouseButtons( - Qt.LeftButton + Qt.MouseButton.LeftButton ) # accepted buttons for movements self.setCursor( - QCursor(Qt.SizeHorCursor) + QCursor(Qt.CursorShape.SizeHorCursor) ) # default cursor when hovering over object self._delta_time_label = QGraphicsTextItem() diff --git a/b_asic/scheduler_gui/main_window.py b/b_asic/scheduler_gui/main_window.py index 5d24b40ac8c41340f35b577b640e074bc6f1fd27..51492d038a5ca9c48bfa58b38afb03a68db897f7 100644 --- a/b_asic/scheduler_gui/main_window.py +++ b/b_asic/scheduler_gui/main_window.py @@ -534,7 +534,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): def info_table_clear_schedule(self) -> None: """Clears the schedule part of the info table.""" - row = self.info_table.findItems("Operator", Qt.MatchExactly) + row = self.info_table.findItems("Operator", Qt.MatchFlag.MatchExactly) if row: row = row[0].row() if row > 2: @@ -552,7 +552,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): def info_table_clear_component(self) -> None: """Clears the component part of the info table.""" - row = self.info_table.findItems("Operator", Qt.MatchExactly) + row = self.info_table.findItems("Operator", Qt.MatchFlag.MatchExactly) if row: row = row[0].row() for _ in range(self.info_table.rowCount() - row + 1):