#include "mainwindow.h" #include "ui_mainwindow.h" #include "itemscrollbox.h" #include "itemsettingsdialog.h" #include "itemcreationdialog.h" #include "../mainobject.h" #include MainWindow::MainWindow(MainObject * const mainObject, QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), colorChooser(this) { ui->setupUi(this); 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())); 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 < globalItems.getItems()->size(); ++i) ui->relayList->addItem(globalItems.getItems()->at(i)); //Sensors ui->sensorListView->setShowHidden(false); ui->sensorListView->sensorsChanged(*globalSensors.getSensors()); connect(&globalSensors, &SensorStore::stateChenged, ui->sensorListView, &SensorListWidget::sensorsChanged); //RGB Leds connect(&colorChooser, SIGNAL(colorSelected(QColor)), this, SLOT(slotChangedRgb(QColor))); connect(ui->button_quit, SIGNAL(clicked()), this, SLOT(close())); connect(ui->button_color, SIGNAL(clicked()), &colorChooser, SLOT(show())); connect(ui->pushButton_addItem, &QPushButton::clicked, this, &MainWindow::showItemCreationDialog); connect(ui->relayList, &ItemScrollBox::deleteRequest, &globalItems, &ItemStore::removeItem); ui->splitter->setStretchFactor(1, 1); } MainWindow::~MainWindow() { delete ui; } void MainWindow::showPowerItemDialog() { ItemSettingsDialog diag(std::shared_ptr(_powerItem), this); diag.show(); diag.exec(); } void MainWindow::slotChangedRgb(const QColor color) { (void)color; //_micro->changeRgbColor(color); } void MainWindow::showItemCreationDialog() { ItemCreationDialog diag(this); diag.show(); if(diag.exec()) { createdItem(diag.item); } } void MainWindow::changeHeaderLableText(QString string) { if(string.size() > 28) { string.remove(28, string.size()-(28)); string.append("..."); } ui->label_serialRecive->setText(string); }