diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index 3d7de60f..50e795b7 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -265,7 +265,7 @@ void MainWindowViewer::createActions() openPreviousComicAction->setDisabled(true); openPreviousComicAction->setData(OPEN_PREVIOUS_COMIC_ACTION_Y); openPreviousComicAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_PREVIOUS_COMIC_ACTION_Y)); - connect(openPreviousComicAction, SIGNAL(triggered()), this, SLOT(openPreviousComic())); + connect(openPreviousComicAction, &QAction::triggered, this, &MainWindowViewer::openLeftComic); openNextComicAction = new QAction(tr("Next Comic"), this); openNextComicAction->setIcon(QIcon(":/images/viewer_toolbar/openNext.png")); @@ -273,7 +273,7 @@ void MainWindowViewer::createActions() openNextComicAction->setDisabled(true); openNextComicAction->setData(OPEN_NEXT_COMIC_ACTION_Y); openNextComicAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_NEXT_COMIC_ACTION_Y)); - connect(openNextComicAction, SIGNAL(triggered()), this, SLOT(openNextComic())); + connect(openNextComicAction, &QAction::triggered, this, &MainWindowViewer::openRightComic); prevAction = new QAction(tr("&Previous"), this); prevAction->setIcon(QIcon(":/images/viewer_toolbar/previous.png")); @@ -282,7 +282,7 @@ void MainWindowViewer::createActions() prevAction->setDisabled(true); prevAction->setData(PREV_ACTION_Y); prevAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(PREV_ACTION_Y)); - connect(prevAction, SIGNAL(triggered()), viewer, SLOT(prev())); + connect(prevAction, SIGNAL(triggered()), viewer, SLOT(left())); nextAction = new QAction(tr("&Next"), this); nextAction->setIcon(QIcon(":/images/viewer_toolbar/next.png")); @@ -291,7 +291,7 @@ void MainWindowViewer::createActions() nextAction->setDisabled(true); nextAction->setData(NEXT_ACTION_Y); nextAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(NEXT_ACTION_Y)); - connect(nextAction, SIGNAL(triggered()), viewer, SLOT(next())); + connect(nextAction, SIGNAL(triggered()), viewer, SLOT(right())); adjustHeightAction = new QAction(tr("Fit Height"), this); adjustHeightAction->setIcon(QIcon(":/images/viewer_toolbar/toHeight.png")); @@ -412,6 +412,7 @@ void MainWindowViewer::createActions() doubleMangaPageAction->setData(DOUBLE_MANGA_PAGE_ACTION_Y); doubleMangaPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(DOUBLE_MANGA_PAGE_ACTION_Y)); connect(doubleMangaPageAction, SIGNAL(triggered()), viewer, SLOT(doubleMangaPageSwitch())); + connect(doubleMangaPageAction, &QAction::triggered, this, &MainWindowViewer::doubleMangaPageSwitch); goToPageAction = new QAction(tr("Go To"), this); goToPageAction->setIcon(QIcon(":/images/viewer_toolbar/goto.png")); @@ -822,9 +823,6 @@ void MainWindowViewer::open() void MainWindowViewer::open(QString path, ComicDB &comic, QList &siblings) { - //currentComicDB = comic; - //siblingComics = siblings; - QFileInfo fi(path); if (!comic.info.title.isNull() && !comic.info.title.toString().isEmpty()) @@ -832,31 +830,22 @@ void MainWindowViewer::open(QString path, ComicDB &comic, QList &siblin else setWindowTitle("YACReader - " + fi.fileName()); + viewer->setMangaWithoutStoringSetting(comic.info.manga.toBool()); + doubleMangaPageAction->setChecked(comic.info.manga.toBool()); + viewer->open(path, comic); enableActions(); int index = siblings.indexOf(comic); + updateOpenPrevNextActions(index > 0, index + 1 < siblings.count()); optionsDialog->setFilters(currentComicDB.info.brightness, currentComicDB.info.contrast, currentComicDB.info.gamma); - - if (index > 0) - openPreviousComicAction->setDisabled(false); - else - openPreviousComicAction->setDisabled(true); - - if (index + 1 < siblings.count()) - openNextComicAction->setDisabled(false); - else - openNextComicAction->setDisabled(true); } void MainWindowViewer::open(QString path, qint64 comicId, qint64 libraryId) { - //QString pathFile = QCoreApplication::arguments().at(1); currentDirectory = path; - //quint64 comicId = QCoreApplication::arguments().at(2).split("=").at(1).toULongLong(); - //libraryId = QCoreApplication::arguments().at(3).split("=").at(1).toULongLong(); + this->libraryId = libraryId; - // this->path=path; enableActions(); @@ -881,8 +870,10 @@ void MainWindowViewer::open(QString path, qint64 comicId, qint64 libraryId) void MainWindowViewer::openComicFromPath(QString pathFile) { + doubleMangaPageAction->setChecked(Configuration::getConfiguration().getDoubleMangaPage()); openComic(pathFile); isClient = false; //this method is used for direct openings + updateOpenPrevNextActions(!previousComicPath.isEmpty(), !nextComicPath.isEmpty()); } //isClient shouldn't be modified when a siblinig comic is opened @@ -1406,6 +1397,16 @@ void MainWindowViewer::setUpShortcutsManagement() ShortcutsManager::getShortcutsManager().registerActions(allActions); } +void MainWindowViewer::doubleMangaPageSwitch() +{ + if (isClient) { + int index = siblingComics.indexOf(currentComicDB); + updateOpenPrevNextActions(index > 0, index + 1 < siblingComics.size()); + } else { + updateOpenPrevNextActions(!previousComicPath.isEmpty(), !nextComicPath.isEmpty()); + } +} + void MainWindowViewer::toggleFitToWidthSlider() { int y; @@ -1497,6 +1498,7 @@ void MainWindowViewer::openNextComic() currentComicDB = siblingComics.at(currentIndex + 1); open(currentDirectory + currentComicDB.path, currentComicDB, siblingComics); } + return; } if (!nextComicPath.isEmpty()) { @@ -1504,6 +1506,24 @@ void MainWindowViewer::openNextComic() } } +void MainWindowViewer::openLeftComic() +{ + if (viewer->getIsMangaMode()) { + openNextComic(); + } else { + openPreviousComic(); + } +} + +void MainWindowViewer::openRightComic() +{ + if (viewer->getIsMangaMode()) { + openPreviousComic(); + } else { + openNextComic(); + } +} + void MainWindowViewer::getSiblingComics(QString path, QString currentComic) { QDir d(path); @@ -1558,15 +1578,13 @@ void MainWindowViewer::getSiblingComics(QString path, QString currentComic) previousComicPath = nextComicPath = ""; if (index > 0) { previousComicPath = path + "/" + list.at(index - 1); - openPreviousComicAction->setDisabled(false); - } else - openPreviousComicAction->setDisabled(true); + } if (index + 1 < list.count()) { nextComicPath = path + "/" + list.at(index + 1); - openNextComicAction->setDisabled(false); - } else - openNextComicAction->setDisabled(true); + } + + updateOpenPrevNextActions(index > 0, index + 1 < list.count()); } void MainWindowViewer::dropEvent(QDropEvent *event) @@ -1671,3 +1689,34 @@ void MainWindowViewer::sendComic() retries--; } } + +void MainWindowViewer::updateOpenPrevNextActions(bool thereIsPrevious, bool thereIsNext) +{ + if (thereIsPrevious) { + if (viewer->getIsMangaMode()) { + openNextComicAction->setDisabled(false); + } else { + openPreviousComicAction->setDisabled(false); + } + } else { + if (viewer->getIsMangaMode()) { + openNextComicAction->setDisabled(true); + } else { + openPreviousComicAction->setDisabled(true); + } + } + + if (thereIsNext) { + if (viewer->getIsMangaMode()) { + openPreviousComicAction->setDisabled(false); + } else { + openNextComicAction->setDisabled(false); + } + } else { + if (viewer->getIsMangaMode()) { + openPreviousComicAction->setDisabled(true); + } else { + openNextComicAction->setDisabled(true); + } + } +} diff --git a/YACReader/main_window_viewer.h b/YACReader/main_window_viewer.h index 21ad8cdd..6acf05cd 100644 --- a/YACReader/main_window_viewer.h +++ b/YACReader/main_window_viewer.h @@ -50,6 +50,8 @@ public slots: void newVersion(); void openPreviousComic(); void openNextComic(); + void openLeftComic(); + void openRightComic(); void openComicFromPath(QString pathFile); void openSiblingComic(QString pathFile); void openComic(QString pathFile); @@ -68,6 +70,7 @@ public slots: void checkNewVersion(); void processReset(); void setUpShortcutsManagement(); + void doubleMangaPageSwitch(); void toggleFitToWidthSlider(); @@ -181,6 +184,7 @@ private: protected: void closeEvent(QCloseEvent *event) override; void sendComic(); + void updateOpenPrevNextActions(bool thereIsPrevious, bool thereIsNext); public: MainWindowViewer(); diff --git a/YACReader/render.cpp b/YACReader/render.cpp index 58501767..ef937088 100644 --- a/YACReader/render.cpp +++ b/YACReader/render.cpp @@ -1028,6 +1028,15 @@ void Render::doublePageSwitch() } } +void Render::setManga(bool manga) +{ + doubleMangaPage = manga; + if (comic && doublePage) { + //invalidate(); + update(); + } +} + void Render::doubleMangaPageSwitch() { doubleMangaPage = !doubleMangaPage; diff --git a/YACReader/render.h b/YACReader/render.h index e852cd64..6cf3bb6c 100644 --- a/YACReader/render.h +++ b/YACReader/render.h @@ -144,6 +144,7 @@ public slots: bool previousPageIsDoublePage(); void goTo(int index); void doublePageSwitch(); + void setManga(bool manga); void doubleMangaPageSwitch(); void setRotation(int degrees); void setComic(Comic *c); diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index dd9e27bd..08fa0914 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -253,6 +253,24 @@ void Viewer::next() shouldOpenPrevious = false; } +void Viewer::left() +{ + if (doubleMangaPage) { + next(); + } else { + prev(); + } +} + +void Viewer::right() +{ + if (doubleMangaPage) { + prev(); + } else { + next(); + } +} + void Viewer::prev() { direction = -1; @@ -889,6 +907,14 @@ void Viewer::doublePageSwitch() Configuration::getConfiguration().setDoublePage(doublePage); } +void Viewer::setMangaWithoutStoringSetting(bool manga) +{ + doubleMangaPage = manga; + render->setManga(manga); + goToFlow->setFlowRightToLeft(doubleMangaPage); + //goToFlow->updateConfig(config.getSettings()); +} + void Viewer::doubleMangaPageSwitch() { doubleMangaPage = !doubleMangaPage; @@ -1026,6 +1052,11 @@ void Viewer::updateZoomRatio(int ratio) updateContentSize(); } +bool Viewer::getIsMangaMode() +{ + return doubleMangaPage; +} + void Viewer::updateConfig(QSettings *settings) { goToFlow->updateConfig(settings); diff --git a/YACReader/viewer.h b/YACReader/viewer.h index 75bc5dc8..4c959a7c 100644 --- a/YACReader/viewer.h +++ b/YACReader/viewer.h @@ -48,6 +48,8 @@ public slots: void open(QString pathFile, const ComicDB &comic); void prev(); void next(); + void left(); + void right(); void showGoToDialog(); void goTo(unsigned int page); void updatePage(); @@ -76,6 +78,7 @@ public slots: void setBookmark(bool); void save(); void doublePageSwitch(); + void setMangaWithoutStoringSetting(bool manga); void doubleMangaPageSwitch(); void resetContent(); void setLoadingMessage(); @@ -102,6 +105,7 @@ public slots: void showIsLastMessage(); int getCurrentPageNumber(); void updateZoomRatio(int ratio); + bool getIsMangaMode(); private: bool information;