Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Fix Qt flags #1041

Merged
merged 2 commits into from
Dec 8, 2023
Merged

refactor: Fix Qt flags #1041

merged 2 commits into from
Dec 8, 2023

Conversation

Czaki
Copy link
Collaborator

@Czaki Czaki commented Dec 7, 2023

Instead of using global Qt or Widget namespaces for enum selection point, enum directly.

Summary by CodeRabbit

  • New Features

    • Enhanced the About dialog to support parent window association for better modal behavior.
    • Advanced tabs, mask control, and advanced window classes now accept a parent argument for improved widget hierarchy management.
    • Profile selection and color map creation processes have been refined with updated initialization parameters.
    • Custom load and save dialog conditions and method calls have been updated for consistency with the latest dialog standards.
  • Bug Fixes

    • Corrected the context menu policy settings for various GUI components to align with updated Qt enumerations.
    • Adjusted file dialog acceptance checks to use the revised dialog code enumeration.
    • Resolved issues with incorrect enum usage in searchable combo boxes and list widgets, ensuring proper item filtering and selection behavior.
  • Documentation

    • Updated comments and docstrings across multiple modules for better clarity and understanding of the codebase.
  • Refactor

    • Standardized the use of enum values across the application, replacing direct value usage with fully qualified enum names for better code maintainability and readability.
  • Style

    • Minor stylistic changes in comments and method calls to adhere to the updated coding standards and conventions.

Please note that these changes are aimed at improving the user experience and ensuring compatibility with the latest standards and practices in application development.

@Czaki Czaki added this to the 0.15.3 milestone Dec 7, 2023
Copy link
Contributor

coderabbitai bot commented Dec 7, 2023

Walkthrough

The changes across various Python files in the package primarily involve updating method calls and enum references to use fully qualified names, adding parent parameters to class constructors for better widget management, and improving comments and docstrings. These updates suggest a shift towards more explicit and possibly more robust code, likely in response to updates in the PyQt library or to adhere to best practices.

Changes

File Path Change Summary
.../about_dialog.py Added parent parameter to AboutDialog constructor.
.../advanced_tabs.py, .../algorithms_description.py, .../colormap_creator.py, .../image_adjustment.py, .../napari_image_view.py, .../searchable_combo_box.py, .../universal_gui_part.py Added parent parameter to class constructors and updated enum references.
.../collapse_checkbox.py Updated comments and changed Qt.TextSingleLine to Qt.TextFlag.TextSingleLine.
.../custom_load_dialog.py, .../custom_save_dialog.py, .../error_report.py, .../multiple_file_widget.py, .../select_multiple_files.py, .../show_directory_dialog.py Updated method calls and enum references to fully qualified names.
.../flow_layout.py Changed QSizePolicy.PushButton to QSizePolicy.ControlType.PushButton.
.../numpy_qimage.py Updated QImage format declaration to QImage.Format.Format_RGBA8888.
.../qt_modal.py Included QKeyEvent import and updated Qt constants to WindowType enum.
.../searchable_list_widget.py Replaced Qt.MatchContains with Qt.MatchFlag.MatchContains.

