From 53cd3dffeb3143784bb20231573c183402d366ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Basile=20Cl=C3=A9ment?= Date: Mon, 24 Mar 2025 17:48:10 +0100 Subject: [PATCH] Warning when using both custom art and the printing selector --- .../ui/picture_loader/picture_loader.cpp | 22 +++++++++++++++++++ .../client/ui/picture_loader/picture_loader.h | 1 + .../printing_selector/printing_selector.cpp | 21 ++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/cockatrice/src/client/ui/picture_loader/picture_loader.cpp b/cockatrice/src/client/ui/picture_loader/picture_loader.cpp index 7d981aee6..ff63ccdec 100644 --- a/cockatrice/src/client/ui/picture_loader/picture_loader.cpp +++ b/cockatrice/src/client/ui/picture_loader/picture_loader.cpp @@ -195,3 +195,25 @@ void PictureLoader::picsPathChanged() { QPixmapCache::clear(); } + +bool PictureLoader::hasCustomArt() +{ + auto picsPath = SettingsCache::instance().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()) { + QFileInfo dir = it.nextFileInfo(); + + 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/client/ui/picture_loader/picture_loader.h b/cockatrice/src/client/ui/picture_loader/picture_loader.h index 8819bddac..68a9424e4 100644 --- a/cockatrice/src/client/ui/picture_loader/picture_loader.h +++ b/cockatrice/src/client/ui/picture_loader/picture_loader.h @@ -36,6 +36,7 @@ public: static void clearPixmapCache(CardInfoPtr card); static void clearPixmapCache(); static void cacheCardPixmaps(QList cards); + static bool hasCustomArt(); public slots: static void clearNetworkCache(); diff --git a/cockatrice/src/client/ui/widgets/printing_selector/printing_selector.cpp b/cockatrice/src/client/ui/widgets/printing_selector/printing_selector.cpp index c0605fc39..b01d2aa97 100644 --- a/cockatrice/src/client/ui/widgets/printing_selector/printing_selector.cpp +++ b/cockatrice/src/client/ui/widgets/printing_selector/printing_selector.cpp @@ -1,12 +1,15 @@ #include "printing_selector.h" #include "../../../../settings/cache_settings.h" +#include "../../picture_loader/picture_loader.h" #include "printing_selector_card_display_widget.h" #include "printing_selector_card_search_widget.h" #include "printing_selector_card_selection_widget.h" #include "printing_selector_card_sorting_widget.h" +#include #include +#include /** * @brief Constructs a PrintingSelector widget to display and manage card printings. @@ -29,6 +32,24 @@ PrintingSelector::PrintingSelector(QWidget *parent, AbstractTabDeckEditor *_deck layout = new QVBoxLayout(this); setLayout(layout); + if (PictureLoader::hasCustomArt()) { + QFrame *warningFrame = new QFrame(this); + warningFrame->setFrameShape(QFrame::StyledPanel); + + QLabel *warningLabel = new QLabel(this); + warningLabel->setTextFormat(Qt::RichText); + warningLabel->setText("Warning: You appear to be using custom card art, which has known bugs when also " + "using the printing selector in this version of Cockatrice."); + warningLabel->setWordWrap(true); + + auto *warningLayout = new QVBoxLayout(warningFrame); + warningFrame->setLayout(warningLayout); + + warningLayout->addWidget(warningLabel); + + layout->addWidget(warningFrame); + } + widgetLoadingBufferTimer = new QTimer(this); flowWidget = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAsNeeded);