mirror of
https://github.com/YACReader/yacreader
synced 2025-07-17 04:24:32 -04:00
Extract opening a comic from YACReaderLibrary to its own file
And send a new param `--readingListId` to tell YACReader that the comic is opened from a reading list.
This commit is contained in:
@ -86,6 +86,8 @@
|
||||
|
||||
#include "whats_new_controller.h"
|
||||
|
||||
#include "library_comic_opener.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
@ -1825,37 +1827,27 @@ void LibraryWindow::checkEmptyFolder()
|
||||
}
|
||||
}
|
||||
|
||||
void LibraryWindow::openComic(const ComicDB &comic)
|
||||
void LibraryWindow::openComic()
|
||||
{
|
||||
if (!importedCovers) {
|
||||
//TODO generate IDS for libraries...
|
||||
quint64 libraryId = libraries.getId(selectedLibrary->currentText());
|
||||
bool yacreaderFound = false;
|
||||
auto libraryId = libraries.getId(selectedLibrary->currentText());
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
QStringList possiblePaths { QDir::cleanPath(QCoreApplication::applicationDirPath() + "/../../../") };
|
||||
possiblePaths += QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation);
|
||||
auto comic = comicsModel->getComic(comicsViewsManager->comicsView->currentIndex());
|
||||
auto mode = comicsModel->getMode();
|
||||
|
||||
for (auto &&ypath : possiblePaths) {
|
||||
QString yacreaderPath = QDir::cleanPath(ypath + "/YACReader.app");
|
||||
if (QFileInfo(yacreaderPath).exists()) {
|
||||
yacreaderFound = true;
|
||||
QStringList parameters { "-n", yacreaderPath, "--args", currentPath(), QString("--comicId=%1").arg(comic.id), QString("--libraryId=%1").arg(libraryId) };
|
||||
QProcess::startDetached("open", parameters);
|
||||
break;
|
||||
}
|
||||
OpenComicSource::Source source;
|
||||
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
QStringList parameters { currentPath(), QString("--comicId=%1").arg(comic.id), QString("--libraryId=%1").arg(libraryId) };
|
||||
yacreaderFound = QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath() + "/YACReader.exe"), parameters);
|
||||
#endif
|
||||
auto yacreaderFound = YACReader::openComic(comic, libraryId, currentPath(), OpenComicSource { source, comicsModel->getSourceId() });
|
||||
|
||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||
QStringList parameters { currentPath(), QString("--comicId=%1").arg(comic.id), QString("--libraryId=%1").arg(libraryId) };
|
||||
yacreaderFound = QProcess::startDetached(QStringLiteral("YACReader"), parameters);
|
||||
#endif
|
||||
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."));
|
||||
@ -1866,14 +1858,6 @@ void LibraryWindow::openComic(const ComicDB &comic)
|
||||
}
|
||||
}
|
||||
|
||||
void LibraryWindow::openComic()
|
||||
{
|
||||
if (!importedCovers) {
|
||||
ComicDB comic = comicsModel->getComic(comicsViewsManager->comicsView->currentIndex());
|
||||
openComic(comic);
|
||||
}
|
||||
}
|
||||
|
||||
void LibraryWindow::setCurrentComicsStatusReaded(YACReaderComicReadStatus readStatus)
|
||||
{
|
||||
comicsModel->setComicsRead(getSelectedComics(), readStatus);
|
||||
|
Reference in New Issue
Block a user