ckb-next  v0.2.8 at branch master
ckb-next driver for corsair devices
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AnimSettingDialog Class Reference

#include <src/ckb/animsettingdialog.h>

+ Inheritance diagram for AnimSettingDialog:
+ Collaboration diagram for AnimSettingDialog:

Public Member Functions

 AnimSettingDialog (QWidget *parent, KbAnim *anim)
 
 ~AnimSettingDialog ()
 
QString name () const
 

Private Slots

void newDuration (double duration)
 
void updateStops ()
 
void angleDialChanged (QString name)
 
void angleSpinnerChanged (QString name)
 
void updateParam (QString name)
 
void on_delayBox_valueChanged (double arg1)
 
void on_repeatBox_valueChanged (double arg1)
 
void on_kpDelayBox_valueChanged (double arg1)
 
void on_kpRepeatBox_valueChanged (double arg1)
 
void on_kpReleaseBox_stateChanged (int arg1)
 

Private Member Functions

QFrame * hLine ()
 

Private Attributes

Ui::AnimSettingDialogui
 
QCheckBox * stopCheck
 
QCheckBox * kpStopCheck
 
bool hasRepeat
 
KbAnim_anim
 
double lastDuration
 
QMap< QString, QWidget * > settingWidgets
 
QSignalMapper updateMapper
 
QMap< QString, QSpinBox * > angleSpinners
 
QSignalMapper angleDialMapper
 
QSignalMapper angleSpinnerMapper
 

Detailed Description

Definition at line 15 of file animsettingdialog.h.

Constructor & Destructor Documentation

AnimSettingDialog::AnimSettingDialog ( QWidget parent,
KbAnim anim 
)
explicit

Definition at line 19 of file animsettingdialog.cpp.

References AnimScript::Param::AGRADIENT, AnimScript::Param::ANGLE, angleDialChanged(), angleDialMapper, angleFlip(), angleSpinnerChanged(), angleSpinnerMapper, angleSpinners, Ui_AnimSettingDialog::animName, AnimScript::Param::ARGB, AnimScript::author(), AnimScript::Param::BOOL, Ui_AnimSettingDialog::delayBox, AnimScript::description(), AnimScript::Param::DOUBLE, AnimScript::Param::GRADIENT, AnimScript::hasKeypress(), AnimScript::hasParam(), KbAnim::hasParameter(), hasRepeat, hLine(), Ui_AnimSettingDialog::kpDelayBox, Ui_AnimSettingDialog::kpModeStopBox, Ui_AnimSettingDialog::kpReleaseBox, Ui_AnimSettingDialog::kpRepeatBox, Ui_AnimSettingDialog::kpRepeatLabel, Ui_AnimSettingDialog::kpRepeatLabel_2, kpStopCheck, AnimScript::Param::LABEL, lastDuration, AnimScript::license(), AnimScript::Param::LONG, AnimScript::Param::maximum, AnimScript::Param::minimum, AnimScript::Param::name, AnimScript::name(), KbAnim::name(), newDuration(), KbAnim::parameter(), AnimScript::paramIterator(), AnimScript::Param::postfix, AnimScript::Param::prefix, Ui_AnimSettingDialog::repeatBox, Ui_AnimSettingDialog::repeatLabel, Ui_AnimSettingDialog::repeatLabel_2, AnimScript::Param::RGB, Ui_AnimSettingDialog::sAuthorLabel, KbAnim::script(), KbAnim::scriptName(), Ui_AnimSettingDialog::sDescLabel, Ui_AnimSettingDialog::settingsGrid, settingWidgets, Ui_AnimSettingDialog::setupUi(), Ui_AnimSettingDialog::sLicenseLabel, Ui_AnimSettingDialog::sNameLabel, stopCheck, AnimScript::Param::STRING, Ui_AnimSettingDialog::sVerLabel, Ui_AnimSettingDialog::sYearLabel, Ui_AnimSettingDialog::timeGrid, AnimScript::Param::type, ui, updateMapper, updateParam(), updateStops(), AnimScript::version(), and AnimScript::year().

