- Add stretch key to scheduler entries

- Fix change logic on pathentry to detect correct
This commit is contained in:
Alfred Reynolds
2021-08-22 09:55:47 +12:00
parent 66d619f49e
commit 94373e6671
6 changed files with 54 additions and 23 deletions

View File

@@ -170,6 +170,8 @@ QVector<PathEntry> 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<PathEntry> 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<PathEntry> parsePathEntry(QJsonObject &jsonMainDoc, bool baseRecursive,
{
window.endDisplay = QTime::fromString(timesJson["end"].toString());
}
entry.timeWindows.append(window);
entry.baseDisplayOptions.timeWindows.append(window);
}
}
}

View File

@@ -16,15 +16,38 @@ struct Config {
};
struct PathEntry {
QVector<DisplayTimeWindow> 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,15 +62,13 @@ 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;

View File

@@ -337,12 +337,12 @@ ListImageSelector::~ListImageSelector()
{
}
void ListImageSelector::AddImageSelector(std::unique_ptr<ImageSelector>& selector, const QVector<DisplayTimeWindow> &displayTimeWindows, const bool exclusiveIn)
void ListImageSelector::AddImageSelector(std::unique_ptr<ImageSelector>& 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);

View File

@@ -70,12 +70,12 @@ public:
ListImageSelector();
virtual ~ListImageSelector();
virtual const ImageDetails getNextImage(const ImageDisplayOptions &baseOptions);
void AddImageSelector(std::unique_ptr<ImageSelector>& selector, const QVector<DisplayTimeWindow> &displayTimeWindows, const bool exclusiveIn);
void AddImageSelector(std::unique_ptr<ImageSelector>& selector, const bool exclusiveIn, const ImageDisplayOptions& baseDisplayOptionsIn);
private:
struct SelectoryEntry {
std::unique_ptr<ImageSelector> selector;
QVector<DisplayTimeWindow> displayTimeWindows;
ImageDisplayOptions baseDisplayOptions;
bool exclusive = false;
};
std::vector<SelectoryEntry> imageSelectors;

View File

@@ -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

View File

@@ -173,7 +173,7 @@ std::unique_ptr<ImageSelector> 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;