Commit 5e0c5f4c authored by Bryant's avatar Bryant

Replaced joystick buttons UI with QLabels.

Added an 11th button display.
parent 8d0f9620
......@@ -7,6 +7,7 @@ JoystickWidget::JoystickWidget(JoystickInput* joystick, QWidget *parent) :
m_ui(new Ui::JoystickWidget)
{
m_ui->setupUi(this);
clearKeys();
this->joystick = joystick;
m_ui->rollMapSpinBox->setValue(joystick->getMappingXAxis());
......@@ -87,55 +88,59 @@ void JoystickWidget::clearKeys()
{
QString colorstyle;
QColor buttonStyleColor = QColor(200, 20, 20);
colorstyle = QString("QGroupBox { border: 1px solid #EEEEEE; border-radius: 4px; padding: 0px; margin: 0px; background-color: %1;}").arg(buttonStyleColor.name());
m_ui->buttonLabel0->setStyleSheet(colorstyle);
m_ui->buttonLabel1->setStyleSheet(colorstyle);
m_ui->buttonLabel2->setStyleSheet(colorstyle);
m_ui->buttonLabel3->setStyleSheet(colorstyle);
m_ui->buttonLabel4->setStyleSheet(colorstyle);
m_ui->buttonLabel5->setStyleSheet(colorstyle);
m_ui->buttonLabel6->setStyleSheet(colorstyle);
m_ui->buttonLabel7->setStyleSheet(colorstyle);
m_ui->buttonLabel8->setStyleSheet(colorstyle);
m_ui->buttonLabel9->setStyleSheet(colorstyle);
colorstyle = QString("QLabel { border: 1px solid #EEEEEE; border-radius: 4px; padding: 0px; margin: 0px; background-color: %1;}").arg(buttonStyleColor.name());
m_ui->button0->setStyleSheet(colorstyle);
m_ui->button1->setStyleSheet(colorstyle);
m_ui->button2->setStyleSheet(colorstyle);
m_ui->button3->setStyleSheet(colorstyle);
m_ui->button4->setStyleSheet(colorstyle);
m_ui->button5->setStyleSheet(colorstyle);
m_ui->button6->setStyleSheet(colorstyle);
m_ui->button7->setStyleSheet(colorstyle);
m_ui->button8->setStyleSheet(colorstyle);
m_ui->button9->setStyleSheet(colorstyle);
m_ui->button10->setStyleSheet(colorstyle);
}
void JoystickWidget::pressKey(int key)
{
QString colorstyle;
QColor buttonStyleColor = QColor(20, 200, 20);
colorstyle = QString("QGroupBox { border: 1px solid #EEEEEE; border-radius: 4px; padding: 0px; margin: 0px; background-color: %1;}").arg(buttonStyleColor.name());
colorstyle = QString("QLabel { border: 1px solid #EEEEEE; border-radius: 4px; padding: 0px; margin: 0px; background-color: %1;}").arg(buttonStyleColor.name());
switch(key) {
case 0:
m_ui->buttonLabel0->setStyleSheet(colorstyle);
m_ui->button0->setStyleSheet(colorstyle);
break;
case 1:
m_ui->buttonLabel1->setStyleSheet(colorstyle);
m_ui->button1->setStyleSheet(colorstyle);
break;
case 2:
m_ui->buttonLabel2->setStyleSheet(colorstyle);
m_ui->button2->setStyleSheet(colorstyle);
break;
case 3:
m_ui->buttonLabel3->setStyleSheet(colorstyle);
m_ui->button3->setStyleSheet(colorstyle);
break;
case 4:
m_ui->buttonLabel4->setStyleSheet(colorstyle);
m_ui->button4->setStyleSheet(colorstyle);
break;
case 5:
m_ui->buttonLabel5->setStyleSheet(colorstyle);
m_ui->button5->setStyleSheet(colorstyle);
break;
case 6:
m_ui->buttonLabel6->setStyleSheet(colorstyle);
m_ui->button6->setStyleSheet(colorstyle);
break;
case 7:
m_ui->buttonLabel7->setStyleSheet(colorstyle);
m_ui->button7->setStyleSheet(colorstyle);
break;
case 8:
m_ui->buttonLabel8->setStyleSheet(colorstyle);
m_ui->button8->setStyleSheet(colorstyle);
break;
case 9:
m_ui->buttonLabel9->setStyleSheet(colorstyle);
m_ui->button9->setStyleSheet(colorstyle);
break;
case 10:
m_ui->button10->setStyleSheet(colorstyle);
break;
}
QTimer::singleShot(20, this, SLOT(clearKeys()));
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment