- Add image list display type, you provide a comma delimited list of fully qualified path names to display
This commit is contained in:
@@ -17,10 +17,11 @@ This project is maintained by myself during my spare time. If you like and use i
|
||||
## Usage
|
||||
|
||||
```
|
||||
slide [-t rotation_seconds] [-a aspect] [-o background_opacity(0..255)] [-b blur_radius] -p image_folder [-r] [-O overlay_string] [-v] [--verbose] [--stretch]
|
||||
slide [-t rotation_seconds] [-a aspect] [-o background_opacity(0..255)] [-b blur_radius] [-p image_folder|-i imageFile,...] [-r] [-O overlay_string] [-v] [--verbose] [--stretch]
|
||||
```
|
||||
|
||||
* `image_folder`: where to search for images (.jpg files)
|
||||
* `-i imageFile,...`: comma delimited list of full paths to image files to display
|
||||
* `-r` for recursive traversal of `image_folder`
|
||||
* `-s` for shuffle instead of random image rotation
|
||||
* `-S` for sorted rotation (files ordered by name, first images then subfolders)
|
||||
|
||||
14
src/main.cpp
14
src/main.cpp
@@ -35,6 +35,7 @@ int main(int argc, char *argv[])
|
||||
bool fitAspectAxisToWindow = false;
|
||||
std::string valid_aspects = "alp"; // all, landscape, portait
|
||||
std::string overlay = "";
|
||||
std::string imageList = ""; // comma delimited list of images to show
|
||||
int debugInt = 0;
|
||||
int stretchInt = 0;
|
||||
static struct option long_options[] =
|
||||
@@ -43,7 +44,7 @@ int main(int argc, char *argv[])
|
||||
{"stretch", no_argument, &stretchInt, 1},
|
||||
};
|
||||
int option_index = 0;
|
||||
while ((opt = getopt_long(argc, argv, "b:p:t:o:O:a:rsSv", long_options, &option_index)) != -1) {
|
||||
while ((opt = getopt_long(argc, argv, "b:p:t:o:O:a:i:rsSv", long_options, &option_index)) != -1) {
|
||||
switch (opt) {
|
||||
case 0:
|
||||
/* If this option set a flag, do nothing else now. */
|
||||
@@ -88,6 +89,9 @@ int main(int argc, char *argv[])
|
||||
case 'v':
|
||||
debugMode = true;
|
||||
break;
|
||||
case 'i':
|
||||
imageList = optarg;
|
||||
break;
|
||||
default: /* '?' */
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
@@ -102,7 +106,7 @@ int main(int argc, char *argv[])
|
||||
fitAspectAxisToWindow = true;
|
||||
}
|
||||
|
||||
if (path.empty())
|
||||
if (path.empty() && imageList.empty())
|
||||
{
|
||||
std::cout << "Error: Path expected." << std::endl;
|
||||
usage(argv[0]);
|
||||
@@ -110,7 +114,11 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
std::unique_ptr<PathTraverser> pathTraverser;
|
||||
if (recursive)
|
||||
if (!imageList.empty())
|
||||
{
|
||||
pathTraverser = std::unique_ptr<PathTraverser>(new ImageListPathTraverser(imageList));
|
||||
}
|
||||
else if (recursive)
|
||||
{
|
||||
pathTraverser = std::unique_ptr<PathTraverser>(new RecursivePathTraverser(path));
|
||||
}
|
||||
|
||||
@@ -61,3 +61,24 @@ const std::string DefaultPathTraverser::getImagePath(const std::string image) co
|
||||
{
|
||||
return directory.filePath(QString(image.c_str())).toStdString();
|
||||
}
|
||||
|
||||
|
||||
ImageListPathTraverser::ImageListPathTraverser(const std::string &imageListString):
|
||||
PathTraverser("")
|
||||
{
|
||||
QString str = QString(imageListString.c_str());
|
||||
imageList = str.split(QLatin1Char(','));
|
||||
}
|
||||
|
||||
ImageListPathTraverser::~ImageListPathTraverser() {}
|
||||
|
||||
|
||||
QStringList ImageListPathTraverser::getImages() const
|
||||
{
|
||||
return imageList;
|
||||
}
|
||||
|
||||
const std::string ImageListPathTraverser::getImagePath(const std::string image) const
|
||||
{
|
||||
return image;
|
||||
}
|
||||
@@ -41,4 +41,14 @@ class DefaultPathTraverser : public PathTraverser
|
||||
QDir directory;
|
||||
};
|
||||
|
||||
class ImageListPathTraverser : public PathTraverser
|
||||
{
|
||||
public:
|
||||
ImageListPathTraverser(const std::string &imageListString);
|
||||
virtual ~ImageListPathTraverser();
|
||||
QStringList getImages() const;
|
||||
virtual const std::string getImagePath(const std::string image) const;
|
||||
private:
|
||||
QStringList imageList;
|
||||
};
|
||||
#endif // PATHTRAVERSER_H
|
||||
|
||||
Reference in New Issue
Block a user