mirror of
https://github.com/AntiMicroX/antimicrox.git
synced 2026-02-18 15:18:07 -05:00
Initial import of project into repository
This commit is contained in:
committed by
Travis Nickles
parent
26c56beeb6
commit
dd901c1918
98
joybuttonwidget.cpp
Normal file
98
joybuttonwidget.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
#include <QDebug>
|
||||
|
||||
#include "joybuttonwidget.h"
|
||||
#include "event.h"
|
||||
|
||||
JoyButtonWidget::JoyButtonWidget(QWidget *parent) :
|
||||
QPushButton(parent)
|
||||
{
|
||||
|
||||
normal = this->palette();
|
||||
flashing = this->palette();
|
||||
|
||||
QColor highlightColor = QColor(0, 0, 255);
|
||||
flashing.setCurrentColorGroup(QPalette::Inactive);
|
||||
flashing.setColor(QPalette::Button, highlightColor);
|
||||
flashing.setColor(QPalette::Light, highlightColor.light(150));
|
||||
flashing.setColor(QPalette::Midlight, highlightColor.light(125));
|
||||
flashing.setColor(QPalette::Dark, highlightColor.dark(200));
|
||||
flashing.setColor(QPalette::Mid, highlightColor.dark(150));
|
||||
|
||||
setPalette(flashing);
|
||||
isflashing = false;
|
||||
}
|
||||
|
||||
JoyButtonWidget::JoyButtonWidget(JoyButton *button, QWidget *parent) :
|
||||
QPushButton(parent)
|
||||
{
|
||||
|
||||
this->button = button;
|
||||
|
||||
normal = this->palette();
|
||||
flashing = this->palette();
|
||||
QColor highlightColor = QColor(0, 0, 255);
|
||||
|
||||
flashing.setCurrentColorGroup(QPalette::Inactive);
|
||||
flashing.setColor(QPalette::Button, highlightColor);
|
||||
flashing.setColor(QPalette::Light, highlightColor.light(150));
|
||||
flashing.setColor(QPalette::Midlight, highlightColor.light(125));
|
||||
flashing.setColor(QPalette::Dark, highlightColor.dark(200));
|
||||
flashing.setColor(QPalette::Mid, highlightColor.dark(150));
|
||||
|
||||
setPalette(normal);
|
||||
isflashing = false;
|
||||
|
||||
setText(button->getName());
|
||||
|
||||
connect (button, SIGNAL(keyChanged(int)), this, SLOT(changeKeyLabel()));
|
||||
connect (button, SIGNAL(mouseChanged(int)), this, SLOT(changeMouseLabel()));
|
||||
connect (button, SIGNAL(clicked(int)), this, SLOT(flash()));
|
||||
connect (button, SIGNAL(released(int)), this, SLOT(unflash()));
|
||||
}
|
||||
|
||||
JoyButton* JoyButtonWidget::getJoyButton()
|
||||
{
|
||||
return button;
|
||||
}
|
||||
|
||||
void JoyButtonWidget::flash()
|
||||
{
|
||||
isflashing = true;
|
||||
setPalette(flashing);
|
||||
emit flashed(isflashing);
|
||||
}
|
||||
|
||||
void JoyButtonWidget::unflash()
|
||||
{
|
||||
isflashing = false;
|
||||
setPalette(normal);
|
||||
emit flashed(isflashing);
|
||||
}
|
||||
|
||||
void JoyButtonWidget::changeKeyLabel()
|
||||
{
|
||||
setText(button->getName());
|
||||
}
|
||||
|
||||
void JoyButtonWidget::changeMouseLabel()
|
||||
{
|
||||
setText(button->getName());
|
||||
}
|
||||
|
||||
void JoyButtonWidget::refreshLabel()
|
||||
{
|
||||
setText(button->getName());
|
||||
}
|
||||
|
||||
void JoyButtonWidget::disableFlashes()
|
||||
{
|
||||
disconnect (button, SIGNAL(clicked(int)), 0, 0);
|
||||
disconnect (button, SIGNAL(released(int)), 0, 0);
|
||||
this->unflash();
|
||||
}
|
||||
|
||||
void JoyButtonWidget::enableFlashes()
|
||||
{
|
||||
connect (button, SIGNAL(clicked(int)), this, SLOT(flash()));
|
||||
connect (button, SIGNAL(released(int)), this, SLOT(unflash()));
|
||||
}
|
||||
Reference in New Issue
Block a user