11 QObject(parent), _previewAnim(0), lastFrameSignal(0), _dimming(0), _start(false), _needsSave(true), _needsMapRefresh(true)
17 QObject(parent), _previewAnim(0), _map(other._map), _qColorMap(other._qColorMap), lastFrameSignal(0), _dimming(other._dimming), _start(false), _needsSave(true), _needsMapRefresh(true)
27 QHashIterator<QString, Key> i(map);
30 const QString& key = i.key();
50 QRgb newRgb = newColor.rgb();
55 QByteArray rawName = key.toLatin1();
63 QRgb newRgb = newColor.rgb();
74 for(
int i = 0; i < mapCount; i++)
86 if(newShareDimming != -1){
88 light->
dimming(newShareDimming);
103 quint64 timestamp = QDateTime::currentMSecsSinceEpoch();
110 QMapIterator<QString, QVariant> i(preset);
127 quint64 timestamp = QDateTime::currentMSecsSinceEpoch();
130 QMapIterator<QString, QVariant> i(preset);
150 quint64 timestamp = QDateTime::currentMSecsSinceEpoch();
180 quint64 timestamp = QDateTime::currentMSecsSinceEpoch();
191 if(anim->
keys().contains(key))
192 anim->
keypress(key, down, QDateTime::currentMSecsSinceEpoch());
207 quint64 timestamp = QDateTime::currentMSecsSinceEpoch();
224 int count = animMap.
count();
225 const char*
const* names = animMap.
keyNames();
226 const QRgb* colors = animMap.
colors();
228 for(
int i = 0; i < count; i++){
232 QRgb
color = colors[i];
233 snprintf(output,
sizeof(output),
":%02x%02x%02x", qRed(color), qGreen(color), qBlue(color));
246 QByteArray rawName = i.key().toLatin1();
247 QRgb
color = i.value();
273 return srgb / 12.92f;
274 return pow((srgb + 0.055f) / 1.055f, 2.4f);
277 static float lToS(
float linear){
278 if(linear <= 0.0031308f)
279 return 12.92f * linear * 255.f;
280 return (1.055f * pow(linear, 1.f / 2.4f) - 0.055f) * 255.f;
292 int value = round(
lToS((r + g + b) / 3.f));
293 return qRgb(value, value, value);
300 quint64 timestamp = QDateTime::currentMSecsSinceEpoch();
311 for(
int i = 0; i < count; i++){
312 QRgb& rgb = colors[i];
314 float g = qGreen(rgb);
315 float b = qBlue(rgb);
317 QRgb rgb2 = indicators[i];
318 if(qAlpha(rgb2) != 0){
319 float r2 = qRed(rgb2);
320 float g2 = qGreen(rgb2);
321 float b2 = qBlue(rgb2);
322 float a2 = qAlpha(rgb2) / 255.f;
323 r = round(r2 * a2 + r * (1.f - a2));
324 g = round(g2 * a2 + g * (1.f - a2));
325 b = round(b2 * a2 + b * (1.f - a2));
343 cmd.write(
"rgb 000000");
349 if(light != 1.f || monochrome){
350 for(
int i = 0; i < count; i++){
351 QRgb& rgb = colors[i];
353 float r =
sToL(qRed(rgb));
354 float g =
sToL(qGreen(rgb));
355 float b =
sToL(qBlue(rgb));
374 cmd.write(QString().sprintf(
"rgb 000000").toLatin1());
384 for(
int i = 0; i < count; i++){
385 QRgb& rgb = colors[i];
386 rgb =
monoRgb(qRed(rgb), qGreen(rgb), qBlue(rgb));
404 SGroup group(settings,
"Lighting");
411 bool useReal = settings.
value(
"UseRealNames").toBool();
413 SGroup group(settings,
"Keys");
414 foreach(QString key, settings.
childKeys()){
415 QString name = key.toLower();
418 QColor
color = settings.
value(key).toString();
420 color = QColor(255, 255, 255);
430 SGroup group(settings,
"Animations");
431 foreach(QString anim, settings.
value(
"List").toStringList()){
442 SGroup group(settings,
"Lighting");
445 settings.
setValue(
"UseRealNames",
true);
448 SGroup group(settings,
"Keys");
452 settings.
setValue(i.key(), QColor(i.value()).name());
457 SGroup group(settings,
"Animations");
460 aList << anim->
guid().toString().toUpper();
461 anim->
save(settings);
QSet< QString > _indicatorList
void setValue(const QString &key, const QVariant &value)
static float sToL(float srgb)
void frameDisplayed(const ColorMap &animatedColors, const QSet< QString > &indicatorList)
KbAnim * duplicateAnim(KbAnim *oldAnim)
KbLight(KbMode *parent, const KeyMap &keyMap)
QStringList childKeys() const
void init(const KeyMap &map)
const QStringList & keys()
void frameUpdate(QFile &cmd, bool monochrome=false)
QHashIterator< QString, QRgb > QColorMapIterator
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
KbAnim * addAnim(const AnimScript *base, const QStringList &keys, const QString &name, const QMap< QString, QVariant > &preset)
void save(CkbSettings &settings)
void trigger(quint64 timestamp, bool ignoreParameter=false)
static float lToS(float linear)
QString fromStorage(const QString &storage)
QRgb * colorForName(const char *name)
void save(CkbSettings &settings)
void previewAnim(const AnimScript *base, const QStringList &keys, const QMap< QString, QVariant > &preset)
void load(CkbSettings &settings)
static int shareDimming()
void animKeypress(const QString &key, bool down)
static QSet< KbLight * > activeLights
const QUuid & guid() const
void color(const QString &key, const QColor &newColor)
const char *const * keyNames() const
void setIndicator(const char *name, QRgb argb)
void printRGB(QFile &cmd, const ColorMap &animMap)
QMutableHashIterator< QString, QRgb > QMutableColorMapIterator
static KeyMap fromName(const QString &name)
void keypress(const QString &key, bool pressed, quint64 timestamp)
QRgb monoRgb(float r, float g, float b)
void base(QFile &cmd, bool ignoreDim=false, bool monochrome=false)
void blend(ColorMap &animMap, quint64 timestamp)
QVariant parameter(const QString &name) const