Warning when using both custom art and the printing selector

This commit is contained in:
Basile Clément 2025-03-24 17:48:10 +01:00
parent b233743825
commit 53cd3dffeb
No known key found for this signature in database
3 changed files with 44 additions and 0 deletions

View file

@ -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;
}

View file

@ -36,6 +36,7 @@ public:
static void clearPixmapCache(CardInfoPtr card);
static void clearPixmapCache();
static void cacheCardPixmaps(QList<CardInfoPtr> cards);
static bool hasCustomArt();
public slots:
static void clearNetworkCache();

View file

@ -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 <QFrame>
#include <QScrollBar>
#include <qboxlayout.h>
/**
* @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("<b>Warning:</b> 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);