From a6aad07f05e1c25698a2adf22289b2d0cef0db5c Mon Sep 17 00:00:00 2001 From: uvos Date: Fri, 15 Apr 2022 12:13:27 +0200 Subject: [PATCH] add message box on save --- src/mainobject.cpp | 2 +- src/ui/mainwindow.cpp | 13 ++++++++++++- src/ui/mainwindow.h | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/mainobject.cpp b/src/mainobject.cpp index 0ed00dc..d143463 100644 --- a/src/mainobject.cpp +++ b/src/mainobject.cpp @@ -168,7 +168,7 @@ bool MainObject::storeJsonObjectToDisk(const QJsonObject& json, QString filePath file.write(document.toJson()); file.close(); QFile::remove(filePath); - file.rename(filePath); + file.rename(filePath); return true; } } diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 5967c0b..12b8bca 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -4,6 +4,7 @@ #include "itemsettingsdialog.h" #include "itemcreationdialog.h" #include "../mainobject.h" +#include MainWindow::MainWindow(MainObject * const mainObject, QWidget *parent) : QMainWindow(parent), @@ -15,9 +16,14 @@ MainWindow::MainWindow(MainObject * const mainObject, QWidget *parent) : 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_power, SIGNAL(clicked()), this, SLOT(showPowerItemDialog())); @@ -42,7 +48,7 @@ MainWindow::MainWindow(MainObject * const mainObject, QWidget *parent) : connect(&globalSensors, &SensorStore::stateChenged, ui->sensorListView, &SensorListWidget::sensorsChanged); //RGB Leds - connect(&colorChooser, SIGNAL(colorSelected(const QColor)), this, SLOT(slotChangedRgb(const QColor))); + 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())); @@ -62,6 +68,11 @@ void MainWindow::showPowerItemDialog() diag.exec(); } +void MainWindow::saved() +{ + QMessageBox::information(this, "Saved", "Settings where saved"); +} + void MainWindow::slotChangedRgb(const QColor color) { _micro->changeRgbColor(color); diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h index e52f025..b07ac7c 100644 --- a/src/ui/mainwindow.h +++ b/src/ui/mainwindow.h @@ -50,10 +50,11 @@ private slots: void slotChangedRgb(const QColor color); void showPowerItemDialog(); void showItemCreationDialog(); + void saved(); public slots: - void changeHeaderLableText(QString string); + void changeHeaderLableText(QString string); }; #endif // MAINWINDOW_H