Fix osx menu roles

This commit is contained in:
artisteacher 2018-04-12 19:41:49 -04:00 committed by GitHub
parent 068277dbc1
commit 9ff9ba1376
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1418,14 +1418,23 @@ QAction *MainWindow::createAction(const char *id, const QString &name,
QAction *action = new DVAction(name, this);
addAction(action);
#ifdef MACOSX
// To prevent the wrong menu items (due to MacOS menu naming conventions), from
// taking Preferences, Quit, or About roles (sometimes happens unexpectedly in
// translations) - all menu items should have "NoRole"
if (MenuFileCommandType || MenuEditCommandType || MenuScanCleanupCommandType
|| MenuLevelCommandType || MenuXsheetCommandType || MenuCellsCommandType ||
MenuViewCommandType || MenuWindowsCommandType) {
action->setMenuRole(QAction::NoRole);
}
// except for Preferences, Quit, and About
if (strcmp(id, MI_Preferences) == 0) {
action->setMenuRole(QAction::PreferencesRole);
}
if (strcmp(id, MI_ShortcutPopup) == 0) {
action->setMenuRole(QAction::NoRole);
if (strcmp(id, MI_Quit) == 0) {
action->setMenuRole(QAction::QuitRole);
}
if (strcmp(id,MI_ExitGroup) == 0) {
action->setMenuRole(QAction::NoRole);
if (strcmp(id, MI_About) == 0) {
action->setMenuRole(QAction::AboutRole);
}
#endif
CommandManager::instance()->define(id, type, defaultShortcut.toStdString(),