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

QtQuick Controls 2 UM.MenuItem #799

Open
fieldOfView opened this issue Mar 21, 2022 · 11 comments
Open

QtQuick Controls 2 UM.MenuItem #799

fieldOfView opened this issue Mar 21, 2022 · 11 comments

Comments

@fieldOfView
Copy link
Contributor

Since the introduction of the QtQuick Controls 2 UM.MenuItem, it is no longer possible to display an ampersand ("&") in menu items, because any ampersand is treated as a prefix for a keyboard shortcut. The markup does not not work well on a ampersand followed by a space:
image

Eliding long(-ish) menuitem labels is a bit of a problematic solution to not being able to auto-adjust the width of the (sub) menu; The convention is that a menuitem that has an ellipsis denotes an action that has further interaction. For example a "Save as..." item has an ellipsis because it opens a filename dialog, but a "Save" item has no ellipsis (because a normal "Save" does not require user interaction). Eliding long(ish) menuitems unpredictably suggests further interaction to the user that may or may not happen.

@fieldOfView
Copy link
Contributor Author

For the second part of the issue, there seems to be a solution:
https://martin.rpdev.net/2018/03/13/qt-quick-controls-2-automatically-set-the-width-of-menus.html

@nallath
Copy link
Member

nallath commented Mar 23, 2022

I've just tried to add it, but it does cause a binding loop somewhere... I will try to find what is causing it

@fieldOfView
Copy link
Contributor Author

I made a PR (#800), but I did not see the binding loop. I may be overlooking it, since at the same time I am fixing SidebarGUI with the latest QtQuick Controls 2 changes...

Perhaps it is caused by the implicitWidth set in Cura.Menu?

@nallath
Copy link
Member

nallath commented Mar 23, 2022

Perhaps it is caused by the implicitWidth set in Cura.Menu?

Good hunch (I hope so, because I had the same one), I tried to mess around with that a bit but it didn't seem to go away.

It does seem to actually work (the size is as I'd expect it to be) but the error spam makes me a bit worried.

@nallath
Copy link
Member

nallath commented Mar 23, 2022

So i think i found what causes it, but I haven't found a fix for it. The binding loops are caused by having a nested menu. If you have a menu with only menu items, it works just fine. At the moment that you have a menu with a menu inside of it, you get binding loops.

@fieldOfView
Copy link
Contributor Author

fieldOfView commented Mar 23, 2022

What version of QT are you on? I am still using 5.15.0 at this point (on Windows), and I don't see the binding loops with #800 (with or without Sidebar GUI).

@nallath
Copy link
Member

nallath commented Mar 24, 2022

QT: 5.15.2
PyQt: 15.15.6

@fieldOfView
Copy link
Contributor Author

fieldOfView commented Mar 24, 2022

I can see the binding loop now too after updating my PyQt. I'll see if I can make it go away again (using another method then to downgrade to PyQt 5.15.0 again, which works by the way).

Edit: the binding loops start with PyQt 5.15.1. Not that knowing that has helped me much sofar...

@fieldOfView
Copy link
Contributor Author

fieldOfView commented Mar 24, 2022

I fixed the binding loop in #800

The problem was the Item with Layout.fillWidth set in MenuItems where there was either a shortcut or a submenu arrow.

Edit: Nope, not yet...

@fieldOfView
Copy link
Contributor Author

I think I got it now...

@fieldOfView
Copy link
Contributor Author

#800 fixed the menu width and eliding, but using an & in a menuitem title is still broken so I am keeping this issue open. In the mean time I have submitted my plugin that had an & in menuitems with altered menuitem titles, so the issue is not very urgent (to me anyway).

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

No branches or pull requests

2 participants