From f3249e405321ce76df4d550237b18c8d42fcb2e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 9 Jul 2023 10:44:43 +0200 Subject: [PATCH] Add shortcuts to control the double page mode offset --- YACReader/main_window_viewer.cpp | 9 ++++++- YACReader/viewer.cpp | 30 ++++++++++++++++++++++ YACReader/viewer.h | 2 ++ shortcuts_management/shortcuts_manager.cpp | 2 ++ shortcuts_management/shortcuts_manager.h | 2 ++ 5 files changed, 44 insertions(+), 1 deletion(-) diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index 2188cb30..6c69254a 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -1252,6 +1252,11 @@ void MainWindowViewer::setUpShortcutsManagement() auto *const goToLastPageAction = addActionWithShortcut(tr("Go to the last page"), GO_TO_LAST_PAGE_ACTION_Y); connect(goToLastPageAction, &QAction::triggered, viewer, &Viewer::goToLastPage); + auto *const offsetDoublePageToTheLeft = addActionWithShortcut(tr("Offset double page to the left"), OFFSET_DOUBLE_PAGE_TO_THE_LEFT_Y); + connect(offsetDoublePageToTheLeft, &QAction::triggered, viewer, &Viewer::offsetDoublePageToTheLeft); + auto *const offsetDoublePageToTheRight = addActionWithShortcut(tr("Offset double page to the right"), OFFSET_DOUBLE_PAGE_TO_THE_RIGHT_Y); + connect(offsetDoublePageToTheRight, &QAction::triggered, viewer, &Viewer::offsetDoublePageToTheRight); + loadedComicActions = { autoScrollForwardAction, autoScrollBackwardAction, autoScrollForwardHorizontalFirstAction, @@ -1263,7 +1268,9 @@ void MainWindowViewer::setUpShortcutsManagement() moveLeftAction, moveRightAction, goToFirstPageAction, - goToLastPageAction }; + goToLastPageAction, + offsetDoublePageToTheLeft, + offsetDoublePageToTheRight }; editShortcutsDialog->addActionsGroup(tr("Reading"), QIcon(":/images/shortcuts_group_reading.svg"), tmpList = QList() diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index 61273666..d8d56582 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -1083,6 +1083,36 @@ void Viewer::setBookmarks() bd->setBookmarks(*render->getBookmarks()); } +void Viewer::offsetDoublePageToTheLeft() +{ + if (!doublePage) { + return; + } + + if (doubleMangaPage) { + render->previousPage(); + } else { + render->nextPage(); + } + + updateInformation(); +} + +void Viewer::offsetDoublePageToTheRight() +{ + if (!doublePage) { + return; + } + + if (doubleMangaPage) { + render->nextPage(); + } else { + render->previousPage(); + } + + updateInformation(); +} + void Viewer::showIsCoverMessage() { if (!shouldOpenPrevious) { diff --git a/YACReader/viewer.h b/YACReader/viewer.h index 42b46b85..b6134d78 100644 --- a/YACReader/viewer.h +++ b/YACReader/viewer.h @@ -101,6 +101,8 @@ public slots: void showMessageErrorOpening(QString); void processCRCError(QString message); void setBookmarks(); + void offsetDoublePageToTheLeft(); + void offsetDoublePageToTheRight(); // deprecated void updateImageOptions(); void updateFilters(int brightness, int contrast, int gamma); diff --git a/shortcuts_management/shortcuts_manager.cpp b/shortcuts_management/shortcuts_manager.cpp index 1680b374..e2ce5841 100644 --- a/shortcuts_management/shortcuts_manager.cpp +++ b/shortcuts_management/shortcuts_manager.cpp @@ -69,6 +69,8 @@ void ShortcutsManager::initDefaultShorcuts() defaultShorcuts.insert(MOVE_UP_ACTION_Y, Qt::Key_Up); defaultShorcuts.insert(GO_TO_FIRST_PAGE_ACTION_Y, Qt::Key_Home); defaultShorcuts.insert(GO_TO_LAST_PAGE_ACTION_Y, Qt::Key_End); + defaultShorcuts.insert(OFFSET_DOUBLE_PAGE_TO_THE_LEFT_Y, Qt::CTRL | Qt::SHIFT | Qt::Key_Left); + defaultShorcuts.insert(OFFSET_DOUBLE_PAGE_TO_THE_RIGHT_Y, Qt::CTRL | Qt::SHIFT | Qt::Key_Right); // mglass defaultShorcuts.insert(SIZE_UP_MGLASS_ACTION_Y, Qt::Key_Plus); defaultShorcuts.insert(SIZE_DOWN_MGLASS_ACTION_Y, Qt::Key_Minus); diff --git a/shortcuts_management/shortcuts_manager.h b/shortcuts_management/shortcuts_manager.h index cb201c88..8f727114 100644 --- a/shortcuts_management/shortcuts_manager.h +++ b/shortcuts_management/shortcuts_manager.h @@ -152,6 +152,8 @@ public: #define MOVE_RIGHT_ACTION_Y "MOVE_RIGHT_ACTION_Y" #define GO_TO_FIRST_PAGE_ACTION_Y "GO_TO_FIRST_PAGE_ACTION_Y" #define GO_TO_LAST_PAGE_ACTION_Y "GO_TO_LAST_PAGE_ACTION_Y" +#define OFFSET_DOUBLE_PAGE_TO_THE_LEFT_Y "OFFSET_DOUBLE_PAGE_TO_THE_LEFT_Y" +#define OFFSET_DOUBLE_PAGE_TO_THE_RIGHT_Y "OFFSET_DOUBLE_PAGE_TO_THE_RIGHT_Y" // mglass #define SIZE_UP_MGLASS_ACTION_Y "SIZE_UP_MGLASS_ACTION_Y" #define SIZE_DOWN_MGLASS_ACTION_Y "SIZE_DOWN_MGLASS_ACTION_Y"