Cockatrice can now load images both with and without .full. Will need to clean-up bool stripped (used to determine .full suffix inclusion).

This commit is contained in:
Peng Liu 2014-08-11 04:37:00 -04:00
parent 8b32a1010a
commit 781460d6ac

View file

@ -135,14 +135,14 @@ void PictureLoader::processLoadQueue()
mutex.unlock();
//The list of paths to the folders in which to search for images
QList<QString> picsPaths = QList<QString>() << _picsPath + "/CUSTOM/" + ptl.getCard()->getCorrectedName() + ".full";
QList<QString> picsPaths = QList<QString>() << _picsPath + "/CUSTOM/" + ptl.getCard()->getCorrectedName();
QString setName=ptl.getSetName();
if(!setName.isEmpty())
{
picsPaths << _picsPath + "/" + setName + "/" + ptl.getCard()->getCorrectedName() + ".full"
<< _picsPath + "/downloadedPics/" + setName + "/" + ptl.getCard()->getCorrectedName() + ".full";
picsPaths << _picsPath + "/" + setName + "/" + ptl.getCard()->getCorrectedName()
<< _picsPath + "/downloadedPics/" + setName + "/" + ptl.getCard()->getCorrectedName();
}
QImage image;
@ -153,6 +153,12 @@ void PictureLoader::processLoadQueue()
//Iterates through the list of paths, searching for images with the desired name with any QImageReader-supported extension
for (int i = 0; i < picsPaths.length() && !found; i ++) {
imgReader.setFileName(picsPaths.at(i));
if (imgReader.read(&image)) {
emit imageLoaded(ptl.getCard(), image);
found = true;
break;
}
imgReader.setFileName(picsPaths.at(i) + ".full");
if (imgReader.read(&image)) {
emit imageLoaded(ptl.getCard(), image);
found = true;
@ -274,11 +280,7 @@ void PictureLoader::picDownloadFinished(QNetworkReply *reply)
return;
}
QString suffix;
if (!cardBeingDownloaded.getStripped())
suffix = ".full";
QFile newPic(picsPath + "/downloadedPics/" + setName + "/" + cardBeingDownloaded.getCard()->getCorrectedName() + suffix + extension);
QFile newPic(picsPath + "/downloadedPics/" + setName + "/" + cardBeingDownloaded.getCard()->getCorrectedName() + extension);
if (!newPic.open(QIODevice::WriteOnly))
return;
newPic.write(picData);