mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Library: allow configuring a shortcut to focus comics view
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).
This commit is contained in:
parent
81e40dabec
commit
8a54100804
@ -258,6 +258,15 @@ void ClassicComicsView::updateCurrentComicView()
|
||||
{
|
||||
}
|
||||
|
||||
void ClassicComicsView::focusComicsNavigation(Qt::FocusReason reason)
|
||||
{
|
||||
const bool comicFlowVisible = stack->currentWidget() == comicFlow && sVertical->sizes().constFirst() != 0;
|
||||
if (comicFlowVisible)
|
||||
comicFlow->setFocus(reason);
|
||||
else // Let the user navigate the table.
|
||||
tableView->setFocus(reason);
|
||||
}
|
||||
|
||||
void ClassicComicsView::selectAll()
|
||||
{
|
||||
tableView->selectAll();
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
void enableFilterMode(bool enabled) override;
|
||||
void selectIndex(int index) override;
|
||||
void updateCurrentComicView() override;
|
||||
void focusComicsNavigation(Qt::FocusReason reason) override;
|
||||
|
||||
public slots:
|
||||
void setCurrentIndex(const QModelIndex &index) override;
|
||||
|
@ -29,6 +29,7 @@ public:
|
||||
virtual void enableFilterMode(bool enabled) = 0;
|
||||
virtual void selectIndex(int index) = 0;
|
||||
virtual void updateCurrentComicView() = 0;
|
||||
virtual void focusComicsNavigation(Qt::FocusReason reason) = 0;
|
||||
|
||||
public slots:
|
||||
virtual void updateInfoForIndex(int index);
|
||||
|
@ -491,6 +491,11 @@ void GridComicsView::updateCurrentComicView()
|
||||
setCurrentComicIfNeeded();
|
||||
}
|
||||
|
||||
void GridComicsView::focusComicsNavigation(Qt::FocusReason reason)
|
||||
{
|
||||
view->setFocus(reason);
|
||||
}
|
||||
|
||||
void GridComicsView::startDrag()
|
||||
{
|
||||
auto drag = new QDrag(this);
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
QSize sizeHint();
|
||||
QByteArray getMimeDataFromSelection();
|
||||
void updateCurrentComicView() override;
|
||||
void focusComicsNavigation(Qt::FocusReason reason) override;
|
||||
|
||||
public slots:
|
||||
//ComicsView
|
||||
|
@ -208,6 +208,11 @@ void InfoComicsView::updateCurrentComicView()
|
||||
{
|
||||
}
|
||||
|
||||
void InfoComicsView::focusComicsNavigation(Qt::FocusReason reason)
|
||||
{
|
||||
view->setFocus(reason);
|
||||
}
|
||||
|
||||
void InfoComicsView::setShowMarks(bool show)
|
||||
{
|
||||
QQmlContext *ctxt = view->rootContext();
|
||||
|
@ -26,6 +26,7 @@ public:
|
||||
void enableFilterMode(bool enabled) override;
|
||||
void selectIndex(int index) override;
|
||||
void updateCurrentComicView() override;
|
||||
void focusComicsNavigation(Qt::FocusReason reason) override;
|
||||
|
||||
public slots:
|
||||
void setShowMarks(bool show);
|
||||
|
@ -378,6 +378,7 @@ void LibraryWindow::setUpShortcutsManagement()
|
||||
<< backAction
|
||||
<< forwardAction
|
||||
<< focusSearchLineAction
|
||||
<< focusComicsViewAction
|
||||
<< helpAboutAction
|
||||
<< optionsAction
|
||||
<< serverConfigAction
|
||||
@ -726,6 +727,11 @@ void LibraryWindow::createActions()
|
||||
focusSearchLineAction->setIcon(QIcon(":/images/iconSearch.png"));
|
||||
addAction(focusSearchLineAction);
|
||||
|
||||
focusComicsViewAction = new QAction(tr("Focus comics view"), this);
|
||||
focusComicsViewAction->setData(FOCUS_COMICS_VIEW_ACTION_YL);
|
||||
focusComicsViewAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(FOCUS_COMICS_VIEW_ACTION_YL));
|
||||
addAction(focusComicsViewAction);
|
||||
|
||||
showEditShortcutsAction = new QAction(tr("Edit shortcuts"), this);
|
||||
showEditShortcutsAction->setData(SHOW_EDIT_SHORTCUTS_ACTION_YL);
|
||||
showEditShortcutsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_EDIT_SHORTCUTS_ACTION_YL));
|
||||
@ -1155,6 +1161,8 @@ void LibraryWindow::createConnections()
|
||||
//connect(emptyFolderWidget,SIGNAL(subfolderSelected(QModelIndex,int)),this,SLOT(selectSubfolder(QModelIndex,int)));
|
||||
|
||||
connect(focusSearchLineAction, &QAction::triggered, searchEdit, [this] { searchEdit->setFocus(Qt::ShortcutFocusReason); });
|
||||
connect(focusComicsViewAction, &QAction::triggered, comicsViewsManager, &YACReaderComicsViewsManager::focusComicsViewViaShortcut);
|
||||
|
||||
connect(showEditShortcutsAction, SIGNAL(triggered()), editShortcutsDialog, SLOT(show()));
|
||||
|
||||
//update folders (partial updates)
|
||||
|
@ -214,6 +214,8 @@ public:
|
||||
QAction *deleteComicsAction;
|
||||
|
||||
QAction *focusSearchLineAction;
|
||||
QAction *focusComicsViewAction;
|
||||
|
||||
QAction *showEditShortcutsAction;
|
||||
|
||||
QAction *updateFolderAction;
|
||||
|
@ -121,6 +121,11 @@ void YACReaderComicsViewsManager::toggleComicsView()
|
||||
}
|
||||
}
|
||||
|
||||
void YACReaderComicsViewsManager::focusComicsViewViaShortcut()
|
||||
{
|
||||
comicsView->focusComicsNavigation(Qt::ShortcutFocusReason);
|
||||
}
|
||||
|
||||
//PROTECTED
|
||||
|
||||
void YACReaderComicsViewsManager::disconnectComicsViewConnections(ComicsView *widget)
|
||||
|
@ -55,6 +55,7 @@ signals:
|
||||
|
||||
public slots:
|
||||
void toggleComicsView();
|
||||
void focusComicsViewViaShortcut();
|
||||
|
||||
void showComicsView();
|
||||
void showEmptyFolderView();
|
||||
|
@ -76,6 +76,7 @@ public:
|
||||
#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 FOCUS_COMICS_VIEW_ACTION_YL "FOCUS_COMICS_VIEW_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"
|
||||
|
Loading…
Reference in New Issue
Block a user