Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-90335

macOS Application menu: can't have more than one "about" item

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15.2, 6.2
    • GUI: Menus
    • None
    • macOS

    Description

      my app does NOT use ui designer to construct the menu bar, it reads a json file and constructs the menus based on what is in the json file. this is a requirement and no i can't change it.

      so when attempting to set up the application menu, i would like to have it appear like this:

      About My App...
      About Qt...
      About Open Source...
      -----------------
      Preferences...
      -----------------
      etc whatever
      -----------------
      Quit
      

      to be clear, we need the three "About" items to appear at the top, one after the other, THEN a separator THEN "Preferences" etc. this is also a requirement that can't be changed.

      the problem is that any item (except the first) with the word "about" in it will throw everything off.

      If I attempt to construct the menu as it is above, it ends up like screenshot 1. Not only is this wrong visually, but the first "about" action is wrong: picking the first "About kJams 2 Debug…" invokes the "about open source" action, although other items perform their stated action.

      if i do NOT have the word "about" in the latter two items, say i use the word "regarding" instead, then it looks like screen shot 2, but now there's this extra separator which i did not ask for.

      so then i must use Cocoa calls directly to remove that separator item, since it is not in the Qt model of the menus, and i finally get closer to what i'm looking for, see screen shot 3, the only problem now is the word "Regarding" instead of "About".

      strangely, to get rid of the extra separator, by trial and error i discovered i had to remove item index 2 (base zero, as in the first item is number zero), but item index 2 from screen shot 2 is "Regarding Qt", NOT the separator, which is index 1 (index 0 is "About kJams 2 Debug").

      This led me to logging what the menu models have in mind, which lead to the following CRAZY output. note this is from BEFORE i remove the "separator", so it corresponds to "screen shot 2". also note in these logs the indexes are base 1, not base 0, meaning the first item is 1.

      Cocoa's notion of the app menu
      -----------------------------
      1: About kJams 2 Debug
      2: Regarding Qt…
      3: Regarding Open Source…
      4: Preferences...
      5: Regarding Qt…
      6: Regarding Open Source…
      7: (-
      8: Preferences…
      9: (-
      10: Services
      11: (-
      12: Hide kJams 2 Debug
      13: Hide Others
      14: Show All
      15: (-
      16: Quit kJams 2 Debug
      17: Quit and Keep Windows
      
      Qt's notion of the app menu 
      -----------------------------
      1: About kJams…
      2: Regarding Qt…
      3: Regarding Open Source…
      4: (-
      5: Preferences…
      6: (-
      7: E&xit kJams 
      

      so i have to ask: what the HECK is going on here?

      footnote: i know i must make this call for items to even appear in the app menu, the actual visual menu that is displayed:

       itemActionP->setMenuRole(QAction::ApplicationSpecificRole);

      I do that only up to "preferences". i do add the rest of the items, ie: the separator and the Quit (Exit) menu items, but i do NOT set their menu role, so they don't show up in the visual menu, which is what i want.

      Attachments

        1. Screen Shot 1.png
          Screen Shot 1.png
          378 kB
        2. Screen Shot 2.png
          Screen Shot 2.png
          396 kB
        3. Screen Shot 3.png
          Screen Shot 3.png
          396 kB
        4. Screen Shot 4.png
          Screen Shot 4.png
          385 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              davecotter David M. Cotter
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes