- Move new overlay color string into appconfig struct
This commit is contained in:
@@ -117,6 +117,15 @@ Config loadConfiguration(const std::string &configFilePath, const Config ¤
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AppConfig loadConfiguration(const std::string &configFilePath, const AppConfig ¤tConfig) {
|
||||||
|
AppConfig userConfig = currentConfig;
|
||||||
|
// make sure to only update the base members, preserve the ones from the copy above
|
||||||
|
(Config &)userConfig = loadConfiguration(configFilePath, (const Config &)userConfig);
|
||||||
|
|
||||||
|
return userConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString getAppConfigFilePath(const std::string &configPath) {
|
QString getAppConfigFilePath(const std::string &configPath) {
|
||||||
std::string userConfigFolder = "~/.config/slide/";
|
std::string userConfigFolder = "~/.config/slide/";
|
||||||
std::string systemConfigFolder = "/etc/slide";
|
std::string systemConfigFolder = "/etc/slide";
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ struct AppConfig : public Config {
|
|||||||
AppConfig( const Config &inConfig ) : Config(inConfig) {}
|
AppConfig( const Config &inConfig ) : Config(inConfig) {}
|
||||||
std::string configPath = "";
|
std::string configPath = "";
|
||||||
std::string overlay = "";
|
std::string overlay = "";
|
||||||
|
QString overlayHexRGB = "#FFFFFF";
|
||||||
QVector<PathEntry> paths;
|
QVector<PathEntry> paths;
|
||||||
|
|
||||||
bool debugMode = false;
|
bool debugMode = false;
|
||||||
|
|||||||
12
src/main.cpp
12
src/main.cpp
@@ -23,9 +23,6 @@ void usage(std::string programName) {
|
|||||||
std::cerr << "Usage: " << programName << " [-t rotation_seconds] [-a aspect('l','p','a', 'm')] [-o background_opacity(0..255)] [-b blur_radius] -p image_folder [-r] [-s] [-v] [--verbose] [--stretch] [-c config_file_path]" << std::endl;
|
std::cerr << "Usage: " << programName << " [-t rotation_seconds] [-a aspect('l','p','a', 'm')] [-o background_opacity(0..255)] [-b blur_radius] -p image_folder [-r] [-s] [-v] [--verbose] [--stretch] [-c config_file_path]" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString overlayHexRGB = QString("#FFFFFF");
|
|
||||||
QRegularExpression hexRGBMatcher("^#([0-9A-Fa-f]{3}){1,2}$");
|
|
||||||
|
|
||||||
bool parseCommandLine(AppConfig &appConfig, int argc, char *argv[]) {
|
bool parseCommandLine(AppConfig &appConfig, int argc, char *argv[]) {
|
||||||
int opt;
|
int opt;
|
||||||
int debugInt = 0;
|
int debugInt = 0;
|
||||||
@@ -90,7 +87,7 @@ bool parseCommandLine(AppConfig &appConfig, int argc, char *argv[]) {
|
|||||||
appConfig.overlay = optarg;
|
appConfig.overlay = optarg;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
overlayHexRGB = QString::fromStdString(optarg);
|
appConfig.overlayHexRGB = QString::fromStdString(optarg);
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
appConfig.debugMode = true;
|
appConfig.debugMode = true;
|
||||||
@@ -132,15 +129,16 @@ void ConfigureWindowFromSettings(MainWindow &w, const AppConfig &appConfig)
|
|||||||
w.setBackgroundOpacity(appConfig.backgroundOpacity);
|
w.setBackgroundOpacity(appConfig.backgroundOpacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!overlayHexRGB.isEmpty())
|
if (!appConfig.overlayHexRGB.isEmpty())
|
||||||
{
|
{
|
||||||
if(!hexRGBMatcher.match(overlayHexRGB).hasMatch())
|
QRegularExpression hexRGBMatcher("^#([0-9A-Fa-f]{3}){1,2}$");
|
||||||
|
if(!hexRGBMatcher.match(appConfig.overlayHexRGB).hasMatch())
|
||||||
{
|
{
|
||||||
std::cout << "Error: hex rgb string expected. e.g. #FFFFFF or #FFF" << std::endl;
|
std::cout << "Error: hex rgb string expected. e.g. #FFFFFF or #FFF" << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
w.setOverlayHexRGB(overlayHexRGB);
|
w.setOverlayHexRGB(appConfig.overlayHexRGB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user