diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cf214c7..f22bc6b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Version counting is based on semantic versioning (Major.Feature.Patch) * Fixed selected folder restoration after folder updates. * Better support for HDPI screens (SVG icons). * Add option to delete metadata from comics. +* Importing ComicInfo.XML is now optional and disabled by default, you can change the behavior in Settings -> General. ### Server * Add webui status page (reachable by navigating to server::port/webui) diff --git a/YACReaderLibrary/initial_comic_info_extractor.cpp b/YACReaderLibrary/initial_comic_info_extractor.cpp index f815a25a..2d889f4c 100644 --- a/YACReaderLibrary/initial_comic_info_extractor.cpp +++ b/YACReaderLibrary/initial_comic_info_extractor.cpp @@ -10,8 +10,8 @@ using namespace YACReader; bool InitialComicInfoExtractor::crash = false; -InitialComicInfoExtractor::InitialComicInfoExtractor(QString fileSource, QString target, int coverPage) - : _fileSource(fileSource), _target(target), _numPages(0), _coverPage(coverPage), _xmlInfoData() +InitialComicInfoExtractor::InitialComicInfoExtractor(QString fileSource, QString target, int coverPage, bool getXMLMetadata) + : _fileSource(fileSource), _target(target), _numPages(0), _coverPage(coverPage), getXMLMetadata(getXMLMetadata), _xmlInfoData() { } @@ -101,16 +101,17 @@ void InitialComicInfoExtractor::extract() QList order = archive.getFileNames(); - // Try to find embeded XML info (ComicRack or ComicTagger) + if (getXMLMetadata) { + // Try to find embeded XML info (ComicRack or ComicTagger) + auto infoIndex = 0; + for (auto &fileName : order) { + if (fileName.endsWith(".xml", Qt::CaseInsensitive)) { + _xmlInfoData = archive.getRawDataAtIndex(infoIndex); + break; + } - auto infoIndex = 0; - for (auto &fileName : order) { - if (fileName.endsWith(".xml", Qt::CaseInsensitive)) { - _xmlInfoData = archive.getRawDataAtIndex(infoIndex); - break; + infoIndex++; } - - infoIndex++; } //-------------------------- diff --git a/YACReaderLibrary/initial_comic_info_extractor.h b/YACReaderLibrary/initial_comic_info_extractor.h index b59024b0..5382d81f 100644 --- a/YACReaderLibrary/initial_comic_info_extractor.h +++ b/YACReaderLibrary/initial_comic_info_extractor.h @@ -9,7 +9,7 @@ class InitialComicInfoExtractor : public QObject Q_OBJECT public: - InitialComicInfoExtractor(QString fileSource, QString target = "", int coverPage = 1); + InitialComicInfoExtractor(QString fileSource, QString target = "", int coverPage = 1, bool getXMLMetadata = false); private: QString _fileSource; @@ -19,6 +19,7 @@ private: QPair _coverSize; QImage _cover; int _coverPage; + int getXMLMetadata; static bool crash; QByteArray _xmlInfoData; void saveCover(const QString &path, const QImage &cover); diff --git a/YACReaderLibrary/library_creator.cpp b/YACReaderLibrary/library_creator.cpp index 4058dd58..d5a15337 100644 --- a/YACReaderLibrary/library_creator.cpp +++ b/YACReaderLibrary/library_creator.cpp @@ -18,6 +18,8 @@ #include "pdf_comic.h" #include "yacreader_global.h" +#include "yacreader_global_gui.h" + #include "QsLog.h" #include @@ -26,8 +28,8 @@ using namespace std; using namespace YACReader; //-------------------------------------------------------------------------------- -LibraryCreator::LibraryCreator() - : creation(false), partialUpdate(false) +LibraryCreator::LibraryCreator(QSettings *settings) + : creation(false), partialUpdate(false), settings(settings) { _nameFilter << Comic::comicExtensions; } @@ -301,7 +303,7 @@ void LibraryCreator::insertComic(const QString &relativePath, const QFileInfo &f QPair originalCoverSize = { 0, 0 }; bool exists = checkCover(hash); - YACReader::InitialComicInfoExtractor ie(QDir::cleanPath(fileInfo.absoluteFilePath()), _target + "/covers/" + hash + ".jpg", comic.info.coverPage.toInt()); + YACReader::InitialComicInfoExtractor ie(QDir::cleanPath(fileInfo.absoluteFilePath()), _target + "/covers/" + hash + ".jpg", comic.info.coverPage.toInt(), settings->value(IMPORT_COMIC_INFO_XML_METADATA, false).toBool()); if (!(comic.hasCover() && exists)) { ie.extract(); diff --git a/YACReaderLibrary/library_creator.h b/YACReaderLibrary/library_creator.h index 80d93a17..1f00a82b 100644 --- a/YACReaderLibrary/library_creator.h +++ b/YACReaderLibrary/library_creator.h @@ -22,7 +22,7 @@ class LibraryCreator : public QThread { Q_OBJECT public: - LibraryCreator(); + LibraryCreator(QSettings *settings); void createLibrary(const QString &source, const QString &target); void updateLibrary(const QString &source, const QString &target); void updateFolder(const QString &source, const QString &target, const QString &folder, const QModelIndex &dest); @@ -54,6 +54,7 @@ private: bool creation; bool partialUpdate; QModelIndex folderDestinationModelIndex; + QSettings *settings; signals: void finished(); diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 32fe2c82..8a905c94 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -167,7 +167,7 @@ void LibraryWindow::setupUI() setUnifiedTitleAndToolBarOnMac(true); - libraryCreator = new LibraryCreator(); + libraryCreator = new LibraryCreator(settings); packageManager = new PackageManager(); xmlInfoLibraryScanner = new XMLInfoLibraryScanner(); diff --git a/YACReaderLibrary/options_dialog.cpp b/YACReaderLibrary/options_dialog.cpp index bc978eea..2e629215 100644 --- a/YACReaderLibrary/options_dialog.cpp +++ b/YACReaderLibrary/options_dialog.cpp @@ -50,13 +50,13 @@ OptionsDialog::OptionsDialog(QWidget *parent) trayIconCheckbox = new QCheckBox(tr("Close to tray")); startToTrayCheckbox = new QCheckBox(tr("Start into the system tray")); - connect(trayIconCheckbox, &QCheckBox::clicked, + connect(trayIconCheckbox, &QCheckBox::clicked, this, [=](bool checked) { settings->setValue(CLOSE_TO_TRAY, checked); startToTrayCheckbox->setEnabled(checked); emit optionsChanged(); }); - connect(startToTrayCheckbox, &QCheckBox::clicked, + connect(startToTrayCheckbox, &QCheckBox::clicked, this, [=](bool checked) { settings->setValue(START_TO_TRAY, checked); }); @@ -74,6 +74,18 @@ OptionsDialog::OptionsDialog(QWidget *parent) connect(apiKeyButton, &QAbstractButton::clicked, this, &OptionsDialog::editApiKey); + auto comicInfoXMLBox = new QGroupBox(tr("ComicInfo.xml legacy support")); + + comicInfoXMLCheckbox = new QCheckBox(tr("Import metada from ComicInfo.xml when adding new comics")); + connect(comicInfoXMLCheckbox, &QCheckBox::clicked, this, + [=](bool checked) { + settings->setValue(IMPORT_COMIC_INFO_XML_METADATA, checked); + }); + + auto comicInfoXMLBoxLayout = new QVBoxLayout(); + comicInfoXMLBoxLayout->addWidget(comicInfoXMLCheckbox); + comicInfoXMLBox->setLayout(comicInfoXMLBoxLayout); + // grid view background config useBackgroundImageCheck = new QCheckBox(tr("Enable background image")); @@ -139,6 +151,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) generalLayout->addWidget(trayIconBox); generalLayout->addWidget(shortcutsBox); generalLayout->addWidget(apiKeyBox); + generalLayout->addWidget(comicInfoXMLBox); generalLayout->addStretch(); tabWidget->addTab(generalW, tr("General")); @@ -172,6 +185,8 @@ void OptionsDialog::restoreOptions(QSettings *settings) startToTrayCheckbox->setChecked(settings->value(START_TO_TRAY, false).toBool()); startToTrayCheckbox->setEnabled(trayIconCheckbox->isChecked()); + comicInfoXMLCheckbox->setChecked(settings->value(IMPORT_COMIC_INFO_XML_METADATA, false).toBool()); + bool useBackgroundImage = settings->value(USE_BACKGROUND_IMAGE_IN_GRID_VIEW, true).toBool(); useBackgroundImageCheck->setChecked(useBackgroundImage); diff --git a/YACReaderLibrary/options_dialog.h b/YACReaderLibrary/options_dialog.h index 7ecc8511..c65500ac 100644 --- a/YACReaderLibrary/options_dialog.h +++ b/YACReaderLibrary/options_dialog.h @@ -37,6 +37,7 @@ private: QCheckBox *displayContinueReadingBannerCheck; QCheckBox *trayIconCheckbox; QCheckBox *startToTrayCheckbox; + QCheckBox *comicInfoXMLCheckbox; }; #endif diff --git a/common/yacreader_global_gui.h b/common/yacreader_global_gui.h index 55b7a441..015c7f4b 100644 --- a/common/yacreader_global_gui.h +++ b/common/yacreader_global_gui.h @@ -71,6 +71,7 @@ #define BLUR_RADIUS_BACKGROUND_IMAGE_IN_GRID_VIEW "BLUR_RADIUS_BACKGROUND_IMAGE_IN_GRID_VIEW" #define USE_SELECTED_COMIC_COVER_AS_BACKGROUND_IMAGE_IN_GRID_VIEW "USE_SELECTED_COMIC_COVER_AS_BACKGROUND_IMAGE_IN_GRID_VIEW" #define DISPLAY_CONTINUE_READING_IN_GRID_VIEW "DISPLAY_CONTINUE_READING_IN_GRID_VIEW" +#define IMPORT_COMIC_INFO_XML_METADATA "IMPORT_COMIC_INFO_XML_METADATA" namespace YACReader { diff --git a/custom_widgets/whats_new_dialog.cpp b/custom_widgets/whats_new_dialog.cpp index f8961009..0566a05b 100644 --- a/custom_widgets/whats_new_dialog.cpp +++ b/custom_widgets/whats_new_dialog.cpp @@ -60,6 +60,9 @@ YACReader::WhatsNewDialog::WhatsNewDialog(QWidget *parent) " • Fixed selected folder restoration after folder updates.
" " • Add option to delete metadata from comics.
" " • Better support for HDPI screens (SVG icons).
" + " • Importing ComicInfo.XML is now optional, you can change the behavior in Settings -> General.
" + "
" + "NOTE: Importing metadata from ComicInfo.XML in now disabled by default, if you want you can enable it Settings -> General.
" "
" "I hope you enjoy the new update. Please, if you like YACReader consider to become a patron in Patreon or donate some money using Pay-Pal and help keeping the project alive. Remember that there is an iOS version available in the Apple App Store."); QFont textLabelFont("Arial", 15, QFont::Light);