Library: add Quit shortcut

The Ctrl+Q shortcut is assigned to Quit action in most applications on
GNU/Linux. Command+Q is used on macOS. The added shortcut should be
automatically mapped to Command+Q on macOS judging by the following
quote from QKeySequence class documentation:
Note: On macOS, references to "Ctrl", Qt::CTRL, Qt::Key_Control and
Qt::ControlModifier correspond to the Command keys on the Macintosh
keyboard

QKeySequence::Quit could be used as the default key sequence in place of
`Qt::CTRL | Qt::Key_Q`. This would leave the shortcut unassigned by
default on Windows. But YACReader doesn't use QKeySequence::StandardKey
anywhere, so perhaps this shortcut should be hard-coded too.

The shortcut is particularly useful when Close to tray option is
enabled, because in this case closing the Library window with a system
window manager shortcut simply hides it.
This commit is contained in:
Igor Kushnir
2021-03-20 18:09:11 +02:00
committed by Luis Ángel San Martín
parent 63b1f9401b
commit 2acfbbfac7
7 changed files with 19 additions and 5 deletions

View File

@ -396,7 +396,8 @@ void LibraryWindow::setUpShortcutsManagement()
<< helpAboutAction
<< optionsAction
<< serverConfigAction
<< showEditShortcutsAction);
<< showEditShortcutsAction
<< quitAction);
allActions << tmpList;
@ -752,6 +753,13 @@ void LibraryWindow::createActions()
showEditShortcutsAction->setShortcutContext(Qt::ApplicationShortcut);
addAction(showEditShortcutsAction);
quitAction = new QAction(tr("&Quit"), this);
quitAction->setIcon(QIcon(":/images/viewer_toolbar/close.png"));
quitAction->setData(QUIT_ACTION_YL);
quitAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(QUIT_ACTION_YL));
// TODO: is `quitAction->setMenuRole(QAction::QuitRole);` useful on macOS?
addAction(quitAction);
updateFolderAction = new QAction(tr("Update folder"), this);
updateFolderAction->setIcon(QIcon(":/images/menus_icons/updateLibraryIcon.png"));
@ -1179,6 +1187,8 @@ void LibraryWindow::createConnections()
connect(showEditShortcutsAction, SIGNAL(triggered()), editShortcutsDialog, SLOT(show()));
connect(quitAction, &QAction::triggered, this, &LibraryWindow::closeApp);
//update folders (partial updates)
connect(updateCurrentFolderAction, SIGNAL(triggered()), this, SLOT(updateCurrentFolder()));
connect(updateFolderAction, SIGNAL(triggered()), this, SLOT(updateCurrentFolder()));