11 QObject(parent), _previewAnim(0), lastFrameSignal(0), _dimming(0), _lastFrameDimming(0), _start(false), _needsSave(true), _needsMapRefresh(true)
17 QObject(parent), _previewAnim(0), _map(other._map), _qColorMap(other._qColorMap), lastFrameSignal(0), _dimming(other._dimming), _lastFrameDimming(other._lastFrameDimming), _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();
318 for(
int i = 0; i < count; i++){
319 QRgb&
rgb = colors[i];
321 float g = qGreen(rgb);
322 float b = qBlue(rgb);
324 QRgb rgb2 = indicators[i];
325 if(qAlpha(rgb2) != 0){
326 float r2 = qRed(rgb2);
327 float g2 = qGreen(rgb2);
328 float b2 = qBlue(rgb2);
329 float a2 = qAlpha(rgb2) / 255.f;
330 r = round(r2 * a2 + r * (1.f - a2));
331 g = round(g2 * a2 + g * (1.f - a2));
332 b = round(b2 * a2 + b * (1.f - a2));
350 cmd.write(
"rgb 000000");
356 if(light != 1.f || monochrome){
357 for(
int i = 0; i < count; i++){
358 QRgb&
rgb = colors[i];
360 float r =
sToL(qRed(rgb));
361 float g =
sToL(qGreen(rgb));
362 float b =
sToL(qBlue(rgb));
381 cmd.write(QString().sprintf(
"rgb 000000").toLatin1());
391 for(
int i = 0; i < count; i++){
392 QRgb&
rgb = colors[i];
393 rgb =
monoRgb(qRed(rgb), qGreen(rgb), qBlue(rgb));
411 SGroup group(settings,
"Lighting");
418 bool useReal = settings.
value(
"UseRealNames").toBool();
420 SGroup group(settings,
"Keys");
422 QString name = key.toLower();
425 QColor
color = settings.
value(key).toString();
427 color = QColor(255, 255, 255);
437 SGroup group(settings,
"Animations");
438 foreach(QString anim, settings.
value(
"List").toStringList()){
449 SGroup group(settings,
"Lighting");
452 settings.
setValue(
"UseRealNames",
true);
455 SGroup group(settings,
"Keys");
459 settings.
setValue(i.key(), QColor(i.value()).name());
464 SGroup group(settings,
"Animations");
467 aList << anim->
guid().toString().toUpper();
468 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
ColorMap _lastFrameIndicatorMap
const QUuid & guid() const
void color(const QString &key, const QColor &newColor)
ColorMap _lastFrameAnimMap
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