most settings are saved and restored
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
#include "..\Header\SettingsWindow.h"
|
||||
#include "..\Header\SettingsManager.h"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// constructor/destructor
|
||||
|
||||
SettingsWindow::SettingsWindow(QVector3D bgOffColor, QVector3D bgOnColor, QVector3D lightColor, bool autoColor, double ambCoef, double attFac, int lightType, QWidget * parent)
|
||||
SettingsWindow::SettingsWindow(QWidget * parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::SettingsWindow)
|
||||
{
|
||||
@@ -15,24 +16,41 @@ SettingsWindow::SettingsWindow(QVector3D bgOffColor, QVector3D bgOnColor, QVecto
|
||||
setupConnections();
|
||||
|
||||
// set default values
|
||||
ui->lightOff_R_SB->setValue((int)bgOffColor[0]);
|
||||
ui->lightOff_G_SB->setValue((int)bgOffColor[1]);
|
||||
ui->lightOff_B_SB->setValue((int)bgOffColor[2]);
|
||||
SettingsManager* sm = SettingsManager::getInstance(this);
|
||||
|
||||
ui->lightOn_R_SB->setValue((int)bgOnColor[0]);
|
||||
ui->lightOn_G_SB->setValue((int)bgOnColor[1]);
|
||||
ui->lightOn_B_SB->setValue((int)bgOnColor[2]);
|
||||
ui->lightOff_R_SB->setValue((int)(sm->getBgColorOff()[0]));
|
||||
ui->lightOff_G_SB->setValue((int)(sm->getBgColorOff()[1]));
|
||||
ui->lightOff_B_SB->setValue((int)(sm->getBgColorOff()[2]));
|
||||
|
||||
ui->light_R_SB->setValue((int)lightColor[0]);
|
||||
ui->light_G_SB->setValue((int)lightColor[1]);
|
||||
ui->light_B_SB->setValue((int)lightColor[2]);
|
||||
ui->lightOn_R_SB->setValue((int)(sm->getBgColorOn()[0]));
|
||||
ui->lightOn_G_SB->setValue((int)(sm->getBgColorOn()[1]));
|
||||
ui->lightOn_B_SB->setValue((int)(sm->getBgColorOn()[2]));
|
||||
|
||||
ui->ambCoef->setValue(ambCoef);
|
||||
ui->attFac->setValue(attFac);
|
||||
ui->light_R_SB->setValue((int)(sm->getLightColor()[0]));
|
||||
ui->light_G_SB->setValue((int)(sm->getLightColor()[1]));
|
||||
ui->light_B_SB->setValue((int)(sm->getLightColor()[2]));
|
||||
|
||||
ui->checkAutoColor->setChecked(autoColor);
|
||||
if (lightType == 1)
|
||||
ui->ambCoef->setValue(sm->getAmbient());
|
||||
ui->attFac->setValue(sm->getAttenuation());
|
||||
|
||||
ui->checkBackfaceCulling->setChecked(sm->isBfCulling());
|
||||
ui->checkAutoColor->setChecked(sm->isAutoColor());
|
||||
ui->checkHeadlight->setChecked(sm->isHeadlight());
|
||||
|
||||
if (sm->getLightType() == 1)
|
||||
ui->radioDirectLight->setChecked(true);
|
||||
else
|
||||
ui->radioPointLight->setChecked(true);
|
||||
|
||||
connect(this, &SettingsWindow::updateBGColorOff, sm, &SettingsManager::setBgColorOff);
|
||||
connect(this, &SettingsWindow::updateBGColorOn, sm, &SettingsManager::setBgColorOn);
|
||||
connect(this, &SettingsWindow::updateLightColor, sm, &SettingsManager::setLightColor);
|
||||
connect(this, &SettingsWindow::updateAttFac, sm, &SettingsManager::setAttenuation);
|
||||
connect(this, &SettingsWindow::updateAmbCoef, sm, &SettingsManager::setAmbient);
|
||||
connect(this, &SettingsWindow::sendHeadlight, sm, &SettingsManager::setHeadlight);
|
||||
connect(this, &SettingsWindow::sendBackfaceCulling, sm, &SettingsManager::setBfCulling);
|
||||
connect(ui->checkAutoColor, &QCheckBox::stateChanged, sm, &SettingsManager::setAutoColor);
|
||||
connect(this, &SettingsWindow::changeLightType, sm, &SettingsManager::setLightType);
|
||||
|
||||
}
|
||||
|
||||
@@ -133,10 +151,12 @@ void SettingsWindow::radioToggled()
|
||||
{
|
||||
ui->attFac->setValue(0.0);
|
||||
ui->attFac->setEnabled(false);
|
||||
emit changeLightType(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->attFac->setEnabled(true);
|
||||
emit changeLightType(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user