init branch
This commit is contained in:
@ -1,21 +1,16 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
MainWindow::MainWindow(QSettings *settings, Microcontroller *micro , bool isRemoteMode , QWidget *parent) :
|
||||
MainWindow::MainWindow(Microcontroller *micro , bool isRemoteMode , QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow),
|
||||
colorChooser(this),
|
||||
_settings(settings),
|
||||
_micro(micro)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
if(!_micro->connected()) ui->label_serialRecive->setText("No IO Port! Debug only.");
|
||||
|
||||
//Settings
|
||||
ui->alarmTime->setTime(_settings->value("alarmTime").toTime());
|
||||
ui->nightTime->setTime(_settings->value("nightTime").toTime());
|
||||
ui->checkBox_alarm->setChecked(_settings->value("alarmOn").toBool());
|
||||
|
||||
//RGB Leds
|
||||
connect(ui->presettApply, SIGNAL(clicked()), this, SLOT(slotApplyPreset()));
|
||||
@ -32,11 +27,16 @@ MainWindow::MainWindow(QSettings *settings, Microcontroller *micro , bool isRemo
|
||||
new QListWidgetItem(tr("Pattern 4 Sunrise"), ui->listWidget_patern);
|
||||
|
||||
|
||||
//Desk light
|
||||
|
||||
connect(ui->horizontalSlider_deskLight, &QAbstractSlider::valueChanged, _micro, [this](int value){ _micro->setAuxPwm(value); });
|
||||
|
||||
//Relays
|
||||
_relayCheckBoxes.push_back(ui->checkBox_amp);
|
||||
_relayCheckBoxes.push_back(ui->checkBox_bspeaker);
|
||||
_relayCheckBoxes.push_back(ui->checkBox_inf);
|
||||
_relayCheckBoxes.push_back(ui->checkBox_aircon);
|
||||
_relayCheckBoxes.push_back(ui->checkBox_SolderingIorn);
|
||||
_relayCheckBoxes.push_back(ui->checkBox_testEquitmpent);
|
||||
|
||||
for(unsigned int i = 0; i < _relayCheckBoxes.size(); i++) connect(_relayCheckBoxes[i], SIGNAL(stateChanged(int)), this, SLOT(relayCheckBoxToggeled(int)));
|
||||
|
||||
@ -47,37 +47,17 @@ MainWindow::MainWindow(QSettings *settings, Microcontroller *micro , bool isRemo
|
||||
//Bedroom Speakers
|
||||
if(!isRemoteMode)connect(ui->checkBox_bspeakerAuto, SIGNAL(stateChanged(int)), this, SLOT(slotBSpeakerAutoToggle(int)));
|
||||
|
||||
|
||||
//Infinity Mirror
|
||||
if(!isRemoteMode)connect(ui->checkBox_infAuto, SIGNAL(stateChanged(int)), this, SLOT(slotInfMirrorAutoToggle(int)));
|
||||
|
||||
if(!isRemoteMode)
|
||||
{
|
||||
//Alarm
|
||||
connect(ui->alarmTime, SIGNAL(timeChanged(QTime)), this, SLOT(slotChangedAlarmTime(QTime)));
|
||||
connect(ui->checkBox_alarm, SIGNAL(stateChanged(int)), this, SIGNAL(signalAlmAlarmStateChanged(int)));
|
||||
connect(ui->checkBox_alarm, SIGNAL(stateChanged(int)), this, SLOT(saveAlarmState(int)));
|
||||
|
||||
|
||||
|
||||
//Night Time
|
||||
connect(ui->nightTime, SIGNAL(timeChanged(QTime)), this, SLOT(slotChangedNightTime(QTime)));
|
||||
connect(ui->checkBox_nightTime, SIGNAL(stateChanged(int)), this, SIGNAL(signalAlmNightStateChanged(int)));
|
||||
}
|
||||
else remoteMode();
|
||||
//adv relays
|
||||
|
||||
//dialogs
|
||||
connect(ui->button_advRelay, SIGNAL(clicked()), this, SIGNAL(showAdvRelayDialog()));
|
||||
connect(ui->pushButton_alarms, SIGNAL(clicked()), this, SIGNAL(showAlmSettingsDialog()));
|
||||
}
|
||||
|
||||
void MainWindow::remoteMode()
|
||||
{
|
||||
ui->alarmTime->setEnabled(false);
|
||||
ui->checkBox_alarm->setEnabled(false);
|
||||
ui->pushButton_alarm->setEnabled(false);
|
||||
|
||||
ui->nightTime->setEnabled(false);
|
||||
ui->checkBox_nightTime->setEnabled(false);
|
||||
ui->label_nightTime->setEnabled(false);
|
||||
|
||||
ui->checkBox_ampAuto->setEnabled(false);
|
||||
ui->checkBox_ampAuto->setChecked(false);
|
||||
@ -90,15 +70,8 @@ void MainWindow::remoteMode()
|
||||
ui->checkBox_infAuto->setChecked(false);
|
||||
}
|
||||
|
||||
void MainWindow::postActivate()
|
||||
{
|
||||
QMetaObject::invokeMethod( this, "signalAlmNightStateChanged", Qt::QueuedConnection, Q_ARG(int, ui->checkBox_nightTime->checkState()) );
|
||||
signalAlmAlarmStateChanged(ui->checkBox_alarm->checkState());
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
_settings->sync();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@ -145,7 +118,7 @@ void MainWindow::slotBSpeakerAutoToggle(int state)
|
||||
|
||||
void MainWindow::slotDoorOpenTimeout()
|
||||
{
|
||||
ui->checkBox_doorOpen->setChecked(true);
|
||||
//ui->checkBox_doorOpen->setChecked(true);
|
||||
}
|
||||
|
||||
void MainWindow::slotInfMirrorAutoToggle(int state)
|
||||
@ -157,21 +130,11 @@ void MainWindow::slotInfMirrorAutoToggle(int state)
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::slotChangedAlarmTime(const QTime time)
|
||||
void MainWindow::auxStateChanged(int value)
|
||||
{
|
||||
_settings->setValue("alarmTime", time);
|
||||
signalAlmAlarmChanged(time);
|
||||
}
|
||||
|
||||
void MainWindow::saveAlarmState(int state)
|
||||
{
|
||||
_settings->setValue("alarmOn", state);
|
||||
}
|
||||
|
||||
void MainWindow::slotChangedNightTime(const QTime time)
|
||||
{
|
||||
_settings->setValue("nightTime", time);
|
||||
signalAlmNightChanged(time);
|
||||
ui->horizontalSlider_deskLight->blockSignals(true);
|
||||
ui->horizontalSlider_deskLight->setValue(value);
|
||||
ui->horizontalSlider_deskLight->blockSignals(false);
|
||||
}
|
||||
|
||||
void MainWindow::slotAmpAutoToggle(int state)
|
||||
|
Reference in New Issue
Block a user