19  :
20  QDialog(parent),
22  _anim(anim), lastDuration(1.0)
23 {
24  ui->setupUi(this);
25  setWindowTitle(anim->scriptName() + " Animation");
26  ui->animName->setText(anim->name());
27  const AnimScript* script = anim->script();
28 
29  connect(&updateMapper, SIGNAL(mapped(QString)), this, SLOT(updateParam(QString)));
30  connect(&angleDialMapper, SIGNAL(mapped(QString)), this, SLOT(angleDialChanged(QString)));
31  connect(&angleSpinnerMapper, SIGNAL(mapped(QString)), this, SLOT(angleSpinnerChanged(QString)));
32 
33  // Build settings UI
34  int row = 1;
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);
37  ui->settingsGrid->addWidget(hLine(), row++, 0, 1, 7);
38  bool rSpacePlaced = false;
39  QListIterator<AnimScript::Param> i(script->paramIterator());
40  while(i.hasNext()){
41  const AnimScript::Param& param = i.next();
42  // Skip timing/playback params
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")
50  continue;
51  QVariant value = anim->parameter(param.name);
52  // Display prefix label on the left (except for booleans and labels)
54  ui->settingsGrid->addWidget(new QLabel(param.prefix, this), row, 1);
55  // Configure and display main widget
56  QWidget* widget = 0;
57  int colSpan = 1;
58  QString postfix = param.postfix;
59  switch(param.type){
61  widget = new QCheckBox(param.prefix, this);
62  ((QCheckBox*)widget)->setChecked(value.toBool());
63  colSpan = 4;
64  connect(widget, SIGNAL(stateChanged(int)), &updateMapper, SLOT(map()));
65  break;
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);
73  postfix = "";
74  }
75  connect(widget, SIGNAL(valueChanged(int)), &updateMapper, SLOT(map()));
76  break;
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);
85  postfix = "";
86  }
87  connect(widget, SIGNAL(valueChanged(double)), &updateMapper, SLOT(map()));
88  break;
90  widget = new ColorButton(this);
91  ((ColorButton*)widget)->color(QColor("#" + value.toString()));
92  colSpan = 3;
93  connect(widget, SIGNAL(colorChanged(QColor)), &updateMapper, SLOT(map()));
94  break;
96  widget = new ColorButton(this, true);
97  QString val = value.toString();
98  QColor color;
99  if(val.length() == 8){
100  color = "#" + val.right(6);
101  color.setAlpha(val.left(2).toInt(0, 16));
102  } else
103  color = "#" + val;
104  ((ColorButton*)widget)->color(color);
105  colSpan = 3;
106  connect(widget, SIGNAL(colorChanged(QColor)), &updateMapper, SLOT(map()));
107  break;
108  }
110  widget = new GradientButton(this);
111  ((GradientButton*)widget)->fromString(value.toString());
112  colSpan = 3;
113  connect(widget, SIGNAL(gradientChanged()), &updateMapper, SLOT(map()));
114  break;
116  widget = new GradientButton(this, true);
117  ((GradientButton*)widget)->fromString(value.toString());
118  colSpan = 3;
119  connect(widget, SIGNAL(gradientChanged()), &updateMapper, SLOT(map()));
120  break;
122  widget = new QDial(this);
123  ((QDial*)widget)->setFixedSize(60, 60);
124  ((QDial*)widget)->setMinimum(0);
125  ((QDial*)widget)->setMaximum(360);
126  // this is NOT a typo... ^
127  // Even though 360 shouldn't be valid, the wheel/arrow keys will lose 1 degree at the bottom unless 360 is set as max
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()));
135  angleDialMapper.setMapping(widget, param.name);
136  connect(widget, SIGNAL(valueChanged(int)), &angleDialMapper, SLOT(map()));
137  break;
139  widget = new QLineEdit(this);
140  ((QLineEdit*)widget)->setText(value.toString());
141  colSpan = 3;
142  connect(widget, SIGNAL(textEdited(const QString&)), &updateMapper, SLOT(map()));
143  break;
145  widget = new QLabel(this);
146  ((QLabel*)widget)->setText(param.prefix);
147  colSpan = 4;
148  break;
149  default:
150  break;
151  }
152  if(widget)
153  updateMapper.setMapping(widget, param.name);
155  // Boolean values are placed on the left with no prefix or postfix
156  settingWidgets[param.name] = widget;
157  ui->settingsGrid->addWidget(widget, row, 3, 1, colSpan);
158  } else {
159  // Display the widget
160  if(widget){
161  settingWidgets[param.name] = widget;
162  ui->settingsGrid->addWidget(widget, row, 3, 1, colSpan);
163  }
164  // Angles additionally have a spin box
165  if(param.type == AnimScript::Param::ANGLE){
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());
172  angleSpinners[param.name] = spinner;
173  angleSpinnerMapper.setMapping(spinner, param.name);
174  connect(spinner, SIGNAL(valueChanged(int)), &angleSpinnerMapper, SLOT(map()));
175  ui->settingsGrid->addWidget(spinner, row, 4);
176  colSpan = 2;
177  }
178  // Display postfix label on the right
179  ui->settingsGrid->addWidget(new QLabel(postfix, this), row, 3 + colSpan, 1, 4 - colSpan);
180  if(colSpan < 3 && !rSpacePlaced){
181  // Add a spacer to compress short elements to the left
182  ui->settingsGrid->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum), row, 4 + colSpan);
183  rSpacePlaced = true;
184  }
185  }
186  row++;
187  }
188  // Add playback info at bottom
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);
191  ui->settingsGrid->addWidget(hLine(), row++, 0, 1, 7);
192  if(script->hasParam("duration")){
193  // Show duration spinner (if allowed)
194  lastDuration = anim->parameter("duration").toDouble();
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);
199  spinner->setValue(lastDuration);
200  connect(spinner, SIGNAL(valueChanged(double)), this, SLOT(newDuration(double)));
201  settingWidgets["duration"] = spinner;
202  ui->settingsGrid->addWidget(spinner, row, 3, 1, 1);
203  ui->settingsGrid->addWidget(new QLabel("seconds", this), row, 4, 1, 2);
204  row++;
205  }
206  // Show boxes for start with mode/with keypress
207  QCheckBox* check = new QCheckBox("Start with mode", this);
208  check->setChecked(anim->parameter("trigger").toBool());
209  ui->settingsGrid->addWidget(check, row, 3, 1, 4);
210  settingWidgets["trigger"] = check;
211  connect(check, SIGNAL(stateChanged(int)), &updateMapper, SLOT(map()));
212  updateMapper.setMapping(check, "trigger");
213  row++;
214  check = new QCheckBox("Start with key press", this);
215  check->setChecked(anim->parameter("kptrigger").toBool());
216  ui->settingsGrid->addWidget(check, row, 3, 1, 2);
217  settingWidgets["kptrigger"] = check;
218  connect(check, SIGNAL(stateChanged(int)), &updateMapper, SLOT(map()));
219  updateMapper.setMapping(check, "kptrigger");
220  // Add an option allowing the user to select keypress mode
221  QComboBox* combo = new QComboBox(this);
222  int selected = anim->parameter("kpmode").toInt();
223  if(script->hasKeypress()){
224  // If the script supports keypresses, show the option to handle them that way (default)
225  combo->addItem("on pressed key");
226  combo->addItem("on whole keyboard");
227  combo->addItem("on keyboard (once)");
228  } else {
229  selected--;
230  // Otherwise, just show the choice of whether to start it every time or just once
231  combo->addItem("every time");
232  combo->addItem("only once");
233  }
234  if(selected < 0 || selected > combo->count())
235  selected = 0;
236  combo->setCurrentIndex(selected);
237  ui->settingsGrid->addWidget(combo, row, 5, 1, 2);
238  settingWidgets["kpmode"] = combo;
239  connect(combo, SIGNAL(activated(int)), &updateMapper, SLOT(map()));
240  updateMapper.setMapping(combo, "kpmode");
241  row++;
242 
243  // Add horizontal spacer to compress content to left
244  ui->settingsGrid->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding), 0, 6);
245  // Add vertical spacer to compress content to top
246  ui->settingsGrid->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), row, 0);
247 
248  // Add timing fields
249  settingWidgets["delay"] = ui->delayBox;
250  ui->delayBox->setValue(anim->parameter("delay").toDouble());
251  settingWidgets["kpdelay"] = ui->kpDelayBox;
252  ui->kpDelayBox->setValue(anim->parameter("kpdelay").toDouble());
253  settingWidgets["kpmodestop"] = ui->kpModeStopBox;
254  ui->kpModeStopBox->setChecked(anim->parameter("kpmodestop").toBool());
255  connect(ui->kpModeStopBox, SIGNAL(clicked(bool)), &updateMapper, SLOT(map()));
256  updateMapper.setMapping(ui->kpModeStopBox, "kpmodestop");
257  settingWidgets["kprelease"] = ui->kpReleaseBox;
258  ui->kpReleaseBox->setChecked(anim->parameter("kprelease").toBool());
259  if(anim->hasParameter("repeat")){
260  hasRepeat = true;
261  settingWidgets["repeat"] = ui->repeatBox;
262  ui->repeatBox->setValue(anim->parameter("repeat").toDouble());
263  settingWidgets["kprepeat"] = ui->kpRepeatBox;
264  ui->kpRepeatBox->setValue(anim->parameter("kprepeat").toDouble());
265  // If repeat is enabled, add repeat counts as integer values
266  // Mode repeat
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());
272  settingWidgets["stop"] = spinner;
273  connect(spinner, SIGNAL(valueChanged(int)), &updateMapper, SLOT(map()));
274  updateMapper.setMapping(spinner, "stop");
275  ui->timeGrid->addWidget(spinner, 4, 3);
276  ui->timeGrid->addWidget(new QLabel("times", this), 4, 4);
277  // KP repeat
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());
283  settingWidgets["kpstop"] = spinner;
284  connect(spinner, SIGNAL(valueChanged(int)), &updateMapper, SLOT(map()));
285  updateMapper.setMapping(spinner, "kpstop");
286  ui->timeGrid->addWidget(spinner, 12, 3);
287  ui->timeGrid->addWidget(new QLabel("times", this), 12, 4);
288  // Infinite repeat toggles
289  stopCheck = new QCheckBox("Forever", this);
290  stopCheck->setChecked(anim->parameter("stop").toInt() < 0);
291  ui->timeGrid->addWidget(stopCheck, 4, 5);
292  kpStopCheck = new QCheckBox("Forever", this);
293  connect(stopCheck, SIGNAL(clicked()), this, SLOT(updateStops()));
294  kpStopCheck->setChecked(anim->parameter("kpstop").toInt() < 0);
295  ui->timeGrid->addWidget(kpStopCheck, 12, 5);
296  connect(kpStopCheck, SIGNAL(clicked()), this, SLOT(updateStops()));
297  } else {
298  hasRepeat = false;
299  // If repeat is not enabled, hide repeat-related fields
300  ui->repeatBox->setHidden(true);
301  ui->repeatLabel->setHidden(true);
302  ui->repeatLabel_2->setHidden(true);
303  ui->kpRepeatBox->setHidden(true);
304  ui->kpRepeatLabel->setHidden(true);
305  ui->kpRepeatLabel_2->setHidden(true);
306  // Add stop times as double values
307  // Stop time
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();
313  if(stop <= 0.)
314  spinner->setValue(lastDuration);
315  else
316  spinner->setValue(stop);
317  settingWidgets["stop"] = spinner;
318  connect(spinner, SIGNAL(valueChanged(double)), &updateMapper, SLOT(map()));
319  updateMapper.setMapping(spinner, "stop");
320  ui->timeGrid->addWidget(spinner, 4, 3);
321  ui->timeGrid->addWidget(new QLabel("seconds", this), 4, 4);
322  // KP stop time
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();
328  if(kpstop <= 0.)
329  spinner->setValue(lastDuration);
330  else
331  spinner->setValue(kpstop);
332  settingWidgets["kpstop"] = spinner;
333  connect(spinner, SIGNAL(valueChanged(double)), &updateMapper, SLOT(map()));
334  updateMapper.setMapping(spinner, "kpstop");
335  ui->timeGrid->addWidget(spinner, 12, 3);
336  ui->timeGrid->addWidget(new QLabel("seconds", this), 12, 4);
337  // Infinite run toggles
338  stopCheck = new QCheckBox("Stop after:", this);
339  stopCheck->setChecked(stop > 0.);
340  ui->timeGrid->addWidget(stopCheck, 4, 1);
341  connect(stopCheck, SIGNAL(clicked()), this, SLOT(updateStops()));
342  kpStopCheck = new QCheckBox("Stop after:", this);
343  kpStopCheck->setChecked(kpstop > 0.);
344  ui->timeGrid->addWidget(kpStopCheck, 12, 1);
345  connect(kpStopCheck, SIGNAL(clicked()), this, SLOT(updateStops()));
346  }
347  updateStops();
348 
349  // Set script info UI
350  ui->sNameLabel->setText(script->name());
351  ui->sVerLabel->setText(script->version());
352  ui->sAuthorLabel->setText(script->author());
353  ui->sYearLabel->setText(script->year());
354  ui->sLicenseLabel->setText(script->license());
355  ui->sDescLabel->setText(script->description());
356 
357  // Lock dialog size
358  setFixedSize(minimumSize());
359 }
void newDuration(double duration)
QDoubleSpinBox * repeatBox
Ui::AnimSettingDialog * ui
bool hasParameter(const QString &name) const
Definition: kbanim.h:44
const QString & name() const
Definition: kbanim.h:73
QSignalMapper angleSpinnerMapper
QMap< QString, QSpinBox * > angleSpinners
const QString & author() const
Definition: animscript.h:64
static int angleFlip(int angle)
const QString & year() const
Definition: animscript.h:63
QDoubleSpinBox * kpDelayBox
QDoubleSpinBox * kpRepeatBox
const QString & description() const
Definition: animscript.h:66
void setupUi(QDialog *AnimSettingDialog)
const QString & scriptName() const
Definition: kbanim.h:82
bool hasParam(const QString &name) const
Definition: animscript.h:74
QVariant maximum
Definition: animscript.h:46
const QString & license() const
Definition: animscript.h:65
QMap< QString, QWidget * > settingWidgets
void angleSpinnerChanged(QString name)
QSignalMapper angleDialMapper
const QString & name() const
Definition: animscript.h:60
void angleDialChanged(QString name)
QVariant minimum
Definition: animscript.h:45
QListIterator< Param > paramIterator() const
Definition: animscript.h:72
QDoubleSpinBox * delayBox
const QString & version() const
Definition: animscript.h:61
const AnimScript * script() const
Definition: kbanim.h:81
void updateParam(QString name)
QCheckBox * kpStopCheck
bool hasKeypress() const
Definition: animscript.h:67
QVariant parameter(const QString &name) const
Definition: kbanim.h:45
QSignalMapper updateMapper

