Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.

Conversation

@ggoneiESS
Copy link
Member

Issue

We want to move the add component window from being a window to being a widget. The behaviour should be similar, but NOT block the navigation of the tree or other components. The behaviour should otherwise be the same.

Description of work

QDialog is a child of QWidget, so that is simple to change. However, the window object is normally deleted, and that is something we want to avoid, so instead we use the hidden attribute. The height of the window changes based on what it is populated with.

Acceptance Criteria

Files associated with the 'add component' window

UI tests

All tests still valid

Nominate for Group Code Review

  • Nominate for code review

@ggoneiESS ggoneiESS self-assigned this Oct 30, 2023
Co-authored-by: Matt Clarke <[email protected]>

def _cancel_new_group(self):
if self._confirm_cancel():
self._rejected()
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you tried seeing what happens if you spam the edit button after selecting a group?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have reintroduced the bug where multiple panes appear. I don't think the relevant code is in this part but in mainwindow.py .

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't pick this piece of code specifically. I just needed somewhere to report it and was too lazy to do a proper comment :D

Copy link
Member Author

Choose a reason for hiding this comment

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

had to check the attribute existed again but it's a cleaner fix than initially (no try catch)

@ggoneiESS ggoneiESS requested a review from mattclarke October 30, 2023 09:51
if hasattr(self, "add_component_window") and not self.add_component_window.isHidden():
self.add_component_window._rejected()
self.add_component_window.setHidden(True)

Copy link
Contributor

Choose a reason for hiding this comment

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

This is just a variation of the hack you were unhappy with last week.
It is also just papering over the cracks.

The question to ponder is: why are we creating a new AppComponentDialog every time?

Copy link
Member Author

Choose a reason for hiding this comment

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

I see the point - the answer is because each component is different in terms of parent node, type etc. You can see in :120 when we edit a group the difference is we pass a different flag which states whether we use empty groups or existing groups. It doesn't simply 'fill in' the dialog/window etc, but creates a new object that has many members initialised with particular values which are important for various methods in the dialog (for example, remembering where the component goes after it is made, or remembering the initial state of the group so it can be restored if the user cancels it). However, there are various object inside the AddComponentDialog class, such as the main UI layout, that mean it makes sense to have as a separate part (rather than as part of this MainWindow class). Finally, the dialog is deleted afterwards so we are not getting a memory leak or anything like that.

I've removed the hasattr check, and now we have have a clean and consistent way of handling the dialog

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not clean.

Repeated clicks of the edit button each create a new AppComponentDialog which are possibly not destructed (I see the memory usage increase on my machine at least).

It should not be necessary to construct a new AppComponentDialog every time just to pass some values into it, i.e. add a method something like def set_initial_values(group, is_new_group).

self.component_tree_view_tab.set_up_model(self.model)
self._update_views()
self.simple_tree_view.triggered.emit()
self.add_component_window = QWidget()
Copy link
Contributor

@mattclarke mattclarke Oct 30, 2023

Choose a reason for hiding this comment

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

This is where you should create the (reusable) AppComponentDialog.

@ggoneiESS ggoneiESS marked this pull request as draft November 2, 2023 15:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants