From e6c1b7515e0d8a13bea0ff1636809a89b4731586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Tue, 15 Oct 2013 09:29:58 +0200 Subject: [PATCH] New feature: open next/previous comic automatically after reaching end/cover for the current comic issue #4 https://bitbucket.org/luisangelsm/yacreader/issue/2/auto-advance-to-next-comic --- YACReader/main_window_viewer.cpp | 4 ++++ YACReader/render.cpp | 4 ++-- YACReader/viewer.cpp | 36 ++++++++++++++++++++++++-------- YACReader/viewer.h | 5 +++++ 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index e7437771..930570f8 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -121,6 +121,10 @@ void MainWindowViewer::setupUI() viewer = new Viewer(this); connect(viewer,SIGNAL(reset()),this,SLOT(disableActions())); + //detected end of comic + connect(viewer,SIGNAL(openNextComic()),this,SLOT(openNextComic())); + //detected start of comic + connect(viewer,SIGNAL(openPreviousComic()),this,SLOT(openPreviousComic())); setCentralWidget(viewer); int heightDesktopResolution = QApplication::desktop()->screenGeometry().height(); diff --git a/YACReader/render.cpp b/YACReader/render.cpp index 46b48e0f..e9d2d318 100644 --- a/YACReader/render.cpp +++ b/YACReader/render.cpp @@ -675,8 +675,8 @@ void Render::createComic(const QString & path) connect(comic,SIGNAL(bookmarksUpdated()),this,SIGNAL(bookmarksUpdated())); - connect(comic,SIGNAL(isLast()),this,SIGNAL(isLast())); - connect(comic,SIGNAL(isCover()),this,SIGNAL(isCover())); + //connect(comic,SIGNAL(isLast()),this,SIGNAL(isLast())); + //connect(comic,SIGNAL(isCover()),this,SIGNAL(isCover())); pagesReady.clear(); } diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index 7db35475..e2cb1ab0 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -27,7 +27,9 @@ wheelStop(false), direction(1), restoreMagnifyingGlass(false), drag(false), -numScrollSteps(22) +numScrollSteps(22), +shouldOpenNext(false), +shouldOpenPrevious(false) { translator = new YACReaderTranslator(this); translator->hide(); @@ -789,6 +791,7 @@ void Viewer::mousePressEvent ( QMouseEvent * event ) setCursor(Qt::ClosedHandCursor); event->accept(); } + void Viewer::mouseReleaseEvent ( QMouseEvent * event ) { drag = false; @@ -810,8 +813,6 @@ void Viewer::updateConfig(QSettings * settings) QPalette palette; palette.setColor(backgroundRole(), Configuration::getConfiguration().getBackgroundColor()); setPalette(palette); - - } //deprecated @@ -832,15 +833,32 @@ void Viewer::setBookmarks() void Viewer::showIsCoverMessage() { - notificationsLabel->setText(tr("Cover!")); - notificationsLabel->flash(); - + if(!shouldOpenPrevious) + { + notificationsLabel->setText(tr("Cover!")); + notificationsLabel->flash(); + shouldOpenPrevious = true; + } + else + { + shouldOpenPrevious = false; + emit (openPreviousComic()); + } } void Viewer::showIsLastMessage() { - notificationsLabel->setText(tr("Last page!")); - notificationsLabel->flash(); + if(!shouldOpenNext) + { + notificationsLabel->setText(tr("Last page!")); + notificationsLabel->flash(); + shouldOpenNext = true; + } + else + { + shouldOpenNext = false; + emit (openNextComic()); + } } unsigned int Viewer::getIndex() @@ -885,4 +903,4 @@ void Viewer::updateComic(ComicDB & comic) } -} \ No newline at end of file +} diff --git a/YACReader/viewer.h b/YACReader/viewer.h index 715e7b65..3b702321 100644 --- a/YACReader/viewer.h +++ b/YACReader/viewer.h @@ -126,6 +126,9 @@ virtual void mouseReleaseEvent ( QMouseEvent * event ); NotificationsLabelWidget * notificationsLabel; + bool shouldOpenNext; + bool shouldOpenPrevious; + private: //!Magnifying glass MagnifyingGlass *mglass; @@ -153,6 +156,8 @@ virtual void mouseReleaseEvent ( QMouseEvent * event ); void pageAvailable(bool); void pageIsBookmark(bool); void reset(); + void openNextComic(); + void openPreviousComic(); }; #endif