+ Here is the call graph for this function:

AnimSettingDialog::~AnimSettingDialog ( )

Definition at line 476 of file animsettingdialog.cpp.

References ui.

476  {
477  delete ui;
478 }
Ui::AnimSettingDialog * ui

Member Function Documentation

void AnimSettingDialog::angleDialChanged ( QString  name)
privateslot

Definition at line 389 of file animsettingdialog.cpp.

References angleFlip(), angleSpinners, name(), settingWidgets, and updateParam().

Referenced by AnimSettingDialog().

389  {
390  // Dial changed; update spinner value
391  angleSpinners[name]->setValue(angleFlip(((QDial*)settingWidgets[name])->value()));
392  updateParam(name);
393 }
QMap< QString, QSpinBox * > angleSpinners
QString name() const
static int angleFlip(int angle)
QMap< QString, QWidget * > settingWidgets
void updateParam(QString name)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AnimSettingDialog::angleSpinnerChanged ( QString  name)
privateslot

Definition at line 395 of file animsettingdialog.cpp.

References angleFlip(), angleSpinners, settingWidgets, and updateParam().

Referenced by AnimSettingDialog().

395  {
396  // Spinner changed; update dial value
397  ((QDial*)settingWidgets[name])->setValue(angleFlip(angleSpinners[name]->value()));
398  updateParam(name);
399 }
QMap< QString, QSpinBox * > angleSpinners
QString name() const
static int angleFlip(int angle)
QMap< QString, QWidget * > settingWidgets
void updateParam(QString name)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

