3 #include <QDoubleSpinBox>
16 return 360 - (angle - 180);
22 _anim(anim), lastDuration(1.0)
25 setWindowTitle(anim->
scriptName() +
" Animation");
35 ui->
settingsGrid->addItem(
new QSpacerItem(0, 10, QSizePolicy::Fixed, QSizePolicy::Fixed), row++, 6);
36 ui->
settingsGrid->addWidget(
new QLabel(
"<b>Animation</b>",
this), row++, 0, 1, 7);
38 bool rSpacePlaced =
false;
43 if(param.
name ==
"duration"
44 || param.
name ==
"trigger" || param.
name ==
"kptrigger"
45 || param.
name ==
"kpmode"
46 || param.
name ==
"delay" || param.
name ==
"kpdelay"
47 || param.
name ==
"repeat" || param.
name ==
"kprepeat"
48 || param.
name ==
"stop" || param.
name ==
"kpstop"
49 || param.
name ==
"kpmodestop" || param.
name ==
"kprelease")
58 QString postfix = param.
postfix;
61 widget =
new QCheckBox(param.
prefix,
this);
62 ((QCheckBox*)widget)->setChecked(value.toBool());
64 connect(widget, SIGNAL(stateChanged(
int)), &
updateMapper, SLOT(map()));
67 widget =
new QSpinBox(
this);
68 ((QSpinBox*)widget)->setMinimum(param.
minimum.toInt());
69 ((QSpinBox*)widget)->setMaximum(param.
maximum.toInt());
70 ((QSpinBox*)widget)->setValue(value.toInt());
71 if(postfix.length() <= 3){
72 ((QSpinBox*)widget)->setSuffix(postfix);
75 connect(widget, SIGNAL(valueChanged(
int)), &
updateMapper, SLOT(map()));
78 widget =
new QDoubleSpinBox(
this);
79 ((QDoubleSpinBox*)widget)->setDecimals(1);
80 ((QDoubleSpinBox*)widget)->setMinimum(param.
minimum.toDouble());
81 ((QDoubleSpinBox*)widget)->setMaximum(param.
maximum.toDouble());
82 ((QDoubleSpinBox*)widget)->setValue(value.toDouble());
83 if(postfix.length() <= 3){
84 ((QDoubleSpinBox*)widget)->setSuffix(postfix);
87 connect(widget, SIGNAL(valueChanged(
double)), &
updateMapper, SLOT(map()));
91 ((
ColorButton*)widget)->color(QColor(
"#" + value.toString()));
93 connect(widget, SIGNAL(colorChanged(QColor)), &
updateMapper, SLOT(map()));
97 QString val = value.toString();
99 if(val.length() == 8){
100 color =
"#" + val.right(6);
101 color.setAlpha(val.left(2).toInt(0, 16));
106 connect(widget, SIGNAL(colorChanged(QColor)), &
updateMapper, SLOT(map()));
113 connect(widget, SIGNAL(gradientChanged()), &
updateMapper, SLOT(map()));
119 connect(widget, SIGNAL(gradientChanged()), &
updateMapper, SLOT(map()));
122 widget =
new QDial(
this);
123 ((QDial*)widget)->setFixedSize(60, 60);
124 ((QDial*)widget)->setMinimum(0);
125 ((QDial*)widget)->setMaximum(360);
128 ((QDial*)widget)->setSingleStep(5);
129 ((QDial*)widget)->setPageStep(15);
130 ((QDial*)widget)->setNotchTarget(6);
131 ((QDial*)widget)->setNotchesVisible(
true);
132 ((QDial*)widget)->setWrapping(
true);
133 ((QDial*)widget)->setInvertedAppearance(
true);
134 ((QDial*)widget)->setValue(
angleFlip(value.toInt()));
136 connect(widget, SIGNAL(valueChanged(
int)), &
angleDialMapper, SLOT(map()));
139 widget =
new QLineEdit(
this);
140 ((QLineEdit*)widget)->setText(value.toString());
142 connect(widget, SIGNAL(textEdited(
const QString&)), &
updateMapper, SLOT(map()));
145 widget =
new QLabel(
this);
146 ((QLabel*)widget)->setText(param.
prefix);
166 QSpinBox* spinner =
new QSpinBox(
this);
167 spinner->setMinimum(0);
168 spinner->setMaximum(359);
169 spinner->setWrapping(
true);
170 spinner->setSuffix(
"°");
171 spinner->setValue(value.toInt());
179 ui->
settingsGrid->addWidget(
new QLabel(postfix,
this), row, 3 + colSpan, 1, 4 - colSpan);
180 if(colSpan < 3 && !rSpacePlaced){
182 ui->
settingsGrid->addItem(
new QSpacerItem(0, 0, QSizePolicy::Minimum), row, 4 + colSpan);
189 ui->
settingsGrid->addItem(
new QSpacerItem(0, 10, QSizePolicy::Fixed, QSizePolicy::Fixed), row++, 6);
190 ui->
settingsGrid->addWidget(
new QLabel(
"<b>Playback</b>",
this), row++, 0, 1, 7);
195 ui->
settingsGrid->addWidget(
new QLabel(
"Duration:",
this), row, 1);
196 QDoubleSpinBox* spinner =
new QDoubleSpinBox(
this);
197 spinner->setDecimals(1);
198 spinner->setMinimum(0.1);
200 connect(spinner, SIGNAL(valueChanged(
double)),
this, SLOT(
newDuration(
double)));
203 ui->
settingsGrid->addWidget(
new QLabel(
"seconds",
this), row, 4, 1, 2);
207 QCheckBox* check =
new QCheckBox(
"Start with mode",
this);
208 check->setChecked(anim->
parameter(
"trigger").toBool());
211 connect(check, SIGNAL(stateChanged(
int)), &
updateMapper, SLOT(map()));
214 check =
new QCheckBox(
"Start with key press",
this);
215 check->setChecked(anim->
parameter(
"kptrigger").toBool());
218 connect(check, SIGNAL(stateChanged(
int)), &
updateMapper, SLOT(map()));
221 QComboBox* combo =
new QComboBox(
this);
222 int selected = anim->
parameter(
"kpmode").toInt();
225 combo->addItem(
"on pressed key");
226 combo->addItem(
"on whole keyboard");
227 combo->addItem(
"on keyboard (once)");
231 combo->addItem(
"every time");
232 combo->addItem(
"only once");
234 if(selected < 0 || selected > combo->count())
236 combo->setCurrentIndex(selected);
239 connect(combo, SIGNAL(activated(
int)), &
updateMapper, SLOT(map()));
244 ui->
settingsGrid->addItem(
new QSpacerItem(0, 0, QSizePolicy::Expanding), 0, 6);
246 ui->
settingsGrid->addItem(
new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), row, 0);
267 ui->
timeGrid->addWidget(
new QLabel(
"Repeat:",
this), 4, 1);
268 QSpinBox* spinner =
new QSpinBox(
this);
269 spinner->setMinimum(0);
270 spinner->setMaximum(1000000);
271 spinner->setValue(anim->
parameter(
"stop").toInt());
273 connect(spinner, SIGNAL(valueChanged(
int)), &
updateMapper, SLOT(map()));
276 ui->
timeGrid->addWidget(
new QLabel(
"times",
this), 4, 4);
278 ui->
timeGrid->addWidget(
new QLabel(
"Repeat:",
this), 12, 1);
279 spinner =
new QSpinBox(
this);
280 spinner->setMinimum(0);
281 spinner->setMaximum(1000000);
282 spinner->setValue(anim->
parameter(
"kpstop").toInt());
284 connect(spinner, SIGNAL(valueChanged(
int)), &
updateMapper, SLOT(map()));
287 ui->
timeGrid->addWidget(
new QLabel(
"times",
this), 12, 4);
289 stopCheck =
new QCheckBox(
"Forever",
this);
308 QDoubleSpinBox* spinner =
new QDoubleSpinBox(
this);
309 spinner->setDecimals(1);
310 spinner->setMinimum(0.1);
311 spinner->setMaximum(24. * 60. * 60.);
312 double stop = anim->
parameter(
"stop").toDouble();
316 spinner->setValue(stop);
318 connect(spinner, SIGNAL(valueChanged(
double)), &
updateMapper, SLOT(map()));
321 ui->
timeGrid->addWidget(
new QLabel(
"seconds",
this), 4, 4);
323 spinner =
new QDoubleSpinBox(
this);
324 spinner->setDecimals(1);
325 spinner->setMinimum(0.1);
326 spinner->setMaximum(24. * 60. * 60.);
327 double kpstop = anim->
parameter(
"kpstop").toDouble();
331 spinner->setValue(kpstop);
333 connect(spinner, SIGNAL(valueChanged(
double)), &
updateMapper, SLOT(map()));
336 ui->
timeGrid->addWidget(
new QLabel(
"seconds",
this), 12, 4);
338 stopCheck =
new QCheckBox(
"Stop after:",
this);
358 setFixedSize(minimumSize());
363 QDoubleSpinBox* rep = (QDoubleSpinBox*)
settingWidgets.value(
"repeat");
364 QDoubleSpinBox* kpRep = (QDoubleSpinBox*)
settingWidgets.value(
"kprepeat");
366 rep->setValue(duration);
368 kpRep->setValue(duration);
409 }
else if(name ==
"kpmode"){
412 int selected = widget->currentIndex();
437 QColor color = widget->
color();
439 snprintf(hex,
sizeof(hex),
"%02x%02x%02x", color.red(), color.green(), color.blue());
445 QColor color = widget->
color();
447 snprintf(hex,
sizeof(hex),
"%02x%02x%02x%02x", color.alpha(), color.red(), color.green(), color.blue());
481 QFrame*
frame =
new QFrame(
this);
482 frame->setFrameShape(QFrame::HLine);
483 frame->setFrameShadow(QFrame::Sunken);
void newDuration(double duration)
Param param(const QString &name) const
QDoubleSpinBox * repeatBox
QGridLayout * settingsGrid
Ui::AnimSettingDialog * ui
void on_kpDelayBox_valueChanged(double arg1)
AnimSettingDialog(QWidget *parent, KbAnim *anim)
bool hasParameter(const QString &name) const
const QString & name() const
QSignalMapper angleSpinnerMapper
void on_repeatBox_valueChanged(double arg1)
QMap< QString, QSpinBox * > angleSpinners
const QString & author() const
static int angleFlip(int angle)
const QString & year() const
QDoubleSpinBox * kpDelayBox
QDoubleSpinBox * kpRepeatBox
void on_delayBox_valueChanged(double arg1)
void on_kpRepeatBox_valueChanged(double arg1)
const QString & description() const
void setupUi(QDialog *AnimSettingDialog)
const QString & scriptName() const
bool hasParam(const QString &name) const
const QString & license() const
QMap< QString, QWidget * > settingWidgets
void angleSpinnerChanged(QString name)
QSignalMapper angleDialMapper
const QString & name() const
QCheckBox * kpModeStopBox
void angleDialChanged(QString name)
QListIterator< Param > paramIterator() const
QDoubleSpinBox * delayBox
const QString & version() const
const AnimScript * script() const
void updateParam(QString name)
void on_kpReleaseBox_stateChanged(int arg1)
QVariant parameter(const QString &name) const
QSignalMapper updateMapper