switched from qsettings to json added editng of actors
This commit is contained in:
@ -1,14 +1,98 @@
|
||||
#include "actorsettingsdialog.h"
|
||||
#include "ui_actorsettingsdialog.h"
|
||||
#include <QDebug>
|
||||
#include <QSpinBox>
|
||||
|
||||
ActorSettingsDialog::ActorSettingsDialog(QWidget *parent) :
|
||||
ActorSettingsDialog::ActorSettingsDialog(AlarmTime* alarm, QWidget *parent):
|
||||
QDialog(parent),
|
||||
actor_(alarm),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
{
|
||||
init();
|
||||
|
||||
widget = new AlarmWidget(alarm, this);
|
||||
ui->vertlayout->addWidget(widget);
|
||||
}
|
||||
|
||||
ActorSettingsDialog::ActorSettingsDialog(SensorActor* actor, SensorStore* sensors, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
actor_(actor),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
{
|
||||
init();
|
||||
|
||||
widget = new SensorActorWidget(actor, sensors, this);
|
||||
ui->vertlayout->addWidget(widget);
|
||||
}
|
||||
|
||||
ActorSettingsDialog::ActorSettingsDialog(Regulator* actor, SensorStore* sensors, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
actor_(actor),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
{
|
||||
init();
|
||||
|
||||
widget = new RegulatorWdiget(actor, sensors, this);
|
||||
ui->vertlayout->addWidget(widget);
|
||||
}
|
||||
|
||||
ActorSettingsDialog::ActorSettingsDialog(TimerActor* actor, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
actor_(actor),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
{
|
||||
init();
|
||||
|
||||
widget = new TimerActorWidget(actor, this);
|
||||
ui->vertlayout->addWidget(widget);
|
||||
}
|
||||
|
||||
|
||||
ActorSettingsDialog::ActorSettingsDialog(Actor* actor, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
actor_(actor),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void ActorSettingsDialog::init()
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->comboBox_action, SIGNAL(currentIndexChanged(int)), this, SLOT(changeAction(int)));
|
||||
connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(valueChanged(int)));
|
||||
ui->spinBox->hide();
|
||||
|
||||
ui->spinBox->setValue(actor_->getTriggerValue());
|
||||
if(actor_->getTriggerValue() == 0) ui->comboBox_action->setCurrentIndex(0);
|
||||
else if(actor_->getTriggerValue() == 1) ui->comboBox_action->setCurrentIndex(1);
|
||||
else ui->comboBox_action->setCurrentIndex(2);
|
||||
}
|
||||
|
||||
ActorSettingsDialog::~ActorSettingsDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ActorSettingsDialog::valueChanged(int value)
|
||||
{
|
||||
actor_->setTriggerValue(value);
|
||||
}
|
||||
|
||||
void ActorSettingsDialog::hideCancle(const bool hide)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ActorSettingsDialog::changeAction(int index)
|
||||
{
|
||||
if(index == 0) actor_->setTriggerValue(0);
|
||||
else if(index == 1) actor_->setTriggerValue(1);
|
||||
else if(index == 2)
|
||||
{
|
||||
ui->spinBox->show();
|
||||
actor_->setTriggerValue(ui->spinBox->value());
|
||||
}
|
||||
if(index != 2)ui->spinBox->hide();
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,11 @@
|
||||
#define ACTORSETTINGSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QWidget>
|
||||
#include "actorwidgets/alarmwidget.h"
|
||||
#include "actorwidgets/sensoractorwidget.h"
|
||||
#include "actorwidgets/timeractorwidget.h"
|
||||
#include "actorwidgets/regulatorwdiget.h"
|
||||
|
||||
namespace Ui {
|
||||
class ActorSettingsDialog;
|
||||
@ -11,10 +16,27 @@ class ActorSettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
Actor* actor_;
|
||||
QWidget* widget;
|
||||
|
||||
void init();
|
||||
|
||||
public:
|
||||
explicit ActorSettingsDialog(QWidget *parent = nullptr);
|
||||
ActorSettingsDialog(AlarmTime* actor, QWidget *parent = nullptr);
|
||||
ActorSettingsDialog(SensorActor* actor, SensorStore* sensors = nullptr, QWidget *parent = nullptr);
|
||||
ActorSettingsDialog(Regulator* actor, SensorStore* sensors = nullptr, QWidget *parent = nullptr);
|
||||
ActorSettingsDialog(TimerActor* actor, QWidget *parent);
|
||||
ActorSettingsDialog(Actor* actor, QWidget *parent);
|
||||
~ActorSettingsDialog();
|
||||
|
||||
void hideCancle(const bool hide);
|
||||
|
||||
private slots:
|
||||
void changeAction(int index);
|
||||
void valueChanged(int value);
|
||||
|
||||
|
||||
private:
|
||||
Ui::ActorSettingsDialog *ui;
|
||||
};
|
||||
|
@ -11,7 +11,11 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>Actor Settings</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../resources.qrc">
|
||||
<normaloff>:/images/UVOSicon.bmp</normaloff>:/images/UVOSicon.bmp</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
@ -33,11 +37,6 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_action">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>On</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Off</string>
|
||||
@ -45,9 +44,21 @@
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Toggle</string>
|
||||
<string>On</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Value</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -66,7 +77,9 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../resources.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
|
73
src/ui/actorwidgets/alarmwidget.cpp
Normal file
73
src/ui/actorwidgets/alarmwidget.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
#include "alarmwidget.h"
|
||||
#include "ui_alarmwidget.h"
|
||||
|
||||
AlarmWidget::AlarmWidget(AlarmTime* alarm, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
alarm_(alarm),
|
||||
ui(new Ui::AlarmWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->checkBox, &QCheckBox::stateChanged, this, &AlarmWidget::toggleRepeating);
|
||||
connect(ui->radioButton, &QRadioButton::clicked, this, &AlarmWidget::setRepeatingType);
|
||||
connect(ui->radioButton_2, &QRadioButton::clicked, this, &AlarmWidget::setRepeatingType);
|
||||
connect(ui->radioButton_3, &QRadioButton::clicked, this, &AlarmWidget::setRepeatingType);
|
||||
connect(ui->radioButton_4, &QRadioButton::clicked, this, &AlarmWidget::setRepeatingType);
|
||||
|
||||
ui->dateTimeEdit->setDateTime(alarm->getDateTime());
|
||||
|
||||
if(alarm_->getRepeat() == AlarmTime::REPEAT_NEVER)
|
||||
{
|
||||
ui->radioButton->setEnabled(false);
|
||||
ui->radioButton_2->setEnabled(false);
|
||||
ui->radioButton_3->setEnabled(false);
|
||||
ui->radioButton_4->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->radioButton->setEnabled(true);
|
||||
ui->radioButton_2->setEnabled(true);
|
||||
ui->radioButton_3->setEnabled(true);
|
||||
ui->radioButton_4->setEnabled(true);
|
||||
}
|
||||
|
||||
if(alarm_->getRepeat() == AlarmTime::REPEAT_DAILY) ui->radioButton->setChecked(true);
|
||||
else if(alarm_->getRepeat() == AlarmTime::REPEAT_WEEKLY) ui->radioButton_2->setChecked(true);
|
||||
else if(alarm_->getRepeat() == AlarmTime::REPEAT_MONTHLY)ui->radioButton_3->setChecked(true);
|
||||
else if(alarm_->getRepeat() == AlarmTime::REPEAT_YEARLY) ui->radioButton_4->setChecked(true);
|
||||
|
||||
connect(ui->dateTimeEdit, &QDateTimeEdit::dateTimeChanged, alarm, &AlarmTime::changeTime);
|
||||
}
|
||||
|
||||
AlarmWidget::~AlarmWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void AlarmWidget::setRepeatingType()
|
||||
{
|
||||
if(ui->radioButton->isChecked())alarm_->setRepeat(AlarmTime::REPEAT_DAILY);
|
||||
if(ui->radioButton_2->isChecked())alarm_->setRepeat(AlarmTime::REPEAT_WEEKLY);
|
||||
if(ui->radioButton_3->isChecked())alarm_->setRepeat(AlarmTime::REPEAT_MONTHLY);
|
||||
if(ui->radioButton_4->isChecked())alarm_->setRepeat(AlarmTime::REPEAT_YEARLY);
|
||||
}
|
||||
|
||||
void AlarmWidget::toggleRepeating(int state)
|
||||
{
|
||||
if(state)
|
||||
{
|
||||
ui->radioButton->setEnabled(true);
|
||||
ui->radioButton_2->setEnabled(true);
|
||||
ui->radioButton_3->setEnabled(true);
|
||||
ui->radioButton_4->setEnabled(true);
|
||||
setRepeatingType();
|
||||
}
|
||||
else
|
||||
{
|
||||
alarm_->setRepeat(AlarmTime::REPEAT_NEVER);
|
||||
ui->radioButton->setEnabled(false);
|
||||
ui->radioButton_2->setEnabled(false);
|
||||
ui->radioButton_3->setEnabled(false);
|
||||
ui->radioButton_4->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define ALARMWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "../../actors/alarmtime.h"
|
||||
|
||||
namespace Ui {
|
||||
class AlarmWidget;
|
||||
@ -11,10 +12,16 @@ class AlarmWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
AlarmTime* alarm_;
|
||||
|
||||
public:
|
||||
explicit AlarmWidget(QWidget *parent = nullptr);
|
||||
explicit AlarmWidget(AlarmTime* alarm, QWidget *parent = nullptr);
|
||||
~AlarmWidget();
|
||||
|
||||
private slots:
|
||||
void toggleRepeating(int state);
|
||||
void setRepeatingType();
|
||||
|
||||
private:
|
||||
Ui::AlarmWidget *ui;
|
||||
};
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>357</width>
|
||||
<height>166</height>
|
||||
<height>208</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -60,7 +60,7 @@
|
||||
<enum>QDateTimeEdit::DaySection</enum>
|
||||
</property>
|
||||
<property name="displayFormat">
|
||||
<string>dd.mM.yyyy hh:mm</string>
|
||||
<string>dd.MM.yyyy hh:mm</string>
|
||||
</property>
|
||||
<property name="calendarPopup">
|
||||
<bool>true</bool>
|
||||
@ -90,7 +90,7 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Monthly</string>
|
||||
<string>&Monthly</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
48
src/ui/actorwidgets/regulatorwdiget.cpp
Normal file
48
src/ui/actorwidgets/regulatorwdiget.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include "regulatorwdiget.h"
|
||||
#include "ui_regulatorwdiget.h"
|
||||
#include <QDebug>
|
||||
|
||||
RegulatorWdiget::~RegulatorWdiget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RegulatorWdiget::RegulatorWdiget(Regulator* regulator, SensorStore* sensors, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
regulator_(regulator),
|
||||
sensors_(sensors),
|
||||
ui(new Ui::RegulatorWdiget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
if(sensors)ui->listView->sensorsChanged(*(sensors->getSensors()));
|
||||
else
|
||||
{
|
||||
ui->listView->hide();
|
||||
ui->label->hide();
|
||||
}
|
||||
ui->doubleSpinBox_setPoint->setValue(regulator->getSetPoint());
|
||||
ui->doubleSpinBox_band->setValue(regulator->getBand());
|
||||
|
||||
connect(ui->listView, &SensorListWidget::clicked, this, &RegulatorWdiget::setSensor);
|
||||
connect(ui->doubleSpinBox_setPoint, SIGNAL(valueChanged(double)), this, SLOT(setPoint(double)));
|
||||
connect(ui->doubleSpinBox_band, SIGNAL(valueChanged(double)), this, SLOT(setBand(double)));
|
||||
}
|
||||
|
||||
void RegulatorWdiget::setPoint(double in)
|
||||
{
|
||||
regulator_->setPoint(in);
|
||||
}
|
||||
|
||||
void RegulatorWdiget::setBand(double band)
|
||||
{
|
||||
regulator_->setBand(band);
|
||||
}
|
||||
|
||||
void RegulatorWdiget::setSensor(const QModelIndex &index)
|
||||
{
|
||||
regulator_->setSensor(sensors_->getSensors()->at(index.row()));
|
||||
setPoint(sensors_->getSensors()->at(index.row()).field);
|
||||
ui->doubleSpinBox_setPoint->setValue(sensors_->getSensors()->at(index.row()).field);
|
||||
}
|
32
src/ui/actorwidgets/regulatorwdiget.h
Normal file
32
src/ui/actorwidgets/regulatorwdiget.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef REGULATORWDIGET_H
|
||||
#define REGULATORWDIGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "../../actors/regulator.h"
|
||||
|
||||
namespace Ui {
|
||||
class RegulatorWdiget;
|
||||
}
|
||||
|
||||
class RegulatorWdiget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Regulator* regulator_;
|
||||
SensorStore* sensors_;
|
||||
|
||||
public:
|
||||
explicit RegulatorWdiget(Regulator* regulator, SensorStore* sensors = nullptr, QWidget *parent = nullptr);
|
||||
~RegulatorWdiget();
|
||||
|
||||
private slots:
|
||||
|
||||
void setPoint(double in);
|
||||
void setBand(double band);
|
||||
void setSensor(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
Ui::RegulatorWdiget *ui;
|
||||
};
|
||||
|
||||
#endif // REGULATORWDIGET_H
|
88
src/ui/actorwidgets/regulatorwdiget.ui
Normal file
88
src/ui/actorwidgets/regulatorwdiget.ui
Normal file
@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RegulatorWdiget</class>
|
||||
<widget class="QWidget" name="RegulatorWdiget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>326</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select Sensor</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="SensorListWidget" name="listView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Set Point</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_setPoint">
|
||||
<property name="minimum">
|
||||
<double>-9999.989999999999782</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9999.989999999999782</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Band</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_band"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>SensorListWidget</class>
|
||||
<extends>QListView</extends>
|
||||
<header location="global">../src/ui/sensorlistwidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
52
src/ui/actorwidgets/sensoractorwidget.cpp
Normal file
52
src/ui/actorwidgets/sensoractorwidget.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
#include "sensoractorwidget.h"
|
||||
#include "ui_sensoractorwidget.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
SensorActorWidget::SensorActorWidget(SensorActor* sensorActor, SensorStore* sensors, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
sensorActor_(sensorActor),
|
||||
sensors_(sensors),
|
||||
ui(new Ui::SensorActorWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
if(sensors)ui->listView->sensorsChanged(*(sensors->getSensors()));
|
||||
else
|
||||
{
|
||||
ui->listView->hide();
|
||||
ui->label->hide();
|
||||
}
|
||||
|
||||
if(sensorActor_->getSloap() == SensorActor::SLOPE_UP) ui->comboBox_slope->setCurrentIndex(0);
|
||||
else if(sensorActor_->getSloap() == SensorActor::SLOPE_DOWN) ui->comboBox_slope->setCurrentIndex(1);
|
||||
else if(sensorActor_->getSloap() == SensorActor::SLOPE_BOTH) ui->comboBox_slope->setCurrentIndex(2);
|
||||
|
||||
ui->doubleSpinBox_threshold->setValue(sensorActor_->getThreshold());
|
||||
|
||||
connect(ui->listView, &SensorListWidget::clicked, this, &SensorActorWidget::setSensor);
|
||||
connect(ui->doubleSpinBox_threshold, SIGNAL(valueChanged(double)), this, SLOT(setThreshold(double)));
|
||||
connect(ui->comboBox_slope, SIGNAL(currentIndexChanged(int)), this, SLOT(setSlope(int)));
|
||||
}
|
||||
|
||||
SensorActorWidget::~SensorActorWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SensorActorWidget::setThreshold(double in)
|
||||
{
|
||||
sensorActor_->setThreshold(in);
|
||||
}
|
||||
|
||||
void SensorActorWidget::setSlope(int index)
|
||||
{
|
||||
if(index == 0) sensorActor_->setSloap(SensorActor::SLOPE_UP);
|
||||
else if(index == 1) sensorActor_->setSloap(SensorActor::SLOPE_DOWN);
|
||||
else if(index == 2) sensorActor_->setSloap(SensorActor::SLOPE_BOTH);
|
||||
}
|
||||
|
||||
void SensorActorWidget::setSensor(const QModelIndex &index)
|
||||
{
|
||||
sensorActor_->setSensor(sensors_->getSensors()->at(index.row()));
|
||||
qDebug()<<"Selected "<<sensors_->getSensors()->at(index.row()).name;
|
||||
}
|
33
src/ui/actorwidgets/sensoractorwidget.h
Normal file
33
src/ui/actorwidgets/sensoractorwidget.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef SENSORACTORWIDGET_H
|
||||
#define SENSORACTORWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QItemSelection>
|
||||
#include "../../actors/sensoractor.h"
|
||||
|
||||
namespace Ui {
|
||||
class SensorActorWidget;
|
||||
}
|
||||
|
||||
class SensorActorWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
SensorActor* sensorActor_;
|
||||
SensorStore* sensors_;
|
||||
|
||||
public:
|
||||
explicit SensorActorWidget(SensorActor* sensorActor, SensorStore* sensors = nullptr, QWidget *parent = nullptr);
|
||||
~SensorActorWidget();
|
||||
|
||||
private slots:
|
||||
|
||||
void setThreshold(double in);
|
||||
void setSlope(int index);
|
||||
void setSensor(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
Ui::SensorActorWidget *ui;
|
||||
};
|
||||
|
||||
#endif // SENSORACTORWIDGET_H
|
97
src/ui/actorwidgets/sensoractorwidget.ui
Normal file
97
src/ui/actorwidgets/sensoractorwidget.ui
Normal file
@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SensorActorWidget</class>
|
||||
<widget class="QWidget" name="SensorActorWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>326</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select Sensor</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="SensorListWidget" name="listView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Threshold</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_slope">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>> =</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>< =</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Passes</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_threshold">
|
||||
<property name="minimum">
|
||||
<double>-9999.989999999999782</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9999.989999999999782</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>SensorListWidget</class>
|
||||
<extends>QListView</extends>
|
||||
<header location="global">../src/ui/sensorlistwidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
20
src/ui/actorwidgets/timeractorwidget.cpp
Normal file
20
src/ui/actorwidgets/timeractorwidget.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include "timeractorwidget.h"
|
||||
#include "ui_timeractorwidget.h"
|
||||
|
||||
#include <QSpinBox>
|
||||
|
||||
TimerActorWidget::TimerActorWidget(TimerActor* actor, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::TimerActorWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->spinBox->setValue(actor->getTimeout());
|
||||
|
||||
connect(ui->spinBox, SIGNAL(valueChanged(int)), actor, SLOT(setTimeout(int)));
|
||||
}
|
||||
|
||||
TimerActorWidget::~TimerActorWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
23
src/ui/actorwidgets/timeractorwidget.h
Normal file
23
src/ui/actorwidgets/timeractorwidget.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef TIMERACTORWIDGET_H
|
||||
#define TIMERACTORWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "../../actors/timeractor.h"
|
||||
|
||||
namespace Ui {
|
||||
class TimerActorWidget;
|
||||
}
|
||||
|
||||
class TimerActorWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TimerActorWidget(TimerActor* actor, QWidget *parent = nullptr);
|
||||
~TimerActorWidget();
|
||||
|
||||
private:
|
||||
Ui::TimerActorWidget *ui;
|
||||
};
|
||||
|
||||
#endif // TIMERACTORWIDGET_H
|
54
src/ui/actorwidgets/timeractorwidget.ui
Normal file
54
src/ui/actorwidgets/timeractorwidget.ui
Normal file
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TimerActorWidget</class>
|
||||
<widget class="QWidget" name="TimerActorWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Timeout</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox">
|
||||
<property name="maximum">
|
||||
<number>999999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Seconds</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,50 +0,0 @@
|
||||
#include "alarmsettingsdialog.h"
|
||||
#include "ui_alarmsettingsdialog.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
AlarmSettingsDialog::AlarmSettingsDialog(AlarmTime* almNight, AlarmTime* almAlarm, QSettings* settings, QWidget *parent): QDialog(parent), ui(new Ui::AlarmSettingsDialog), almNight_(almNight), almAlarm_(almAlarm), settings_(settings)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
//restore settings
|
||||
ui->checkBox_Alarm->setChecked(settings_->value("Alarms/alarmOn").toBool());
|
||||
ui->checkBox_Sunrise->setChecked(settings_->value("Alarms/sunrise").toBool());
|
||||
ui->timeEdit_Shutdown->setTime(settings_->value("Alarms/shutdownTime").toTime());
|
||||
ui->timeEdit_Alarm->setTime(settings_->value("Alarms/alarmTime").toTime());
|
||||
ui->lineEdit->setText(settings_->value("Alarms/alarmSoundFile").toString());
|
||||
|
||||
connect(ui->pushButton_changeFile, SIGNAL(clicked()), this, SLOT(showFileChooser()));
|
||||
}
|
||||
|
||||
AlarmSettingsDialog::~AlarmSettingsDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void AlarmSettingsDialog::accept()
|
||||
{
|
||||
//store settings
|
||||
settings_->setValue("Alarms/alarmOn", ui->checkBox_Alarm->checkState());
|
||||
settings_->setValue("Alarms/sunrise", ui->checkBox_Sunrise->checkState());
|
||||
settings_->setValue("Alarms/shutdownTime", ui->timeEdit_Shutdown->time());
|
||||
settings_->setValue("Alarms/alarmTime", ui->timeEdit_Alarm->time());
|
||||
settings_->setValue("Alarms/alarmSoundFile", ui->lineEdit->text());
|
||||
|
||||
//send signals
|
||||
signalAlarmSoundFile(ui->lineEdit->text());
|
||||
signalSunrise(ui->checkBox_Sunrise->checkState());
|
||||
|
||||
//modify alarm objects
|
||||
almAlarm_->changeTime(ui->timeEdit_Alarm->time());
|
||||
almNight_->changeTime(ui->timeEdit_Shutdown->time());
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void AlarmSettingsDialog::showFileChooser()
|
||||
{
|
||||
ui->lineEdit->setText(QFileDialog::getOpenFileName(this));
|
||||
}
|
||||
|
||||
|
@ -1,43 +0,0 @@
|
||||
#ifndef ALARMSETTINGSDIALOG_H
|
||||
#define ALARMSETTINGSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTime>
|
||||
#include <QString>
|
||||
#include <QSettings>
|
||||
|
||||
#include "alarmtime.h"
|
||||
|
||||
namespace Ui {
|
||||
class AlarmSettingsDialog;
|
||||
}
|
||||
|
||||
class AlarmSettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
AlarmTime* almNight_;
|
||||
AlarmTime* almAlarm_;
|
||||
QSettings* settings_;
|
||||
|
||||
|
||||
public:
|
||||
explicit AlarmSettingsDialog(AlarmTime* almNight, AlarmTime* almAlarm, QSettings* settings, QWidget* parent = nullptr);
|
||||
~AlarmSettingsDialog();
|
||||
|
||||
signals:
|
||||
void signalAlarmSoundFile(QString fileName);
|
||||
void signalSunrise(bool enabled);
|
||||
|
||||
public slots:
|
||||
void accept();
|
||||
|
||||
private slots:
|
||||
void showFileChooser();
|
||||
|
||||
|
||||
private:
|
||||
Ui::AlarmSettingsDialog *ui;
|
||||
};
|
||||
|
||||
#endif // ALARMSETTINGSDIALOG_H
|
@ -1,241 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AlarmSettingsDialog</class>
|
||||
<widget class="QDialog" name="AlarmSettingsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>462</width>
|
||||
<height>406</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Alarm</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_alm">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTimeEdit" name="timeEdit_Alarm">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_Alarm">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_snd">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sound File</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_changeFile">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Change</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Sunrise</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_Sunrise">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Auto Power off</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTimeEdit" name="timeEdit_Shutdown"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_Shutdown">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>AlarmSettingsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>AlarmSettingsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -1,142 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AlarmSettingsDialog</class>
|
||||
<widget class="QDialog" name="AlarmSettingsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>423</width>
|
||||
<height>281</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Sound File:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Change</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Sunrise</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>AlarmSettingsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>AlarmSettingsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -1,71 +0,0 @@
|
||||
<ui version="4.0">
|
||||
<author/>
|
||||
<comment/>
|
||||
<exportmacro/>
|
||||
<class>AlarmSettingsDialog</class>
|
||||
<widget name="AlarmSettingsDialog" class="QDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget name="buttonBox" class="QDialogButtonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>240</y>
|
||||
<width>341</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<pixmapfunction/>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>AlarmSettingsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>AlarmSettingsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -1,14 +0,0 @@
|
||||
#include "alarmwidget.h"
|
||||
#include "ui_alarmwidget.h"
|
||||
|
||||
AlarmWidget::AlarmWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::AlarmWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
AlarmWidget::~AlarmWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
48
src/ui/itemscrollbox.cpp
Normal file
48
src/ui/itemscrollbox.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include "itemscrollbox.h"
|
||||
#include "ui_relayscrollbox.h"
|
||||
#include "../items/auxitem.h"
|
||||
|
||||
ItemScrollBox::ItemScrollBox(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::RelayScrollBox)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QScroller::grabGesture(ui->scrollArea, QScroller::TouchGesture);
|
||||
QScroller::grabGesture(ui->scrollArea, QScroller::LeftMouseButtonGesture);
|
||||
}
|
||||
|
||||
ItemScrollBox::~ItemScrollBox()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ItemScrollBox::addItem(std::weak_ptr<Item> item)
|
||||
{
|
||||
if(auto workItem = item.lock())
|
||||
{
|
||||
if(dynamic_cast<AuxItem*>(workItem.get()))
|
||||
{
|
||||
widgets_.push_back(new ItemWidget(item, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
widgets_.push_back(new ItemWidget(item));
|
||||
}
|
||||
ui->relayWidgetVbox->addWidget(widgets_.back());
|
||||
}
|
||||
}
|
||||
|
||||
void ItemScrollBox::removeItem(const ItemData& item)
|
||||
{
|
||||
for(unsigned i = 0; i < widgets_.size(); i++)
|
||||
{
|
||||
if(widgets_[i]->controles(item))
|
||||
{
|
||||
ui->relayWidgetVbox->removeWidget(widgets_[i]);
|
||||
delete widgets_[i];
|
||||
widgets_.erase(widgets_.begin()+i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
41
src/ui/itemscrollbox.h
Normal file
41
src/ui/itemscrollbox.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef RELAYSCROLLBOX_H
|
||||
#define RELAYSCROLLBOX_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <QScroller>
|
||||
#include "itemwidget.h"
|
||||
#include "../items/relay.h"
|
||||
#include "../items/item.h"
|
||||
#include "../items/itemstore.h"
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class RelayScrollBox;
|
||||
}
|
||||
|
||||
class ItemScrollBox : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
std::vector< ItemWidget* > widgets_;
|
||||
|
||||
public:
|
||||
explicit ItemScrollBox(QWidget *parent = nullptr);
|
||||
~ItemScrollBox();
|
||||
|
||||
void setItemStore(ItemStore* itemStore);
|
||||
|
||||
public slots:
|
||||
|
||||
void addItem(std::weak_ptr<Item> item);
|
||||
void removeItem(const ItemData& item);
|
||||
|
||||
private:
|
||||
Ui::RelayScrollBox *ui;
|
||||
};
|
||||
|
||||
#endif // RELAYSCROLLBOX_H
|
||||
|
||||
|
148
src/ui/itemsettingsdialog.cpp
Normal file
148
src/ui/itemsettingsdialog.cpp
Normal file
@ -0,0 +1,148 @@
|
||||
#include "itemsettingsdialog.h"
|
||||
#include "ui_itemsettingsdialog.h"
|
||||
#include "actorsettingsdialog.h"
|
||||
#include "../actors/alarmtime.h"
|
||||
#include "../actors/sensoractor.h"
|
||||
#include "../actors/timeractor.h"
|
||||
#include "../actors/regulator.h"
|
||||
|
||||
#include<memory>
|
||||
|
||||
ItemSettingsDialog::ItemSettingsDialog(Item* item, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
item_(item),
|
||||
ui(new Ui::ItemSettingsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setModal(false);
|
||||
|
||||
ui->label_name->setText(item_->getName());
|
||||
|
||||
if(Relay* relay = dynamic_cast<Relay*>(item_))
|
||||
{
|
||||
ui->label_address->setText(QString::number(relay->getAddress(), 2));
|
||||
ui->label_id->setText(QString::number(relay->getId(), 10));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->label_address->hide();
|
||||
ui->label_id->hide();
|
||||
ui->label_address_lable->hide();
|
||||
ui->label_id_lable->hide();
|
||||
}
|
||||
ui->checkBox_auto->setChecked(item_->actorsActive());
|
||||
|
||||
connect(ui->checkBox_auto, &QCheckBox::toggled, item_, &Relay::setActorsActive);
|
||||
connect(ui->pushButton_add, &QPushButton::clicked, this, &ItemSettingsDialog::addActor);
|
||||
connect(ui->pushButton_remove, &QPushButton::clicked, this, &ItemSettingsDialog::removeActor);
|
||||
connect(ui->pushButton_edit, &QPushButton::clicked, this, &ItemSettingsDialog::editActor);
|
||||
|
||||
ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem("Actor"));
|
||||
ui->tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem("Action"));
|
||||
ui->tableWidget->setHorizontalHeaderItem(2, new QTableWidgetItem("Acts on"));
|
||||
ui->tableWidget->setHorizontalHeaderItem(3, new QTableWidgetItem("Enabled"));
|
||||
ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
ui->tableWidget->horizontalHeader()->resizeSection(1, 60);
|
||||
ui->tableWidget->horizontalHeader()->resizeSection(2, 60);
|
||||
ui->tableWidget->horizontalHeader()->resizeSection(3, 75);
|
||||
loadActorList();
|
||||
}
|
||||
|
||||
ItemSettingsDialog::~ItemSettingsDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ItemSettingsDialog::loadActorList()
|
||||
{
|
||||
//ui->listWidget->clear();
|
||||
ui->tableWidget->setRowCount(item_->getActors().size());
|
||||
|
||||
for(unsigned i = 0; i < item_->getActors().size(); i++)
|
||||
{
|
||||
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(item_->getActors()[i]->getName()));
|
||||
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(item_->getActors()[i]->actionName()));
|
||||
ui->tableWidget->setItem(i, 2, new QTableWidgetItem("Item"));
|
||||
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(item_->getActors()[i]->isActive() ? "Y" : "N"));
|
||||
}
|
||||
}
|
||||
|
||||
void ItemSettingsDialog::addActor()
|
||||
{
|
||||
ActorSettingsDialog* dialog = nullptr;
|
||||
Actor* actor = nullptr;
|
||||
|
||||
if(ui->comboBox->currentText() == "Alarm")
|
||||
{
|
||||
AlarmTime* alarm = new AlarmTime;
|
||||
actor = alarm;
|
||||
dialog = new ActorSettingsDialog(alarm, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Sensor" && item_->getSensorStore() != nullptr)
|
||||
{
|
||||
SensorActor* sensorActor = new SensorActor();
|
||||
actor = sensorActor;
|
||||
dialog = new ActorSettingsDialog(sensorActor, item_->getSensorStore(), this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Timer" )
|
||||
{
|
||||
TimerActor* timerActor = new TimerActor();
|
||||
actor = timerActor;
|
||||
dialog = new ActorSettingsDialog(timerActor, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Regulator" && item_->getSensorStore() != nullptr)
|
||||
{
|
||||
Regulator* regulator = new Regulator();
|
||||
actor = regulator;
|
||||
dialog = new ActorSettingsDialog(regulator, item_->getSensorStore(), this);
|
||||
}
|
||||
|
||||
|
||||
if(dialog != nullptr)
|
||||
{
|
||||
dialog->setParent(this);
|
||||
dialog->show();
|
||||
if(dialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
item_->addActor(actor);
|
||||
loadActorList();
|
||||
}
|
||||
else delete actor;
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ItemSettingsDialog::removeActor()
|
||||
{
|
||||
if(item_->getActors().size() > ui->tableWidget->currentRow())
|
||||
{
|
||||
item_->removeActor(item_->getActors().at(ui->tableWidget->currentRow()));
|
||||
loadActorList();
|
||||
}
|
||||
}
|
||||
|
||||
void ItemSettingsDialog::editActor()
|
||||
{
|
||||
if(item_->getActors().size() > ui->tableWidget->currentRow())
|
||||
{
|
||||
Actor* actor = item_->getActors()[ui->tableWidget->currentRow()];
|
||||
|
||||
AlarmTime* alarmTime = dynamic_cast<AlarmTime*>(actor);
|
||||
Regulator* regulator = dynamic_cast<Regulator*>(actor);
|
||||
SensorActor* sensorActor = dynamic_cast<SensorActor*>(actor);
|
||||
TimerActor* timerActor = dynamic_cast<TimerActor*>(actor);
|
||||
|
||||
ActorSettingsDialog* dialog;
|
||||
|
||||
if(alarmTime) dialog = new ActorSettingsDialog(alarmTime, this);
|
||||
else if(regulator) dialog = new ActorSettingsDialog(regulator, nullptr, this);
|
||||
else if(sensorActor) dialog = new ActorSettingsDialog(sensorActor, nullptr, this);
|
||||
else if(timerActor) dialog = new ActorSettingsDialog(timerActor, this);
|
||||
else dialog = new ActorSettingsDialog(actor, this);
|
||||
dialog->setParent(this);
|
||||
dialog->show();
|
||||
dialog->exec();
|
||||
}
|
||||
}
|
34
src/ui/itemsettingsdialog.h
Normal file
34
src/ui/itemsettingsdialog.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef RELAYSETTINGSDIALOG_H
|
||||
#define RELAYSETTINGSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QSettings>
|
||||
#include "../items/relay.h"
|
||||
|
||||
namespace Ui {
|
||||
class ItemSettingsDialog;
|
||||
}
|
||||
|
||||
class ItemSettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Item* item_;
|
||||
|
||||
private:
|
||||
void loadActorList();
|
||||
|
||||
public:
|
||||
explicit ItemSettingsDialog(Item* item, QWidget *parent = nullptr);
|
||||
~ItemSettingsDialog();
|
||||
|
||||
private slots:
|
||||
|
||||
void removeActor();
|
||||
void addActor();
|
||||
void editActor();
|
||||
|
||||
private:
|
||||
Ui::ItemSettingsDialog *ui;
|
||||
};
|
||||
|
||||
#endif // RELAYSETTINGSDIALOG_H
|
@ -1,20 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RelaySettingsDialog</class>
|
||||
<widget class="QDialog" name="RelaySettingsDialog">
|
||||
<class>ItemSettingsDialog</class>
|
||||
<widget class="QDialog" name="ItemSettingsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>319</height>
|
||||
<width>577</width>
|
||||
<height>390</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Relay Settings</string>
|
||||
<string>Item Settings</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="resources.qrc">
|
||||
<iconset resource="../../resources.qrc">
|
||||
<normaloff>:/images/UVOSicon.bmp</normaloff>:/images/UVOSicon.bmp</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@ -29,15 +29,15 @@
|
||||
<property name="bottomMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_id_lable">
|
||||
<property name="text">
|
||||
<string>Address</string>
|
||||
<string>ID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="label_address">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_id">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
@ -65,6 +65,23 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_address_lable">
|
||||
<property name="text">
|
||||
<string>Address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="label_address">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
@ -75,39 +92,136 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_id">
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_auto">
|
||||
<property name="text">
|
||||
<string>Actors enabled</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidget">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="autoScroll">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="tabKeyNavigation">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="showDropIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="dragDropOverwriteMode">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="gridStyle">
|
||||
<enum>Qt::SolidLine</enum>
|
||||
</property>
|
||||
<property name="cornerButtonEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="rowCount">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderMinimumSectionSize">
|
||||
<number>32</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderHighlightSections">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderDefaultSectionSize">
|
||||
<number>32</number>
|
||||
</attribute>
|
||||
<column/>
|
||||
<column/>
|
||||
<column/>
|
||||
<column/>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_remove">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_edit">
|
||||
<property name="text">
|
||||
<string>ID:</string>
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Act on</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Sensor</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Linear</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Regulator</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Alarm</string>
|
||||
@ -118,26 +232,6 @@
|
||||
<string>Timer</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Speaker</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>RGB Value</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Temperature</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -168,13 +262,13 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="resources.qrc"/>
|
||||
<include location="../../resources.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>RelaySettingsDialog</receiver>
|
||||
<receiver>ItemSettingsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
@ -190,7 +284,7 @@
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>RelaySettingsDialog</receiver>
|
||||
<receiver>ItemSettingsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
98
src/ui/itemwidget.cpp
Normal file
98
src/ui/itemwidget.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
#include "itemwidget.h"
|
||||
#include "ui_itemwidget.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDebug>
|
||||
#include <QSlider>
|
||||
|
||||
ItemWidget::ItemWidget(std::weak_ptr<Item> item, bool analog, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
item_(item),
|
||||
ui(new Ui::ItemWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
if(analog)
|
||||
{
|
||||
ui->horizontalSpacer->changeSize(0,0);
|
||||
ui->checkBox->hide();
|
||||
//ui->label->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->slider->hide();
|
||||
}
|
||||
|
||||
if(auto workingRelay = item_.lock())
|
||||
{
|
||||
ui->checkBox->setChecked(workingRelay->getValue());
|
||||
|
||||
ui->label->setText(workingRelay->getName());
|
||||
|
||||
if(analog)connect(ui->slider, &QSlider::valueChanged, this, &ItemWidget::moveToValue);
|
||||
else connect(ui->checkBox, &QCheckBox::toggled, this, &ItemWidget::moveToState);
|
||||
connect(ui->pushButton, &QPushButton::clicked, this, &ItemWidget::showSettingsDialog);
|
||||
connect(workingRelay.get(), &Relay::valueChanged, this, &ItemWidget::stateChanged);
|
||||
|
||||
}
|
||||
else disable();
|
||||
}
|
||||
|
||||
void ItemWidget::moveToValue(int value)
|
||||
{
|
||||
if(auto workingItem = item_.lock()) workingItem->setValue(value);
|
||||
else disable();
|
||||
}
|
||||
|
||||
void ItemWidget::moveToState(bool state)
|
||||
{
|
||||
if(auto workingItem = item_.lock()) workingItem->setValue(state);
|
||||
else disable();
|
||||
}
|
||||
|
||||
void ItemWidget::disable()
|
||||
{
|
||||
ui->checkBox->setEnabled(false);
|
||||
ui->label->setEnabled(false);
|
||||
}
|
||||
|
||||
bool ItemWidget::controles(const ItemData& relay)
|
||||
{
|
||||
if(auto workingRelay = item_.lock())
|
||||
{
|
||||
if(relay == *workingRelay) return true;
|
||||
else return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ItemWidget::showSettingsDialog()
|
||||
{
|
||||
if(auto workingRelay = item_.lock())
|
||||
{
|
||||
ItemSettingsDialog dialog(workingRelay.get(), this);
|
||||
dialog.exec();
|
||||
}
|
||||
else disable();
|
||||
}
|
||||
|
||||
std::weak_ptr<Item> ItemWidget::getItem()
|
||||
{
|
||||
return item_;
|
||||
}
|
||||
|
||||
void ItemWidget::stateChanged(int state)
|
||||
{
|
||||
qDebug()<<"widget got state "<<state;
|
||||
ui->slider->blockSignals(true);
|
||||
ui->slider->setValue(state);
|
||||
ui->slider->blockSignals(false);
|
||||
ui->checkBox->blockSignals(true);
|
||||
ui->checkBox->setChecked(state);
|
||||
ui->checkBox->blockSignals(false);
|
||||
}
|
||||
|
||||
ItemWidget::~ItemWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
40
src/ui/itemwidget.h
Normal file
40
src/ui/itemwidget.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef RELAYWIDGET_H
|
||||
#define RELAYWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <memory>
|
||||
#include "itemsettingsdialog.h"
|
||||
#include "../items/item.h"
|
||||
|
||||
namespace Ui {
|
||||
class ItemWidget;
|
||||
}
|
||||
|
||||
class ItemWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
std::weak_ptr<Item> item_;
|
||||
|
||||
void disable();
|
||||
|
||||
private slots:
|
||||
void showSettingsDialog();
|
||||
void moveToState(bool state);
|
||||
void moveToValue(int value);
|
||||
|
||||
public:
|
||||
explicit ItemWidget(std::weak_ptr<Item> item, bool analog = false, QWidget *parent = nullptr);
|
||||
std::weak_ptr<Item> getItem();
|
||||
bool controles(const ItemData& relay);
|
||||
~ItemWidget();
|
||||
|
||||
public slots:
|
||||
|
||||
void stateChanged(int state);
|
||||
|
||||
private:
|
||||
Ui::ItemWidget *ui;
|
||||
};
|
||||
|
||||
#endif // RELAYWIDGET_H
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RelayWidget</class>
|
||||
<widget class="QWidget" name="RelayWidget">
|
||||
<class>ItemWidget</class>
|
||||
<widget class="QWidget" name="ItemWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -10,6 +10,12 @@
|
||||
<height>48</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
@ -35,19 +41,22 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>On</string>
|
||||
<widget class="QSlider" name="slider">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="tracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_auto">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>Auto</string>
|
||||
<string>On</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
261
src/ui/mainwindow-android.ui
Normal file
261
src/ui/mainwindow-android.ui
Normal file
@ -0,0 +1,261 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>650</width>
|
||||
<height>513</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>50</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>650</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Smart Home Interface</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../resources.qrc">
|
||||
<normaloff>:/images/UVOSicon.bmp</normaloff>:/images/UVOSicon.bmp</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_10" stretch="0,1">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0,0,0">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_serialRecive">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>SHinterface</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::AutoText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Sensors</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="SensorListWidget" name="sensorListView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="showDropIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="defaultDropAction">
|
||||
<enum>Qt::TargetMoveAction</enum>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
</property>
|
||||
<property name="selectionRectVisible">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="button_color">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>50</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>128</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_alarms">
|
||||
<property name="text">
|
||||
<string>Alarms</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,0">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Relays</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="ItemScrollBox" name="relayList" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_refesh">
|
||||
<property name="text">
|
||||
<string>Refesh</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="button_quit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Quit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ItemScrollBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">../src/ui/itemscrollbox.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>SensorListWidget</class>
|
||||
<extends>QListView</extends>
|
||||
<header location="global">../src/ui/sensorlistwidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,47 +1,34 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "relayscrollbox.h"
|
||||
#include "itemscrollbox.h"
|
||||
|
||||
MainWindow::MainWindow(Microcontroller *micro , bool isRemoteMode , QWidget *parent) :
|
||||
#include "itemsettingsdialog.h"
|
||||
|
||||
MainWindow::MainWindow(Microcontroller *micro, PowerItem* powerItem, ItemStore* itemStore, SensorStore *sensorStore, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow),
|
||||
colorChooser(this),
|
||||
_micro(micro)
|
||||
_micro(micro),
|
||||
_powerItem(powerItem)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
if(!_micro->connected()) ui->label_serialRecive->setText("No IO Port! Debug only.");
|
||||
connect(ui->pushButton_power, SIGNAL(clicked()), this, SLOT(showPowerItemDialog()));
|
||||
|
||||
//Relays
|
||||
connect(ui->pushButton_refesh, SIGNAL(clicked()), _micro, SLOT(requestRelayList()));
|
||||
ui->relayList->setMicrocontoller(_micro);
|
||||
connect(_micro, &Microcontroller::gotRelayList, ui->relayList, &RelayScrollBox::gotRelays);
|
||||
connect(_micro, &Microcontroller::relayStateChanged, ui->relayList, &RelayScrollBox::relaySateChanged);
|
||||
connect(ui->pushButton_refesh, SIGNAL(clicked()), _micro, SLOT(requestState()));
|
||||
connect(itemStore, &ItemStore::itemAdded, ui->relayList, &ItemScrollBox::addItem);
|
||||
connect(itemStore, &ItemStore::itemDeleted, ui->relayList, &ItemScrollBox::removeItem);
|
||||
|
||||
//Sensors
|
||||
|
||||
ui->sensorListView->sensorsChanged(*(sensorStore->getSensors()));
|
||||
connect(sensorStore, &SensorStore::stateChenged, ui->sensorListView, &SensorListWidget::sensorsChanged);
|
||||
|
||||
//RGB Leds
|
||||
connect(ui->presettApply, SIGNAL(clicked()), this, SLOT(slotApplyPreset()));
|
||||
connect(&colorChooser, SIGNAL(colorSelected(const QColor)), this, SLOT(slotChangedRgb(const QColor)));
|
||||
connect(ui->button_lightsOn, SIGNAL(clicked()), _micro, SLOT(rgbOn()));
|
||||
connect(ui->button_lightsOff, SIGNAL(clicked()), _micro, SLOT(rgbOff()));
|
||||
connect(ui->button_quit, SIGNAL(clicked()), this, SLOT(close()));
|
||||
connect(ui->button_color, SIGNAL(clicked()), &colorChooser, SLOT(show()));
|
||||
|
||||
new QListWidgetItem(tr("Pattern 0 Solid"), ui->listWidget_patern);
|
||||
new QListWidgetItem(tr("Pattern 1"), ui->listWidget_patern);
|
||||
new QListWidgetItem(tr("Pattern 2 Alarm"), ui->listWidget_patern);
|
||||
new QListWidgetItem(tr("Pattern 3"), ui->listWidget_patern);
|
||||
new QListWidgetItem(tr("Pattern 4 Sunrise"), ui->listWidget_patern);
|
||||
|
||||
//Desk light
|
||||
|
||||
connect(ui->horizontalSlider_deskLight, &QAbstractSlider::valueChanged, _micro, [this](int value){ _micro->setAuxPwm(value); });
|
||||
|
||||
connect(ui->pushButton_alarms, SIGNAL(clicked()), this, SIGNAL(showAlmSettingsDialog()));
|
||||
}
|
||||
|
||||
void MainWindow::remoteMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@ -49,30 +36,24 @@ MainWindow::~MainWindow()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::showPowerItemDialog()
|
||||
{
|
||||
ItemSettingsDialog diag(_powerItem, this);
|
||||
diag.show();
|
||||
diag.exec();
|
||||
}
|
||||
|
||||
void MainWindow::slotChangedRgb(const QColor color)
|
||||
{
|
||||
_micro->changeRgbColor(color);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::slotApplyPreset()
|
||||
{
|
||||
if(ui->listWidget_patern->selectedItems().count() == 1) _micro->setPattern(ui->listWidget_patern->currentRow());
|
||||
}
|
||||
|
||||
void MainWindow::slotDoorOpenTimeout()
|
||||
{
|
||||
//ui->checkBox_doorOpen->setChecked(true);
|
||||
}
|
||||
|
||||
void MainWindow::auxStateChanged(int value)
|
||||
{
|
||||
ui->horizontalSlider_deskLight->blockSignals(true);
|
||||
ui->horizontalSlider_deskLight->setValue(value);
|
||||
ui->horizontalSlider_deskLight->blockSignals(false);
|
||||
}
|
||||
|
||||
void MainWindow::changeHeaderLableText(const QString string)
|
||||
void MainWindow::changeHeaderLableText(QString string)
|
||||
{
|
||||
if(string.size() > 28)
|
||||
{
|
||||
string.remove(28, string.size()-(28));
|
||||
string.append("...");
|
||||
}
|
||||
ui->label_serialRecive->setText(string);
|
||||
}
|
||||
|
@ -6,8 +6,11 @@
|
||||
#include <QListWidgetItem>
|
||||
#include <QTime>
|
||||
#include <vector>
|
||||
#include "alarmtime.h"
|
||||
#include "microcontroller.h"
|
||||
#include "../actors/alarmtime.h"
|
||||
#include "../microcontroller.h"
|
||||
#include "../sensors/sensor.h"
|
||||
#include "../items/itemstore.h"
|
||||
#include "../items/poweritem.h"
|
||||
|
||||
|
||||
namespace Ui
|
||||
@ -20,7 +23,7 @@ class MainWindow : public QMainWindow
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(Microcontroller *micro, bool isRemoteMode = false, QWidget *parent = nullptr);
|
||||
explicit MainWindow(Microcontroller *micro, PowerItem* powerItem, ItemStore* itemStore, SensorStore *sensorStore, QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
private:
|
||||
@ -30,30 +33,17 @@ private:
|
||||
|
||||
Microcontroller *_micro;
|
||||
|
||||
void remoteMode();
|
||||
|
||||
signals:
|
||||
|
||||
void signalAmpOn();
|
||||
void signalAmpOff();
|
||||
|
||||
void showAlmSettingsDialog();
|
||||
PowerItem *_powerItem;
|
||||
|
||||
private slots:
|
||||
|
||||
//RGB
|
||||
void slotChangedRgb(const QColor color);
|
||||
void slotApplyPreset();
|
||||
|
||||
void changeHeaderLableText(const QString string);
|
||||
|
||||
//door
|
||||
void slotDoorOpenTimeout();
|
||||
void showPowerItemDialog();
|
||||
|
||||
public slots:
|
||||
|
||||
void auxStateChanged(int value);
|
||||
|
||||
void changeHeaderLableText(QString string);
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>862</width>
|
||||
<height>570</height>
|
||||
<width>887</width>
|
||||
<height>530</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -18,15 +18,15 @@
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>197</height>
|
||||
<width>650</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Smart Home Interface</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="resources.qrc">
|
||||
<iconset resource="../../resources.qrc">
|
||||
<normaloff>:/images/UVOSicon.bmp</normaloff>:/images/UVOSicon.bmp</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
@ -42,79 +42,63 @@
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_10" stretch="0,1">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_serialRecive">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>SHinterface</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Relays</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="RelayScrollBox" name="relayList" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_refesh">
|
||||
<property name="text">
|
||||
<string>Refesh</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_patern">
|
||||
<widget class="QLabel" name="label_serialRecive">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>SHinterface</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::AutoText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Sensors</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="SensorListWidget" name="sensorListView">
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="gridStyle">
|
||||
<enum>Qt::NoPen</enum>
|
||||
</property>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="button_color">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -128,65 +112,7 @@
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>120</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="presettApply">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>128</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="button_color">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>50</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>80</height>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
@ -196,121 +122,82 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Choose Color</string>
|
||||
<string>Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,0">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="button_lightsOn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>50</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ON</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="button_lightsOff">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>50</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OFF</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Desk Light</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="horizontalSlider_deskLight">
|
||||
<property name="maximum">
|
||||
<number>254</number>
|
||||
</property>
|
||||
<property name="tracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_alarms">
|
||||
<property name="text">
|
||||
<string>Alarms</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="button_quit">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Quit</string>
|
||||
<property name="title">
|
||||
<string>Items</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="ItemScrollBox" name="relayList" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_power">
|
||||
<property name="text">
|
||||
<string>Config Shutdown</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_refesh">
|
||||
<property name="text">
|
||||
<string>Refesh</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="button_quit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Quit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
@ -319,14 +206,19 @@
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>RelayScrollBox</class>
|
||||
<class>ItemScrollBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>relayscrollbox.h</header>
|
||||
<header location="global">../src/ui/itemscrollbox.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>SensorListWidget</class>
|
||||
<extends>QTableWidget</extends>
|
||||
<header location="global">../src/ui/sensorlistwidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="resources.qrc"/>
|
||||
<include location="../../resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -1,230 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RelayDialog</class>
|
||||
<widget class="QDialog" name="RelayDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>358</width>
|
||||
<height>320</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Advanced Relays</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Advanced</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>3Dator</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_R0">
|
||||
<property name="text">
|
||||
<string>On</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>3040</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_R1">
|
||||
<property name="text">
|
||||
<string>On</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Aux</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_R2">
|
||||
<property name="text">
|
||||
<string>On</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Enterance Watch</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>Inside</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_2">
|
||||
<property name="text">
|
||||
<string>Watch</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>RelayDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>RelayDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -1,32 +0,0 @@
|
||||
#include "relayscrollbox.h"
|
||||
#include "ui_relayscrollbox.h"
|
||||
|
||||
RelayScrollBox::RelayScrollBox(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::RelayScrollBox)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QScroller::grabGesture(ui->scrollArea, QScroller::TouchGesture);
|
||||
QScroller::grabGesture(ui->scrollArea, QScroller::LeftMouseButtonGesture);
|
||||
}
|
||||
|
||||
RelayScrollBox::~RelayScrollBox()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void RelayScrollBox::addRelay(std::weak_ptr<Relay> relay)
|
||||
{
|
||||
widgets_.push_back(new RelayWidget(relay));
|
||||
ui->relayWidgetVbox->addWidget(widgets_.back());
|
||||
}
|
||||
|
||||
void RelayScrollBox::removeRelay(const RelayStore& realy)
|
||||
{
|
||||
for(unsigned i = 0; i < widgets_.size(); i++)
|
||||
{
|
||||
if(widgets_[i]->controles(realy)) widgets_.erase(widgets_.begin()+i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,40 +0,0 @@
|
||||
#ifndef RELAYSCROLLBOX_H
|
||||
#define RELAYSCROLLBOX_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <QScroller>
|
||||
#include "relaywidget.h"
|
||||
#include "../relay.h"
|
||||
#include "../item.h"
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class RelayScrollBox;
|
||||
}
|
||||
|
||||
class RelayScrollBox : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
std::vector< RelayWidget* > widgets_;
|
||||
|
||||
public:
|
||||
explicit RelayScrollBox(QWidget *parent = nullptr);
|
||||
~RelayScrollBox();
|
||||
|
||||
void setItemStore(ItemStore* itemStore);
|
||||
|
||||
public slots:
|
||||
|
||||
void addRelay(std::weak_ptr<Relay> relay);
|
||||
void removeRelay(const RelayStore& Realy);
|
||||
|
||||
private:
|
||||
Ui::RelayScrollBox *ui;
|
||||
};
|
||||
|
||||
#endif // RELAYSCROLLBOX_H
|
||||
|
||||
|
@ -16,6 +16,18 @@
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -24,8 +36,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>384</width>
|
||||
<height>284</height>
|
||||
<width>388</width>
|
||||
<height>288</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
|
@ -1,18 +0,0 @@
|
||||
#include "relaysettingsdialog.h"
|
||||
#include "ui_relaysettingsdialog.h"
|
||||
|
||||
RelaySettingsDialog::RelaySettingsDialog(RelayStore* relay, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
relay_(relay),
|
||||
ui(new Ui::RelaySettingsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->label_address->setText(QString::number(relay_->getAddress(), 2));
|
||||
ui->label_name->setText(relay_->getName());
|
||||
ui->label_id->setText(QString::number(relay_->getId(), 10));
|
||||
}
|
||||
|
||||
RelaySettingsDialog::~RelaySettingsDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
#ifndef RELAYSETTINGSDIALOG_H
|
||||
#define RELAYSETTINGSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "relay.h"
|
||||
|
||||
namespace Ui {
|
||||
class RelaySettingsDialog;
|
||||
}
|
||||
|
||||
class RelaySettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
RelayStore* relay_;
|
||||
|
||||
public:
|
||||
explicit RelaySettingsDialog(RelayStore* relay, QWidget *parent = nullptr);
|
||||
~RelaySettingsDialog();
|
||||
|
||||
private:
|
||||
Ui::RelaySettingsDialog *ui;
|
||||
};
|
||||
|
||||
#endif // RELAYSETTINGSDIALOG_H
|
@ -1,50 +0,0 @@
|
||||
#include "relaywidget.h"
|
||||
#include "ui_relaywidget.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
|
||||
RelayWidget::RelayWidget(Relay* relay, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
relay_(relay),
|
||||
ui(new Ui::RelayWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
relay_->setParent(this);
|
||||
|
||||
if(!relay->hasActors())
|
||||
{
|
||||
ui->checkBox_auto->hide();
|
||||
|
||||
}
|
||||
ui->checkBox_auto->setChecked(relay->actorsActive());
|
||||
ui->checkBox->setChecked(relay->getState());
|
||||
|
||||
ui->label->setText(relay_->getName());
|
||||
|
||||
connect(ui->checkBox, &QCheckBox::toggled, relay_, &Relay::moveToState);
|
||||
connect(ui->checkBox_auto, &QCheckBox::toggled, relay_, &Relay::setActorsActive);
|
||||
connect(ui->pushButton, &QPushButton::clicked, this, &RelayWidget::showSettingsDialog);
|
||||
}
|
||||
|
||||
void RelayWidget::showSettingsDialog()
|
||||
{
|
||||
RelaySettingsDialog dialog(relay_, this);
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
Relay* RelayWidget::getRelay()
|
||||
{
|
||||
return relay_;
|
||||
}
|
||||
|
||||
void RelayWidget::stateChanged(bool state)
|
||||
{
|
||||
ui->checkBox->setChecked(state);
|
||||
relay_->setState(state);
|
||||
}
|
||||
|
||||
RelayWidget::~RelayWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
#ifndef RELAYWIDGET_H
|
||||
#define RELAYWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "relaysettingsdialog.h"
|
||||
#include "relay.h"
|
||||
|
||||
namespace Ui {
|
||||
class RelayWidget;
|
||||
}
|
||||
|
||||
class RelayWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
Relay* relay_;
|
||||
|
||||
private slots:
|
||||
void showSettingsDialog();
|
||||
|
||||
public:
|
||||
explicit RelayWidget(Relay* relay_, QWidget *parent = nullptr);
|
||||
Relay* getRelay();
|
||||
~RelayWidget();
|
||||
|
||||
public slots:
|
||||
void stateChanged(bool state);
|
||||
|
||||
private:
|
||||
Ui::RelayWidget *ui;
|
||||
};
|
||||
|
||||
#endif // RELAYWIDGET_H
|
@ -1,14 +0,0 @@
|
||||
#include "sensoractorwidget.h"
|
||||
#include "ui_sensoractorwidget.h"
|
||||
|
||||
SensorActorWidget::SensorActorWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::SensorActorWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
SensorActorWidget::~SensorActorWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
#ifndef SENSORACTORWIDGET_H
|
||||
#define SENSORACTORWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class SensorActorWidget;
|
||||
}
|
||||
|
||||
class SensorActorWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SensorActorWidget(QWidget *parent = nullptr);
|
||||
~SensorActorWidget();
|
||||
|
||||
private:
|
||||
Ui::SensorActorWidget *ui;
|
||||
};
|
||||
|
||||
#endif // SENSORACTORWIDGET_H
|
@ -1,21 +0,0 @@
|
||||
<ui version="4.0">
|
||||
<author/>
|
||||
<comment/>
|
||||
<exportmacro/>
|
||||
<class>SensorActorWidget</class>
|
||||
<widget name="SensorActorWidget" class="QWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
</widget>
|
||||
<pixmapfunction/>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,33 +1,47 @@
|
||||
#include "sensorlistwidget.h"
|
||||
|
||||
SensorListWidget::SensorListWidget(QWidget *parent): QListWidget (parent)
|
||||
{}
|
||||
#include <QDebug>
|
||||
#include <QHeaderView>
|
||||
|
||||
SensorListWidget::SensorListWidget(SensorStore& sensorStore, QWidget* parent): QListWidget (parent)
|
||||
SensorListWidget::SensorListWidget(QWidget *parent): QTableWidget(parent)
|
||||
{
|
||||
setColumnCount(2);
|
||||
setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
|
||||
setHorizontalHeaderItem(0, new QTableWidgetItem("Sensor"));
|
||||
setHorizontalHeaderItem(1, new QTableWidgetItem("Value"));
|
||||
}
|
||||
|
||||
SensorListWidget::SensorListWidget(SensorStore& sensorStore, QWidget* parent): QTableWidget (parent)
|
||||
{
|
||||
sensorsChanged(*(sensorStore.getSensors()));
|
||||
}
|
||||
|
||||
|
||||
void SensorListWidget::sensorsChanged(std::vector<Sensor> sensors)
|
||||
{
|
||||
clear();
|
||||
setHorizontalHeaderItem(0, new QTableWidgetItem("Sensor"));
|
||||
setHorizontalHeaderItem(1, new QTableWidgetItem("Value"));
|
||||
setRowCount(sensors.size());
|
||||
for(size_t i = 0; i < sensors.size(); ++i)
|
||||
{
|
||||
QString itemString = sensors[i].name + ": ";
|
||||
QString itemString;
|
||||
itemString.append(QString::number(sensors[i].field));
|
||||
itemString.append(' ');
|
||||
|
||||
if(sensors[i].type == Sensor::TYPE_DOOR)
|
||||
{
|
||||
if(sensors[i].field) itemString.append("Open");
|
||||
else itemString.append("Closed");
|
||||
if(sensors[i].field) itemString.append("\"Open\"");
|
||||
else itemString.append("\"Closed\"");
|
||||
}
|
||||
else if(sensors[i].type == Sensor::TYPE_AUDIO_OUTPUT)
|
||||
{
|
||||
if(sensors[i].field) itemString.append("Playing");
|
||||
else itemString.append("Silent");
|
||||
if(sensors[i].field) itemString.append("\"Playing\"");
|
||||
else itemString.append("\"Silent\"");
|
||||
}
|
||||
else itemString.append(QString::number(sensors[i].field));
|
||||
addItem(itemString);
|
||||
setItem(i, 0, new QTableWidgetItem(sensors[i].name));
|
||||
setItem(i, 1, new QTableWidgetItem(itemString));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
#include <QListWidget>
|
||||
#include <QTableWidget>
|
||||
#include <vector>
|
||||
#include "../sensor.h"
|
||||
#include "../sensors/sensor.h"
|
||||
|
||||
class SensorListWidget : public QListWidget
|
||||
class SensorListWidget : public QTableWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@ -15,4 +15,5 @@ public:
|
||||
public slots:
|
||||
|
||||
void sensorsChanged(std::vector<Sensor> sensors);
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user