Ultimaker / Uranium

A Python framework for building Desktop applications.
GNU Lesser General Public License v3.0
322 stars 184 forks source link

QtQuick Controls 2 UM.MenuItem #799

Open fieldOfView opened 2 years ago

fieldOfView commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

QT: 5.15.2 PyQt: 15.15.6

fieldOfView commented 2 years ago

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 commented 2 years ago

~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 commented 2 years ago

I think I got it now...

fieldOfView commented 2 years ago

https://github.com/Ultimaker/uranium/pull/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).