Skip to content

Conversation

@TrigamDev
Copy link
Contributor

@TrigamDev TrigamDev commented Oct 31, 2025

Summary

Various refactors of the different entry field widgets (field_widget.py, text_field.py, color_box.py, and tag_box_view.py/tag_box_controller.py).

  • Field widgets have been grouped into a fields directory under their respective directories (so views/fields and controllers/fields) to make locating them easier.
    • I'm aware that this isn't reflective of the current organization of the frontend, and can revert the change if this is an unwanted one. I've just personally found the lack of organization of the frontend a bit tedious to work with, and would love to see more deliberate organization as opposed to big, unorganized lists of files. Again, though, this can be reverted if this is something that's unwanted.
  • Field widgets have been split (where applicable) and moved from mixed into either views/fields or controllers/fields.
  • Some field widgets have had their file and/or class names changed for consistency.
  • Docstrings and return types have been added to most classes and methods.
  • Some variables and methods have been renamed to be more descriptive, consistent, or better fitting.
  • Some code has had spacing tweaks and comments added to help improve readability, particularly in large, repetitive sections of UI initialization.

mixed/field_widget.py

  • field_widget.py has had it's classes FieldWidget and FieldContainer split into their own files, views/preview_panel/fields/field_widget.py and views/preview_panel/fields/field_container.py.
    • Having both the base class that field widgets inherit from and the container widget both in the same file isn't the best idea in my opinion. Both classes serve fairly different purposes, and having both in the same file makes either a bit difficult to find. Having them split makes things simpler and easier.
  • The stylesheet and icons have been moved from inside the class to above it.
    • The stylesheet has also been changed to use a multi-line f-string.
  • root_layout has been renamed to __root_layout for consistency.
  • FieldContainer.set_inner_widget() and variables referencing inner_widget have been renamed to set_field_widget() and field_widget respectively.
    • This makes the intention more obvious. A FieldContainer's field_widget is more intuitive than an inner_widget, which can easily be confused for something internal and not the intended method.
  • root_layout has been renamed to base_layout for consistency.
  • inner_layout has been renamed to container_layout.
  • In the enterEvent, the copy, edit, and remove buttons now have their visibility set to whether their respective callback is None, as opposed to conditionally setting it to false.
    • This helps reduce the number of lines needed while retaining the same behavior.
    • As an example:
      if self.__copy_callback:
          self.copy_button.setHidden(False)
      to
      self.copy_button.setHidden(self.__copy_callback is None)
  • In the leaveEvent, the checks for callbacks have been removed, now setting all the buttons to hidden regardless of if they have a callback or not.
    • I'm not entirely sure why this was there in the first place. The buttons will be hidden if they don't have a callback, so avoiding setting the buttons without a callback to be hidden is redundant. Also, it could potentially lead to issues where if a button were to somehow have it's callback removed while visible, it would then not be set to hidden upon the cursor leaving the field container, becoming permanently stuck as visible.

Things to look into:

  • The field container widget itself is named "fieldContainer", but contains a child widget also named "fieldContainer".

mixed/text_field.py

  • Moved and renamed to views/preview_panel/fields/text_field_widget.py.
  • TextWidget has been renamed to TextFieldWidget.
  • base_layout has been renamed to __root_layout for consistency.

mixed/color_box.py

  • Split into a view and controller in accordance to doc: Add QT MVC structure to style guide #950.
    • Located at views/preview_panel/fields/color_box_widget_view.py and controllers/preview_panel/fields/color_box_widget_controller.py.
  • base_layout has been renamed to __root_layout for consistency.
  • update signal has been renamed to on_update to be more consistent with the tag box widget.
  • The 'add button' stylesheet has been moved from inside the class to above it.
    • Again, the stylesheet has also been changed to use a multi-line f-string.
  • edit_color() and delete_color() have been renamed to _on_edit_color() and _on_delete_color().

views/tag_box_view.py

  • Moved and renamed to views/tag_box_widget_view.py.

controllers/tag_box_controller.py

  • Moved and renamed to controllers/tag_box_widget_controller.py.

Tasks Completed

  • Platforms Tested:
    • Windows x86
    • Windows ARM
    • macOS x86
    • macOS ARM
    • Linux x86
    • Linux ARM
  • Tested For:
    • Basic functionality
    • PyInstaller executable

@TrigamDev TrigamDev marked this pull request as ready for review October 31, 2025 19:20
@TrigamDev TrigamDev mentioned this pull request Nov 4, 2025
8 tasks
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