diff --git a/src/appconfig.cpp b/src/appconfig.cpp index 8a18eae..fe06e57 100644 --- a/src/appconfig.cpp +++ b/src/appconfig.cpp @@ -170,6 +170,8 @@ QVector parsePathEntry(QJsonObject &jsonMainDoc, bool baseRecursive, SetJSONBool(entry.shuffle, schedulerJson, "shuffle"); SetJSONBool(entry.sorted, schedulerJson, "sorted"); + SetJSONBool(entry.baseDisplayOptions.fitAspectAxisToWindow, schedulerJson, "stretch"); + std::string pathString = ParseJSONString(schedulerJson, "path"); if(!pathString.empty()) { entry.path = pathString; @@ -178,10 +180,7 @@ QVector parsePathEntry(QJsonObject &jsonMainDoc, bool baseRecursive, if(!imageListString.empty()) { entry.imageList = imageListString; } - std::string typeString = ParseJSONString(schedulerJson, "type"); - if(!pathString.empty()) { - entry.type = typeString; - } + SetJSONBool(entry.exclusive, schedulerJson, "exclusive"); if(schedulerJson.contains("times") && schedulerJson["times"].isArray()) @@ -201,7 +200,7 @@ QVector parsePathEntry(QJsonObject &jsonMainDoc, bool baseRecursive, { window.endDisplay = QTime::fromString(timesJson["end"].toString()); } - entry.timeWindows.append(window); + entry.baseDisplayOptions.timeWindows.append(window); } } } diff --git a/src/appconfig.h b/src/appconfig.h index 61fadb3..849de7b 100644 --- a/src/appconfig.h +++ b/src/appconfig.h @@ -16,15 +16,38 @@ struct Config { }; struct PathEntry { - QVector timeWindows; std::string path = ""; std::string imageList = ""; - std::string type = ""; - bool exclusive = false; + bool exclusive = false; // only use this entry when it is valid, skip others bool recursive = false; bool shuffle = false; bool sorted = false; + ImageDisplayOptions baseDisplayOptions; + + bool operator==(const PathEntry &b) const + { + return !operator!=(b); + } + bool operator!=(const PathEntry &b) const + { + if (b.exclusive != exclusive) + return true; + if (b.recursive != recursive || b.shuffle != shuffle || b.sorted != sorted) + return true; + if(b.baseDisplayOptions.fitAspectAxisToWindow != baseDisplayOptions.fitAspectAxisToWindow) + return true; + if (b.path != path || b.imageList != imageList) + return true; + if (b.baseDisplayOptions.timeWindows.count() != baseDisplayOptions.timeWindows.count()) + return true; + for(int i = 0; i < baseDisplayOptions.timeWindows.count(); ++i) + { + if (b.baseDisplayOptions.timeWindows[i] != baseDisplayOptions.timeWindows[i]) + return true; + } + return false; + } }; // app level configuration @@ -39,18 +62,16 @@ struct AppConfig : public Config { static const std::string valid_aspects; public: - bool PathOptionsChanged(AppConfig &other) { + bool PathOptionsChanged(AppConfig &other) + { if (paths.count() != other.paths.count()) return true; for(int index = 0; index < paths.count(); ++index) { - if ( other.paths[index].recursive != paths[index].recursive || other.paths[index].shuffle != paths[index].shuffle - || other.paths[index].sorted != paths[index].sorted) - return true; - if ( other.paths[index].path != paths[index].path || other.paths[index].imageList != paths[index].imageList ) + if(other.paths[index] != paths[index]) return true; } - return false; + return false; } }; diff --git a/src/imageselector.cpp b/src/imageselector.cpp index 839a919..147d94b 100644 --- a/src/imageselector.cpp +++ b/src/imageselector.cpp @@ -337,12 +337,12 @@ ListImageSelector::~ListImageSelector() { } -void ListImageSelector::AddImageSelector(std::unique_ptr& selector, const QVector &displayTimeWindows, const bool exclusiveIn) +void ListImageSelector::AddImageSelector(std::unique_ptr& selector, const bool exclusiveIn, const ImageDisplayOptions& baseDisplayOptionsIn) { SelectoryEntry entry; entry.selector = std::move(selector); - entry.displayTimeWindows = displayTimeWindows; entry.exclusive = exclusiveIn; + entry.baseDisplayOptions = baseDisplayOptionsIn; imageSelectors.push_back(std::move(entry)); currentSelector = imageSelectors.begin(); } @@ -353,9 +353,12 @@ const ImageDetails ListImageSelector::getNextImage(const ImageDisplayOptions& ba // check for exclusive time windows for(auto& selector: imageSelectors) { - if (imageInsideTimeWindow(selector.displayTimeWindows) && selector.exclusive) + if (imageInsideTimeWindow(selector.baseDisplayOptions.timeWindows) && selector.exclusive) { - return selector.selector->getNextImage(baseOptions); + ImageDisplayOptions options = baseOptions; + if (selector.baseDisplayOptions.fitAspectAxisToWindow) + options.fitAspectAxisToWindow = true; + return selector.selector->getNextImage(options); } } @@ -367,9 +370,12 @@ const ImageDetails ListImageSelector::getNextImage(const ImageDisplayOptions& ba { currentSelector = imageSelectors.begin(); } - if (imageInsideTimeWindow(currentSelector->displayTimeWindows)) + if (imageInsideTimeWindow(currentSelector->baseDisplayOptions.timeWindows)) { - return currentSelector->selector->getNextImage(baseOptions); + ImageDisplayOptions options = baseOptions; + if (currentSelector->baseDisplayOptions.fitAspectAxisToWindow) + options.fitAspectAxisToWindow = true; + return currentSelector->selector->getNextImage(options); } } while(true); diff --git a/src/imageselector.h b/src/imageselector.h index eeaccc3..4443160 100644 --- a/src/imageselector.h +++ b/src/imageselector.h @@ -70,12 +70,12 @@ public: ListImageSelector(); virtual ~ListImageSelector(); virtual const ImageDetails getNextImage(const ImageDisplayOptions &baseOptions); - void AddImageSelector(std::unique_ptr& selector, const QVector &displayTimeWindows, const bool exclusiveIn); + void AddImageSelector(std::unique_ptr& selector, const bool exclusiveIn, const ImageDisplayOptions& baseDisplayOptionsIn); private: struct SelectoryEntry { std::unique_ptr selector; - QVector displayTimeWindows; + ImageDisplayOptions baseDisplayOptions; bool exclusive = false; }; std::vector imageSelectors; diff --git a/src/imagestructs.h b/src/imagestructs.h index ce937fc..b7042ba 100644 --- a/src/imagestructs.h +++ b/src/imagestructs.h @@ -12,6 +12,11 @@ struct DisplayTimeWindow { QTime startDisplay = QTime(0,0,0,0); QTime endDisplay = QTime(23,59,59,0); + + bool operator!=(const DisplayTimeWindow &b) const + { + return startDisplay != b.startDisplay || endDisplay != b.endDisplay; + } }; // options to consider when displaying an image diff --git a/src/main.cpp b/src/main.cpp index f2c3d4c..26ed635 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -173,7 +173,7 @@ std::unique_ptr GetSelectorForApp(const AppConfig& appConfig) for(const auto &path : appConfig.paths) { auto selector = GetSelectorForConfig(path, appConfig.debugMode); - listSelector->AddImageSelector(selector,path.timeWindows, path.exclusive); + listSelector->AddImageSelector(selector, path.exclusive, path.baseDisplayOptions); } // new things return listSelector;