Summary: | KActionCollection, menu/action reuse and the native Mac menubar | ||
---|---|---|---|
Product: | [Frameworks and Libraries] frameworks-kxmlgui | Reporter: | RJVB <rjvbertin> |
Component: | general | Assignee: | kdelibs bugs <kdelibs-bugs> |
Status: | CLOSED UPSTREAM | ||
Severity: | major | CC: | christoph, faure, mk-lists |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | macOS | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
RJVB
2016-09-24 08:45:01 UTC
The basic QAction concept is that you can add the same action to multiple widgets. If this doesn't work in some cases, it's a Qt bug, not a problem in KActionCollection (which is really just a container of qactions). => report this on the Qt bug tracker. Preferrably with an actual testcase. The thing is that their documentation makes it clear that you cannot add a QAction to multiple menus if one of them corresponds to a menu item in a menu that's part of the native menubar. I've already tried to discuss this on the Qt MLs (development, I think), but that didn't lead anywhere. Which makes me think that they don't consider this a bug, simply a limitation that we have to live with. That's also how they treated the bug report about "texted" menu sections which don't work on OS X that way: just don't use them. The only difference here is that in this case one can make a point that the limitation didn't exist in Qt4, and thus is a feature regression. So no, this issue is not resolved (I'll leave it closed though). Amazing. So a QAction in both a toolbar and a menu in the native menubar is OK? Or as soon as a QAction is in a native menu (short for "menu in the native menubar") it can't be used anywhere else? This totally defeats the QAction concept, asking apps to create multiple QActions and keep them in sync. We're back to Qt 2 then... If you open a Qt bug report I can weigh in about how unacceptable this is ;) I guess this depends on exactly what you use it for in the toolbar, but yes, it's possible. The problem is a bit that I'm not perfectly sure exactly which classes are concerned. The last time I've seen a real problem arise was with Kate's (and thus KDevelop's) Mode and Highlighting menus. IIRC those are populated with QAction instances; the symptom was that most items were disabled and some never appeared. That corresponds to what is written in the docs for *QWidgetAction* : OS X: If you add a widget to a menu in the application's menu bar on OS X, the widget will be added and it will function but with some limitations: 1. The widget is reparented away from the QMenu to the native menu view. If you show the menu in some other place (e.g. as a popup menu), the widget will not be there. What makes this extra annoying is that it is hard to predict exactly what happens. The claim above ("will not be there") is not necessarily true for instance, at least not always. Usually I've been able to see the items in both the native menu and a context menu, for instance. And the Mode/Highlighting issue in Kate weren't affected from my first attempts with KF5 (Kate was the 1st app I built). They worked, but the Bookmark menu didn't; the Mode and Highlighting menus were affected only recently but the code didn't or hardly change. IOW, the actual effects of the reparenting *may* depend on the order in which things happen, which could depend on changes in related code (kxmlgui..) or even compiler options (I think). I'll try to find some time tomorrow to see exactly what was being added to those Kate menus that remained disabled (but I take it that the limitation would be almost just as unacceptable for QWidgetActions?). So, I should have reread my original report... The Mode and Highlighting menus are provided by the KTextEditor framework. They're both KActionMenu instances, so QWidgetActions. However, they are populated with QAction* instances, and it's those instances that are problematic. The Mode and Highlighting menus themselves appear and appear to work as they should in themselves. Distilling this into a simple test case seems a rather daunting task ... |