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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue