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.
Focusing the current comics view allows to use keyboard arrow keys to
choose among the visible comics.
The shortcut for this new action should not be a single character
without modifiers because it won't work when the search line has focus.
The Qt::FocusReason parameter in ComicsView::focusComicsNavigation()
allows to reuse this function for other keyboard navigation features.
For instance the search line can transfer focus to comics navigation
when the user presses Return or Enter key. In this case
Qt::OtherFocusReason can be used (an application-specific reason).
The Ctrl+F shortcut gives focus to a search bar in many applications.
In this case it allows to search the library without touching a mouse.
YACReaderMacOSXSearchLineEdit::setFocus() will have to be implemented to
make the shortcut work on macOS.
Before this commit starting a search when an empty folder or an empty
reading list was selected left all comics actions disabled. Fixes#213.
When search mode is exited, we always call either
YACReaderNavigationController::loadFolderInfo() or
YACReaderNavigationController::loadListInfo(). Both of them call
LibraryWindow::disableComicsActions(), so the enabled/disabled state of
the comics actions stays up-to-date at all times.
Currently these objects are created once at program startup and are
never destroyed. Printing debug messages in the models' destructors
confirms the leaks and proves that with this fix the objects are
destroyed at Library exit.
finished() signal of both FoldersRemover and ComicsRemover was not
connected to their QThread's quit() slot. So the thread kept running
after the deletion completed. The QThread's parent is LibraryWindow.
Thus LibraryWindow's ~QObject() invokes the QThread's destructor.
As a result, when the user exited YACReader Library after deleting at
least one folder or comic, it printed the following FATAL message and
crashed at exit: "QThread: Destroyed while thread is still running".
Extract signal-slot connections between a remover and a QThread into
moveAndConnectRemoverToThread() to reduce code duplication.
Remove always true (thread != NULL) checks.