-
Notifications
You must be signed in to change notification settings - Fork 204
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: Menus, Toolbars and Actions in MainWindow #1478
Conversation
No problem and no hurry. Thanks. Last time I used Qt was with C++ and Qt3 or 4 a 100 years ago. With this PR I learned some new things about Qt and how to handle it. EDIT: Maybe viewing the diff in your terminal using |
@buhtz Incredible work to introduce such a clear It is very good like it is now and is ready to be merged. I have just two questions to learn more about the reasons to implement the actions using an
|
Good question. I don't have a computer science like answer to this. It is just a habit. I saw something like this before I kind a liked it. I see no disadvantage of a factory function. Maybe it is because I see actions and gui elements as data. So I put this data elements in a data structure like a dict. It is more a feeling than a strong professional opinion. 😃
Yes I thought the same. But I just stopped at this point to prevent the blowing up the PR. |
Absolutely OK so. One possible impact could be the missing or reduced intellisense and code navigation functionality in the IDE, let's try it and see how clever PyCharm is to handle this :-) |
Partly reorganized code in MainWindow related to generation of menus, toolbars and the actions behind it. Also fixed some minor issues. The issues came up on the fly. I saw no way to separate them in a different Issue. But I keep to declare this PR/commit as "refactor" and not as "fix" because the Issues are tiny and didn't cause harm. See detailed list below.
I checked aryodas branch
1306_tray_icon_master_issue
and can't find potential merge conflicts. But I'll wait for your feedback on that.My first intention was to add a new menu to give the user the opportunity to modify the UI language. That is why the branch name is that way. But I realized I have to reorganize the code before doing this.
__init__()
._
) for variable names (e.g. actions) because it is PEP8 convention. Camel case is suited for class names only.self.*
because there is no need of them. Qt elements are managed by QMainWindow (or components of it) in the back. No need to keep references of them just to keep them alive.qttools.Menu
class, which was a workaround to offer tooltips for menu entries. Qt 5.1 is able to do it itself.This screencast do illustrate the drop-down toolbar buttons and the new "Snapshots" menu.
Let's compare this with this screenshot of an older version of BIT. Take a look at the three red circles. There are "down arrows" on each of that buttons. But they didn't work in the current BIT version because the drop down menu setup code wasn't finished. It might be that it worked in an older version with Qt4 or something like that.