🐇✨
A hop of code, a leap of enums,
Refactoring's done, the code now hums.
With parents set, and types so clear,
CodeRabbit's work brings cheer! 🎉🐰

 (\(\  
 ( -.-)  
 o_(")(")  

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

@Czaki Czaki changed the title Fix Qt flags refactor: Fix Qt flags Dec 7, 2023
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between fb4a266 and bae1c06.
Files selected for processing (19)
  • package/PartSeg/common_gui/about_dialog.py (2 hunks)
  • package/PartSeg/common_gui/advanced_tabs.py (4 hunks)
  • package/PartSeg/common_gui/algorithms_description.py (3 hunks)
  • package/PartSeg/common_gui/collapse_checkbox.py (2 hunks)
  • package/PartSeg/common_gui/colormap_creator.py (2 hunks)
  • package/PartSeg/common_gui/custom_load_dialog.py (1 hunks)
  • package/PartSeg/common_gui/custom_save_dialog.py (3 hunks)
  • package/PartSeg/common_gui/error_report.py (2 hunks)
  • package/PartSeg/common_gui/flow_layout.py (1 hunks)
  • package/PartSeg/common_gui/image_adjustment.py (1 hunks)
  • package/PartSeg/common_gui/multiple_file_widget.py (6 hunks)
  • package/PartSeg/common_gui/napari_image_view.py (1 hunks)
  • package/PartSeg/common_gui/numpy_qimage.py (1 hunks)
  • package/PartSeg/common_gui/qt_modal.py (3 hunks)
  • package/PartSeg/common_gui/searchable_combo_box.py (1 hunks)
  • package/PartSeg/common_gui/searchable_list_widget.py (1 hunks)
  • package/PartSeg/common_gui/select_multiple_files.py (4 hunks)
  • package/PartSeg/common_gui/show_directory_dialog.py (1 hunks)
  • package/PartSeg/common_gui/universal_gui_part.py (5 hunks)
Files skipped from review due to trivial changes (2)
  • package/PartSeg/common_gui/flow_layout.py
  • package/PartSeg/common_gui/show_directory_dialog.py
Additional comments: 46
package/PartSeg/common_gui/about_dialog.py (3)
  • 13-14: The addition of the parent parameter to the AboutDialog constructor is consistent with the PR's objective to improve widget management and maintainability.

  • 50-50: The QGridLayout constructor is correctly initialized with self as the parent widget, which is a good practice for ensuring proper ownership and cleanup of the layout.

  • 46-53: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [13-53]

The summary mentions updates to method calls and layout initialization to use the parent argument, but the parent argument is not used in the hunk provided. Please verify if the summary is accurate or if additional changes are expected in the code.

package/PartSeg/common_gui/advanced_tabs.py (4)
  • 236-238: The summary indicates a change in the AdvancedWindow class constructor's settings parameter type from ViewSettings to BaseSettings, but the provided hunk already uses BaseSettings. This might be an outdated summary or the change was made prior to this hunk.

  • 86-86: The summary suggests that the MaskControl class constructor should accept a BaseSettings object, but the hunk shows it still accepts a ViewSettings object. If the PR objective includes this change, the constructor needs to be updated.

  • 54-54: The addition of the parent parameter to the DevelopTab class constructor aligns with the PR objectives to improve widget management.

  • 90-92: Direct manipulation of UI elements in the MaskControl constructor is acceptable, but ensure it aligns with the PR objectives and UI consistency across the application.

package/PartSeg/common_gui/algorithms_description.py (3)
  • 74-77: The addition of the parent parameter to the ProfileSelect class constructor is consistent with the PR objective to improve widget management.

  • 191-193: The explicit specification of the parent parameter as None when instantiating ChannelComboBox aligns with the PR objective to enhance code clarity.

  • 207-208: The explicit specification of the parent parameter as None when instantiating QComboBox objects aligns with the PR objective to enhance code clarity.

package/PartSeg/common_gui/collapse_checkbox.py (2)
  • 28-28: The change from Qt.TextSingleLine to Qt.TextFlag.TextSingleLine is consistent with the PR's objective to use fully qualified enum names for clarity.

  • 13-20: The addition of periods at the end of sentences in the comments improves readability and consistency in documentation style.

package/PartSeg/common_gui/colormap_creator.py (3)
  • 88-96: The use of Qt.GlobalColor constants for brush colors in the paintEvent method is consistent with the PR's objective to improve enum referencing.

  • 498-498: The inclusion of the self parameter in the central_widget initialization is correct and follows best practices for PyQt widget hierarchy.

  • 495-501: The changes in the ColormapList class constructor seem to be related to layout initialization and widget setup, which is not directly mentioned in the summary. However, these changes do not appear to alter the enum usage and are likely part of the general codebase improvements.

package/PartSeg/common_gui/custom_load_dialog.py (1)
  • 150-155: The change from QFileDialog.Accepted to QFileDialog.DialogCode.Accepted aligns with the PR's objective to use fully qualified enum names, enhancing code clarity and maintainability.
package/PartSeg/common_gui/custom_save_dialog.py (3)
  • 59-70: The changes to the enum references in the CustomSaveDialog constructor align with the PR's objective to use fully qualified enum names, which should improve code clarity and maintainability.

  • 161-167: The changes to the enum references in the PSaveDialog constructor align with the PR's objective to use fully qualified enum names, which should improve code clarity and maintainability.

  • 183-189: The changes to the accept method in PSaveDialog are consistent with the PR's objective to use fully qualified enum names, and the logic for updating the settings with the directory and filter path is maintained.

package/PartSeg/common_gui/error_report.py (2)
  • 259-267: The change from QListWidgetItem.UserType to QListWidgetItem.ItemType.UserType aligns with the PR's objective to use fully qualified enum names for clarity and maintainability.

  • 360-363: The change from QMessageBox.Ok to QMessageBox.StandardButton.Ok aligns with the PR's objective to use fully qualified enum names for clarity and maintainability.

package/PartSeg/common_gui/image_adjustment.py (1)
  • 22-26: The change to call get_fields_per_dimension with list(image.get_dimension_letters()) ensures that the method receives the correct data type. This is a good practice to avoid potential issues if the method expects a list and not another iterable type.
package/PartSeg/common_gui/multiple_file_widget.py (6)
  • 42-48: The update to use fully qualified enum Qt.ContextMenuPolicy.CustomContextMenu is consistent with the PR's objective to improve enum referencing.

  • 69-71: The update to use fully qualified enum Qt.CursorShape.ArrowCursor is consistent with the PR's objective to improve enum referencing.

  • 79-86: The update to use fully qualified enum QAbstractItemView.SelectionMode.ExtendedSelection and Qt.ItemDataRole.UserRole is consistent with the PR's objective to improve enum referencing.

  • 107-111: The usage of fully qualified enum Qt.ItemDataRole.UserRole in the get_files method is consistent with the PR's objective to improve enum referencing.

  • 281-287: The update to use fully qualified enum Qt.TextElideMode.ElideLeft in the save_state_action method is consistent with the PR's objective to improve enum referencing.

  • 382-388: The update to use fully qualified enum QFileDialog.FileMode.ExistingFiles in the MultipleLoadDialog constructor is consistent with the PR's objective to improve enum referencing.

package/PartSeg/common_gui/napari_image_view.py (1)
  • 171-177: The change from Qt.CustomContextMenu to Qt.ContextMenuPolicy.CustomContextMenu for setting the context menu policy of roll_dim_button aligns with the PR's objective to use fully qualified enum names for clarity and maintainability.
package/PartSeg/common_gui/numpy_qimage.py (1)
  • 19-24: The change from QImage.Format_RGBA8888 to QImage.Format.Format_RGBA8888 correctly uses the fully qualified enum name, which is consistent with the PR's objective to improve enum referencing.
package/PartSeg/common_gui/qt_modal.py (5)
  • 3-3: The import statement has been updated to include QKeyEvent, which is consistent with the PR objective to use fully qualified names.

  • 37-37: The addition of the parent parameter to the QtPopup class constructor is consistent with the PR objective and improves widget management.

  • 40-40: The setWindowFlags method call has been updated to use the WindowType enum, which is consistent with the PR objective and enhances code clarity.

  • 124-124: The keyPressEvent method signature has been updated to include type hinting, which is consistent with the PR objective and improves code readability and maintainability.

  • 132-132: The comparison of key codes in the keyPressEvent method has been updated to use the Key enum from Qt.Key, which is consistent with the PR objective and enhances code clarity.

package/PartSeg/common_gui/searchable_combo_box.py (1)
  • 16-26: The changes to the enum values in the SearchComboBox class constructor are correct and align with the PR's objective to use fully qualified enum names for clarity and maintainability.
package/PartSeg/common_gui/searchable_list_widget.py (1)
  • 24-28: The update to use Qt.MatchFlag.MatchContains in the findItems method call is consistent with the PR's objective to use fully qualified enum names for clarity and maintainability.
package/PartSeg/common_gui/select_multiple_files.py (4)
  • 41-41: The change to use the fully qualified name for the enum SelectionMode.ExtendedSelection is consistent with the PR's objective to improve enum referencing.

  • 81-81: The change to use the fully qualified name for the enum ContextMenuPolicy.CustomContextMenu is consistent with the PR's objective to improve enum referencing.

  • 198-198: The change to use the fully qualified name for the enum StandardButton.Ok in the QMessageBox call is consistent with the PR's objective to improve enum referencing.

  • 212-212: The change to use the fully qualified name for the enum FileMode.ExistingFiles in the QFileDialog call is consistent with the PR's objective to improve enum referencing.

package/PartSeg/common_gui/universal_gui_part.py (5)
  • 141-153: The changes to use fully qualified enum names in the Spacing class align with the PR's objective and enhance code clarity.

  • 173-176: The update to use fully qualified enum names in the right_label function is consistent with the PR's objective and improves code readability.

  • 191-195: The update to use a fully qualified enum name in the CustomSpinBox class is consistent with the PR's objective and improves code readability.

  • 210-214: The update to use a fully qualified enum name in the CustomDoubleSpinBox class is consistent with the PR's objective and improves code readability.

  • 352-356: The update to use a fully qualified enum name in the TextShow class is consistent with the PR's objective and improves code readability.


# noinspection PyArgumentList
self.reload_btn = QPushButton("Reload algorithms", clicked=self.reload_algorithm_action)
layout = QGridLayout()
layout = QGridLayout(self)
layout.addWidget(self.reload_btn, 0, 0)
layout.setColumnStretch(1, 1)
layout.setRowStretch(1, 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing or redirecting the debug print statements from sys.stderr to a logging framework for better control over the output in the reload_algorithm_action method.

Copy link

codecov bot commented Dec 7, 2023

Codecov Report

Attention: Patch coverage is 93.33333% with 4 lines in your changes missing coverage. Please review.

Project coverage is 92.29%. Comparing base (43c0be1) to head (23a9f78).
Report is 128 commits behind head on develop.

Files with missing lines Patch % Lines
package/PartSeg/common_gui/error_report.py 33.33% 2 Missing ⚠️
package/PartSeg/common_gui/multiple_file_widget.py 87.50% 1 Missing ⚠️
...ackage/PartSeg/common_gui/select_multiple_files.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1041      +/-   ##
===========================================
+ Coverage    92.25%   92.29%   +0.04%     
===========================================
  Files          206      206              
  Lines        32318    32321       +3     
===========================================
+ Hits         29814    29831      +17     
+ Misses        2504     2490      -14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

sonarcloud bot commented Dec 8, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between bae1c06 and 23a9f78.
Files selected for processing (1)
  • package/tests/test_PartSeg/test_colormap_create.py (2 hunks)
Additional comments: 3
package/tests/test_PartSeg/test_colormap_create.py (3)
  • 36-36: The addition of the qapp parameter to the test_click method is consistent with the PR objectives to improve code clarity and maintainability.

  • 38-38: The call to widget.show() before qtbot.addWidget(widget) ensures that the widget is properly initialized for the test.

  • 51-52: The calls to qapp.processEvents() and widget.hide() at the end of the test ensure that any pending events are processed and the widget is hidden after the test, which is good for test isolation and cleanup.

@Czaki Czaki merged commit 107c615 into develop Dec 8, 2023
50 checks passed
@Czaki Czaki deleted the fix_qt_flags branch December 8, 2023 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant