Commit ea18ad76 authored by Leander Schulten's avatar Leander Schulten
Browse files

Add Settings to the settings system

parent cb851ea0
......@@ -59,6 +59,45 @@ Pane{
text: Settings.updatePauseInMs;
onAccepted: Settings.updatePauseInMs = text;
}
Label{
Layout.fillWidth: true
text: "Module Directory:"
}
TextInputField{
Layout.fillWidth: true
text: Settings.moduleDirPath
onAccepted: Settings.moduleDirPath = text;
MouseArea{
anchors.fill: parent
onClicked: {
fileDialog.folder = Settings.moduleDirPath;
fileDialog.open();
fileDialog.addSelection(Settings.moduleDirPath);
fileDialog.callback = function(file){
console.log(file);
Settings.moduleDirPath = file;
};
}
}
}
Label{
Layout.fillWidth: true
text: "Compiler Flags:"
}
TextInputField{
Layout.fillWidth: true
text: Settings.compilerFlags
onAccepted: Settings.compilerFlags = text;
}
Label{
Layout.fillWidth: true
text: "Compiler Library Flags:"
}
TextInputField{
Layout.fillWidth: true
text: Settings.compilerLibraryFlags
onAccepted: Settings.compilerLibraryFlags = text;
}
}
FileDialog{
property var callback;
......
......@@ -36,9 +36,9 @@
int main(int argc, char *argv[])
{
Test::TestModulSystem testModulSystem;
/*Test::TestModulSystem testModulSystem;
testModulSystem.runTest();
return 0;
return 0;*/
class CatchingErrorApplication : public QGuiApplication{
public:
......@@ -121,6 +121,9 @@ int main(int argc, char *argv[])
Driver::getCurrentDriver()->setWaitTime(std::chrono::milliseconds(settings.getUpdatePauseInMs()));
}
});
settings.connect(&settings,&Settings::moduleDirPathChanged,[&](){
Modules::ModuleManager::singletone()->loadAllModulesInDir(settings.getModuleDirPath());
});
engine.rootContext()->setContextProperty("ModelManager",new ModelManager());
......
......@@ -6,6 +6,7 @@ namespace Modules {
class Compiler
{
public:
static QString compilerCmd;
static QString compilerLibraryFlags;
static QString compilerFlags;
......
......@@ -42,8 +42,14 @@ typedef Modules::Programm* (*CreateProgramm)(unsigned int index);
void ModuleManager::loadAllModulesInDir(QDir dir){
for(auto s : dir.entryList(QDir::Files)){
#ifdef Q_OS_WIN
if(s.endsWith(".dll"))
#endif
loadModule(s);
}
for(auto s : dir.entryList(QDir::Dirs)){
loadAllModulesInDir(s);
}
}
}
......@@ -4,6 +4,7 @@
#include <QObject>
#include <QSettings>
#include <QFile>
#include "programms/compiler.h"
class Settings : public QObject
{
......@@ -11,6 +12,10 @@ class Settings : public QObject
QSettings settings;
Q_PROPERTY(QString jsonSettingsFilePath READ getJsonSettingsFilePath WRITE setJsonSettingsFilePath NOTIFY jsonSettingsFilePathChanged)
Q_PROPERTY(QString driverFilePath READ getDriverFilePath WRITE setDriverFilePath NOTIFY driverFilePathChanged)
Q_PROPERTY(QString moduleDirPath READ getModuleDirPath WRITE setModuleDirPath NOTIFY moduleDirPathChanged)
Q_PROPERTY(QString compilerPath READ getCompilerPath WRITE setCompilerPath NOTIFY compilerPathChanged)
Q_PROPERTY(QString compilerFlags READ getCompilerFlags WRITE setCompilerFlags NOTIFY compilerFlagsChanged)
Q_PROPERTY(QString compilerLibraryFlags READ getCompilerLibraryFlags WRITE setCompilerLibraryFlags NOTIFY compilerLibraryFlagsChanged)
Q_PROPERTY(unsigned int updatePauseInMs READ getUpdatePauseInMs WRITE setUpdatePauseInMs NOTIFY updatePauseInMsChanged)
public:
explicit Settings(QObject *parent = nullptr);
......@@ -20,10 +25,49 @@ public:
QString getDriverFilePath()const{return settings.value("driverFilePath").toString();}
void setUpdatePauseInMs(unsigned int pause){settings.setValue("updatePauseInMs",pause);emit updatePauseInMsChanged();}
unsigned int getUpdatePauseInMs()const{return settings.value("updatePauseInMs").toUInt();}
void setModuleDirPath( const QString _moduleDirPath){
if(!QFile::exists(_moduleDirPath))return;
settings.setValue("moduleDirPath",_moduleDirPath); emit moduleDirPathChanged();
}
QString getModuleDirPath() const {
return settings.value("moduleDirPath").toString();
}
void setCompilerPath( const QString _compilerPath){
if(_compilerPath != Modules::Compiler::compilerCmd){
Modules::Compiler::compilerCmd = _compilerPath; emit compilerPathChanged();
}
}
QString getCompilerPath() const {
return Modules::Compiler::compilerCmd;
}
void setCompilerFlags( const QString _compilerFlags){
if(_compilerFlags != Modules::Compiler::compilerFlags){
Modules::Compiler::compilerFlags = _compilerFlags; emit compilerFlagsChanged();
}
}
QString getCompilerFlags() const {
return Modules::Compiler::compilerFlags;
}
void setCompilerLibraryFlags( const QString _compilerLibraryFlags){
if(_compilerLibraryFlags != Modules::Compiler::compilerLibraryFlags){
Modules::Compiler::compilerLibraryFlags = _compilerLibraryFlags; emit compilerLibraryFlagsChanged();
}
}
QString getCompilerLibraryFlags() const {
return Modules::Compiler::compilerLibraryFlags;
}
signals:
void jsonSettingsFilePathChanged();
void driverFilePathChanged();
void updatePauseInMsChanged();
void moduleDirPathChanged();
void compilerPathChanged();
void compilerFlagsChanged();
void compilerLibraryFlagsChanged();
public slots:
};
......
Markdown is supported
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