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

Preferences item under "QGIS" menu opens shortcut settings on OSX #15260

Closed
qgib opened this issue Jun 6, 2012 · 8 comments
Closed

Preferences item under "QGIS" menu opens shortcut settings on OSX #15260

qgib opened this issue Jun 6, 2012 · 8 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! GUI/UX Related to QGIS application GUI or User Experience High Priority
Milestone

Comments

@qgib
Copy link
Contributor

qgib commented Jun 6, 2012

Author Name: John Tull (John Tull)
Original Redmine Issue: 5754
Affected QGIS version: master
Redmine category:gui


On OSX, a "Preferences" item is available in the "QGIS" menu drop-down. Unfortunately, it opens the shortcut settings rather than the QGIS options dialog. This should be mapped correctly to maintain OSX standards. In applications on OS X, the keyboard shortcut command-, opens program preferences. Currently, this opens the shortcut settings instead for QGIS. This is also mapped to the same "Preferences" menu item, so both of these issues should be resolved at the same time by remapping that item correctly.


@qgib
Copy link
Contributor Author

qgib commented Jun 6, 2012

Author Name: Larry Shaffer (Larry Shaffer)


John, or anyone else with a Mac, I have fixed this on my latest build. Apply attached patch to test.

Here's what's happening:

The mActionConfigureShortcuts's text starts with 'config' and has its MenuRole set to QAction::TextHeuristicRole[0]. This causes the action to be used for the Preferences... menu action instead of mActionOptions, even though that action's MenuRole is set to QAction::PreferencesRole [1]. Must be that heuristic check overrides, or comes before, the src/ui/qgisapp.ui setting.

I did the following to fix it:

  1. Set mActionConfigureShortcuts's MenuRole to QAction::NoRole so it doesn't cause the issue.

  2. Added mActionOptionsMac action (basically a copy of mActionOptions) to the Settings menu. The options() action is in two places, like before, with 1.7.4. This was added because, on the Mac, Qt will move the QAction::PreferencesRole and QAction::AboutRole actions under QGIS (application) menu. Not sure when that happens, otherwise mActionOptions could re-added to the Settings menu, which, as a test, can be done in the Python console after launch.

I chose to just use the text of mActionOptions ('Options...'), since there is a string freeze. However, mActionOptionsMac really should be shifted to 'Preferences...' for that full Mac OS experience.

A more deluxe fix would loop all actions and set any action's MenuRole that starts with config, options, setup, settings or preferences, or about.* to QAction::NoRole excepting mActionOptions and mActionAbout specifically. This way, if someone in the future accidentally adds another problem action to src/ui/qgisapp.ui and forgets to set it to QAction::NoRole (TextHeuristicRole is default), it might override the About or Preferences... menus's actions.

If this fix works for you (works on 10.6.8 and 10.7.4 here), I'll set up a pull request tonight, and contact William Kyngesburye as well. Not sure if he has extra steps to deal with this during packaging, but now it might be in master branch.

[0] http://doc.qt.nokia.com/4.7.1/qaction.html#MenuRole-enum
[1] http://doc.qt.nokia.com/4.7.1/qmenubar.html#qmenubar-on-mac-os-x


  • 4553 was configured as prefs-patch-1.8_git.diff

@qgib
Copy link
Contributor Author

qgib commented Jun 11, 2012

Author Name: John Tull (John Tull)


Larry: Sorry I was not able to test this sooner. Was this already applied to trunk? If so, it probably should be closed. I wasn't sure if the patch applied or it was already in the code upstream.

@qgib
Copy link
Contributor Author

qgib commented Jun 11, 2012

Author Name: Larry Shaffer (Larry Shaffer)


John, this was mostly fixed with:

f01c6ad

But I have a better fix now that I need to test on Mac 10.6.8 (good to go on 10.7.4) that keeps all third-party plugins from hijacking About or Preferences. It's more of a hack, but it works well. Will send pull request in an hour or two. I have added it here as a diff, if you would like to test.

It keeps the menu items from being hijacked and preserves the menu items in their respective menus: Options... under Settings and About under Help. Before, Qt would move them from there.

The problem here is that this Mac-only Qt menu merge 'feature' is re-assessed (left-to-right) on each menubar change, not just at launch. So, if a third-party plugin is loaded and adds a top-level menu before the Help menu, it will hijack the app's about menu, if it has a menu that starts with the text 'about'. CadTools does, as well as others. This has been an issue for several QGIS versions now.

My little hack adds duplicate menus for About and Options (they are set to AboutRole and PreferencesRole already) to the bottom of the File Menu, which Qt discovers and moves to the appropriate app menus before it runs into any others, regardless of whether they load later, like with plugins.

One small flaw here is if a plugin or C++ dev adds to the File Menu above these with a TextHeuristicRole-triggered 'about' or 'config, options, etc' action. It is doubtful this will happen, though. Otherwise, I can't think of another solution, short of a change to Qt concerning this. It's a bad auto-feature IMHO.


  • 4574 was configured as fix-hijacked-menus-patch.diff

@qgib
Copy link
Contributor Author

qgib commented Jun 11, 2012

Author Name: Larry Shaffer (Larry Shaffer)


John, the patch supplied in previous post works well under 10.6.8, too. In the attached screen snap for 1.8.0 you can see CadTools and SEXTANTE (Analysis menu) loaded before Help (after Window, though, due to other ordering issue).

In snap for 1.7.4-4 there was no hijacking of the About menu, but only because of the screwed-up menu ordering issue: Help preceded all plugin menus.

Please let me know if you get similar results with patch and only those two plugins loaded. Compare results under 1.7.4-4 and 1.8.0, if possible. Thanks.


  • 4576 was configured as fix-hijacked-menus_1.7.4-4.png
  • 4575 was configured as fix-hijacked-menus-patch_1.8.0.png

@qgib
Copy link
Contributor Author

qgib commented Jun 11, 2012

Author Name: John Tull (John Tull)


I did get the same result with Sextante plugin. The Analysis menu item is between Windows and Help. This is tested in trunk build only. I don't have time to build 1.7.4 right now, though.

@qgib
Copy link
Contributor Author

qgib commented Jun 11, 2012

Author Name: Larry Shaffer (Larry Shaffer)


Should be reasonably fixed with:

cc9b898

Recommend setting issue to Closed.

@qgib
Copy link
Contributor Author

qgib commented Jul 7, 2012

Author Name: Larry Shaffer (Larry Shaffer)


This should be set to closed. Fixed for 1.8.0+.

@qgib
Copy link
Contributor Author

qgib commented Jul 7, 2012

Author Name: John Tull (John Tull)


  • status_id was changed from Open to Closed

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority GUI/UX Related to QGIS application GUI or User Experience labels May 24, 2019
@qgib qgib added this to the Version 2.0.0 milestone May 24, 2019
@qgib qgib closed this as completed May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! GUI/UX Related to QGIS application GUI or User Experience High Priority
Projects
None yet
Development

No branches or pull requests

1 participant