SettingsWindow.cpp 4.28 KB
Newer Older
Anakin's avatar
Anakin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include "..\Header\SettingsWindow.h"
#include <QString>
#include <QLineEdit>
#include <QSlider>

SettingsWindow::SettingsWindow(QWidget * parent)
	: QWidget(parent)
	, ui(new Ui::SettingsWindow)
{
	ui->setupUi(this);

	setWindowFlags(Qt::Tool | Qt::NoDropShadowWindowHint);

	// light off
C-Fu's avatar
C-Fu committed
15 16
	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));});
Anakin's avatar
Anakin committed
17

C-Fu's avatar
C-Fu committed
18 19
	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));});
Anakin's avatar
Anakin committed
20

C-Fu's avatar
C-Fu committed
21 22
	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));});
Anakin's avatar
Anakin committed
23 24

	// light on
C-Fu's avatar
C-Fu committed
25 26
	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));});
Anakin's avatar
Anakin committed
27

C-Fu's avatar
C-Fu committed
28 29
	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));});
Anakin's avatar
Anakin committed
30

C-Fu's avatar
C-Fu committed
31 32
	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));});
Anakin's avatar
Anakin committed
33 34

	// light
C-Fu's avatar
C-Fu committed
35
	connect(ui->light_R_LE, &QLineEdit::textChanged, [this](const QString& value){ui->light_R_S->setValue(value.toInt());});
C-Fu's avatar
C-Fu committed
36
	connect(ui->light_R_S, &QSlider::valueChanged, [this](const int& value){ui->light_R_LE->setText(QString::number(value)); if(ui->checkAutoColor->isCecked()) ui->lightOn_R_S->setValue((int)(value / 50));});
Anakin's avatar
Anakin committed
37

C-Fu's avatar
C-Fu committed
38
	connect(ui->light_G_LE, &QLineEdit::textChanged, [this](const QString& value){ui->light_G_S->setValue(value.toInt());});
C-Fu's avatar
C-Fu committed
39
	connect(ui->light_G_S, &QSlider::valueChanged, [this](const int& value){ui->light_G_LE->setText(QString::number(value)); if(ui->checkAutoColor->isCecked()) ui->lightOn_G_S->setValue((int)(value / 50));});
Anakin's avatar
Anakin committed
40

C-Fu's avatar
C-Fu committed
41
	connect(ui->light_B_LE, &QLineEdit::textChanged, [this](const QString& value){ui->light_B_S->setValue(value.toInt());});
C-Fu's avatar
C-Fu committed
42
	connect(ui->light_B_S, &QSlider::valueChanged, [this](const int& value){ui->light_B_LE->setText(QString::number(value)); if(ui->checkAutoColor->isCecked()) ui->lightOn_B_S->setValue((int)(value / 50));});
Anakin's avatar
Anakin committed
43 44 45 46 47 48 49 50 51 52 53 54 55


	connect(ui->checkAutoColor, &QCheckBox::toggled, this, &SettingsWindow::autoColorToggled);

	connect(ui->radioDirectLight, &QRadioButton::toggled, this, &SettingsWindow::radioToggled);
}

SettingsWindow::~SettingsWindow()
{
	delete ui;
}

////////////////////////////////////////////////////////////////////////////////
C-Fu's avatar
C-Fu committed
56
// connection slots
Anakin's avatar
Anakin committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98

void SettingsWindow::autoColorToggled()
{
	if (!ui->checkAutoColor->isChecked())
	{
		ui->lightOn_R_LE->setEnabled(true);
		ui->lightOn_R_S->setEnabled(true);
		ui->lightOn_G_LE->setEnabled(true);
		ui->lightOn_G_S->setEnabled(true);
		ui->lightOn_B_LE->setEnabled(true);
		ui->lightOn_B_S->setEnabled(true);
	}
	else
	{
		ui->lightOn_R_LE->setEnabled(false);
		ui->lightOn_R_S->setEnabled(false);
		ui->lightOn_G_LE->setEnabled(false);
		ui->lightOn_G_S->setEnabled(false);
		ui->lightOn_B_LE->setEnabled(false);
		ui->lightOn_B_S->setEnabled(false);

		ui->lightOn_R_LE->setText(QString::number((int)(ui->light_R_S->value() / 50)));
		ui->lightOn_R_S->setValue((int)(ui->light_R_S->value() / 50));
		ui->lightOn_G_LE->setText(QString::number((int)(ui->light_G_S->value() / 50)));
		ui->lightOn_G_S->setValue((int)(ui->light_G_S->value() / 50));
		ui->lightOn_B_LE->setText(QString::number((int)(ui->light_B_S->value() / 50)));
		ui->lightOn_B_S->setValue((int)(ui->light_B_S->value() / 50));
	}
}

void SettingsWindow::radioToggled()
{
	if(ui->radioDirectLight->isChecked())
	{
		ui->attFac->setValue(0.0);
		ui->attFac->setEnabled(false);
	}
	else
	{
		ui->attFac->setEnabled(true);
	}
}