From 75c50a42096ab865297cdb7d1275867ac5ddfdcf Mon Sep 17 00:00:00 2001 From: Alfred Reynolds Date: Sat, 31 Jul 2021 14:42:13 +1200 Subject: [PATCH] - Implement aspect ratio checking for the shuffle and sorted image list modes --- src/imageselector.cpp | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/src/imageselector.cpp b/src/imageselector.cpp index c2f7306..5271291 100644 --- a/src/imageselector.cpp +++ b/src/imageselector.cpp @@ -159,8 +159,20 @@ std::string ShuffleImageSelector::getNextImage() std::string filename = pathTraverser->getImagePath(images.at(current_image_shuffle).toStdString()); if(!QFileInfo::exists(QString(filename.c_str()))) { - std::cout << "file not found: " << filename << std::endl; - current_image_shuffle = images.size(); + if(debugMode) + { + std::cout << "file not found: " << filename << std::endl; + } + current_image_shuffle = current_image_shuffle + 1; // ignore and move to next image + return getNextImage(); + } + if (!imageValidForAspect(filename)) + { + if(debugMode) + { + std::cout << "image has invalid aspect: " << filename << "(images left:" << (images.size()-current_image_shuffle) << ")" << std::endl; + } + current_image_shuffle = current_image_shuffle + 1; // ignore and move to next image return getNextImage(); } std::cout << "updating image: " << filename << std::endl; @@ -197,10 +209,13 @@ std::string SortedImageSelector::getNextImage() { images = pathTraverser->getImages(); std::sort(images.begin(), images.end()); - std::cout << "read " << images.size() << " images." << std::endl; - for (int i = 0;i getImagePath(images.takeFirst().toStdString()); if(!QFileInfo::exists(QString(filename.c_str()))) { - std::cout << "file not found: " << filename << std::endl; + if(debugMode) + { + std::cout << "file not found: " << filename << std::endl; + } return getNextImage(); } + if (!imageValidForAspect(filename)) + { + if(debugMode) + { + std::cout << "image has invalid aspect: " << filename << std::endl; + } + return getNextImage(); + } + std::cout << "updating image: " << filename << std::endl; return filename; }