mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Update CustomParameter.h
Former-commit-id: 99fa0c1a3d6321dc41f4fb1623aee5b364220a67
This commit is contained in:
parent
0bafc4a3cc
commit
a15a680dc3
@ -12,6 +12,7 @@
|
||||
|
||||
// hyperion-remote includes
|
||||
#include "ColorTransformValues.h"
|
||||
#include "ColorCorrectionValues.h"
|
||||
|
||||
/// Data parameter for a color
|
||||
typedef vlofgren::PODParameter<std::vector<QColor>> ColorParameter;
|
||||
@ -22,6 +23,9 @@ typedef vlofgren::PODParameter<QImage> ImageParameter;
|
||||
/// Data parameter for color transform values (list of three values)
|
||||
typedef vlofgren::PODParameter<ColorTransformValues> TransformParameter;
|
||||
|
||||
/// Data parameter for color correction values (list of three values)
|
||||
typedef vlofgren::PODParameter<ColorCorrectionValues> CorrectionParameter;
|
||||
|
||||
namespace vlofgren {
|
||||
///
|
||||
/// Translates a string (as passed on the commandline) to a vector of colors
|
||||
@ -128,4 +132,33 @@ namespace vlofgren {
|
||||
|
||||
return transform;
|
||||
}
|
||||
|
||||
template<>
|
||||
ColorCorrectionValues CorrectionParameter::validate(const std::string& s) throw (Parameter::ParameterRejected)
|
||||
{
|
||||
ColorCorrectionValues correction;
|
||||
|
||||
// s should be split in 3 parts
|
||||
// seperators are either a ',' or a space
|
||||
QStringList components = QString(s.c_str()).split(" ", QString::SkipEmptyParts);
|
||||
|
||||
if (components.size() == 3)
|
||||
{
|
||||
bool ok1, ok2, ok3;
|
||||
correction.valueRed = components[0].toInt(&ok1);
|
||||
correction.valueGreen = components[1].toInt(&ok2);
|
||||
correction.valueBlue = components[2].toInt(&ok3);
|
||||
|
||||
if (ok1 && ok2 && ok3)
|
||||
{
|
||||
return correction;
|
||||
}
|
||||
}
|
||||
|
||||
std::stringstream errorMessage;
|
||||
errorMessage << "Argument " << s << " can not be parsed to 3 integer values";
|
||||
throw Parameter::ParameterRejected(errorMessage.str());
|
||||
|
||||
return correction;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user