QFrame * AnimSettingDialog::hLine ( )
private

Definition at line 480 of file animsettingdialog.cpp.

References frame.

Referenced by AnimSettingDialog().

480  {
481  QFrame* frame = new QFrame(this);
482  frame->setFrameShape(QFrame::HLine);
483  frame->setFrameShadow(QFrame::Sunken);
484  return frame;
485 }
double frame
Definition: main.c:65

+ Here is the caller graph for this function:

QString AnimSettingDialog::name ( ) const

Definition at line 472 of file animsettingdialog.cpp.

References Ui_AnimSettingDialog::animName, and ui.

Referenced by angleDialChanged(), and KbAnimWidget::on_propertyButton_clicked().

472  {
473  return ui->animName->text();
474 }
Ui::AnimSettingDialog * ui

+ Here is the caller graph for this function:

void AnimSettingDialog::newDuration ( double  duration)
privateslot

Definition at line 361 of file animsettingdialog.cpp.

References lastDuration, settingWidgets, and updateParam().

Referenced by AnimSettingDialog().

361  {
362  // Duration changed. Automatically fix Repeat and KP Repeat to the same values, if they matched before
363  QDoubleSpinBox* rep = (QDoubleSpinBox*)settingWidgets.value("repeat");
364  QDoubleSpinBox* kpRep = (QDoubleSpinBox*)settingWidgets.value("kprepeat");
365  if(rep && rep->value() == lastDuration)
366  rep->setValue(duration);
367  if(kpRep && kpRep->value() == lastDuration)
368  kpRep->setValue(duration);
369  lastDuration = duration;
370  updateParam("duration");
371  updateParam("repeat");
372  updateParam("kprepeat");
373 }
QMap< QString, QWidget * > settingWidgets
void updateParam(QString name)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AnimSettingDialog::on_delayBox_valueChanged ( double  arg1)
privateslot

