From 96ac58225358035c49fddf62edf29bf53e4a491f Mon Sep 17 00:00:00 2001 From: Le Tan Date: Sun, 25 Jun 2017 22:22:45 +0800 Subject: [PATCH] bug-fix: set menu role for certain actions On macOS, OS will try to merge some actions to the application menu by text matching, which will be broken in Chinese. So we need to set these actions' role specifically, including: settings, exit, about, about QT. --- src/vmainwindow.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vmainwindow.cpp b/src/vmainwindow.cpp index 3359117b..29a3aed1 100644 --- a/src/vmainwindow.cpp +++ b/src/vmainwindow.cpp @@ -347,11 +347,13 @@ void VMainWindow::initHelpMenu() QAction *aboutAct = new QAction(tr("&About VNote"), this); aboutAct->setToolTip(tr("View information about VNote")); + aboutAct->setMenuRole(QAction::AboutRole); connect(aboutAct, &QAction::triggered, this, &VMainWindow::aboutMessage); QAction *aboutQtAct = new QAction(tr("About &Qt"), this); aboutQtAct->setToolTip(tr("View information about Qt")); + aboutQtAct->setMenuRole(QAction::AboutQtRole); connect(aboutQtAct, &QAction::triggered, qApp, &QApplication::aboutQt); @@ -537,6 +539,7 @@ void VMainWindow::initFileMenu() QAction *settingsAct = newAction(QIcon(":/resources/icons/settings.svg"), tr("&Settings"), this); settingsAct->setToolTip(tr("View and change settings for VNote")); + settingsAct->setMenuRole(QAction::PreferencesRole); connect(settingsAct, &QAction::triggered, this, &VMainWindow::viewSettings); @@ -548,6 +551,7 @@ void VMainWindow::initFileMenu() QAction *exitAct = new QAction(tr("&Exit"), this); exitAct->setToolTip(tr("Exit VNote")); exitAct->setShortcut(QKeySequence("Ctrl+Q")); + exitAct->setMenuRole(QAction::QuitRole); connect(exitAct, &QAction::triggered, this, &VMainWindow::close);