Library: add a shortcut to focus search line

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.
This commit is contained in:
Igor Kushnir 2019-05-19 15:54:59 +03:00
parent 6ab5a83e01
commit 81e40dabec
6 changed files with 18 additions and 0 deletions

View File

@ -377,6 +377,7 @@ void LibraryWindow::setUpShortcutsManagement()
tmpList = QList<QAction *>()
<< backAction
<< forwardAction
<< focusSearchLineAction
<< helpAboutAction
<< optionsAction
<< serverConfigAction
@ -719,6 +720,12 @@ void LibraryWindow::createActions()
getInfoAction->setIcon(QIcon(":/images/comics_view_toolbar/getInfo.png"));
//-------------------------------------------------------------------------
focusSearchLineAction = new QAction(tr("Focus search line"), this);
focusSearchLineAction->setData(FOCUS_SEARCH_LINE_ACTION_YL);
focusSearchLineAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(FOCUS_SEARCH_LINE_ACTION_YL));
focusSearchLineAction->setIcon(QIcon(":/images/iconSearch.png"));
addAction(focusSearchLineAction);
showEditShortcutsAction = new QAction(tr("Edit shortcuts"), this);
showEditShortcutsAction->setData(SHOW_EDIT_SHORTCUTS_ACTION_YL);
showEditShortcutsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_EDIT_SHORTCUTS_ACTION_YL));
@ -1147,6 +1154,7 @@ void LibraryWindow::createConnections()
//connect(comicsModel,SIGNAL(searchNumResults(int)),this,SLOT(checkSearchNumResults(int)));
//connect(emptyFolderWidget,SIGNAL(subfolderSelected(QModelIndex,int)),this,SLOT(selectSubfolder(QModelIndex,int)));
connect(focusSearchLineAction, &QAction::triggered, searchEdit, [this] { searchEdit->setFocus(Qt::ShortcutFocusReason); });
connect(showEditShortcutsAction, SIGNAL(triggered()), editShortcutsDialog, SLOT(show()));
//update folders (partial updates)

View File

@ -213,6 +213,7 @@ public:
QAction *forceCoverExtractedAction;
QAction *deleteComicsAction;
QAction *focusSearchLineAction;
QAction *showEditShortcutsAction;
QAction *updateFolderAction;

View File

@ -12,6 +12,7 @@ class YACReaderMacOSXSearchLineEdit : public QObject
Q_OBJECT
public:
YACReaderMacOSXSearchLineEdit();
void setFocus(Qt::FocusReason reason);
void *getNSTextField();
public slots:

View File

@ -316,6 +316,12 @@ YACReaderMacOSXSearchLineEdit::YACReaderMacOSXSearchLineEdit()
nstextfield = searchEdit;
}
void YACReaderMacOSXSearchLineEdit::setFocus(Qt::FocusReason reason)
{
Q_UNUSED(reason)
// TODO: implement
}
void *YACReaderMacOSXSearchLineEdit::getNSTextField()
{
return nstextfield;

View File

@ -13,6 +13,7 @@ void ShortcutsManager::initDefaultShorcuts()
{
#ifdef YACREADER_LIBRARY
//ACTIONS
defaultShorcuts.insert(FOCUS_SEARCH_LINE_ACTION_YL, Qt::CTRL | Qt::Key_F);
defaultShorcuts.insert(CREATE_LIBRARY_ACTION_YL, Qt::Key_A);
defaultShorcuts.insert(OPEN_LIBRARY_ACTION_YL, Qt::Key_O);
defaultShorcuts.insert(UPDATE_LIBRARY_ACTION_YL, Qt::Key_U);

View File

@ -75,6 +75,7 @@ public:
#define DELETE_COMICS_ACTION_YL "DELETE_COMICS_ACTION_YL"
#define HIDE_COMIC_VIEW_ACTION_YL "HIDE_COMIC_VIEW_ACTION_YL"
#define GET_INFO_ACTION_YL "GET_INFO_ACTION_YL"
#define FOCUS_SEARCH_LINE_ACTION_YL "FOCUS_SEARCH_LINE_ACTION_YL"
#define SHOW_EDIT_SHORTCUTS_ACTION_YL "SHOW_EDIT_SHORTCUTS_ACTION_YL"
#define UPDATE_CURRENT_FOLDER_ACTION_YL "UPDATE_CURRENT_FOLDER_ACTION_YL"
#define ADD_FOLDER_ACTION_YL "ADD_FOLDER_ACTION_YL"