Major wip refactor
Allow running without gui Remove serialPortMultiplexer broadcast use Add TcpServer and TcpClient Introduce the concept of an item source
This commit is contained in:
parent
cbeb8d49a7
commit
6d742e60db
38 changed files with 928 additions and 825 deletions
|
|
@ -9,38 +9,20 @@
|
|||
MainWindow::MainWindow(MainObject * const mainObject, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow),
|
||||
colorChooser(this),
|
||||
_micro(&mainObject->micro),
|
||||
_powerItem(mainObject->powerItem)
|
||||
colorChooser(this)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
if(!mainObject->master)
|
||||
{
|
||||
connect(ui->pushButton_broadcast, &QPushButton::clicked, this, &MainWindow::sigBrodcast);
|
||||
}
|
||||
else
|
||||
{
|
||||
connect(ui->pushButton_broadcast, &QPushButton::clicked, this, &MainWindow::sigSave);
|
||||
connect(ui->pushButton_broadcast, &QPushButton::clicked, this, &MainWindow::saved);
|
||||
}
|
||||
connect(ui->pushButton_broadcast, &QPushButton::clicked, this, &MainWindow::sigSave);
|
||||
connect(ui->pushButton_broadcast, &QPushButton::clicked, this, [this](){QMessageBox::information(this, "Saved", "Settings where saved");});
|
||||
|
||||
connect(ui->pushButton_power, SIGNAL(clicked()), this, SLOT(showPowerItemDialog()));
|
||||
|
||||
//Relays
|
||||
if(mainObject->master)connect(ui->pushButton_refesh, &QPushButton::clicked, _micro, &Microcontroller::requestState);
|
||||
else
|
||||
{
|
||||
connect(ui->pushButton_refesh, &QPushButton::clicked, &mainObject->broadCast, &BroadCast::requestJson);
|
||||
connect(ui->pushButton_refesh, &QPushButton::clicked, &mainObject->broadCast, &BroadCast::requestSensors);
|
||||
}
|
||||
connect(&mainObject->items, &ItemStore::itemAdded, ui->relayList, &ItemScrollBox::addItem);
|
||||
connect(&mainObject->items, &ItemStore::itemDeleted, ui->relayList, &ItemScrollBox::removeItem);
|
||||
connect(ui->pushButton_refesh, &QPushButton::clicked, mainObject, &MainObject::refresh);
|
||||
connect(&globalItems, &ItemStore::itemAdded, ui->relayList, &ItemScrollBox::addItem);
|
||||
connect(&globalItems, &ItemStore::itemDeleted, ui->relayList, &ItemScrollBox::removeItem);
|
||||
|
||||
for(size_t i = 0; i < mainObject->items.getItems()->size(); ++i)
|
||||
{
|
||||
ui->relayList->addItem(mainObject->items.getItems()->at(i));
|
||||
}
|
||||
for(size_t i = 0; i < globalItems.getItems()->size(); ++i)
|
||||
ui->relayList->addItem(globalItems.getItems()->at(i));
|
||||
|
||||
//Sensors
|
||||
ui->sensorListView->setShowHidden(false);
|
||||
|
|
@ -53,7 +35,7 @@ MainWindow::MainWindow(MainObject * const mainObject, QWidget *parent) :
|
|||
connect(ui->button_color, SIGNAL(clicked()), &colorChooser, SLOT(show()));
|
||||
|
||||
connect(ui->pushButton_addItem, &QPushButton::clicked, this, &MainWindow::showItemCreationDialog);
|
||||
connect(ui->relayList, &ItemScrollBox::deleteRequest, &mainObject->items, &ItemStore::removeItem);
|
||||
connect(ui->relayList, &ItemScrollBox::deleteRequest, &globalItems, &ItemStore::removeItem);
|
||||
|
||||
ui->splitter->setStretchFactor(1, 1);
|
||||
}
|
||||
|
|
@ -70,14 +52,10 @@ void MainWindow::showPowerItemDialog()
|
|||
diag.exec();
|
||||
}
|
||||
|
||||
void MainWindow::saved()
|
||||
{
|
||||
QMessageBox::information(this, "Saved", "Settings where saved");
|
||||
}
|
||||
|
||||
void MainWindow::slotChangedRgb(const QColor color)
|
||||
{
|
||||
_micro->changeRgbColor(color);
|
||||
(void)color;
|
||||
//_micro->changeRgbColor(color);
|
||||
}
|
||||
|
||||
void MainWindow::showItemCreationDialog()
|
||||
|
|
|
|||
|
|
@ -5,13 +5,8 @@
|
|||
#include <QColorDialog>
|
||||
#include <QListWidgetItem>
|
||||
#include <QTime>
|
||||
#include <vector>
|
||||
#include "../actors/alarmtime.h"
|
||||
#include "../microcontroller.h"
|
||||
#include "../sensors/sensor.h"
|
||||
#include "../items/itemstore.h"
|
||||
#include "../items/poweritem.h"
|
||||
#include "../broadcast.h"
|
||||
#include <memory>
|
||||
#include "src/items/poweritem.h"
|
||||
|
||||
|
||||
class MainObject;
|
||||
|
|
@ -34,13 +29,10 @@ private:
|
|||
|
||||
QColorDialog colorChooser;
|
||||
|
||||
Microcontroller *_micro;
|
||||
|
||||
std::shared_ptr<PowerItem> _powerItem;
|
||||
|
||||
signals:
|
||||
|
||||
void sigBrodcast();
|
||||
void sigSave();
|
||||
void createdItem(std::shared_ptr<Item> item);
|
||||
|
||||
|
|
@ -50,7 +42,6 @@ private slots:
|
|||
void slotChangedRgb(const QColor color);
|
||||
void showPowerItemDialog();
|
||||
void showItemCreationDialog();
|
||||
void saved();
|
||||
|
||||
public slots:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue