diff --git a/YACReaderLibrary/comics_view.h b/YACReaderLibrary/comics_view.h index 2b4f0551..cee4c6ab 100644 --- a/YACReaderLibrary/comics_view.h +++ b/YACReaderLibrary/comics_view.h @@ -38,7 +38,7 @@ public slots: signals: void selected(unsigned int); - void openComic(); + void openComic(const ComicDB &comic, const ComicModel::Mode mode); void comicRated(int, QModelIndex); //Context menus diff --git a/YACReaderLibrary/grid_comics_view.cpp b/YACReaderLibrary/grid_comics_view.cpp index 77bde157..40140c16 100644 --- a/YACReaderLibrary/grid_comics_view.cpp +++ b/YACReaderLibrary/grid_comics_view.cpp @@ -398,7 +398,11 @@ void GridComicsView::selectIndex(int index) void GridComicsView::triggerOpenCurrentComic() { - emit openComic(); + if (model == nullptr) { + return; + } + + emit openComic(currentComic, model->getMode()); } void GridComicsView::rate(int index, int rating) diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index e359f8fb..ae50be94 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -1840,31 +1840,37 @@ void LibraryWindow::checkEmptyFolder() void LibraryWindow::openComic() { if (!importedCovers) { - auto libraryId = libraries.getId(selectedLibrary->currentText()); auto comic = comicsModel->getComic(comicsViewsManager->comicsView->currentIndex()); auto mode = comicsModel->getMode(); - OpenComicSource::Source source; + openComic(comic, mode); + } +} - if (mode == ComicModel::ReadingList) { - source = OpenComicSource::Source::ReadingList; - } else if (mode == ComicModel::Reading) { - //TODO check where the comic was opened from the last time it was read - source = OpenComicSource::Source::Folder; - } else { - source = OpenComicSource::Source::Folder; - } +void LibraryWindow::openComic(const ComicDB &comic, const ComicModel::Mode mode) +{ + auto libraryId = libraries.getId(selectedLibrary->currentText()); - auto yacreaderFound = YACReader::openComic(comic, libraryId, currentPath(), OpenComicSource { source, comicsModel->getSourceId() }); + OpenComicSource::Source source; - if (!yacreaderFound) { + if (mode == ComicModel::ReadingList) { + source = OpenComicSource::Source::ReadingList; + } else if (mode == ComicModel::Reading) { + //TODO check where the comic was opened from the last time it was read + source = OpenComicSource::Source::Folder; + } else { + source = OpenComicSource::Source::Folder; + } + + auto yacreaderFound = YACReader::openComic(comic, libraryId, currentPath(), OpenComicSource { source, comicsModel->getSourceId() }); + + if (!yacreaderFound) { #ifdef Q_OS_WIN - QMessageBox::critical(this, tr("YACReader not found"), tr("YACReader not found. YACReader should be installed in the same folder as YACReaderLibrary.")); + QMessageBox::critical(this, tr("YACReader not found"), tr("YACReader not found. YACReader should be installed in the same folder as YACReaderLibrary.")); #else - QMessageBox::critical(this, tr("YACReader not found"), tr("YACReader not found. There might be a problem with your YACReader installation.")); + QMessageBox::critical(this, tr("YACReader not found"), tr("YACReader not found. There might be a problem with your YACReader installation.")); #endif - } } } diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h index 7b0a14e8..2db2c7c4 100644 --- a/YACReaderLibrary/library_window.h +++ b/YACReaderLibrary/library_window.h @@ -13,6 +13,8 @@ #include "comic_query_result_processor.h" #include "folder_query_result_processor.h" +#include "comic_model.h" + #include #include @@ -77,7 +79,6 @@ class YACReaderHistoryController; class EmptyLabelWidget; class EmptySpecialListWidget; class EmptyReadingListWidget; -class YACReaderComicsViewsManager; namespace YACReader { class TrayIconController; @@ -315,6 +316,7 @@ public slots: void selectSubfolder(const QModelIndex &mi, int child); void checkEmptyFolder(); void openComic(); + void openComic(const ComicDB &comic, const ComicModel::Mode mode); void createLibrary(); void create(QString source, QString dest, QString name); void showAddLibrary(); diff --git a/YACReaderLibrary/yacreader_comics_views_manager.cpp b/YACReaderLibrary/yacreader_comics_views_manager.cpp index fa1a9a6a..585a6533 100644 --- a/YACReaderLibrary/yacreader_comics_views_manager.cpp +++ b/YACReaderLibrary/yacreader_comics_views_manager.cpp @@ -146,7 +146,7 @@ void YACReaderComicsViewsManager::doComicsViewConnections() connect(comicsView, SIGNAL(comicRated(int, QModelIndex)), libraryWindow->comicsModel, SLOT(updateRating(int, QModelIndex))); connect(libraryWindow->showHideMarksAction, SIGNAL(toggled(bool)), comicsView, SLOT(setShowMarks(bool))); connect(comicsView, SIGNAL(selected(unsigned int)), libraryWindow, SLOT(openComic())); - connect(comicsView, SIGNAL(openComic()), libraryWindow, SLOT(openComic())); + connect(comicsView, SIGNAL(openComic(const ComicDB &, const ComicModel::Mode)), libraryWindow, SLOT(openComic(const ComicDB &, const ComicModel::Mode))); connect(libraryWindow->selectAllComicsAction, SIGNAL(triggered()), comicsView, SLOT(selectAll()));