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

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

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

	// light off
13 14
	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));});
15
	connect(ui->lightOff_R_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOffChanged);
Anakin's avatar
Anakin committed
16

17 18
	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));});
19
	connect(ui->lightOff_G_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOffChanged);
Anakin's avatar
Anakin committed
20

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));});
23
	connect(ui->lightOff_B_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOffChanged);
Anakin's avatar
Anakin committed
24 25

	// light on
26 27
	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));});
28
	connect(ui->lightOn_R_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOnChanged);
Anakin's avatar
Anakin committed
29

30 31
	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));});
32
	connect(ui->lightOn_G_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOnChanged);
Anakin's avatar
Anakin committed
33

34 35
	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));});
36
	connect(ui->lightOn_B_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOnChanged);
Anakin's avatar
Anakin committed
37 38

	// light
39
	connect(ui->light_R_LE, &QLineEdit::textChanged, [this](const QString& value){ui->light_R_S->setValue(value.toInt());});
40 41
	connect(ui->light_R_S, &QSlider::valueChanged, [this](const int& value){ui->light_R_LE->setText(QString::number(value)); if(ui->checkAutoColor->isChecked()) ui->lightOn_R_S->setValue((int)(value / 50));});
	connect(ui->light_R_S, &QSlider::valueChanged, this, &SettingsWindow::lightColorChanged);
Anakin's avatar
Anakin committed
42

43
	connect(ui->light_G_LE, &QLineEdit::textChanged, [this](const QString& value){ui->light_G_S->setValue(value.toInt());});
44 45
	connect(ui->light_G_S, &QSlider::valueChanged, [this](const int& value){ui->light_G_LE->setText(QString::number(value)); if(ui->checkAutoColor->isChecked()) ui->lightOn_G_S->setValue((int)(value / 50));});
	connect(ui->light_G_S, &QSlider::valueChanged, this, &SettingsWindow::lightColorChanged);
Anakin's avatar
Anakin committed
46

47
	connect(ui->light_B_LE, &QLineEdit::textChanged, [this](const QString& value){ui->light_B_S->setValue(value.toInt());});
48 49
	connect(ui->light_B_S, &QSlider::valueChanged, [this](const int& value){ui->light_B_LE->setText(QString::number(value)); if(ui->checkAutoColor->isChecked()) ui->lightOn_B_S->setValue((int)(value / 50));});
	connect(ui->light_B_S, &QSlider::valueChanged, this, &SettingsWindow::lightColorChanged);
Anakin's avatar
Anakin committed
50 51 52 53


	connect(ui->checkAutoColor, &QCheckBox::toggled, this, &SettingsWindow::autoColorToggled);
	connect(ui->radioDirectLight, &QRadioButton::toggled, this, &SettingsWindow::radioToggled);
54 55
	connect(ui->ambCoef, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [this](double value) {emit updateAmbCoef(value); });
	connect(ui->attFac, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [this](double value) {emit updateAttFac(value); });
Anakin's avatar
Anakin committed
56 57 58 59 60 61 62 63
}

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

////////////////////////////////////////////////////////////////////////////////
64
// connection slots
Anakin's avatar
Anakin committed
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 99 100

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);
101
		ui->ambCoef->setEnabled(false);
Anakin's avatar
Anakin committed
102 103 104 105
	}
	else
	{
		ui->attFac->setEnabled(true);
106
		ui->ambCoef->setEnabled(true);
Anakin's avatar
Anakin committed
107 108
	}
}
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124

void SettingsWindow::backgroundColorOffChanged()
{
	emit updateBGColorOff(QVector3D(ui->lightOff_R_S->value(), ui->lightOff_G_S->value(), ui->lightOff_B_S->value()));
}

void SettingsWindow::backgroundColorOnChanged()
{
	emit updateBGColorOn(QVector3D(ui->lightOn_R_S->value(), ui->lightOn_G_S->value(), ui->lightOn_B_S->value()));
}

void SettingsWindow::lightColorChanged()
{
	emit updateLightColor(QVector3D(ui->light_R_S->value(), ui->light_G_S->value(), ui->light_B_S->value()));
}