From c29e228ae08be6f386cd2e8970f290102de1c6b6 Mon Sep 17 00:00:00 2001 From: Alfred Reynolds Date: Sun, 1 Aug 2021 11:27:22 +1200 Subject: [PATCH 01/30] - Add image list display type, you provide a comma delimited list of fully qualified path names to display --- README.md | 3 ++- src/main.cpp | 14 +++++++++++--- src/pathtraverser.cpp | 21 +++++++++++++++++++++ src/pathtraverser.h | 10 ++++++++++ 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0246fe4..64441b7 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/src/main.cpp b/src/main.cpp index accc571..871cb9f 100644 --- a/src/main.cpp +++ b/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; - if (recursive) + if (!imageList.empty()) + { + pathTraverser = std::unique_ptr(new ImageListPathTraverser(imageList)); + } + else if (recursive) { pathTraverser = std::unique_ptr(new RecursivePathTraverser(path)); } diff --git a/src/pathtraverser.cpp b/src/pathtraverser.cpp index a6f3317..bb20a0f 100644 --- a/src/pathtraverser.cpp +++ b/src/pathtraverser.cpp @@ -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; +} \ No newline at end of file diff --git a/src/pathtraverser.h b/src/pathtraverser.h index 743278c..8d32e08 100644 --- a/src/pathtraverser.h +++ b/src/pathtraverser.h @@ -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 From 5eaf7ee539659d12d3b38ad2bd99d80817d8af4f Mon Sep 17 00:00:00 2001 From: Alfred Reynolds Date: Sun, 1 Aug 2021 13:05:43 +1200 Subject: [PATCH 02/30] - Add support for per folder image display options. The file called options.json contains json keys to control image options when displaying files in this folder. Currently a singled option, fitAspectAxisToWindow, is supported - Remove duplicated image rotation reading code, have the image selector logic just pass this up via the per image options --- README.md | 11 ++++++- src/imageselector.cpp | 51 +++++++++++++++++++------------ src/imageselector.h | 26 ++++++++++------ src/imageswitcher.cpp | 5 +-- src/main.cpp | 14 ++++----- src/mainwindow.cpp | 51 ++++--------------------------- src/mainwindow.h | 8 ++--- src/pathtraverser.cpp | 71 +++++++++++++++++++++++++++++++++++++------ src/pathtraverser.h | 15 ++++++--- 9 files changed, 149 insertions(+), 103 deletions(-) diff --git a/README.md b/README.md index 64441b7..34d10f5 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,16 @@ slide [-t rotation_seconds] [-a aspect] [-o background_opacity(0..255)] [-b blur * ``directory of the current image * ``path to the current image without filename * Example: `slide -p ./images -O "20|60|Time: