|
@ -43,6 +43,8 @@ MainWindow::MainWindow(QWidget *parent) : |
|
|
*/ |
|
|
*/ |
|
|
QGridLayout *mainLayout = new QGridLayout; |
|
|
QGridLayout *mainLayout = new QGridLayout; |
|
|
|
|
|
|
|
|
|
|
|
m_state_btn.setText(tr("Auto")); |
|
|
|
|
|
|
|
|
if (s->nbZones() < 4) { |
|
|
if (s->nbZones() < 4) { |
|
|
// TODO
|
|
|
// TODO
|
|
|
qDebug() << "bad configuration" ; |
|
|
qDebug() << "bad configuration" ; |
|
@ -52,11 +54,13 @@ MainWindow::MainWindow(QWidget *parent) : |
|
|
mainLayout->addWidget(new QPushButton(tr("Menu")), 0, 2); |
|
|
mainLayout->addWidget(new QPushButton(tr("Menu")), 0, 2); |
|
|
mainLayout->addWidget(m_zones.at(2), 1, 0); |
|
|
mainLayout->addWidget(m_zones.at(2), 1, 0); |
|
|
mainLayout->addWidget(m_zones.at(3), 1, 1); |
|
|
mainLayout->addWidget(m_zones.at(3), 1, 1); |
|
|
mainLayout->addWidget(new QPushButton(tr("Auto")), 1, 2); |
|
|
|
|
|
|
|
|
mainLayout->addWidget(&m_state_btn, 1, 2); |
|
|
} |
|
|
} |
|
|
|
|
|
m_pwr_state = OFF; |
|
|
|
|
|
update_state_btn(m_pwr_state); |
|
|
|
|
|
|
|
|
QWidget *mainWidget = new QWidget; |
|
|
QWidget *mainWidget = new QWidget; |
|
|
mainWidget->setLayout(mainLayout); |
|
|
mainWidget->setLayout(mainLayout); |
|
|
|
|
|
|
|
|
/*
|
|
|
/*
|
|
|
* Top widget |
|
|
* Top widget |
|
|
*/ |
|
|
*/ |
|
@ -66,12 +70,50 @@ MainWindow::MainWindow(QWidget *parent) : |
|
|
m_backLoop.start(); |
|
|
m_backLoop.start(); |
|
|
|
|
|
|
|
|
mqttclient->connectToHost(); |
|
|
mqttclient->connectToHost(); |
|
|
|
|
|
|
|
|
|
|
|
connect(&m_state_btn, SIGNAL(clicked()), this, SLOT(change_state())); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
MainWindow::~MainWindow() |
|
|
MainWindow::~MainWindow() |
|
|
{ |
|
|
{ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::update_state_btn(enum power_states st) |
|
|
|
|
|
{ |
|
|
|
|
|
switch (st) { |
|
|
|
|
|
case OFF: |
|
|
|
|
|
m_state_btn.setText(tr("Force off")); |
|
|
|
|
|
break; |
|
|
|
|
|
case ON: |
|
|
|
|
|
m_state_btn.setText(tr("Force on")); |
|
|
|
|
|
break; |
|
|
|
|
|
case AUTO: |
|
|
|
|
|
m_state_btn.setText(tr("Auto")); |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
m_state_btn.setText(tr("Error")); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::change_state(void) |
|
|
|
|
|
{ |
|
|
|
|
|
switch (m_pwr_state) { |
|
|
|
|
|
case OFF: |
|
|
|
|
|
m_pwr_state = ON; |
|
|
|
|
|
break; |
|
|
|
|
|
case ON: |
|
|
|
|
|
m_pwr_state = AUTO; |
|
|
|
|
|
break; |
|
|
|
|
|
case AUTO: |
|
|
|
|
|
/* fall through */ |
|
|
|
|
|
default: |
|
|
|
|
|
m_pwr_state = OFF; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
update_state_btn(m_pwr_state); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void MainWindow::temperature_slot(int idx, double val) |
|
|
void MainWindow::temperature_slot(int idx, double val) |
|
|
{ |
|
|
{ |
|
|
Settings *s = Settings::getInstance(); |
|
|
Settings *s = Settings::getInstance(); |
|
|