zxcalc / zxlive

A graphical tool for the ZX calculus
Apache License 2.0
45 stars 15 forks source link

Make dialogs API more consistent #156

Open dlyongemallo opened 8 months ago

dlyongemallo commented 8 months ago

In dialogs.py, the various dialogs don't always take a parent parameter consistently. In particular, show_error_msg doesn't take a parent at all, and error messages can sometimes show up behind the main window which is rendered inactive, which is a confusing state for the user.

Also: in other dialog-showing functions, the parent parameter is sometimes typed QWidget and sometimes typed MainWindow, and it's sometimes the first parameter and sometimes the last. The API would be nicer if this was made consistent.

valleyofblackpanther commented 5 months ago

Hi, @dlyongemallo @RazinShaikh check this commit commit

  1. I have modified the show_error_msg function to accept a parent parameter. This parameter is then used to specify the parent of the QMessageBox so that the error message box is modal to the parent.
  2. In each function that invokes show_error_msg, i ensured to pass the parent parameter. This means I added a parent argument to the signature of those fucntions if it's not already there. I did modification in the function import_diagram_from_file.
RazinShaikh commented 6 days ago

The original problem of dialog windows being hidden behind the main window is now solved. I have renamed the issue as per @dlyongemallo 's suggestion. The following still needs to be updated:

In several dialog-showing functions, the parent parameter is sometimes typed QWidget and sometimes typed MainWindow, and it's sometimes the first parameter and sometimes the last. The API would be nicer if this was made consistent.

jvdwetering commented 6 days ago

In Qt, the parent is always the first parameter, so that is probably the way to go. I think in general the parent should be the closest QWidget above it, and so the type should be QWidget.