use lambda expressions instead of slots

This commit is contained in:
C-Fu 2017-01-24 11:40:38 +01:00
parent 73ee8a4040
commit 11af758eee

View File

@ -12,34 +12,34 @@ SettingsWindow::SettingsWindow(QWidget * parent)
setWindowFlags(Qt::Tool | Qt::NoDropShadowWindowHint);
// light off
connect(ui->lightOff_R_LE, SIGNAL(textChanged(QString)), this, SLOT(lightOffRValueChanged(QString)));
connect(ui->lightOff_R_S, SIGNAL(valueChanged(int)), this, SLOT(lightOffRValueChanged(int)));
connect(ui->lightOff_R_LE, &QLineEdit::textChanged, [this](const QString& value){ui->lightOff_R_S->setValue(value.toInt());});
connect(ui->lightOff_R_S, &QSlider::valueChanged, [this](const int& value){ui->lightOff_R_LE->setText(QString::number(value));});
connect(ui->lightOff_G_LE, SIGNAL(textChanged(QString)), this, SLOT(lightOffGValueChanged(QString)));
connect(ui->lightOff_G_S, SIGNAL(valueChanged(int)), this, SLOT(lightOffGValueChanged(int)));
connect(ui->lightOff_G_LE, &QLineEdit::textChanged, [this](const QString& value){ui->lightOff_G_S->setValue(value.toInt());});
connect(ui->lightOff_G_S, &QSlider::valueChanged, [this](const int& value){ui->lightOff_G_LE->setText(QString::number(value));});
connect(ui->lightOff_B_LE, SIGNAL(textChanged(QString)), this, SLOT(lightOffBValueChanged(QString)));
connect(ui->lightOff_B_S, SIGNAL(valueChanged(int)), this, SLOT(lightOffBValueChanged(int)));
connect(ui->lightOff_B_LE, &QLineEdit::textChanged, [this](const QString& value){ui->lightOff_B_S->setValue(value.toInt());});
connect(ui->lightOff_B_S, &QSlider::valueChanged, [this](const int& value){ui->lightOff_B_LE->setText(QString::number(value));});
// light on
connect(ui->lightOn_R_LE, SIGNAL(textChanged(QString)), this, SLOT(lightOnRValueChanged(QString)));
connect(ui->lightOn_R_S, SIGNAL(valueChanged(int)), this, SLOT(lightOnRValueChanged(int)));
connect(ui->lightOn_R_LE, &QLineEdit::textChanged, [this](const QString& value){ui->lightOn_R_S->setValue(value.toInt());});
connect(ui->lightOn_R_S, &QSlider::valueChanged, [this](const int& value){ui->lightOn_R_LE->setText(QString::number(value));});
connect(ui->lightOn_G_LE, SIGNAL(textChanged(QString)), this, SLOT(lightOnGValueChanged(QString)));
connect(ui->lightOn_G_S, SIGNAL(valueChanged(int)), this, SLOT(lightOnGValueChanged(int)));
connect(ui->lightOn_G_LE, &QLineEdit::textChanged, [this](const QString& value){ui->lightOn_G_S->setValue(value.toInt());});
connect(ui->lightOn_G_S, &QSlider::valueChanged, [this](const int& value){ui->lightOn_G_LE->setText(QString::number(value));});
connect(ui->lightOn_B_LE, SIGNAL(textChanged(QString)), this, SLOT(lightOnBValueChanged(QString)));
connect(ui->lightOn_B_S, SIGNAL(valueChanged(int)), this, SLOT(lightOnBValueChanged(int)));
connect(ui->lightOn_B_LE, &QLineEdit::textChanged, [this](const QString& value){ui->lightOn_B_S->setValue(value.toInt());});
connect(ui->lightOn_B_S, &QSlider::valueChanged, [this](const int& value){ui->lightOn_B_LE->setText(QString::number(value));});
// light
connect(ui->light_R_LE, SIGNAL(textChanged(QString)), this, SLOT(lightRValueChanged(QString)));
connect(ui->light_R_S, SIGNAL(valueChanged(int)), this, SLOT(lightRValueChanged(int)));
connect(ui->light_R_LE, &QLineEdit::textChanged, [this](const QString& value){ui->light_R_S->setValue(value.toInt());});
connect(ui->light_R_S, &QSlider::valueChanged, [this](const int& value){ui->light_R_LE->setText(QString::number(value));});
connect(ui->light_G_LE, SIGNAL(textChanged(QString)), this, SLOT(lightGValueChanged(QString)));
connect(ui->light_G_S, SIGNAL(valueChanged(int)), this, SLOT(lightGValueChanged(int)));
connect(ui->light_G_LE, &QLineEdit::textChanged, [this](const QString& value){ui->light_G_S->setValue(value.toInt());});
connect(ui->light_G_S, &QSlider::valueChanged, [this](const int& value){ui->light_G_LE->setText(QString::number(value));});
connect(ui->light_B_LE, SIGNAL(textChanged(QString)), this, SLOT(lightBValueChanged(QString)));
connect(ui->light_B_S, SIGNAL(valueChanged(int)), this, SLOT(lightBValueChanged(int)));
connect(ui->light_B_LE, &QLineEdit::textChanged, [this](const QString& value){ui->light_B_S->setValue(value.toInt());});
connect(ui->light_B_S, &QSlider::valueChanged, [this](const int& value){ui->light_B_LE->setText(QString::number(value));});
connect(ui->checkAutoColor, &QCheckBox::toggled, this, &SettingsWindow::autoColorToggled);
@ -53,146 +53,7 @@ SettingsWindow::~SettingsWindow()
}
////////////////////////////////////////////////////////////////////////////////
// Slider - LineEdit connections
#pragma region light off
void SettingsWindow::lightOffRValueChanged(QString value)
{
ui->lightOff_R_S->setValue(value.toInt());
}
void SettingsWindow::lightOffRValueChanged(int value)
{
ui->lightOff_R_LE->setText(QString::number(value));
}
void SettingsWindow::lightOffGValueChanged(QString value)
{
ui->lightOff_G_S->setValue(value.toInt());
}
void SettingsWindow::lightOffGValueChanged(int value)
{
ui->lightOff_G_LE->setText(QString::number(value));
}
void SettingsWindow::lightOffBValueChanged(QString value)
{
ui->lightOff_B_S->setValue(value.toInt());
}
void SettingsWindow::lightOffBValueChanged(int value)
{
ui->lightOff_B_LE->setText(QString::number(value));
}
#pragma endregion
#pragma region light on
void SettingsWindow::lightOnRValueChanged(QString value)
{
ui->lightOn_R_S->setValue(value.toInt());
}
void SettingsWindow::lightOnRValueChanged(int value)
{
ui->lightOn_R_LE->setText(QString::number(value));
}
void SettingsWindow::lightOnGValueChanged(QString value)
{
ui->lightOn_G_S->setValue(value.toInt());
}
void SettingsWindow::lightOnGValueChanged(int value)
{
ui->lightOn_G_LE->setText(QString::number(value));
}
void SettingsWindow::lightOnBValueChanged(QString value)
{
ui->lightOn_B_S->setValue(value.toInt());
}
void SettingsWindow::lightOnBValueChanged(int value)
{
ui->lightOn_B_LE->setText(QString::number(value));
}
#pragma endregion
#pragma region light
void SettingsWindow::lightRValueChanged(QString value)
{
ui->light_R_S->setValue(value.toInt());
if (ui->checkAutoColor->isChecked())
{
ui->lightOn_R_LE->setText(QString::number((int)(value.toInt() / 50)));
ui->lightOn_R_S->setValue((int)(value.toInt() / 50));
}
}
void SettingsWindow::lightRValueChanged(int value)
{
ui->light_R_LE->setText(QString::number(value));
if (ui->checkAutoColor->isChecked())
{
ui->lightOn_R_LE->setText(QString::number((int)(value / 50)));
ui->lightOn_R_S->setValue((int)(value / 50));
}
}
void SettingsWindow::lightGValueChanged(QString value)
{
ui->light_G_S->setValue(value.toInt());
if (ui->checkAutoColor->isChecked())
{
ui->lightOn_G_LE->setText(QString::number((int)(value.toInt() / 50)));
ui->lightOn_G_S->setValue((int)(value.toInt() / 50));
}
}
void SettingsWindow::lightGValueChanged(int value)
{
ui->light_G_LE->setText(QString::number(value));
if (ui->checkAutoColor->isChecked())
{
ui->lightOn_G_LE->setText(QString::number((int)(value / 50)));
ui->lightOn_G_S->setValue((int)(value / 50));
}
}
void SettingsWindow::lightBValueChanged(QString value)
{
ui->light_B_S->setValue(value.toInt());
if (ui->checkAutoColor->isChecked())
{
ui->lightOn_B_LE->setText(QString::number((int)(value.toInt() / 50)));
ui->lightOn_B_S->setValue((int)(value.toInt() / 50));
}
}
void SettingsWindow::lightBValueChanged(int value)
{
ui->light_B_LE->setText(QString::number(value));
if (ui->checkAutoColor->isChecked())
{
ui->lightOn_B_LE->setText(QString::number((int)(value / 50)));
ui->lightOn_B_S->setValue((int)(value / 50));
}
}
#pragma endregion
// connection slots
void SettingsWindow::autoColorToggled()
{