Definition at line 487 of file animsettingdialog.cpp.

References updateParam().

487  {
488  updateParam("delay");
489 }
void updateParam(QString name)

+ Here is the call graph for this function:

void AnimSettingDialog::on_kpDelayBox_valueChanged ( double  arg1)
privateslot

Definition at line 495 of file animsettingdialog.cpp.

References updateParam().

495  {
496  updateParam("kpdelay");
497 }
void updateParam(QString name)

+ Here is the call graph for this function:

void AnimSettingDialog::on_kpReleaseBox_stateChanged ( int  arg1)
privateslot

Definition at line 503 of file animsettingdialog.cpp.

References updateParam().

503  {
504  updateParam("kprelease");
505 }
void updateParam(QString name)

+ Here is the call graph for this function:

void AnimSettingDialog::on_kpRepeatBox_valueChanged ( double  arg1)
privateslot

Definition at line 499 of file animsettingdialog.cpp.

References updateParam().

499  {
500  updateParam("kprepeat");
501 }
void updateParam(QString name)

+ Here is the call graph for this function:

void AnimSettingDialog::on_repeatBox_valueChanged ( double  arg1)
privateslot

Definition at line 491 of file animsettingdialog.cpp.

References updateParam().

491  {
492  updateParam("repeat");
493 }
void updateParam(QString name)

