Files
slide/src/appconfig.h
Nathan Coad 806d701535
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
add more immich control options
2026-02-01 21:24:24 +11:00

175 lines
4.5 KiB
C++

#ifndef APPCONFIG_H
#define APPCONFIG_H
#include <QDateTime>
#include "imagestructs.h"
#include <QVector>
#include <vector>
struct ImmichConfig {
bool enabled = false;
std::string url = "";
std::string apiKey = "";
std::vector<std::string> albumIds;
std::vector<std::string> personIds;
std::string size = "fullsize";
std::string order = "desc";
int pageSize = 200;
int maxAssets = 1000;
std::string cachePath = "";
int cacheMaxMB = 512;
bool includeArchived = false;
bool operator==(const ImmichConfig &b) const
{
if (enabled != b.enabled)
return false;
if (url != b.url || apiKey != b.apiKey)
return false;
if (size != b.size || order != b.order)
return false;
if (pageSize != b.pageSize || maxAssets != b.maxAssets)
return false;
if (cachePath != b.cachePath || cacheMaxMB != b.cacheMaxMB)
return false;
if (includeArchived != b.includeArchived)
return false;
if (albumIds.size() != b.albumIds.size())
return false;
for (size_t i = 0; i < albumIds.size(); ++i)
{
if (albumIds[i] != b.albumIds[i])
return false;
}
if (personIds.size() != b.personIds.size())
return false;
for (size_t i = 0; i < personIds.size(); ++i)
{
if (personIds[i] != b.personIds[i])
return false;
}
return true;
}
bool operator!=(const ImmichConfig &b) const
{
return !operator==(b);
}
};
struct MqttConfig {
bool enabled = false;
std::string host = "localhost";
int port = 1883;
std::string topic = "slide/control";
std::string immichTopic = "";
std::string clientId = "slide";
std::string username = "";
std::string password = "";
int keepAlive = 30;
int qos = 0;
bool operator==(const MqttConfig &b) const
{
return enabled == b.enabled &&
host == b.host &&
port == b.port &&
topic == b.topic &&
immichTopic == b.immichTopic &&
clientId == b.clientId &&
username == b.username &&
password == b.password &&
keepAlive == b.keepAlive &&
qos == b.qos;
}
bool operator!=(const MqttConfig &b) const
{
return !operator==(b);
}
};
// configuration options that apply to an image/folder of images
struct Config {
public:
unsigned int rotationSeconds = 30;
unsigned int transitionTime = 1;
int blurRadius = -1;
int backgroundOpacity = -1;
ImageDisplayOptions baseDisplayOptions;
QDateTime loadTime;
};
struct PathEntry {
std::string path = "";
std::string imageList = "";
bool exclusive = false; // only use this entry when it is valid, skip others
ImmichConfig immich;
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.immich != immich)
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
struct AppConfig : public Config {
AppConfig() {}
AppConfig( const Config &inConfig ) : Config(inConfig) {}
std::string configPath = "";
std::string overlay = "";
QString overlayHexRGB = "#FFFFFF";
QVector<PathEntry> paths;
MqttConfig mqtt;
bool debugMode = false;
static const std::string valid_aspects;
public:
bool PathOptionsChanged(AppConfig &other)
{
if (paths.count() != other.paths.count())
return true;
for(int index = 0; index < paths.count(); ++index)
{
if(other.paths[index] != paths[index])
return true;
}
return false;
}
};
AppConfig loadAppConfiguration(const AppConfig &commandLineConfig);
Config getConfigurationForFolder(const std::string &folderPath, const Config &currentConfig);
ImageAspectScreenFilter parseAspectFromString(char aspect);
QString getAppConfigFilePath(const std::string &configPath);
#endif