globals--, fmt string fix, foreeach++, better names++, close fds, tray icon activates/closes

This commit is contained in:
Mathias Panzenböck
2014-02-16 04:37:11 +01:00
parent f2a566cc06
commit cfa17f8947
24 changed files with 208 additions and 206 deletions

View File

@ -15,33 +15,32 @@ JoyPadWidget::JoyPadWidget( JoyPad* jp, int i, QWidget* parent )
int insertCounter = 0;
quickset = NULL;
foreach (Axis *axis, joypad->Axes) {
foreach (Axis *axis, joypad->axes) {
AxisWidget *aw = new AxisWidget(axis,this);
axes.append(aw);
connect( aw, SIGNAL( flashed( bool ) ), this, SLOT( flash( bool )));
layoutMain->addWidget(aw, insertCounter / 2, insertCounter %2);
layoutMain->addWidget(aw, insertCounter / 2, insertCounter % 2);
insertCounter++;
}
foreach (Button *button, joypad->Buttons) {
foreach (Button *button, joypad->buttons) {
ButtonWidget *bw = new ButtonWidget(button,this);
buttons.append(bw);
connect( bw, SIGNAL( flashed( bool ) ), this, SLOT( flash( bool )));
layoutMain->addWidget(bw, insertCounter/2, insertCounter%2);
layoutMain->addWidget(bw, insertCounter / 2, insertCounter % 2);
insertCounter++;
}
if (insertCounter % 2 == 1) {
insertCounter ++;
}
insertCounter += 2;
btnClear = new QPushButton("Clear", this);
connect(btnClear, SIGNAL(clicked()), this, SLOT(clear()));
layoutMain->addWidget(btnClear, insertCounter / 2, insertCounter %2);
layoutMain->addWidget(btnClear, insertCounter / 2, insertCounter % 2);
insertCounter++;
btnAll = new QPushButton("Quick Set", this);
layoutMain->addWidget(btnAll, insertCounter /2, insertCounter%2);
layoutMain->addWidget(btnAll, insertCounter / 2, insertCounter % 2);
connect(btnAll, SIGNAL(clicked()), this, SLOT(setAll()));
}
@ -86,16 +85,18 @@ void JoyPadWidget::setAll() {
quickset = NULL;
}
void JoyPadWidget::jsevent( js_event msg ) {
void JoyPadWidget::jsevent( const js_event& msg ) {
//notify the component this event applies to. this cannot generate anything
//other than a flash :)
if (msg.type == JS_EVENT_AXIS) {
qulonglong type = msg.type & ~JS_EVENT_INIT;
if (type == JS_EVENT_AXIS) {
if (msg.number < axes.count()) axes[msg.number]->jsevent(msg.value);
}
else {
else if (type == JS_EVENT_BUTTON) {
if (msg.number < buttons.count()) buttons[msg.number]->jsevent(msg.value);
}
//if we're doing quickset, it needs to know when we do something.
if (quickset != NULL)
if (quickset != NULL) {
quickset->jsevent(msg);
}
}