+ Here is the call graph for this function:

void AnimSettingDialog::updateParam ( QString  name)
privateslot

Definition at line 401 of file animsettingdialog.cpp.

References _anim, AnimScript::Param::AGRADIENT, AnimScript::Param::ANGLE, angleFlip(), AnimScript::Param::ARGB, AnimScript::Param::BOOL, ColorButton::color(), AnimScript::Param::DOUBLE, AnimScript::Param::GRADIENT, AnimScript::hasKeypress(), hasRepeat, kpStopCheck, AnimScript::Param::LONG, AnimScript::param(), KbAnim::parameter(), AnimScript::Param::RGB, KbAnim::script(), settingWidgets, stopCheck, AnimScript::Param::STRING, GradientButton::toString(), and AnimScript::Param::type.

Referenced by angleDialChanged(), angleSpinnerChanged(), AnimSettingDialog(), newDuration(), on_delayBox_valueChanged(), on_kpDelayBox_valueChanged(), on_kpReleaseBox_stateChanged(), on_kpRepeatBox_valueChanged(), on_repeatBox_valueChanged(), and updateStops().

401  {
402  if(!settingWidgets.contains(name))
403  return;
404  // stop and kpstop have defeat switches
405  if((name == "stop" && stopCheck->isChecked() == hasRepeat)
406  || (name == "kpstop" && kpStopCheck->isChecked() == hasRepeat)){
407  _anim->parameter(name, -1);
408  return;
409  } else if(name == "kpmode"){
410  // kpmode uses a drop-down, and selection is inverted
411  QComboBox* widget = (QComboBox*)settingWidgets[name];
412  int selected = widget->currentIndex();
413  if(!_anim->script()->hasKeypress())
414  selected++;
415  _anim->parameter(name, selected);
416  return;
417  }
418  // Read value based on type
419  switch(_anim->script()->param(name).type){
421  QCheckBox* widget = (QCheckBox*)settingWidgets[name];
422  _anim->parameter(name, (int)widget->isChecked());
423  break;
424  }
426  QSpinBox* widget = (QSpinBox*)settingWidgets[name];
427  _anim->parameter(name, widget->value());
428  break;
429  }
431  QDoubleSpinBox* widget = (QDoubleSpinBox*)settingWidgets[name];
432  _anim->parameter(name, widget->value());
433  break;
434  }
437  QColor color = widget->color();
438  char hex[7];
439  snprintf(hex, sizeof(hex), "%02x%02x%02x", color.red(), color.green(), color.blue());
440  _anim->parameter(name, QString(hex));
441  break;
442  }
445  QColor color = widget->color();
446  char hex[9];
447  snprintf(hex, sizeof(hex), "%02x%02x%02x%02x", color.alpha(), color.red(), color.green(), color.blue());
448  _anim->parameter(name, QString(hex));
449  break;
450  }
454  _anim->parameter(name, widget->toString());
455  break;
456  }
458  QDial* widget = (QDial*)settingWidgets[name];
459  _anim->parameter(name, angleFlip(widget->value()));
460  break;
461  }
463  QLineEdit* widget = (QLineEdit*)settingWidgets[name];
464  _anim->parameter(name, widget->text());
465  break;
466  }
467  default:
468  break;
469  }
470 }
Param param(const QString &name) const
Definition: animscript.h:73
const QColor & color() const
Definition: colorbutton.h:13
QString name() const
static int angleFlip(int angle)
QMap< QString, QWidget * > settingWidgets
const AnimScript * script() const
Definition: kbanim.h:81
QCheckBox * kpStopCheck
bool hasKeypress() const
Definition: animscript.h:67
QVariant parameter(const QString &name) const
Definition: kbanim.h:45
QString toString() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AnimSettingDialog::updateStops ( )
privateslot

