diff --git a/cockatrice/src/interface/card_picture_loader/card_picture_loader.cpp b/cockatrice/src/interface/card_picture_loader/card_picture_loader.cpp index e1f760d9d..b8a54761a 100644 --- a/cockatrice/src/interface/card_picture_loader/card_picture_loader.cpp +++ b/cockatrice/src/interface/card_picture_loader/card_picture_loader.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -334,8 +334,7 @@ void CardPictureLoader::saveCardImageToLocalStorage(const ExactCard &card, } } -void CardPictureLoader::overridePrintingConnectLocalSaveAndEnqueue(const ExactCard &originalCard, - const ExactCard &overrideCard) +void CardPictureLoader::installPrintingOverrideOnLoad(const ExactCard &originalCard, const ExactCard &overrideCard) { // Overriding a card with itself is the reset case, not a real override: every code path below // would re-enter itself through emitPixmapUpdated(). Reject it outright. @@ -391,10 +390,9 @@ void CardPictureLoader::overridePrintingConnectLocalSaveAndEnqueue(const ExactCa CardPictureLoader::getInstance().worker->enqueueImageLoad(overrideCard); } -void CardPictureLoader::overridePrintingEnsurePixmapExistsAndSaveLocally(const ExactCard &originalCard, - const ExactCard &overrideCard) +void CardPictureLoader::installPrintingOverride(const ExactCard &originalCard, const ExactCard &overrideCard) { - // Same guard as overridePrintingConnectLocalSaveAndEnqueue: self-override is the reset case. + // Same guard as installPrintingOverrideOnLoad: self-override is the reset case. if (originalCard == overrideCard) { return; } @@ -409,7 +407,7 @@ void CardPictureLoader::overridePrintingEnsurePixmapExistsAndSaveLocally(const E } // Cache miss or previously failed load — enqueue load and wait for the signal. - overridePrintingConnectLocalSaveAndEnqueue(originalCard, overrideCard); + installPrintingOverrideOnLoad(originalCard, overrideCard); } bool CardPictureLoader::hasLocalOverrides(const ExactCard &card) @@ -499,32 +497,3 @@ void CardPictureLoader::cardLangChanged() QPixmapCache::clear(); failedAt.clear(); } - -bool CardPictureLoader::hasCustomArt() -{ - auto picsPath = SettingsCache::instance().paths().getPicsPath(); - QDirIterator it(picsPath, QDir::Dirs | QDir::NoDotAndDotDot); - - // Check if there is at least one non-directory file in the pics path, other - // than in the "downloadedPics" subdirectory. - while (it.hasNext()) { -#if (QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)) - QFileInfo dir(it.nextFileInfo()); -#else - // nextFileInfo() is only available in Qt 6.3+, for previous versions, we build - // the QFileInfo from a QString which requires more system calls. - QFileInfo dir(it.next()); -#endif - - if (it.fileName() == "downloadedPics") { - continue; - } - - QDirIterator subIt(it.filePath(), QDir::Files, QDirIterator::Subdirectories | QDirIterator::FollowSymlinks); - if (subIt.hasNext()) { - return true; - } - } - - return false; -} diff --git a/cockatrice/src/interface/card_picture_loader/card_picture_loader.h b/cockatrice/src/interface/card_picture_loader/card_picture_loader.h index 6e7d19df1..0a4934e6d 100644 --- a/cockatrice/src/interface/card_picture_loader/card_picture_loader.h +++ b/cockatrice/src/interface/card_picture_loader/card_picture_loader.h @@ -96,12 +96,6 @@ public: */ static void cacheCardPixmaps(const QList &cards); - /** - * @brief Check if the user has custom card art in the picsPath directory. - * @return True if any custom art exists. - */ - static bool hasCustomArt(); - /** * @brief Check if a local override image already exists for the card. * @param card The card to check. @@ -109,6 +103,12 @@ public: */ static bool hasLocalOverrides(const ExactCard &card); + /** + * @brief Removes all locally stored override images for the card. + * @param card The card to remove the override images of. + */ + static void deleteAllLocalOverrides(const ExactCard &card); + /** * @brief Clears the in-memory QPixmap cache for all cards. */ @@ -127,10 +127,9 @@ public slots: * @param image Loaded QImage. */ void imageLoaded(const ExactCard &card, const QImage &image); - void deleteAllLocalOverrides(const ExactCard &card); void saveCardImageToLocalStorage(const ExactCard &card, const QPixmap &pixmap, bool allowOverwrite = false); - void overridePrintingConnectLocalSaveAndEnqueue(const ExactCard &originalCard, const ExactCard &overrideCard); - void overridePrintingEnsurePixmapExistsAndSaveLocally(const ExactCard &originalCard, const ExactCard &overrideCard); + void installPrintingOverride(const ExactCard &originalCard, const ExactCard &overrideCard); + void installPrintingOverrideOnLoad(const ExactCard &originalCard, const ExactCard &overrideCard); private slots: /**