From cb7fc792738fc7b82b4e68d70dba91b02b2e53da Mon Sep 17 00:00:00 2001 From: Robier Al Kaadi <robal695@student.liu.se> Date: Fri, 26 Jul 2024 15:45:48 +0200 Subject: [PATCH] Solve Preference dialogue for scheduler GUI --- .gitlab-ci.yml | 2 +- b_asic/scheduler_gui/main_window.py | 72 +++++++++++++++++++++++------ 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 983895ad..32946f44 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -130,7 +130,7 @@ run-doc-test: - pip install black velin - velin . --check --black - pip install ruff - - ruff b_asic --output-format=gitlab > ruff.json + - ruff check b_asic --output-format=gitlab > ruff.json artifacts: name: "${CI_PROJECT_NAME}_code_quality" when: always diff --git a/b_asic/scheduler_gui/main_window.py b/b_asic/scheduler_gui/main_window.py index 509f8428..b7940b79 100644 --- a/b_asic/scheduler_gui/main_window.py +++ b/b_asic/scheduler_gui/main_window.py @@ -1146,7 +1146,10 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): dialog.exec_() def creat_color_button(self, color: ColorDataType) -> ColorButton: - """Create a colored button to be used to modify a certain color""" + """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": @@ -1162,7 +1165,10 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): return button def set_latency_color_by_type_name(self, all: bool): - """Set latency color based on operation type names""" + """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: @@ -1203,7 +1209,7 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): 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 self._color_changed_perType): + 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(): @@ -1240,7 +1246,10 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): ) def Color_button_clicked(self, color_type: ColorDataType): - """Open a color dialog to select a color based on the specified color type""" + """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 @@ -1264,7 +1273,14 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): def font_clicked( self, Sizeline: QLineEdit, italicbutton: ColorButton, boldbutton: ColorButton ): - """Open a font dialog to select a font and update the current font""" + """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: @@ -1358,13 +1374,19 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): 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""" + """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""" + """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) ( @@ -1375,7 +1397,10 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): self.Update_font() def Bold_font_clicked(self, button: ColorButton): - """Toggle the font style to bold if not already bold, otherwise unbold""" + """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) @@ -1387,15 +1412,22 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): self.Update_font() def Incr_font_clicked(self, line: QLineEdit): - """Increase the font size by 1""" - ( + """ + 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""" + """ + 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 @@ -1432,7 +1464,14 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): def reset_font_clicked( self, Sizeline: QLineEdit, italicbutton: ColorButton, boldbutton: ColorButton ): - """Reset the font settings""" + """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 @@ -1453,7 +1492,14 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): def Match_Dialog_Font( self, Sizeline: QLineEdit, italicbutton: ColorButton, boldbutton: ColorButton ): - """Update the widgets on the pref dialog to match the current font""" + """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)) ( -- GitLab