Definition at line 375 of file animsettingdialog.cpp.

References hasRepeat, kpStopCheck, settingWidgets, stopCheck, and updateParam().

Referenced by AnimSettingDialog().

375  {
376  if(hasRepeat){
377  // When repeat is enabled, the check box is "repeat forever", so disable stop count if checked
378  settingWidgets.value("stop")->setDisabled(stopCheck->isChecked());
379  settingWidgets.value("kpstop")->setDisabled(kpStopCheck->isChecked());
380  } else {
381  // When repeat is disabled, the check box is "stop after", so disable stop count UNLESS checked
382  settingWidgets.value("stop")->setEnabled(stopCheck->isChecked());
383  settingWidgets.value("kpstop")->setEnabled(kpStopCheck->isChecked());
384  }
385  updateParam("stop");
386  updateParam("kpstop");
387 }
QMap< QString, QWidget * > settingWidgets
void updateParam(QString name)
QCheckBox * kpStopCheck

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

KbAnim* AnimSettingDialog::_anim
private

Definition at line 32 of file animsettingdialog.h.

Referenced by updateParam().

QSignalMapper AnimSettingDialog::angleDialMapper
private

Definition at line 38 of file animsettingdialog.h.

Referenced by AnimSettingDialog().

QSignalMapper AnimSettingDialog::angleSpinnerMapper
private

Definition at line 38 of file animsettingdialog.h.

Referenced by AnimSettingDialog().

QMap<QString, QSpinBox*> AnimSettingDialog::angleSpinners
private

Definition at line 37 of file animsettingdialog.h.

Referenced by angleDialChanged(), angleSpinnerChanged(), and AnimSettingDialog().

bool AnimSettingDialog::hasRepeat
private

Definition at line 30 of file animsettingdialog.h.

Referenced by AnimSettingDialog(), updateParam(), and updateStops().

QCheckBox * AnimSettingDialog::kpStopCheck
private

Definition at line 29 of file animsettingdialog.h.

Referenced by AnimSettingDialog(), updateParam(), and updateStops().

double AnimSettingDialog::lastDuration
private

Definition at line 33 of file animsettingdialog.h.

Referenced by AnimSettingDialog(), and newDuration().

QMap<QString, QWidget*> AnimSettingDialog::settingWidgets
private
QCheckBox* AnimSettingDialog::stopCheck
private

Definition at line 29 of file animsettingdialog.h.

Referenced by AnimSettingDialog(), updateParam(), and updateStops().

Ui::AnimSettingDialog* AnimSettingDialog::ui
private

Definition at line 28 of file animsettingdialog.h.

Referenced by AnimSettingDialog(), name(), and ~AnimSettingDialog().

QSignalMapper AnimSettingDialog::updateMapper
private

Definition at line 35 of file animsettingdialog.h.

Referenced by AnimSettingDialog().


The documentation for this class was generated from the following files: