Commit 8de914ab authored by Leander Schulten's avatar Leander Schulten
Browse files

Update Settings

set dmx data to 0 when starting
make security copy of settings
parent 0fddc984
...@@ -48,6 +48,17 @@ Pane{ ...@@ -48,6 +48,17 @@ Pane{
} }
} }
} }
Label{
text: "Update pause for dmx in ms:"
}
TextInputField{
validator: IntValidator{
bottom: 10
top: 10000
}
text: Settings.updatePauseInMs;
onAccepted: Settings.updatePauseInMs = text;
}
} }
FileDialog{ FileDialog{
property var callback; property var callback;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "programm.h" #include "programm.h"
#include "dmxchannelfilter.h" #include "dmxchannelfilter.h"
#include <QDir> #include <QDir>
#include <cstring>
HardwareInterface * driver = nullptr; HardwareInterface * driver = nullptr;
...@@ -35,6 +36,7 @@ namespace Driver { ...@@ -35,6 +36,7 @@ namespace Driver {
ErrorNotifier::get()->newError(s); ErrorNotifier::get()->newError(s);
}); });
inter->setSetValuesCallback([](unsigned char* values, int size, double time){ inter->setSetValuesCallback([](unsigned char* values, int size, double time){
std::memset(values,0,size);
DMXChannelFilter::initValues(values,size); DMXChannelFilter::initValues(values,size);
Programm::fill(values,size,time); Programm::fill(values,size,time);
DMXChannelFilter::filterValues(values,size); DMXChannelFilter::filterValues(values,size);
......
...@@ -86,7 +86,7 @@ int main(int argc, char *argv[]) ...@@ -86,7 +86,7 @@ int main(int argc, char *argv[])
Settings settings; Settings settings;
settings.setJsonSettingsFilePath("QTJSONFile.json"); settings.setJsonSettingsFilePath("QTJSONFile.json");
QFile file(settings.getJsonSettingsFilePath()); QFile file(settings.getJsonSettingsFilePath());
file.copy(settings.getJsonSettingsFilePath()+"_"+QDateTime::currentDateTime().toString("dd.MM.YYYY HH:mm:ss"));
#warning Dont use IDBase<xxxxx>::getAllIDBases() in this file. It will crash the aplication when its closing #warning Dont use IDBase<xxxxx>::getAllIDBases() in this file. It will crash the aplication when its closing
...@@ -108,6 +108,11 @@ int main(int argc, char *argv[]) ...@@ -108,6 +108,11 @@ int main(int argc, char *argv[])
settings.connect(&settings,&Settings::driverFilePathChanged,[&](){ settings.connect(&settings,&Settings::driverFilePathChanged,[&](){
Driver::loadAndStartDriver(settings.getDriverFilePath()); Driver::loadAndStartDriver(settings.getDriverFilePath());
}); });
settings.connect(&settings,&Settings::updatePauseInMsChanged,[&](){
if(Driver::getCurrentDriver()){
Driver::getCurrentDriver()->setWaitTime(std::chrono::milliseconds(settings.getUpdatePauseInMs()));
}
});
engine.rootContext()->setContextProperty("ModelManager",new ModelManager()); engine.rootContext()->setContextProperty("ModelManager",new ModelManager());
...@@ -129,7 +134,7 @@ int main(int argc, char *argv[]) ...@@ -129,7 +134,7 @@ int main(int argc, char *argv[])
// Treiber laden // Treiber laden
#define USE_DUMMY_DRIVER //#define USE_DUMMY_DRIVER
#ifndef USE_DUMMY_DRIVER #ifndef USE_DUMMY_DRIVER
if(!Driver::loadAndStartDriver(settings.getDriverFilePath())){ if(!Driver::loadAndStartDriver(settings.getDriverFilePath())){
ErrorNotifier::showError("Cant start driver."); ErrorNotifier::showError("Cant start driver.");
......
...@@ -11,15 +11,19 @@ class Settings : public QObject ...@@ -11,15 +11,19 @@ class Settings : public QObject
QSettings settings; QSettings settings;
Q_PROPERTY(QString jsonSettingsFilePath READ getJsonSettingsFilePath WRITE setJsonSettingsFilePath NOTIFY jsonSettingsFilePathChanged) Q_PROPERTY(QString jsonSettingsFilePath READ getJsonSettingsFilePath WRITE setJsonSettingsFilePath NOTIFY jsonSettingsFilePathChanged)
Q_PROPERTY(QString driverFilePath READ getDriverFilePath WRITE setDriverFilePath NOTIFY driverFilePathChanged) Q_PROPERTY(QString driverFilePath READ getDriverFilePath WRITE setDriverFilePath NOTIFY driverFilePathChanged)
Q_PROPERTY(unsigned int updatePauseInMs READ getUpdatePauseInMs WRITE setUpdatePauseInMs NOTIFY updatePauseInMsChanged)
public: public:
explicit Settings(QObject *parent = nullptr); explicit Settings(QObject *parent = nullptr);
void setJsonSettingsFilePath(QString file){if(!QFile::exists(file))return;settings.setValue("jsonSettingsFilePath",file);emit jsonSettingsFilePathChanged();} void setJsonSettingsFilePath(QString file){if(!QFile::exists(file))return;settings.setValue("jsonSettingsFilePath",file);emit jsonSettingsFilePathChanged();}
QString getJsonSettingsFilePath()const{return settings.value("jsonSettingsFilePath").toString();} QString getJsonSettingsFilePath()const{return settings.value("jsonSettingsFilePath").toString();}
void setDriverFilePath(QString file){if(!QFile::exists(file))return;settings.setValue("driverFilePath",file);emit driverFilePathChanged();} void setDriverFilePath(QString file){if(!QFile::exists(file))return;settings.setValue("driverFilePath",file);emit driverFilePathChanged();}
QString getDriverFilePath()const{return settings.value("driverFilePath").toString();} QString getDriverFilePath()const{return settings.value("driverFilePath").toString();}
void setUpdatePauseInMs(unsigned int pause){settings.setValue("driverFilePath",pause);emit updatePauseInMsChanged();}
unsigned int getUpdatePauseInMs()const{return settings.value("driverFilePath").toUInt();}
signals: signals:
void jsonSettingsFilePathChanged(); void jsonSettingsFilePathChanged();
void driverFilePathChanged(); void driverFilePathChanged();
void updatePauseInMsChanged();
public slots: public slots:
}; };
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment