diff --git a/rascal2/dialogs/project_dialog.py b/rascal2/dialogs/project_dialog.py index d6373c2..926f73c 100644 --- a/rascal2/dialogs/project_dialog.py +++ b/rascal2/dialogs/project_dialog.py @@ -8,7 +8,7 @@ class ProjectDialog(QtWidgets.QDialog): """ - The Project Dialog + The Project dialog """ _button_style = """background-color: {}; @@ -25,7 +25,7 @@ class ProjectDialog(QtWidgets.QDialog): def __init__(self, parent): """ - Initializes the dialog + Initialize dialog. Parameters ---------- @@ -41,13 +41,13 @@ def __init__(self, parent): self.name_error = False self.folder_error = False - self.create_project_dialog_labels() - self.create_project_dialog_buttons() + self.create_buttons() + self.create_labels() self.add_widgets_to_layout() def add_widgets_to_layout(self) -> None: """ - Adds the widgets to the layout + Add widgets to the layout. """ self.main_layout = QtWidgets.QVBoxLayout() @@ -79,9 +79,9 @@ def add_widgets_to_layout(self) -> None: self.setLayout(self.main_layout) - def create_project_dialog_labels(self) -> None: + def create_labels(self) -> None: """ - Creates the labels for the project dialog. + Create labels. """ # Project name labels self.project_name_label = QtWidgets.QLabel("Project Name:", self) @@ -108,17 +108,17 @@ def create_project_dialog_labels(self) -> None: self.project_folder_error.setStyleSheet(self._error_style) self.project_folder_error.hide() - def create_project_dialog_buttons(self) -> None: + def create_buttons(self) -> None: """ - Creates the buttons for the project dialog. + Create buttons. """ self.browse_button = QtWidgets.QPushButton(" Browse", self) - self.browse_button.setIcon(QtGui.QIcon(path_for("open-project-light.png"))) + self.browse_button.setIcon(QtGui.QIcon(path_for("browse-light.png"))) self.browse_button.clicked.connect(self.open_folder_selector) self.browse_button.setStyleSheet(self._button_style.format("#403F3F")) self.create_button = QtWidgets.QPushButton(" Create", self) - self.create_button.setIcon(QtGui.QIcon(path_for("plus.png"))) + self.create_button.setIcon(QtGui.QIcon(path_for("create.png"))) self.create_button.clicked.connect(self.create_project) self.create_button.setStyleSheet(self._button_style.format("#0D69BB")) @@ -136,7 +136,7 @@ def cancel_project_creation(self) -> None: def reset_variables(self) -> None: """ - Resets the variables. + Reset variables. """ self.project_folder.setText("") self.project_name.setText("") @@ -145,7 +145,7 @@ def reset_variables(self) -> None: def open_folder_selector(self) -> None: """ - Opens the folder selector. + Open folder selector. """ folder_path = QtWidgets.QFileDialog.getExistingDirectory(self, "Select Folder") if folder_path: @@ -153,28 +153,26 @@ def open_folder_selector(self) -> None: if files_in_folder: self.handle_error("folder") else: - self.handle_non_error("folder") + self.handle_success("folder") self.project_folder.setText(folder_path) def handle_error(self, tag: Literal["name", "folder"]) -> None: """ - Displays the line edit error msgs. + Display error msgs. Parameters ---------- tag: Literal["name", "folder"] - Specifies whether the input verification - is for the project name or folder. + Specifies whether to show the error + for the project name or folder. """ - input = getattr(self, "project_" + tag) - input.setStyleSheet(self._line_edit_error_style) - error_label = getattr(self, "project_" + tag + "_error") - error_label.show() + getattr(self, "project_" + tag).setStyleSheet(self._line_edit_error_style) + getattr(self, "project_" + tag + "_error").show() setattr(self, tag + "_error", True) - def handle_non_error(self, tag: Literal["name", "folder"]) -> None: + def handle_success(self, tag: Literal["name", "folder"]) -> None: """ - Clears the style sheets of the error line edits. + Hide error msgs. Parameters ---------- @@ -182,15 +180,13 @@ def handle_non_error(self, tag: Literal["name", "folder"]) -> None: Specifies whether to clear the error for the project name or folder. """ - input = getattr(self, "project_" + tag) - input.setStyleSheet("") - error_label = getattr(self, "project_" + tag + "_error") - error_label.hide() + getattr(self, "project_" + tag).setStyleSheet("") + getattr(self, "project_" + tag + "_error").hide() setattr(self, tag + "_error", False) def verify_inputs(self, tag: Literal["name", "folder"]) -> None: """ - Verifies the name and folder inputs of the project dialog. + Verify inputs. Parameters ---------- @@ -201,11 +197,11 @@ def verify_inputs(self, tag: Literal["name", "folder"]) -> None: if getattr(self, "project_" + tag).text() == "": self.handle_error(tag) else: - self.handle_non_error(tag) + self.handle_success(tag) def create_project(self) -> None: """ - Verifies the inputs specified. + Create project if inputs verified. """ self.verify_inputs("name") self.verify_inputs("folder") diff --git a/rascal2/static/images/open-project.png b/rascal2/static/images/browse-dark.png similarity index 100% rename from rascal2/static/images/open-project.png rename to rascal2/static/images/browse-dark.png diff --git a/rascal2/static/images/open-project-light.png b/rascal2/static/images/browse-light.png similarity index 100% rename from rascal2/static/images/open-project-light.png rename to rascal2/static/images/browse-light.png diff --git a/rascal2/static/images/plus.png b/rascal2/static/images/create.png similarity index 100% rename from rascal2/static/images/plus.png rename to rascal2/static/images/create.png diff --git a/rascal2/ui/view.py b/rascal2/ui/view.py index 4d3a9a6..a1407b5 100644 --- a/rascal2/ui/view.py +++ b/rascal2/ui/view.py @@ -75,7 +75,7 @@ def createActions(self): self.open_project_action = QtGui.QAction("&Open", self) self.open_project_action.setStatusTip("Open an existing project") - self.open_project_action.setIcon(QtGui.QIcon(path_for("open-project.png"))) + self.open_project_action.setIcon(QtGui.QIcon(path_for("browse-dark.png"))) self.open_project_action.setShortcut(QtGui.QKeySequence.StandardKey.Open) self.save_project_action = QtGui.QAction("&Save", self) diff --git a/rascal2/widgets/startup_widget.py b/rascal2/widgets/startup_widget.py index a55d6d2..b9aeb2e 100644 --- a/rascal2/widgets/startup_widget.py +++ b/rascal2/widgets/startup_widget.py @@ -19,7 +19,7 @@ class StartUpWidget(QtWidgets.QWidget): def __init__(self, parent): """ - Initializes the widget + Initialize widget. Parameters ---------- @@ -29,14 +29,14 @@ def __init__(self, parent): super().__init__(parent) self.create_banner_and_footer() - self.create_buttons_for_startup_page() - self.create_labels_for_startup_page() + self.create_buttons() + self.create_labels() - self.add_widgets_to_startup_page_layout() + self.add_widgets_to_layout() - def add_widgets_to_startup_page_layout(self) -> None: + def add_widgets_to_layout(self) -> None: """ - Adds the widgets to the startup layout. + Add widgets to layout. """ startup_layout = QtWidgets.QVBoxLayout() @@ -62,44 +62,42 @@ def add_widgets_to_startup_page_layout(self) -> None: def create_banner_and_footer(self) -> None: """ - Creates the banner and footer for the startup page. + Create banner and footer. """ - # Create the banner self.banner_label = QtWidgets.QLabel(self) self.banner_label.setPixmap(QtGui.QPixmap(path_for("banner.png"))) self.banner_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) - # Create the footer self.footer_label = QtWidgets.QLabel(self) self.footer_label.setPixmap(QtGui.QPixmap(path_for("footer.png"))) self.footer_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) def toggle_view(self) -> None: """ - Shows the project dialog + Show ProjectDialog. """ self.parent().toggleView() - def create_buttons_for_startup_page(self) -> None: + def create_buttons(self) -> None: """ - Creates the buttons for the startup page. + Create buttons. """ self.new_project_button = QtWidgets.QPushButton(self) - self.new_project_button.setIcon(QtGui.QIcon(path_for("plus.png"))) + self.new_project_button.setIcon(QtGui.QIcon(path_for("create.png"))) self.new_project_button.clicked.connect(self.toggle_view) self.new_project_button.setStyleSheet(self._button_style) self.import_project_button = QtWidgets.QPushButton(self) - self.import_project_button.setIcon(QtGui.QIcon(path_for("open-project-light.png"))) + self.import_project_button.setIcon(QtGui.QIcon(path_for("browse-light.png"))) self.import_project_button.setStyleSheet(self._button_style) self.import_r1_button = QtWidgets.QPushButton(self) self.import_r1_button.setIcon(QtGui.QIcon(path_for("import-r1.png"))) self.import_r1_button.setStyleSheet(self._button_style) - def create_labels_for_startup_page(self) -> None: + def create_labels(self) -> None: """ - Creates the labels for the startup page. + Create labels. """ self.new_project_label = QtWidgets.QLabel("New\nProject", self) self.new_project_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) diff --git a/tests/test_dialogs.py b/tests/test_dialogs.py index e43b2a6..c5ed412 100644 --- a/tests/test_dialogs.py +++ b/tests/test_dialogs.py @@ -25,7 +25,7 @@ def setup_project_dialog_widget(): def test_project_dialog_initial_state(setup_project_dialog_widget): """ - Tests the inital state of the project dialog. + Tests the inital state of the ProjectDialog class. """ project_dialog, _ = setup_project_dialog_widget @@ -57,9 +57,9 @@ def test_project_dialog_initial_state(setup_project_dialog_widget): assert not project_dialog.folder_error -def test_lineedit_errors(setup_project_dialog_widget): +def test_inline_error_msgs(setup_project_dialog_widget): """ - Tests the project name and folder line edit errors displayed. + Tests the project name and folder inline errors. """ project_dialog, _ = setup_project_dialog_widget