diff --git a/b_asic/GUI/arrow.py b/b_asic/GUI/arrow.py index e1b66d7573b0437de01a5e8a588989c1911d5757..84d524419b7639edf79fe76c988ae7415be35f54 100644 --- a/b_asic/GUI/arrow.py +++ b/b_asic/GUI/arrow.py @@ -124,7 +124,6 @@ class Arrow(QGraphicsPathItem): ---------- destination : :class:`~b_asic.operation.Operation` The operation to use as destination. - """ self._destination_port_button._operation_button.operation = destination diff --git a/b_asic/GUI/drag_button.py b/b_asic/GUI/drag_button.py index 36d03c0796c3139db13f6a5b15e0abb6f71238d0..dc13b7563c8c2eb99fabc6979f480c84b39eb1b9 100644 --- a/b_asic/GUI/drag_button.py +++ b/b_asic/GUI/drag_button.py @@ -41,6 +41,8 @@ class DragButton(QPushButton): Parent MainWindow. parent : unknown, optional Passed to QPushButton. + *args, **kwargs + Additional arguments are passed to QPushButton. """ connectionRequested = Signal(QPushButton) diff --git a/b_asic/architecture.py b/b_asic/architecture.py index 3ccb1a8dbf6e3a19109f9914fee7fc23d170918e..f55f7d8b08ec2931cc2327c121bdc1302aaf0c9e 100644 --- a/b_asic/architecture.py +++ b/b_asic/architecture.py @@ -53,6 +53,10 @@ class HardwareBlock: entity_name : str, optional The name of the resulting entity. """ + + __slots__ = "_entity_name" + _entity_name: Optional[str] + __slots__ = "_entity_name" _entity_name: Optional[str] @@ -383,7 +387,7 @@ class ProcessingElement(Resource): _color = f"#{''.join(f'{v:0>2X}' for v in PE_COLOR)}" __slots__ = ("_process_collection", "_entity_name") _process_collection: ProcessCollection - _entity_name : Optional[str] + _entity_name: Optional[str] def __init__( self, diff --git a/b_asic/gui_utils/color_button.py b/b_asic/gui_utils/color_button.py index 5f753e9292ccb84c8655ed0982f3cac90eb0f7d8..834d07271576b177ec95efdb5a69a1b1fee77e97 100644 --- a/b_asic/gui_utils/color_button.py +++ b/b_asic/gui_utils/color_button.py @@ -4,7 +4,7 @@ Qt button for use in preference dialogs, selecting color. from qtpy.QtCore import Qt, Signal from qtpy.QtGui import QColor -from qtpy.QtWidgets import QColorDialog, QPushButton +from qtpy.QtWidgets import QPushButton class ColorButton(QPushButton): @@ -26,7 +26,6 @@ class ColorButton(QPushButton): self._color = None self._default = color - self.pressed.connect(self.pick_color) # Set the initial/default state. self.set_color(self._default) @@ -38,24 +37,19 @@ class ColorButton(QPushButton): self._color_changed.emit(color) if self._color: - self.setStyleSheet("background-color: %s;" % self._color) + self.setStyleSheet(f"background-color: {self._color.name()};") else: self.setStyleSheet("") + def set_text_color(self, color: QColor): + """Set text color.""" + self.setStyleSheet(f"color: {color.name()};") + @property def color(self): """Current color.""" return self._color - def pick_color(self): - """Show color-picker dialog to select color.""" - dlg = QColorDialog(self) - if self._color: - dlg.setCurrentColor(self._color) - - if dlg.exec_(): - self.set_color(dlg.currentColor()) - def mousePressEvent(self, e): if e.button() == Qt.RightButton: self.set_color(self._default) diff --git a/b_asic/scheduler_gui/_preferences.py b/b_asic/scheduler_gui/_preferences.py index b0cbcf7004b12f634f2fd8192eaf1c5a189199b1..15daaf995454659ac72f288b0350ad4a1daa5585 100644 --- a/b_asic/scheduler_gui/_preferences.py +++ b/b_asic/scheduler_gui/_preferences.py @@ -1,4 +1,4 @@ -from qtpy.QtGui import QColor +from qtpy.QtGui import QColor, QFont from b_asic._preferences import EXECUTION_TIME_COLOR, LATENCY_COLOR, SIGNAL_COLOR @@ -18,3 +18,67 @@ OPERATION_HEIGHT = 0.75 OPERATION_GAP = 1 - OPERATION_HEIGHT # TODO: For now, should really fix the bug SCHEDULE_INDENT = 0.2 +DEFAULT_FONT = QFont("Times", 12) +DEFAULT_FONT_COLOR = QColor(*SIGNAL_COLOR) + + +class ColorDataType: + def __init__( + self, + DEFAULT: QColor, + current_color: QColor = SIGNAL_INACTIVE, + changed: bool = False, + name: str = '', + ): + self.current_color = current_color + self.DEFAULT = DEFAULT + self.changed = changed + self.name = name + + +Latency_Color = ColorDataType( + current_color=OPERATION_LATENCY_INACTIVE, + DEFAULT=OPERATION_LATENCY_INACTIVE, + name='Latency Color', +) +Execution_Time_Color = ColorDataType( + current_color=OPERATION_EXECUTION_TIME_ACTIVE, + DEFAULT=OPERATION_EXECUTION_TIME_ACTIVE, + name='Execution Time Color', +) +Signal_Warning_Color = ColorDataType( + current_color=SIGNAL_WARNING, DEFAULT=SIGNAL_WARNING, name='Warning Color' +) +Signal_Color = ColorDataType( + current_color=SIGNAL_INACTIVE, DEFAULT=SIGNAL_INACTIVE, name='Signal Color' +) +Active_Color = ColorDataType( + current_color=SIGNAL_ACTIVE, DEFAULT=SIGNAL_ACTIVE, name='Active Color' +) + + +class FontDataType: + def __init__( + self, + current_font: QFont, + DEFAULT: QFont = DEFAULT_FONT, + DEFAULT_COLOR: QColor = DEFAULT_FONT_COLOR, + color: QColor = DEFAULT_FONT_COLOR, + size: int = 12, + italic: bool = False, + bold: bool = False, + changed: bool = False, + ): + self.current_font = current_font + self.DEFAULT = DEFAULT + self.DEFAULT_COLOR = DEFAULT_COLOR + self.size = size + self.color = color + self.italic = italic + self.bold = bold + self.changed = changed + + +Font = FontDataType( + current_font=DEFAULT_FONT, DEFAULT=DEFAULT_FONT, DEFAULT_COLOR=DEFAULT_FONT_COLOR +) diff --git a/b_asic/scheduler_gui/main_window.py b/b_asic/scheduler_gui/main_window.py index 7a0c41147385419af5af61a34ee7ef9f333b68fc..bd03b5f2039b0dd98bb01827d0662370dfad6875 100644 --- a/b_asic/scheduler_gui/main_window.py +++ b/b_asic/scheduler_gui/main_window.py @@ -14,10 +14,11 @@ import webbrowser from collections import defaultdict, deque from copy import deepcopy from importlib.machinery import SourceFileLoader -from typing import TYPE_CHECKING, Deque, List, Optional, cast, overload +from typing import TYPE_CHECKING, Deque, Dict, List, Optional, cast, overload # Qt/qtpy import qtpy +import qtpy.QtCore # QGraphics and QPainter imports from qtpy.QtCore import ( @@ -30,19 +31,28 @@ from qtpy.QtCore import ( Qt, Slot, ) -from qtpy.QtGui import QCloseEvent +from qtpy.QtGui import QCloseEvent, QColor, QFont, QIcon, QIntValidator from qtpy.QtWidgets import ( QAbstractButton, QAction, QApplication, QCheckBox, + QColorDialog, + QDialog, + QDialogButtonBox, QFileDialog, + QFontDialog, QGraphicsItemGroup, QGraphicsScene, + QGroupBox, + QHBoxLayout, QInputDialog, + QLabel, + QLineEdit, QMainWindow, QMessageBox, QTableWidgetItem, + QVBoxLayout, ) # B-ASIC @@ -50,9 +60,19 @@ import b_asic.scheduler_gui.logger as logger from b_asic._version import __version__ from b_asic.graph_component import GraphComponent, GraphID from b_asic.gui_utils.about_window import AboutWindow +from b_asic.gui_utils.color_button import ColorButton from b_asic.gui_utils.icons import get_icon from b_asic.gui_utils.mpl_window import MPLWindow from b_asic.schedule import Schedule +from b_asic.scheduler_gui._preferences import ( + Active_Color, + ColorDataType, + Execution_Time_Color, + Font, + Latency_Color, + Signal_Color, + Signal_Warning_Color, +) from b_asic.scheduler_gui.axes_item import AxesItem from b_asic.scheduler_gui.operation_item import OperationItem from b_asic.scheduler_gui.scheduler_item import SchedulerItem @@ -106,6 +126,8 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): _splitter_pos: int _splitter_min: int _zoom: float + _color_per_type: Dict[str, QColor] = dict() + converted_colorPerType: Dict[str, str] = dict() def __init__(self): """Initialize Scheduler-GUI.""" @@ -125,6 +147,8 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): self._execution_time_for_variables = None self._execution_time_plot_dialogs = defaultdict(lambda: None) self._ports_accesses_for_storage = None + self._color_changed_perType = False + self.changed_operation_colors: Dict[str, QColor] = dict() # Recent files self._max_recent_files = 4 @@ -148,6 +172,7 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): self.menu_save.setIcon(get_icon('save')) self.menu_save_as.triggered.connect(self.save_as) self.menu_save_as.setIcon(get_icon('save-as')) + self.actionPreferences.triggered.connect(self.Preferences_Dialog_clicked) self.menu_quit.triggered.connect(self.close) self.menu_quit.setIcon(get_icon('quit')) self.menu_node_info.triggered.connect(self.show_info_table) @@ -426,6 +451,7 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): self.action_view_variables.setEnabled(False) self.action_view_port_accesses.setEnabled(False) self.menu_view_execution_times.setEnabled(False) + self.actionPreferences.setEnabled(False) @Slot() def save(self) -> None: @@ -678,6 +704,8 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): self._graph._signals.execution_time_plot.connect(self._execution_time_plot) self.info_table_fill_schedule(self._schedule) self._update_operation_types() + self.actionPreferences.setEnabled(True) + self.load_preferences() self.action_view_variables.setEnabled(True) self.action_view_port_accesses.setEnabled(True) self.update_statusbar(self.tr("Schedule loaded successfully")) @@ -713,6 +741,31 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): settings.setValue("scheduler/splitter/state", self.splitter.saveState()) settings.setValue("scheduler/splitter/pos", self.splitter.sizes()[1]) + settings.beginGroup("scheduler/preferences") + settings.setValue("font", Font.current_font.toString()) + settings.setValue("fontSize", Font.size) + settings.setValue("fontColor", Font.color) + settings.setValue("fontBold", Font.current_font.bold()) + settings.setValue("fontItalic", Font.current_font.italic()) + settings.setValue("fontChanged", Font.changed) + + settings.setValue(Signal_Color.name, Signal_Color.current_color.name()) + settings.setValue(Active_Color.name, Active_Color.current_color.name()) + settings.setValue( + Signal_Warning_Color.name, Signal_Warning_Color.current_color.name() + ) + settings.setValue( + Execution_Time_Color.name, Execution_Time_Color.current_color.name() + ) + + settings.setValue(f"{Signal_Color.name}_changed", Signal_Color.changed) + settings.setValue(f"{Active_Color.name}_changed", Active_Color.changed) + settings.setValue( + f"{Signal_Warning_Color.name}_changed", Signal_Warning_Color.changed + ) + self.Save_colortype() + settings.sync() + if settings.isWritable(): log.debug(f"Settings written to '{settings.fileName()}'.") else: @@ -738,6 +791,78 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): settings.value("scheduler/hide_exit_dialog", False, bool) ) + settings.beginGroup("scheduler/preferences") + Font.current_font = QFont( + settings.value("font", defaultValue=Font.DEFAULT.toString(), type=str) + ) + Font.size = settings.value( + "fontSize", defaultValue=Font.DEFAULT.pointSizeF(), type=int + ) + Font.color = QColor( + settings.value("fontColor", defaultValue=Font.DEFAULT_COLOR, type=str) + ) + Font.bold = settings.value( + "fontBold", defaultValue=Font.DEFAULT.bold(), type=bool + ) + Font.italic = settings.value( + "fontItalic", defaultValue=Font.DEFAULT.italic(), type=bool + ) + Font.changed = settings.value("fontChanged", Font.changed, bool) + + Signal_Color.current_color = QColor( + settings.value( + "Signal Color", defaultValue=Signal_Color.DEFAULT.name(), type=str + ) + ) + Active_Color.current_color = QColor( + settings.value( + "Active Color", defaultValue=Active_Color.DEFAULT.name(), type=str + ) + ) + Signal_Warning_Color.current_color = QColor( + settings.value( + "Warning Color", + defaultValue=Signal_Warning_Color.DEFAULT.name(), + type=str, + ) + ) + Latency_Color.current_color = QColor( + settings.value( + "Latency Color", defaultValue=Latency_Color.DEFAULT.name(), type=str + ) + ) + Execution_Time_Color.current_color = QColor( + settings.value( + "Execution Time Color", + defaultValue=Execution_Time_Color.DEFAULT.name(), + type=str, + ) + ) + Signal_Color.changed = settings.value( + f"{Signal_Color.name}_changed", False, bool + ) + Active_Color.changed = settings.value( + f"{Active_Color.name}_changed", False, bool + ) + Signal_Warning_Color.changed = settings.value( + f"{Signal_Warning_Color.name}_changed", + False, + bool, + ) + Latency_Color.changed = settings.value( + f"{Latency_Color.name}_changed", False, bool + ) + Execution_Time_Color.changed = settings.value( + f"{Execution_Time_Color.name}_changed", + False, + bool, + ) + self._color_changed_perType = settings.value( + "_color_changed_perType", False, bool + ) + + settings.endGroup() + settings.sync() log.debug(f"Settings read from '{settings.fileName()}'.") def info_table_fill_schedule(self, schedule: Schedule) -> None: @@ -859,6 +984,536 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): ) self.menu_view_execution_times.addAction(type_action) + def Preferences_Dialog_clicked(self): + """Open the Preferences dialog to customize fonts, colors, and settings""" + dialog = QDialog() + dialog.setWindowTitle("Preferences") + layout = QVBoxLayout() + layout.setSpacing(15) + + # Add label for the dialog + label = QLabel("Personalize Your Fonts and Colors") + layout.addWidget(label) + + groupbox = QGroupBox() + Hlayout = QHBoxLayout() + label = QLabel("Color Settings:") + layout.addWidget(label) + Hlayout.setSpacing(20) + + Hlayout.addWidget(self.creat_color_button(Execution_Time_Color)) + Hlayout.addWidget(self.creat_color_button(Latency_Color)) + Hlayout.addWidget( + self.creat_color_button( + ColorDataType( + current_color=Latency_Color.DEFAULT, + DEFAULT=QColor('skyblue'), + name="Latency Color per Type", + ) + ) + ) + + groupbox.setLayout(Hlayout) + layout.addWidget(groupbox) + + label = QLabel("Signal Colors:") + layout.addWidget(label) + groupbox = QGroupBox() + Hlayout = QHBoxLayout() + Hlayout.setSpacing(20) + + Signal_button = self.creat_color_button(Signal_Color) + Signal_button.setStyleSheet( + f"color: {QColor(255,255,255,0).name()}; background-color: {Signal_Color.DEFAULT.name()}" + ) + + Hlayout.addWidget(Signal_button) + Hlayout.addWidget(self.creat_color_button(Signal_Warning_Color)) + Hlayout.addWidget(self.creat_color_button(Active_Color)) + + groupbox.setLayout(Hlayout) + layout.addWidget(groupbox) + + Reset_Color_button = ColorButton(QColor('silver')) + Reset_Color_button.setText('Reset All Color settings') + Reset_Color_button.pressed.connect(self.reset_color_clicked) + layout.addWidget(Reset_Color_button) + + label = QLabel("Font Settings:") + layout.addWidget(label) + + groupbox = QGroupBox() + Hlayout = QHBoxLayout() + Hlayout.setSpacing(10) + + Font_button = ColorButton(QColor('moccasin')) + Font_button.setText('Font Settings') + Hlayout.addWidget(Font_button) + + Font_color_button = ColorButton(QColor('moccasin')) + Font_color_button.setText('Font Color') + Font_color_button.pressed.connect(self.font_color_clicked) + Hlayout.addWidget(Font_color_button) + + groupbox2 = QGroupBox() + Hlayout2 = QHBoxLayout() + + icon = QIcon.fromTheme("format-text-italic") + Italicbutton = ( + ColorButton(QColor('silver')) + if Font.italic + else ColorButton(QColor('snow')) + ) + Italicbutton.setIcon(icon) + Italicbutton.pressed.connect(lambda: self.Italic_font_clicked(Italicbutton)) + Hlayout2.addWidget(Italicbutton) + + icon = QIcon.fromTheme("format-text-bold") + Boldbutton = ( + ColorButton(QColor('silver')) if Font.bold else ColorButton(QColor('snow')) + ) + Boldbutton.setIcon(icon) + Boldbutton.pressed.connect(lambda: self.Bold_font_clicked(Boldbutton)) + Hlayout2.addWidget(Boldbutton) + + groupbox2.setLayout(Hlayout2) + Hlayout.addWidget(groupbox2) + + groupbox2 = QGroupBox() + Hlayout2 = QHBoxLayout() + Font_Size_input = QLineEdit() + Font_button.pressed.connect( + lambda: self.font_clicked(Font_Size_input, Italicbutton, Boldbutton) + ) + + icon = QIcon.fromTheme("list-add") + Incr_button = ColorButton(QColor('smoke')) + Incr_button.setIcon(icon) + Incr_button.pressed.connect(lambda: self.Incr_font_clicked(Font_Size_input)) + Incr_button.setShortcut(QCoreApplication.translate("MainWindow", "Ctrl++")) + Hlayout2.addWidget(Incr_button) + + Font_Size_input.setPlaceholderText('Font Size') + Font_Size_input.setText(f'Font Size: {Font.size}') + Font_Size_input.setValidator(QIntValidator(0, 99)) + Font_Size_input.setAlignment(Qt.AlignCenter) + Font_Size_input.textChanged.connect( + lambda: self.set_fontSize_clicked(Font_Size_input.text()) + ) + Font_Size_input.textChanged.connect( + lambda: self.set_fontSize_clicked(Font_Size_input.text()) + ) + Hlayout2.addWidget(Font_Size_input) + + icon = QIcon.fromTheme("list-remove") + Decr_button = ColorButton(QColor('smoke')) + Decr_button.setIcon(icon) + Decr_button.pressed.connect(lambda: self.Decr_font_clicked(Font_Size_input)) + Decr_button.setShortcut(QCoreApplication.translate("MainWindow", "Ctrl+-")) + + Hlayout2.addWidget(Decr_button) + + groupbox2.setLayout(Hlayout2) + Hlayout.addWidget(groupbox2) + + groupbox.setLayout(Hlayout) + layout.addWidget(groupbox) + + Reset_Font_button = ColorButton(QColor('silver')) + Reset_Font_button.setText('Reset All Font Settings') + Reset_Font_button.pressed.connect( + lambda: self.reset_font_clicked(Font_Size_input, Italicbutton, Boldbutton) + ) + layout.addWidget(Reset_Font_button) + + label = QLabel("") + layout.addWidget(label) + + Reset_button = ColorButton(QColor('salmon')) + Reset_button.setText('Reset All Settings') + Reset_button.pressed.connect( + lambda: self.reset_all_clicked(Font_Size_input, Italicbutton, Boldbutton) + ) + layout.addWidget(Reset_button) + + dialog.setLayout(layout) + buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Close) + buttonBox.ButtonLayout(QDialogButtonBox.MacLayout) + buttonBox.accepted.connect(dialog.accept) + buttonBox.rejected.connect(dialog.close) + layout.addWidget(buttonBox) + + dialog.exec_() + + def creat_color_button(self, color: ColorDataType) -> ColorButton: + """Create a colored button to be used to modify a certain color + color_type: ColorDataType + The color_type assigned to the butten to be created. + """ + button = ColorButton(color.DEFAULT) + button.setText(color.name) + if color.name == "Latency Color": + button.pressed.connect( + lambda: self.set_latency_color_by_type_name(all=True) + ) + elif color.name == "Latency Color per Type": + button.pressed.connect( + lambda: self.set_latency_color_by_type_name(all=False) + ) + else: + button.pressed.connect(lambda: self.Color_button_clicked(color)) + return button + + def set_latency_color_by_type_name(self, all: bool): + """Set latency color based on operation type names + all: bool + Indicates if the color of all type names to be modified. + """ + if Latency_Color.changed: + current_color = Latency_Color.current_color + else: + current_color = Latency_Color.DEFAULT + + # Prompt user to select operation type if not setting color for all types + if not all: + used_types = self._schedule.get_used_type_names() + type, ok = QInputDialog.getItem( + self, "Select Operation Type", "Type", used_types, editable=False + ) + else: + type = "all operations" + ok = False + + # Open a color dialog to get the selected color + if all or ok: + color = QColorDialog.getColor( + current_color, self, f"Select the color of {type}" + ) + + # If a valid color is selected, update color settings and graph + if color.isValid(): + if all: + Latency_Color.changed = True + self._color_changed_perType = False + self.changed_operation_colors.clear() + Latency_Color.current_color = color + # Save color settings for each operation type + else: + self._color_changed_perType = True + self.changed_operation_colors[type] = color + self.color_pref_update() + self.update_statusbar("Preferences Updated") + + def color_pref_update(self): + """Update preferences of Latency color per type""" + for type in self._schedule.get_used_type_names(): + if Latency_Color.changed and not self._color_changed_perType: + self._color_per_type[type] = Latency_Color.current_color + elif not Latency_Color.changed and not self._color_changed_perType: + self._color_per_type[type] = Latency_Color.DEFAULT + elif not Latency_Color.changed and self._color_changed_perType: + if type in self.changed_operation_colors.keys(): + self._color_per_type[type] = self.changed_operation_colors[type] + else: + self._color_per_type[type] = Latency_Color.DEFAULT + else: + if type in self.changed_operation_colors.keys(): + self._color_per_type[type] = self.changed_operation_colors[type] + else: + self._color_per_type[type] = Latency_Color.current_color + self.Save_colortype() + + def Save_colortype(self): + """Save preferences of Latency color per type in settings""" + settings = QSettings() + for key, color in self._color_per_type.items(): + self._graph._color_change(color, key) + self.converted_colorPerType[key] = color.name() + settings.setValue( + f"scheduler/preferences/{Latency_Color.name}", + Latency_Color.current_color, + ) + settings.setValue( + f"scheduler/preferences/{Latency_Color.name}_changed", Latency_Color.changed + ) + settings.setValue( + f"scheduler/preferences/{Latency_Color.name}/perType", + self.converted_colorPerType, + ) + settings.setValue( + f"scheduler/preferences/{Latency_Color.name}/perType_changed", + self._color_changed_perType, + ) + + def Color_button_clicked(self, color_type: ColorDataType): + """Open a color dialog to select a color based on the specified color type + color_type: ColorDataType + The color_type to be changed. + """ + settings = QSettings() + if color_type.changed: + current_color = color_type.current_color + else: + current_color = color_type.DEFAULT + + color = QColorDialog.getColor(current_color, self, f"Select {color_type.name}") + # If a valid color is selected, update the current color and settings + if color.isValid(): + color_type.current_color = color + # colorbutton.set_color(color) + color_type.changed = ( + False if color_type.current_color == color_type.DEFAULT else True + ) + settings.setValue(f"scheduler/preferences/{color_type.name}", color.name()) + settings.sync() + + self._graph._signals.reopen.emit() + self.update_statusbar("Preferences Updated") + + def font_clicked( + self, Sizeline: QLineEdit, italicbutton: ColorButton, boldbutton: ColorButton + ): + """Open a font dialog to select a font and update the current font + Sizeline: QLineEdit + The line displaying the text size to be matched with the chosen font. + italicbutton: ColorButton + The button displaying the italic state to be matched with the chosen font. + boldbutton: ColorButton + The button displaying the bold state to be matched with the chosen font. + """ + if Font.changed: + current_font = Font.current_font + else: + current_font = Font.DEFAULT + + (ok, font) = QFontDialog.getFont(current_font, self) + if ok: + Font.current_font = font + Font.size = int(font.pointSizeF()) + Font.bold = font.bold() + Font.italic = font.italic() + self.Update_font() + self.Match_Dialog_Font(Sizeline, italicbutton, boldbutton) + self.update_statusbar("Preferences Updated") + + def Update_font(self): + """Update font preferences based on current Font settings""" + settings = QSettings() + Font.changed = ( + False + if ( + Font.current_font == Font.DEFAULT + and Font.size == int(Font.DEFAULT.pointSizeF()) + and Font.italic == Font.DEFAULT.italic() + and Font.bold == Font.DEFAULT.bold() + ) + else True + ) + settings.setValue("scheduler/preferences/font", Font.current_font.toString()) + settings.setValue("scheduler/preferences/fontSize", Font.size) + settings.setValue("scheduler/preferences/fontBold", Font.bold) + settings.setValue("scheduler/preferences/fontItalic", Font.italic) + settings.sync() + self.load_preferences() + + def load_preferences(self): + "Load the last saved preferences from settings" + settings = QSettings() + Latency_Color.current_color = QColor( + settings.value( + f"scheduler/preferences/{Latency_Color.name}", + defaultValue=Latency_Color.DEFAULT, + type=str, + ) + ) + Latency_Color.changed = settings.value( + f"scheduler/preferences/{Latency_Color.name}_changed", False, bool + ) + self.converted_colorPerType = settings.value( + f"scheduler/preferences/{Latency_Color.name}/perType", + self.converted_colorPerType, + ) + self._color_changed_perType = settings.value( + f"scheduler/preferences/{Latency_Color.name}/perType_changed", False, bool + ) + settings.sync() + + for key, color_str in self.converted_colorPerType.items(): + color = QColor(color_str) + self._color_per_type[key] = color + Match = ( + (color == Latency_Color.current_color) + if Latency_Color.changed + else (color == Latency_Color.DEFAULT) + ) + if self._color_changed_perType and not Match: + self.changed_operation_colors[key] = color + self.color_pref_update() + + if Font.changed: + Font.current_font.setPointSizeF(Font.size) + Font.current_font.setItalic(Font.italic) + Font.current_font.setBold(Font.bold) + self._graph._font_change(Font.current_font) + self._graph._font_color_change(Font.color) + else: + self._graph._font_change(Font.DEFAULT) + self._graph._font_color_change(Font.DEFAULT_COLOR) + + self.update_statusbar("Saved Preferences Loaded") + + def font_color_clicked(self): + """Select a font color and update preferences""" + settings = QSettings() + color = QColorDialog.getColor(Font.color, self, "Select Font Color") + if color.isValid(): + Font.color = color + Font.changed = True + settings.setValue("scheduler/preferences/fontColor", Font.color.name()) + settings.sync() + self._graph._font_color_change(Font.color) + + def set_fontSize_clicked(self, size): + """Set the font size to the specified size and update the font + size + The font size to be set. + """ + Font.size = int(size) if (not size == "") else 6 + Font.current_font.setPointSizeF(Font.size) + self.Update_font() + + def Italic_font_clicked(self, button: ColorButton): + """Toggle the font style to italic if not already italic, otherwise remove italic + button: ColorButton + The clicked button. Used to indicate state on/off. + """ + Font.italic = not Font.italic + Font.current_font.setItalic(Font.italic) + ( + button.set_color(QColor('silver')) + if Font.italic + else button.set_color(QColor('snow')) + ) + self.Update_font() + + def Bold_font_clicked(self, button: ColorButton): + """Toggle the font style to bold if not already bold, otherwise unbold + button: ColorButton + The clicked button. Used to indicate state on/off. + """ + Font.bold = not Font.bold + Font.current_font.setBold(Font.bold) + Font.current_font.setWeight(50) + ( + button.set_color(QColor('silver')) + if Font.bold + else button.set_color(QColor('snow')) + ) + self.Update_font() + + def Incr_font_clicked(self, line: QLineEdit): + """ + Increase the font size by 1. + line: QLineEdit + The line displaying the text size to be matched. + """ + ( + line.setText(str(Font.size + 1)) + if Font.size <= 71 + else line.setText(str(Font.size)) + ) + + def Decr_font_clicked(self, line: QLineEdit): + """ + Decrease the font size by 1. + line: QLineEdit + The line displaying the text size to be matched. + """ + ( + line.setText(str(Font.size - 1)) + if Font.size >= 7 + else line.setText(str(Font.size)) + ) + + def reset_color_clicked(self): + """Reset the color settings""" + settings = QSettings() + Latency_Color.changed = False + Active_Color.changed = False + Signal_Warning_Color.changed = False + Signal_Color.changed = False + Execution_Time_Color.changed = False + self._color_changed_perType = False + self.color_pref_update() + + settings.beginGroup("scheduler/preferences") + settings.setValue(Latency_Color.name, Latency_Color.DEFAULT.name()) + settings.setValue(Signal_Color.name, Signal_Color.DEFAULT.name()) + settings.setValue(Active_Color.name, Active_Color.DEFAULT.name()) + settings.setValue( + Signal_Warning_Color.name, Signal_Warning_Color.DEFAULT.name() + ) + settings.setValue( + Execution_Time_Color.name, Execution_Time_Color.DEFAULT.name() + ) + settings.endGroup() + + self._graph._color_change(Latency_Color.DEFAULT, "all operations") + self._graph._signals.reopen.emit() + self.load_preferences() + + def reset_font_clicked( + self, Sizeline: QLineEdit, italicbutton: ColorButton, boldbutton: ColorButton + ): + """Reset the font settings. + Sizeline: QLineEdit + The line displaying the text size to be matched with the chosen font. + italicbutton: ColorButton + The button displaying the italic state to be matched with the chosen font. + boldbutton: ColorButton + The button displaying the bold state to be matched with the chosen font. + """ + Font.current_font = QFont("Times", 12) + Font.changed = False + Font.color = Font.DEFAULT_COLOR + Font.size = int(Font.DEFAULT.pointSizeF()) + Font.bold = Font.DEFAULT.bold() + Font.italic = Font.DEFAULT.italic() + self.Update_font() + self.load_preferences() + self.Match_Dialog_Font(Sizeline, italicbutton, boldbutton) + + def reset_all_clicked( + self, Sizeline: QLineEdit, italicbutton: ColorButton, boldbutton: ColorButton + ): + """Reset both the color and the font settings""" + self.reset_color_clicked() + self.reset_font_clicked(Sizeline, italicbutton, boldbutton) + + def Match_Dialog_Font( + self, Sizeline: QLineEdit, italicbutton: ColorButton, boldbutton: ColorButton + ): + """Update the widgets on the pref dialog to match the current font + Sizeline: QLineEdit + The line displaying the text size to be matched with the current font. + italicbutton: ColorButton + The button displaying the italic state to be matched with the current font. + boldbutton: ColorButton + The button displaying the bold state to be matched with the current font. + """ + Sizeline.setText(str(Font.size)) + + ( + italicbutton.set_color(QColor('silver')) + if Font.italic + else italicbutton.set_color(QColor('snow')) + ) + ( + boldbutton.set_color(QColor('silver')) + if Font.bold + else boldbutton.set_color(QColor('snow')) + ) + @Slot(str) def _show_execution_times_for_type(self, type_name): self._execution_time_plot(type_name) diff --git a/b_asic/scheduler_gui/main_window.ui b/b_asic/scheduler_gui/main_window.ui index beff930750f26903996b2826b115228b50ab96e4..ef5c7e679c50d02e0b5575a36c5604c1aa8a6eb4 100644 --- a/b_asic/scheduler_gui/main_window.ui +++ b/b_asic/scheduler_gui/main_window.ui @@ -202,7 +202,7 @@ <x>0</x> <y>0</y> <width>800</width> - <height>22</height> + <height>20</height> </rect> </property> <widget class="QMenu" name="menuFile"> @@ -215,13 +215,15 @@ </property> </widget> <addaction name="menu_open"/> + <addaction name="menu_Recent_Schedule"/> + <addaction name="menu_load_from_file"/> + <addaction name="separator"/> <addaction name="menu_save"/> <addaction name="menu_save_as"/> - <addaction name="menu_load_from_file"/> - <addaction name="menu_close_schedule"/> <addaction name="separator"/> - <addaction name="menu_Recent_Schedule"/> + <addaction name="actionPreferences"/> <addaction name="separator"/> + <addaction name="menu_close_schedule"/> <addaction name="menu_quit"/> </widget> <widget class="QMenu" name="menuView"> @@ -229,12 +231,12 @@ <string>&View</string> </property> <widget class="QMenu" name="menu_view_execution_times"> - <property name="title"> - <string>View execution times of type</string> - </property> <property name="enabled"> <bool>false</bool> </property> + <property name="title"> + <string>View execution times of type</string> + </property> </widget> <addaction name="menu_node_info"/> <addaction name="actionToolbar"/> @@ -359,7 +361,7 @@ <string>Show/hide node information</string> </property> <property name="shortcut"> - <string>Ctrl+I</string> + <string>Ctrl+N</string> </property> <property name="iconVisibleInMenu"> <bool>false</bool> @@ -391,6 +393,9 @@ <property name="toolTip"> <string>Save schedule with new file name</string> </property> + <property name="shortcut"> + <string>Ctrl+Shift+S</string> + </property> </action> <action name="menu_exit_dialog"> <property name="checkable"> @@ -421,6 +426,9 @@ <property name="text"> <string>&Close schedule</string> </property> + <property name="shortcut"> + <string>Ctrl+W</string> + </property> </action> <action name="actionAbout"> <property name="text"> @@ -445,6 +453,9 @@ <property name="toolTip"> <string>Reorder schedule based on start time</string> </property> + <property name="shortcut"> + <string>Ctrl+R</string> + </property> </action> <action name="actionPlot_schedule"> <property name="text"> @@ -455,23 +466,23 @@ </property> </action> <action name="action_view_variables"> - <property name="text"> - <string>View execution times of variables</string> - </property> <property name="enabled"> <bool>false</bool> </property> + <property name="text"> + <string>View execution times of variables</string> + </property> <property name="toolTip"> <string>View all variables</string> </property> </action> <action name="action_view_port_accesses"> - <property name="text"> - <string>View port access statistics</string> - </property> <property name="enabled"> <bool>false</bool> </property> + <property name="text"> + <string>View port access statistics</string> + </property> <property name="toolTip"> <string>View port access statistics for storage</string> </property> @@ -495,7 +506,7 @@ <string>Redo</string> </property> <property name="shortcut"> - <string>Ctrl+R</string> + <string>Ctrl+Y, Ctrl+Shift+Z</string> </property> </action> <action name="actionIncrease_time_resolution"> @@ -576,6 +587,9 @@ </property> </action> <action name="menu_open"> + <property name="icon"> + <iconset theme="personal"/> + </property> <property name="text"> <string>&Open...</string> </property> @@ -597,6 +611,20 @@ <string>F11</string> </property> </action> + <action name="actionPreferences"> + <property name="icon"> + <iconset theme="preferences-desktop-personal"/> + </property> + <property name="text"> + <string>Preferences</string> + </property> + <property name="toolTip"> + <string>Color and Fonts</string> + </property> + <property name="shortcut"> + <string>Ctrl+M</string> + </property> + </action> </widget> <resources/> <connections/> diff --git a/b_asic/scheduler_gui/operation_item.py b/b_asic/scheduler_gui/operation_item.py index f488689fc07d07de3c73e51af21a985ab70850fb..6b9fc774d48b284389763cec26ad264f35e426c0 100644 --- a/b_asic/scheduler_gui/operation_item.py +++ b/b_asic/scheduler_gui/operation_item.py @@ -9,7 +9,7 @@ from typing import TYPE_CHECKING, Dict, List, Union, cast # QGraphics and QPainter imports from qtpy.QtCore import QPointF, Qt -from qtpy.QtGui import QBrush, QColor, QCursor, QPainterPath, QPen +from qtpy.QtGui import QBrush, QColor, QCursor, QFont, QPainterPath, QPen from qtpy.QtWidgets import ( QAction, QGraphicsEllipseItem, @@ -26,13 +26,12 @@ from b_asic.graph_component import GraphID from b_asic.gui_utils.icons import get_icon from b_asic.operation import Operation from b_asic.scheduler_gui._preferences import ( - OPERATION_EXECUTION_TIME_INACTIVE, OPERATION_HEIGHT, - OPERATION_LATENCY_ACTIVE, - OPERATION_LATENCY_INACTIVE, - SIGNAL_ACTIVE, - SIGNAL_INACTIVE, - SIGNAL_WARNING, + Active_Color, + Execution_Time_Color, + Latency_Color, + Signal_Color, + Signal_Warning_Color, ) if TYPE_CHECKING: @@ -64,6 +63,7 @@ class OperationItem(QGraphicsItemGroup): _label_item: QGraphicsSimpleTextItem _port_items: List[QGraphicsEllipseItem] _port_number_items: List[QGraphicsSimpleTextItem] + _inactive_color: QColor = Latency_Color.DEFAULT def __init__( self, @@ -97,16 +97,30 @@ class OperationItem(QGraphicsItemGroup): QCursor(Qt.CursorShape.OpenHandCursor) ) # default cursor when hovering over object - self._port_filling_brush = QBrush(SIGNAL_INACTIVE) - self._port_outline_pen = QPen(SIGNAL_INACTIVE) + if Signal_Color.changed: + self._port_filling_brush = QBrush(Signal_Color.current_color) + self._port_outline_pen = QPen(Signal_Color.current_color) + else: + self._port_filling_brush = QBrush(Signal_Color.DEFAULT) + self._port_outline_pen = QPen(Signal_Color.DEFAULT) self._port_outline_pen.setWidthF(0) - self._port_filling_brush_active = QBrush(SIGNAL_ACTIVE) - self._port_outline_pen_active = QPen(SIGNAL_ACTIVE) + if Active_Color.changed: + self._port_filling_brush_active = QBrush(Active_Color.current_color) + self._port_outline_pen_active = QPen(Active_Color.current_color) + else: + self._port_filling_brush_active = QBrush(Active_Color.DEFAULT) + self._port_outline_pen_active = QPen(Active_Color.DEFAULT) self._port_outline_pen_active.setWidthF(0) - self._port_filling_brush_warning = QBrush(SIGNAL_WARNING) - self._port_outline_pen_warning = QPen(SIGNAL_WARNING) + if Signal_Warning_Color.changed: + self._port_filling_brush_warning = QBrush( + Signal_Warning_Color.current_color + ) + self._port_outline_pen_warning = QPen(Signal_Warning_Color.current_color) + else: + self._port_filling_brush_warning = QBrush(Signal_Warning_Color.DEFAULT) + self._port_outline_pen_warning = QPen(Signal_Warning_Color.DEFAULT) self._port_outline_pen_warning.setWidthF(0) self._make_component() @@ -184,20 +198,47 @@ class OperationItem(QGraphicsItemGroup): def set_active(self) -> None: """Set the item as active, i.e., draw it in special colors.""" - self._set_background(OPERATION_LATENCY_ACTIVE) + if Active_Color.changed: + self._set_background(Active_Color.current_color) + else: + self._set_background(Active_Color.DEFAULT) self.setCursor(QCursor(Qt.CursorShape.ClosedHandCursor)) def set_inactive(self) -> None: """Set the item as inactive, i.e., draw it in standard colors.""" - self._set_background(OPERATION_LATENCY_INACTIVE) + if Latency_Color.changed: + self._set_background(self._inactive_color) + else: + self._set_background(Latency_Color.DEFAULT) self.setCursor(QCursor(Qt.CursorShape.OpenHandCursor)) + def Set_font(self, font: QFont) -> None: + """Set the items font settings according to a give QFont.""" + self._label_item.prepareGeometryChange() + self._label_item.setFont(font) + center = self._latency_item.boundingRect().center() + center -= self._label_item.boundingRect().center() / self._scale + self._label_item.setPos(self._latency_item.pos() + center) + + def Set_fontColor(self, color: QColor) -> None: + """Set the items font color settings according to a give QColor""" + self._label_item.prepareGeometryChange() + self._label_item.setBrush(color) + def set_show_port_numbers(self, port_number: bool = True): for item in self._port_number_items: item.setVisible(port_number) def set_port_active(self, key: str): item = self._ports[key]["item"] + if Active_Color.changed: + self._port_filling_brush_active = QBrush(Active_Color.current_color) + self._port_outline_pen_active = QPen(Active_Color.current_color) + else: + self._port_filling_brush_active = QBrush(Active_Color.DEFAULT) + self._port_outline_pen_active = QPen(Active_Color.DEFAULT) + + self._port_outline_pen_active.setWidthF(0) item.setBrush(self._port_filling_brush_active) item.setPen(self._port_outline_pen_active) @@ -226,7 +267,10 @@ class OperationItem(QGraphicsItemGroup): port_size = 7 / self._scale # the diameter of a port - execution_time_color = QColor(OPERATION_EXECUTION_TIME_INACTIVE) + if Execution_Time_Color.changed: + execution_time_color = QColor(Execution_Time_Color.current_color) + else: + execution_time_color = QColor(Execution_Time_Color.DEFAULT) execution_time_color.setAlpha(200) # 0-255 execution_time_pen = QPen() # used by execution time outline execution_time_pen.setColor(execution_time_color) @@ -254,7 +298,7 @@ class OperationItem(QGraphicsItemGroup): self._execution_time_item.setPen(execution_time_pen) # component item - self._set_background(OPERATION_LATENCY_INACTIVE) # used by component filling + self._set_background(Latency_Color.DEFAULT) # used by component filling def create_ports(io_coordinates, prefix): for i, (x, y) in enumerate(io_coordinates): diff --git a/b_asic/scheduler_gui/scheduler_event.py b/b_asic/scheduler_gui/scheduler_event.py index 6df2b67917ba4103536ad4216370b2f3bb194307..89d4a3848c9967418bf819dc7f48b396b4995bae 100644 --- a/b_asic/scheduler_gui/scheduler_event.py +++ b/b_asic/scheduler_gui/scheduler_event.py @@ -38,6 +38,7 @@ class SchedulerEvent: # PyQt5 redraw_all = Signal() reopen = Signal() execution_time_plot = Signal(str) + TextSignal = Signal(str) _axes: Optional[AxesItem] _current_pos: QPointF diff --git a/b_asic/scheduler_gui/scheduler_item.py b/b_asic/scheduler_gui/scheduler_item.py index 63cae2433380545488696264b05a4bc42b42285e..dcd4b993722a1cd37a5453583f5d6cfa01084f8e 100644 --- a/b_asic/scheduler_gui/scheduler_item.py +++ b/b_asic/scheduler_gui/scheduler_item.py @@ -12,6 +12,7 @@ from typing import Dict, List, Optional, Set, cast # QGraphics and QPainter imports from qtpy.QtCore import Signal +from qtpy.QtGui import QColor, QFont from qtpy.QtWidgets import QGraphicsItem, QGraphicsItemGroup # B-ASIC @@ -141,6 +142,26 @@ class SchedulerItem(SchedulerEvent, QGraphicsItemGroup): # PySide2 / PyQt5 for signal in self._get_all_signals(): signal.update_path() + def _color_change(self, color: QColor, name: str) -> None: + """Change inactive color of operation item *.""" + for op in self.components: + if name == "all operations": + op._set_background(color) + op._inactive_color = color + elif name == op.operation.type_name(): + op._set_background(color) + op._inactive_color = color + + def _font_change(self, font: QFont) -> None: + """Update font in the schedule.""" + for op in self.components: + op.Set_font(font) + + def _font_color_change(self, color: QColor) -> None: + """Update font color in the schedule.""" + for op in self.components: + op.Set_fontColor(color) + def _redraw_lines(self, item: OperationItem) -> None: """Update lines connected to *item*.""" for signal in self._signal_dict[item]: diff --git a/b_asic/scheduler_gui/signal_item.py b/b_asic/scheduler_gui/signal_item.py index 723bf228c22daee09108097406128870ae4aa6e6..1cdc5186fd929f408e06a333fb9e237150c614db 100644 --- a/b_asic/scheduler_gui/signal_item.py +++ b/b_asic/scheduler_gui/signal_item.py @@ -14,12 +14,12 @@ from qtpy.QtWidgets import QGraphicsPathItem # B-ASIC from b_asic.scheduler_gui._preferences import ( SCHEDULE_INDENT, - SIGNAL_ACTIVE, - SIGNAL_INACTIVE, - SIGNAL_WARNING, SIGNAL_WIDTH, SIGNAL_WIDTH_ACTIVE, SIGNAL_WIDTH_WARNING, + Active_Color, + Signal_Color, + Signal_Warning_Color, ) from b_asic.scheduler_gui.operation_item import OperationItem from b_asic.signal import Signal @@ -100,13 +100,24 @@ class SignalItem(QGraphicsPathItem): def _refresh_pens(self) -> None: """Create pens.""" - pen = QPen(SIGNAL_ACTIVE) + if Active_Color.changed: + pen = QPen(Active_Color.current_color) + else: + pen = QPen(Active_Color.DEFAULT) pen.setWidthF(SIGNAL_WIDTH_ACTIVE) self._active_pen = pen - pen = QPen(SIGNAL_INACTIVE) + + if Signal_Color.changed: + pen = QPen(Signal_Color.current_color) + else: + pen = QPen(Signal_Color.DEFAULT) pen.setWidthF(SIGNAL_WIDTH) self._inactive_pen = pen - pen = QPen(SIGNAL_WARNING) + + if Signal_Warning_Color.changed: + pen = QPen(Signal_Warning_Color.current_color) + else: + pen = QPen(Signal_Warning_Color.DEFAULT) pen.setWidthF(SIGNAL_WIDTH_WARNING) self._warning_pen = pen diff --git a/b_asic/scheduler_gui/ui_main_window.py b/b_asic/scheduler_gui/ui_main_window.py index 4a48600a4254b210a50982330367344922cc4d72..ec17436987d4f37c991acff66913a7fab6fb357d 100644 --- a/b_asic/scheduler_gui/ui_main_window.py +++ b/b_asic/scheduler_gui/ui_main_window.py @@ -1,264 +1,303 @@ -# Form implementation generated from reading ui file '.\main_window.ui' -# -# Created by: PyQt5 UI code generator 5.15.7 -# -# WARNING: Any manual changes made to this file will be lost when pyuic5 is -# run again. Do not edit this file unless you know what you are doing. +################################################################################ +## Form generated from reading UI file 'main_window.ui' +## +## Created by: Qt User Interface Compiler version 5.15.8 +## +## WARNING! All changes made in this file will be lost when recompiling UI file! +################################################################################ - -from qtpy import QtCore, QtGui, QtWidgets +from qtpy.QtCore import QSize, QCoreApplication, QRect, QMetaObject +from qtpy.QtGui import QIcon, QColor, QFont, QBrush, Qt, QPainter +from qtpy.QtWidgets import ( + QSizePolicy, + QAction, + QMenu, + QMenuBar, + QToolBar, + QHBoxLayout, + QWidget, + QGraphicsView, + QSplitter, + QTableWidgetItem, + QTableWidget, + QAbstractItemView, + QStatusBar, +) class Ui_MainWindow: def setupUi(self, MainWindow): - MainWindow.setObjectName("MainWindow") + if not MainWindow.objectName(): + MainWindow.setObjectName("MainWindow") MainWindow.resize(800, 600) - sizePolicy = QtWidgets.QSizePolicy( - QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred - ) + sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth()) MainWindow.setSizePolicy(sizePolicy) - icon = QtGui.QIcon() - icon.addPixmap( - QtGui.QPixmap(":/icons/basic/small_logo.png"), - QtGui.QIcon.Normal, - QtGui.QIcon.Off, - ) + icon = QIcon() + icon.addFile(":/icons/basic/small_logo.png", QSize(), QIcon.Normal, QIcon.Off) MainWindow.setWindowIcon(icon) - self.centralwidget = QtWidgets.QWidget(MainWindow) - sizePolicy = QtWidgets.QSizePolicy( - QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred - ) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth( - self.centralwidget.sizePolicy().hasHeightForWidth() - ) - self.centralwidget.setSizePolicy(sizePolicy) - self.centralwidget.setObjectName("centralwidget") - self.horizontalLayout = QtWidgets.QHBoxLayout(self.centralwidget) - self.horizontalLayout.setContentsMargins(0, 0, 0, 0) - self.horizontalLayout.setSpacing(0) - self.horizontalLayout.setObjectName("horizontalLayout") - self.splitter = QtWidgets.QSplitter(self.centralwidget) - self.splitter.setOrientation(QtCore.Qt.Horizontal) - self.splitter.setHandleWidth(0) - self.splitter.setObjectName("splitter") - self.view = QtWidgets.QGraphicsView(self.splitter) - self.view.setAlignment( - QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop - ) - self.view.setRenderHints( - QtGui.QPainter.Antialiasing | QtGui.QPainter.TextAntialiasing - ) - self.view.setViewportUpdateMode(QtWidgets.QGraphicsView.FullViewportUpdate) - self.view.setObjectName("view") - self.info_table = QtWidgets.QTableWidget(self.splitter) - self.info_table.setStyleSheet( - "alternate-background-color: #fadefb;background-color: #ebebeb;" - ) - self.info_table.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) - self.info_table.setAlternatingRowColors(True) - self.info_table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) - self.info_table.setRowCount(2) - self.info_table.setColumnCount(2) - self.info_table.setObjectName("info_table") - item = QtWidgets.QTableWidgetItem() - self.info_table.setVerticalHeaderItem(0, item) - item = QtWidgets.QTableWidgetItem() - self.info_table.setVerticalHeaderItem(1, item) - item = QtWidgets.QTableWidgetItem() - item.setTextAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignVCenter) - font = QtGui.QFont() - font.setBold(False) - font.setWeight(50) - item.setFont(font) - self.info_table.setHorizontalHeaderItem(0, item) - item = QtWidgets.QTableWidgetItem() - item.setTextAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignVCenter) - self.info_table.setHorizontalHeaderItem(1, item) - item = QtWidgets.QTableWidgetItem() - font = QtGui.QFont() - font.setBold(False) - font.setWeight(50) - font.setKerning(True) - item.setFont(font) - brush = QtGui.QBrush(QtGui.QColor(160, 160, 164)) - brush.setStyle(QtCore.Qt.SolidPattern) - item.setBackground(brush) - brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - item.setForeground(brush) - item.setFlags( - QtCore.Qt.ItemIsSelectable - | QtCore.Qt.ItemIsEditable - | QtCore.Qt.ItemIsDragEnabled - | QtCore.Qt.ItemIsDropEnabled - | QtCore.Qt.ItemIsUserCheckable - ) - self.info_table.setItem(0, 0, item) - item = QtWidgets.QTableWidgetItem() - font = QtGui.QFont() - font.setBold(False) - font.setWeight(50) - item.setFont(font) - brush = QtGui.QBrush(QtGui.QColor(160, 160, 164)) - brush.setStyle(QtCore.Qt.SolidPattern) - item.setBackground(brush) - brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - item.setForeground(brush) - item.setFlags( - QtCore.Qt.ItemIsSelectable - | QtCore.Qt.ItemIsEditable - | QtCore.Qt.ItemIsDragEnabled - | QtCore.Qt.ItemIsDropEnabled - | QtCore.Qt.ItemIsUserCheckable - ) - self.info_table.setItem(1, 0, item) - self.info_table.horizontalHeader().setHighlightSections(False) - self.info_table.horizontalHeader().setStretchLastSection(True) - self.info_table.verticalHeader().setVisible(False) - self.info_table.verticalHeader().setDefaultSectionSize(24) - self.horizontalLayout.addWidget(self.splitter) - MainWindow.setCentralWidget(self.centralwidget) - self.menubar = QtWidgets.QMenuBar(MainWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 22)) - self.menubar.setObjectName("menubar") - self.menuFile = QtWidgets.QMenu(self.menubar) - self.menuFile.setObjectName("menuFile") - self.menu_Recent_Schedule = QtWidgets.QMenu(self.menuFile) - self.menu_Recent_Schedule.setObjectName("menu_Recent_Schedule") - self.menuView = QtWidgets.QMenu(self.menubar) - self.menuView.setObjectName("menuView") - self.menu_view_execution_times = QtWidgets.QMenu(self.menuView) - self.menu_view_execution_times.setEnabled(False) - self.menu_view_execution_times.setObjectName("menu_view_execution_times") - self.menu_Edit = QtWidgets.QMenu(self.menubar) - self.menu_Edit.setObjectName("menu_Edit") - self.menuWindow = QtWidgets.QMenu(self.menubar) - self.menuWindow.setObjectName("menuWindow") - self.menuHelp = QtWidgets.QMenu(self.menubar) - self.menuHelp.setObjectName("menuHelp") - MainWindow.setMenuBar(self.menubar) - self.statusbar = QtWidgets.QStatusBar(MainWindow) - self.statusbar.setObjectName("statusbar") - MainWindow.setStatusBar(self.statusbar) - self.toolBar = QtWidgets.QToolBar(MainWindow) - self.toolBar.setObjectName("toolBar") - MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar) - self.menu_load_from_file = QtWidgets.QAction(MainWindow) - icon = QtGui.QIcon.fromTheme("document-open-folder") - self.menu_load_from_file.setIcon(icon) - self.menu_load_from_file.setStatusTip("") + self.menu_load_from_file = QAction(MainWindow) self.menu_load_from_file.setObjectName("menu_load_from_file") - self.menu_save = QtWidgets.QAction(MainWindow) - self.menu_save.setEnabled(False) - icon = QtGui.QIcon.fromTheme("document-save") - self.menu_save.setIcon(icon) + icon1 = QIcon() + iconThemeName = "document-open-folder" + if QIcon.hasThemeIcon(iconThemeName): + icon1 = QIcon.fromTheme(iconThemeName) + else: + icon1.addFile("../../../.designer/backup", QSize(), QIcon.Normal, QIcon.Off) + + self.menu_load_from_file.setIcon(icon1) + self.menu_save = QAction(MainWindow) self.menu_save.setObjectName("menu_save") - self.menu_node_info = QtWidgets.QAction(MainWindow) + self.menu_save.setEnabled(False) + icon2 = QIcon() + iconThemeName = "document-save" + if QIcon.hasThemeIcon(iconThemeName): + icon2 = QIcon.fromTheme(iconThemeName) + else: + icon2.addFile("../../../.designer/backup", QSize(), QIcon.Normal, QIcon.Off) + + self.menu_save.setIcon(icon2) + self.menu_node_info = QAction(MainWindow) + self.menu_node_info.setObjectName("menu_node_info") self.menu_node_info.setCheckable(True) self.menu_node_info.setChecked(True) - icon1 = QtGui.QIcon() - icon1.addPixmap( - QtGui.QPixmap(":/icons/misc/right_panel.svg"), - QtGui.QIcon.Normal, - QtGui.QIcon.Off, - ) - icon1.addPixmap( - QtGui.QPixmap(":/icons/misc/right_filled_panel.svg"), - QtGui.QIcon.Normal, - QtGui.QIcon.On, - ) - self.menu_node_info.setIcon(icon1) + icon3 = QIcon() + icon3.addFile(":/icons/misc/right_panel.svg", QSize(), QIcon.Normal, QIcon.Off) + icon3.addFile( + ":/icons/misc/right_filled_panel.svg", QSize(), QIcon.Normal, QIcon.On + ) + self.menu_node_info.setIcon(icon3) self.menu_node_info.setIconVisibleInMenu(False) - self.menu_node_info.setObjectName("menu_node_info") - self.menu_quit = QtWidgets.QAction(MainWindow) - icon = QtGui.QIcon.fromTheme("application-exit") - self.menu_quit.setIcon(icon) + self.menu_quit = QAction(MainWindow) self.menu_quit.setObjectName("menu_quit") - self.menu_save_as = QtWidgets.QAction(MainWindow) - self.menu_save_as.setEnabled(False) - icon = QtGui.QIcon.fromTheme("document-save-as") - self.menu_save_as.setIcon(icon) + icon4 = QIcon() + iconThemeName = "application-exit" + if QIcon.hasThemeIcon(iconThemeName): + icon4 = QIcon.fromTheme(iconThemeName) + else: + icon4.addFile("../../../.designer/backup", QSize(), QIcon.Normal, QIcon.Off) + + self.menu_quit.setIcon(icon4) + self.menu_save_as = QAction(MainWindow) self.menu_save_as.setObjectName("menu_save_as") - self.menu_exit_dialog = QtWidgets.QAction(MainWindow) + self.menu_save_as.setEnabled(False) + icon5 = QIcon() + iconThemeName = "document-save-as" + if QIcon.hasThemeIcon(iconThemeName): + icon5 = QIcon.fromTheme(iconThemeName) + else: + icon5.addFile("../../../.designer/backup", QSize(), QIcon.Normal, QIcon.Off) + + self.menu_save_as.setIcon(icon5) + self.menu_exit_dialog = QAction(MainWindow) + self.menu_exit_dialog.setObjectName("menu_exit_dialog") self.menu_exit_dialog.setCheckable(True) self.menu_exit_dialog.setChecked(True) - icon = QtGui.QIcon.fromTheme("view-close") - self.menu_exit_dialog.setIcon(icon) - self.menu_exit_dialog.setObjectName("menu_exit_dialog") - self.menu_close_schedule = QtWidgets.QAction(MainWindow) - self.menu_close_schedule.setEnabled(False) - icon = QtGui.QIcon.fromTheme("view-close") - self.menu_close_schedule.setIcon(icon) + icon6 = QIcon() + iconThemeName = "view-close" + if QIcon.hasThemeIcon(iconThemeName): + icon6 = QIcon.fromTheme(iconThemeName) + else: + icon6.addFile("../../../.designer/backup", QSize(), QIcon.Normal, QIcon.Off) + + self.menu_exit_dialog.setIcon(icon6) + self.menu_close_schedule = QAction(MainWindow) self.menu_close_schedule.setObjectName("menu_close_schedule") - self.actionAbout = QtWidgets.QAction(MainWindow) + self.menu_close_schedule.setEnabled(False) + self.menu_close_schedule.setIcon(icon6) + self.actionAbout = QAction(MainWindow) self.actionAbout.setObjectName("actionAbout") - self.actionDocumentation = QtWidgets.QAction(MainWindow) + self.actionDocumentation = QAction(MainWindow) self.actionDocumentation.setObjectName("actionDocumentation") - self.actionReorder = QtWidgets.QAction(MainWindow) + self.actionReorder = QAction(MainWindow) self.actionReorder.setObjectName("actionReorder") - self.actionPlot_schedule = QtWidgets.QAction(MainWindow) + self.actionPlot_schedule = QAction(MainWindow) self.actionPlot_schedule.setObjectName("actionPlot_schedule") - self.action_view_variables = QtWidgets.QAction(MainWindow) - self.action_view_variables.setEnabled(False) + self.action_view_variables = QAction(MainWindow) self.action_view_variables.setObjectName("action_view_variables") - self.action_view_port_accesses = QtWidgets.QAction(MainWindow) - self.action_view_port_accesses.setEnabled(False) + self.action_view_variables.setEnabled(False) + self.action_view_port_accesses = QAction(MainWindow) self.action_view_port_accesses.setObjectName("action_view_port_accesses") - self.actionUndo = QtWidgets.QAction(MainWindow) - self.actionUndo.setEnabled(False) + self.action_view_port_accesses.setEnabled(False) + self.actionUndo = QAction(MainWindow) self.actionUndo.setObjectName("actionUndo") - self.actionRedo = QtWidgets.QAction(MainWindow) - self.actionRedo.setEnabled(False) + self.actionUndo.setEnabled(False) + self.actionRedo = QAction(MainWindow) self.actionRedo.setObjectName("actionRedo") - self.actionIncrease_time_resolution = QtWidgets.QAction(MainWindow) + self.actionRedo.setEnabled(False) + self.actionIncrease_time_resolution = QAction(MainWindow) self.actionIncrease_time_resolution.setObjectName( "actionIncrease_time_resolution" ) - self.actionDecrease_time_resolution = QtWidgets.QAction(MainWindow) + self.actionDecrease_time_resolution = QAction(MainWindow) self.actionDecrease_time_resolution.setObjectName( "actionDecrease_time_resolution" ) - self.actionZoom_to_fit = QtWidgets.QAction(MainWindow) + self.actionZoom_to_fit = QAction(MainWindow) self.actionZoom_to_fit.setObjectName("actionZoom_to_fit") - self.actionStatus_bar = QtWidgets.QAction(MainWindow) + self.actionStatus_bar = QAction(MainWindow) + self.actionStatus_bar.setObjectName("actionStatus_bar") self.actionStatus_bar.setCheckable(True) self.actionStatus_bar.setChecked(True) - self.actionStatus_bar.setObjectName("actionStatus_bar") - self.actionToolbar = QtWidgets.QAction(MainWindow) + self.actionToolbar = QAction(MainWindow) + self.actionToolbar.setObjectName("actionToolbar") self.actionToolbar.setCheckable(True) self.actionToolbar.setChecked(True) - self.actionToolbar.setObjectName("actionToolbar") - self.action_show_port_numbers = QtWidgets.QAction(MainWindow) + self.action_show_port_numbers = QAction(MainWindow) + self.action_show_port_numbers.setObjectName("action_show_port_numbers") self.action_show_port_numbers.setCheckable(True) self.action_show_port_numbers.setChecked(False) self.action_show_port_numbers.setIconVisibleInMenu(False) - self.action_show_port_numbers.setObjectName("action_show_port_numbers") - self.action_incorrect_execution_time = QtWidgets.QAction(MainWindow) - self.action_incorrect_execution_time.setCheckable(True) - self.action_incorrect_execution_time.setChecked(True) - self.action_incorrect_execution_time.setIconVisibleInMenu(False) + self.action_incorrect_execution_time = QAction(MainWindow) self.action_incorrect_execution_time.setObjectName( "action_incorrect_execution_time" ) - self.menu_open = QtWidgets.QAction(MainWindow) + self.action_incorrect_execution_time.setCheckable(True) + self.action_incorrect_execution_time.setChecked(True) + self.action_incorrect_execution_time.setIconVisibleInMenu(False) + self.menu_open = QAction(MainWindow) self.menu_open.setObjectName("menu_open") - self.actionToggle_full_screen = QtWidgets.QAction(MainWindow) - self.actionToggle_full_screen.setCheckable(True) + icon7 = QIcon(QIcon.fromTheme("personal")) + self.menu_open.setIcon(icon7) + self.actionToggle_full_screen = QAction(MainWindow) self.actionToggle_full_screen.setObjectName("actionToggle_full_screen") + self.actionToggle_full_screen.setCheckable(True) + self.actionPreferences = QAction(MainWindow) + self.actionPreferences.setObjectName("actionPreferences") + icon8 = QIcon(QIcon.fromTheme("preferences-desktop-personal")) + self.actionPreferences.setIcon(icon8) + self.centralwidget = QWidget(MainWindow) + self.centralwidget.setObjectName("centralwidget") + sizePolicy.setHeightForWidth( + self.centralwidget.sizePolicy().hasHeightForWidth() + ) + self.centralwidget.setSizePolicy(sizePolicy) + self.horizontalLayout = QHBoxLayout(self.centralwidget) + self.horizontalLayout.setSpacing(0) + self.horizontalLayout.setObjectName("horizontalLayout") + self.horizontalLayout.setContentsMargins(0, 0, 0, 0) + self.splitter = QSplitter(self.centralwidget) + self.splitter.setObjectName("splitter") + self.splitter.setOrientation(Qt.Horizontal) + self.splitter.setHandleWidth(0) + self.view = QGraphicsView(self.splitter) + self.view.setObjectName("view") + self.view.setAlignment(Qt.AlignLeading | Qt.AlignLeft | Qt.AlignTop) + self.view.setRenderHints(QPainter.Antialiasing | QPainter.TextAntialiasing) + self.view.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) + self.splitter.addWidget(self.view) + self.info_table = QTableWidget(self.splitter) + if self.info_table.columnCount() < 2: + self.info_table.setColumnCount(2) + font = QFont() + font.setBold(False) + font.setWeight(50) + __qtablewidgetitem = QTableWidgetItem() + __qtablewidgetitem.setTextAlignment(Qt.AlignLeading | Qt.AlignVCenter) + __qtablewidgetitem.setFont(font) + self.info_table.setHorizontalHeaderItem(0, __qtablewidgetitem) + __qtablewidgetitem1 = QTableWidgetItem() + __qtablewidgetitem1.setTextAlignment(Qt.AlignLeading | Qt.AlignVCenter) + self.info_table.setHorizontalHeaderItem(1, __qtablewidgetitem1) + if self.info_table.rowCount() < 2: + self.info_table.setRowCount(2) + __qtablewidgetitem2 = QTableWidgetItem() + self.info_table.setVerticalHeaderItem(0, __qtablewidgetitem2) + __qtablewidgetitem3 = QTableWidgetItem() + self.info_table.setVerticalHeaderItem(1, __qtablewidgetitem3) + brush = QBrush(QColor(255, 255, 255, 255)) + brush.setStyle(Qt.SolidPattern) + brush1 = QBrush(QColor(160, 160, 164, 255)) + brush1.setStyle(Qt.SolidPattern) + font1 = QFont() + font1.setBold(False) + font1.setWeight(50) + font1.setKerning(True) + __qtablewidgetitem4 = QTableWidgetItem() + __qtablewidgetitem4.setFont(font1) + __qtablewidgetitem4.setBackground(brush1) + __qtablewidgetitem4.setForeground(brush) + __qtablewidgetitem4.setFlags( + Qt.ItemIsSelectable + | Qt.ItemIsEditable + | Qt.ItemIsDragEnabled + | Qt.ItemIsDropEnabled + | Qt.ItemIsUserCheckable + ) + self.info_table.setItem(0, 0, __qtablewidgetitem4) + __qtablewidgetitem5 = QTableWidgetItem() + __qtablewidgetitem5.setFont(font) + __qtablewidgetitem5.setBackground(brush1) + __qtablewidgetitem5.setForeground(brush) + __qtablewidgetitem5.setFlags( + Qt.ItemIsSelectable + | Qt.ItemIsEditable + | Qt.ItemIsDragEnabled + | Qt.ItemIsDropEnabled + | Qt.ItemIsUserCheckable + ) + self.info_table.setItem(1, 0, __qtablewidgetitem5) + self.info_table.setObjectName("info_table") + self.info_table.setStyleSheet( + "alternate-background-color: #fadefb;background-color: #ebebeb;" + ) + self.info_table.setEditTriggers(QAbstractItemView.NoEditTriggers) + self.info_table.setAlternatingRowColors(True) + self.info_table.setSelectionBehavior(QAbstractItemView.SelectRows) + self.info_table.setRowCount(2) + self.info_table.setColumnCount(2) + self.splitter.addWidget(self.info_table) + self.info_table.horizontalHeader().setHighlightSections(False) + self.info_table.horizontalHeader().setStretchLastSection(True) + self.info_table.verticalHeader().setVisible(False) + self.info_table.verticalHeader().setDefaultSectionSize(24) + + self.horizontalLayout.addWidget(self.splitter) + + MainWindow.setCentralWidget(self.centralwidget) + self.menubar = QMenuBar(MainWindow) + self.menubar.setObjectName("menubar") + self.menubar.setGeometry(QRect(0, 0, 800, 20)) + self.menuFile = QMenu(self.menubar) + self.menuFile.setObjectName("menuFile") + self.menu_Recent_Schedule = QMenu(self.menuFile) + self.menu_Recent_Schedule.setObjectName("menu_Recent_Schedule") + self.menuView = QMenu(self.menubar) + self.menuView.setObjectName("menuView") + self.menu_view_execution_times = QMenu(self.menuView) + self.menu_view_execution_times.setObjectName("menu_view_execution_times") + self.menu_view_execution_times.setEnabled(False) + self.menu_Edit = QMenu(self.menubar) + self.menu_Edit.setObjectName("menu_Edit") + self.menuWindow = QMenu(self.menubar) + self.menuWindow.setObjectName("menuWindow") + self.menuHelp = QMenu(self.menubar) + self.menuHelp.setObjectName("menuHelp") + MainWindow.setMenuBar(self.menubar) + self.statusbar = QStatusBar(MainWindow) + self.statusbar.setObjectName("statusbar") + MainWindow.setStatusBar(self.statusbar) + self.toolBar = QToolBar(MainWindow) + self.toolBar.setObjectName("toolBar") + MainWindow.addToolBar(Qt.TopToolBarArea, self.toolBar) + + self.menubar.addAction(self.menuFile.menuAction()) + self.menubar.addAction(self.menu_Edit.menuAction()) + self.menubar.addAction(self.menuView.menuAction()) + self.menubar.addAction(self.menuWindow.menuAction()) + self.menubar.addAction(self.menuHelp.menuAction()) self.menuFile.addAction(self.menu_open) + self.menuFile.addAction(self.menu_Recent_Schedule.menuAction()) + self.menuFile.addAction(self.menu_load_from_file) + self.menuFile.addSeparator() self.menuFile.addAction(self.menu_save) self.menuFile.addAction(self.menu_save_as) - self.menuFile.addAction(self.menu_load_from_file) - self.menuFile.addAction(self.menu_close_schedule) self.menuFile.addSeparator() - self.menuFile.addAction(self.menu_Recent_Schedule.menuAction()) + self.menuFile.addAction(self.actionPreferences) self.menuFile.addSeparator() + self.menuFile.addAction(self.menu_close_schedule) self.menuFile.addAction(self.menu_quit) self.menuView.addAction(self.menu_node_info) self.menuView.addAction(self.actionToolbar) @@ -283,11 +322,6 @@ class Ui_MainWindow: self.menuHelp.addAction(self.actionDocumentation) self.menuHelp.addSeparator() self.menuHelp.addAction(self.actionAbout) - self.menubar.addAction(self.menuFile.menuAction()) - self.menubar.addAction(self.menu_Edit.menuAction()) - self.menubar.addAction(self.menuView.menuAction()) - self.menubar.addAction(self.menuWindow.menuAction()) - self.menubar.addAction(self.menuHelp.menuAction()) self.toolBar.addAction(self.menu_open) self.toolBar.addAction(self.menu_save) self.toolBar.addAction(self.menu_save_as) @@ -301,121 +335,300 @@ class Ui_MainWindow: self.toolBar.addAction(self.actionReorder) self.retranslateUi(MainWindow) - QtCore.QMetaObject.connectSlotsByName(MainWindow) + + QMetaObject.connectSlotsByName(MainWindow) + + # setupUi def retranslateUi(self, MainWindow): - _translate = QtCore.QCoreApplication.translate - item = self.info_table.verticalHeaderItem(0) - item.setText(_translate("MainWindow", "1")) - item = self.info_table.verticalHeaderItem(1) - item.setText(_translate("MainWindow", "2")) - item = self.info_table.horizontalHeaderItem(0) - item.setText(_translate("MainWindow", "Property")) - item = self.info_table.horizontalHeaderItem(1) - item.setText(_translate("MainWindow", "Value")) - __sortingEnabled = self.info_table.isSortingEnabled() - self.info_table.setSortingEnabled(False) - item = self.info_table.item(0, 0) - item.setText(_translate("MainWindow", "Schedule")) - item = self.info_table.item(1, 0) - item.setText(_translate("MainWindow", "Operator")) - self.info_table.setSortingEnabled(__sortingEnabled) - self.menuFile.setTitle(_translate("MainWindow", "&File")) - self.menu_Recent_Schedule.setTitle(_translate("MainWindow", "Open &recent")) - self.menuView.setTitle(_translate("MainWindow", "&View")) - self.menu_view_execution_times.setTitle( - _translate("MainWindow", "View execution times of type") - ) - self.menu_Edit.setTitle(_translate("MainWindow", "&Edit")) - self.menuWindow.setTitle(_translate("MainWindow", "&Window")) - self.menuHelp.setTitle(_translate("MainWindow", "&Help")) - self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar")) self.menu_load_from_file.setText( - _translate("MainWindow", "&Import schedule from file...") + QCoreApplication.translate( + "MainWindow", "&Import schedule from file...", None + ) ) + # if QT_CONFIG(tooltip) self.menu_load_from_file.setToolTip( - _translate("MainWindow", "Import schedule from python script") + QCoreApplication.translate( + "MainWindow", "Import schedule from python script", None + ) ) - self.menu_load_from_file.setShortcut(_translate("MainWindow", "Ctrl+I")) - self.menu_save.setText(_translate("MainWindow", "&Save")) - self.menu_save.setToolTip(_translate("MainWindow", "Save schedule")) - self.menu_save.setShortcut(_translate("MainWindow", "Ctrl+S")) - self.menu_node_info.setText(_translate("MainWindow", "&Node info")) + # endif // QT_CONFIG(tooltip) + # if QT_CONFIG(statustip) + self.menu_load_from_file.setStatusTip("") + # endif // QT_CONFIG(statustip) + # if QT_CONFIG(shortcut) + self.menu_load_from_file.setShortcut( + QCoreApplication.translate("MainWindow", "Ctrl+I", None) + ) + # endif // QT_CONFIG(shortcut) + self.menu_save.setText(QCoreApplication.translate("MainWindow", "&Save", None)) + # if QT_CONFIG(tooltip) + self.menu_save.setToolTip( + QCoreApplication.translate("MainWindow", "Save schedule", None) + ) + # endif // QT_CONFIG(tooltip) + # if QT_CONFIG(shortcut) + self.menu_save.setShortcut( + QCoreApplication.translate("MainWindow", "Ctrl+S", None) + ) + # endif // QT_CONFIG(shortcut) + self.menu_node_info.setText( + QCoreApplication.translate("MainWindow", "&Node info", None) + ) + # if QT_CONFIG(tooltip) self.menu_node_info.setToolTip( - _translate("MainWindow", "Show/hide node information") + QCoreApplication.translate("MainWindow", "Show/hide node information", None) + ) + # endif // QT_CONFIG(tooltip) + # if QT_CONFIG(shortcut) + self.menu_node_info.setShortcut( + QCoreApplication.translate("MainWindow", "Ctrl+N", None) + ) + # endif // QT_CONFIG(shortcut) + self.menu_quit.setText(QCoreApplication.translate("MainWindow", "&Quit", None)) + # if QT_CONFIG(shortcut) + self.menu_quit.setShortcut( + QCoreApplication.translate("MainWindow", "Ctrl+Q", None) ) - self.menu_node_info.setShortcut(_translate("MainWindow", "Ctrl+I")) - self.menu_quit.setText(_translate("MainWindow", "&Quit")) - self.menu_quit.setShortcut(_translate("MainWindow", "Ctrl+Q")) - self.menu_save_as.setText(_translate("MainWindow", "Save &as...")) + # endif // QT_CONFIG(shortcut) + self.menu_save_as.setText( + QCoreApplication.translate("MainWindow", "Save &as...", None) + ) + # if QT_CONFIG(tooltip) self.menu_save_as.setToolTip( - _translate("MainWindow", "Save schedule with new file name") - ) - self.menu_exit_dialog.setText(_translate("MainWindow", "&Hide exit dialog")) - self.menu_exit_dialog.setToolTip(_translate("MainWindow", "Hide exit dialog")) - self.menu_close_schedule.setText(_translate("MainWindow", "&Close schedule")) - self.actionAbout.setText(_translate("MainWindow", "&About")) - self.actionAbout.setToolTip(_translate("MainWindow", "Open about window")) - self.actionDocumentation.setText(_translate("MainWindow", "&Documentation")) + QCoreApplication.translate( + "MainWindow", "Save schedule with new file name", None + ) + ) + # endif // QT_CONFIG(tooltip) + # if QT_CONFIG(shortcut) + self.menu_save_as.setShortcut( + QCoreApplication.translate("MainWindow", "Ctrl+Shift+S", None) + ) + # endif // QT_CONFIG(shortcut) + self.menu_exit_dialog.setText( + QCoreApplication.translate("MainWindow", "&Hide exit dialog", None) + ) + # if QT_CONFIG(tooltip) + self.menu_exit_dialog.setToolTip( + QCoreApplication.translate("MainWindow", "Hide exit dialog", None) + ) + # endif // QT_CONFIG(tooltip) + self.menu_close_schedule.setText( + QCoreApplication.translate("MainWindow", "&Close schedule", None) + ) + # if QT_CONFIG(shortcut) + self.menu_close_schedule.setShortcut( + QCoreApplication.translate("MainWindow", "Ctrl+W", None) + ) + # endif // QT_CONFIG(shortcut) + self.actionAbout.setText( + QCoreApplication.translate("MainWindow", "&About", None) + ) + # if QT_CONFIG(tooltip) + self.actionAbout.setToolTip( + QCoreApplication.translate("MainWindow", "Open about window", None) + ) + # endif // QT_CONFIG(tooltip) + self.actionDocumentation.setText( + QCoreApplication.translate("MainWindow", "&Documentation", None) + ) + # if QT_CONFIG(tooltip) self.actionDocumentation.setToolTip( - _translate("MainWindow", "Open documentation") + QCoreApplication.translate("MainWindow", "Open documentation", None) ) - self.actionReorder.setText(_translate("MainWindow", "Reorder")) + # endif // QT_CONFIG(tooltip) + self.actionReorder.setText( + QCoreApplication.translate("MainWindow", "Reorder", None) + ) + # if QT_CONFIG(tooltip) self.actionReorder.setToolTip( - _translate("MainWindow", "Reorder schedule based on start time") + QCoreApplication.translate( + "MainWindow", "Reorder schedule based on start time", None + ) + ) + # endif // QT_CONFIG(tooltip) + # if QT_CONFIG(shortcut) + self.actionReorder.setShortcut( + QCoreApplication.translate("MainWindow", "Ctrl+R", None) ) - self.actionPlot_schedule.setText(_translate("MainWindow", "&Plot schedule")) - self.actionPlot_schedule.setToolTip(_translate("MainWindow", "Plot schedule")) + # endif // QT_CONFIG(shortcut) + self.actionPlot_schedule.setText( + QCoreApplication.translate("MainWindow", "&Plot schedule", None) + ) + # if QT_CONFIG(tooltip) + self.actionPlot_schedule.setToolTip( + QCoreApplication.translate("MainWindow", "Plot schedule", None) + ) + # endif // QT_CONFIG(tooltip) self.action_view_variables.setText( - _translate("MainWindow", "View execution times of variables") + QCoreApplication.translate( + "MainWindow", "View execution times of variables", None + ) ) + # if QT_CONFIG(tooltip) self.action_view_variables.setToolTip( - _translate("MainWindow", "View all variables") + QCoreApplication.translate("MainWindow", "View all variables", None) ) + # endif // QT_CONFIG(tooltip) self.action_view_port_accesses.setText( - _translate("MainWindow", "View port access statistics") + QCoreApplication.translate( + "MainWindow", "View port access statistics", None + ) ) + # if QT_CONFIG(tooltip) self.action_view_port_accesses.setToolTip( - _translate("MainWindow", "View port access statistics for storage") + QCoreApplication.translate( + "MainWindow", "View port access statistics for storage", None + ) + ) + # endif // QT_CONFIG(tooltip) + self.actionUndo.setText(QCoreApplication.translate("MainWindow", "Undo", None)) + # if QT_CONFIG(shortcut) + self.actionUndo.setShortcut( + QCoreApplication.translate("MainWindow", "Ctrl+Z", None) + ) + # endif // QT_CONFIG(shortcut) + self.actionRedo.setText(QCoreApplication.translate("MainWindow", "Redo", None)) + # if QT_CONFIG(shortcut) + self.actionRedo.setShortcut( + QCoreApplication.translate("MainWindow", "Ctrl+Y, Ctrl+Shift+Z", None) ) - self.actionUndo.setText(_translate("MainWindow", "Undo")) - self.actionUndo.setShortcut(_translate("MainWindow", "Ctrl+Z")) - self.actionRedo.setText(_translate("MainWindow", "Redo")) - self.actionRedo.setShortcut(_translate("MainWindow", "Ctrl+R")) + # endif // QT_CONFIG(shortcut) self.actionIncrease_time_resolution.setText( - _translate("MainWindow", "Increase time resolution...") + QCoreApplication.translate( + "MainWindow", "Increase time resolution...", None + ) ) self.actionDecrease_time_resolution.setText( - _translate("MainWindow", "Decrease time resolution...") + QCoreApplication.translate( + "MainWindow", "Decrease time resolution...", None + ) + ) + self.actionZoom_to_fit.setText( + QCoreApplication.translate("MainWindow", "Zoom to &fit", None) ) - self.actionZoom_to_fit.setText(_translate("MainWindow", "Zoom to &fit")) - self.actionStatus_bar.setText(_translate("MainWindow", "&Status bar")) + self.actionStatus_bar.setText( + QCoreApplication.translate("MainWindow", "&Status bar", None) + ) + # if QT_CONFIG(tooltip) self.actionStatus_bar.setToolTip( - _translate("MainWindow", "Show/hide status bar") + QCoreApplication.translate("MainWindow", "Show/hide status bar", None) + ) + # endif // QT_CONFIG(tooltip) + self.actionToolbar.setText( + QCoreApplication.translate("MainWindow", "&Toolbar", None) + ) + # if QT_CONFIG(tooltip) + self.actionToolbar.setToolTip( + QCoreApplication.translate("MainWindow", "Show/hide toolbar", None) ) - self.actionToolbar.setText(_translate("MainWindow", "&Toolbar")) - self.actionToolbar.setToolTip(_translate("MainWindow", "Show/hide toolbar")) + # endif // QT_CONFIG(tooltip) self.action_show_port_numbers.setText( - _translate("MainWindow", "S&how port numbers") + QCoreApplication.translate("MainWindow", "S&how port numbers", None) ) + # if QT_CONFIG(tooltip) self.action_show_port_numbers.setToolTip( - _translate("MainWindow", "Show port numbers of operation") + QCoreApplication.translate( + "MainWindow", "Show port numbers of operation", None + ) ) + # endif // QT_CONFIG(tooltip) self.action_incorrect_execution_time.setText( - _translate("MainWindow", "&Incorrect execution time") + QCoreApplication.translate("MainWindow", "&Incorrect execution time", None) ) + # if QT_CONFIG(tooltip) self.action_incorrect_execution_time.setToolTip( - _translate( + QCoreApplication.translate( "MainWindow", "Highlight processes with execution time longer than schedule time", + None, ) ) - self.menu_open.setText(_translate("MainWindow", "&Open...")) + # endif // QT_CONFIG(tooltip) + self.menu_open.setText( + QCoreApplication.translate("MainWindow", "&Open...", None) + ) + # if QT_CONFIG(tooltip) self.menu_open.setToolTip( - _translate("MainWindow", "Open previously saved schedule") + QCoreApplication.translate( + "MainWindow", "Open previously saved schedule", None + ) + ) + # endif // QT_CONFIG(tooltip) + # if QT_CONFIG(shortcut) + self.menu_open.setShortcut( + QCoreApplication.translate("MainWindow", "Ctrl+O", None) ) - self.menu_open.setShortcut(_translate("MainWindow", "Ctrl+O")) + # endif // QT_CONFIG(shortcut) self.actionToggle_full_screen.setText( - _translate("MainWindow", "Toggle f&ull screen") + QCoreApplication.translate("MainWindow", "Toggle f&ull screen", None) + ) + # if QT_CONFIG(shortcut) + self.actionToggle_full_screen.setShortcut( + QCoreApplication.translate("MainWindow", "F11", None) + ) + # endif // QT_CONFIG(shortcut) + self.actionPreferences.setText( + QCoreApplication.translate("MainWindow", "Preferences", None) + ) + # if QT_CONFIG(tooltip) + self.actionPreferences.setToolTip( + QCoreApplication.translate("MainWindow", "Color and Fonts", None) + ) + # endif // QT_CONFIG(tooltip) + # if QT_CONFIG(shortcut) + self.actionPreferences.setShortcut( + QCoreApplication.translate("MainWindow", "Ctrl+M", None) + ) + # endif // QT_CONFIG(shortcut) + ___qtablewidgetitem = self.info_table.horizontalHeaderItem(0) + ___qtablewidgetitem.setText( + QCoreApplication.translate("MainWindow", "Property", None) + ) + ___qtablewidgetitem1 = self.info_table.horizontalHeaderItem(1) + ___qtablewidgetitem1.setText( + QCoreApplication.translate("MainWindow", "Value", None) + ) + ___qtablewidgetitem2 = self.info_table.verticalHeaderItem(0) + ___qtablewidgetitem2.setText( + QCoreApplication.translate("MainWindow", "1", None) + ) + ___qtablewidgetitem3 = self.info_table.verticalHeaderItem(1) + ___qtablewidgetitem3.setText( + QCoreApplication.translate("MainWindow", "2", None) + ) + + __sortingEnabled = self.info_table.isSortingEnabled() + self.info_table.setSortingEnabled(False) + ___qtablewidgetitem4 = self.info_table.item(0, 0) + ___qtablewidgetitem4.setText( + QCoreApplication.translate("MainWindow", "Schedule", None) + ) + ___qtablewidgetitem5 = self.info_table.item(1, 0) + ___qtablewidgetitem5.setText( + QCoreApplication.translate("MainWindow", "Operator", None) + ) + self.info_table.setSortingEnabled(__sortingEnabled) + + self.menuFile.setTitle(QCoreApplication.translate("MainWindow", "&File", None)) + self.menu_Recent_Schedule.setTitle( + QCoreApplication.translate("MainWindow", "Open &recent", None) ) - self.actionToggle_full_screen.setShortcut(_translate("MainWindow", "F11")) + self.menuView.setTitle(QCoreApplication.translate("MainWindow", "&View", None)) + self.menu_view_execution_times.setTitle( + QCoreApplication.translate( + "MainWindow", "View execution times of type", None + ) + ) + self.menu_Edit.setTitle(QCoreApplication.translate("MainWindow", "&Edit", None)) + self.menuWindow.setTitle( + QCoreApplication.translate("MainWindow", "&Window", None) + ) + self.menuHelp.setTitle(QCoreApplication.translate("MainWindow", "&Help", None)) + self.toolBar.setWindowTitle( + QCoreApplication.translate("MainWindow", "toolBar", None) + ) + pass + + # retranslateUi diff --git a/test/conftest.py b/test/conftest.py index 138fefe00e2bcb08efdbd238f297181febffe186..aa7b33341a7634662738570da88fefe9b2b558f1 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -4,7 +4,7 @@ from test.fixtures.operation_tree import * from test.fixtures.port import * from test.fixtures.resources import * from test.fixtures.schedule import * -from test.fixtures.signal import signal, signals +from test.fixtures.signal import signal, signals # noqa: F401 from test.fixtures.signal_flow_graph import * import pytest diff --git a/test/test_sfg.py b/test/test_sfg.py index 2c1b8f118b556aac10c68b13ad29bc1a6cb2b4e1..6ece6b74ab738baace869143a3f2dd0a800d8f6d 100644 --- a/test/test_sfg.py +++ b/test/test_sfg.py @@ -1352,7 +1352,8 @@ class TestSFGErrors: out1 = Output(adaptor.output(0)) out2 = Output() with pytest.raises( - ValueError, match="At least one output operation is not connected!, Tips: Check for output ports that are connected to the same signal" + ValueError, + match="At least one output operation is not connected!, Tips: Check for output ports that are connected to the same signal", ): SFG([in1, in2], [out1, out2]) @@ -1424,7 +1425,8 @@ class TestSFGErrors: out1 = Output(adaptor.output(0)) signal = Signal(adaptor.output(1)) with pytest.raises( - ValueError, match="At least one output operation is not connected!, Tips: Check for output ports that are connected to the same signal" + ValueError, + match="At least one output operation is not connected!, Tips: Check for output ports that are connected to the same signal", ): SFG([in1, in2], [out1], output_signals=[signal, signal])