mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-01-27 01:54:44 +01:00
Added persistant config for file source
This commit is contained in:
parent
bed0712be1
commit
ce8b4ceb44
@ -45,10 +45,11 @@ bool FileSelect::render(std::string id) {
|
|||||||
return _pathChanged;
|
return _pathChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileSelect::setPath(std::string path) {
|
void FileSelect::setPath(std::string path, bool markChanged) {
|
||||||
this->path = path;
|
this->path = path;
|
||||||
std::string expandedPath = expandString(path);
|
std::string expandedPath = expandString(path);
|
||||||
pathValid = std::filesystem::is_regular_file(expandedPath);
|
pathValid = std::filesystem::is_regular_file(expandedPath);
|
||||||
|
if (markChanged) { pathChanged = true; }
|
||||||
strcpy(strPath, path.c_str());
|
strcpy(strPath, path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ class FileSelect {
|
|||||||
public:
|
public:
|
||||||
FileSelect(std::string defaultPath, std::vector<std::string> filter = {"All Files", "*"});
|
FileSelect(std::string defaultPath, std::vector<std::string> filter = {"All Files", "*"});
|
||||||
bool render(std::string id);
|
bool render(std::string id);
|
||||||
void setPath(std::string path);
|
void setPath(std::string path, bool markChanged = false);
|
||||||
bool pathIsValid();
|
bool pathIsValid();
|
||||||
|
|
||||||
std::string expandString(std::string input);
|
std::string expandString(std::string input);
|
||||||
|
@ -44,10 +44,11 @@ bool FolderSelect::render(std::string id) {
|
|||||||
return _pathChanged;
|
return _pathChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FolderSelect::setPath(std::string path) {
|
void FolderSelect::setPath(std::string path, bool markChanged) {
|
||||||
this->path = path;
|
this->path = path;
|
||||||
std::string expandedPath = expandString(path);
|
std::string expandedPath = expandString(path);
|
||||||
pathValid = std::filesystem::is_directory(expandedPath);
|
pathValid = std::filesystem::is_directory(expandedPath);
|
||||||
|
if (markChanged) { pathChanged = true; }
|
||||||
strcpy(strPath, path.c_str());
|
strcpy(strPath, path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class FolderSelect {
|
|||||||
public:
|
public:
|
||||||
FolderSelect(std::string defaultPath);
|
FolderSelect(std::string defaultPath);
|
||||||
bool render(std::string id);
|
bool render(std::string id);
|
||||||
void setPath(std::string path);
|
void setPath(std::string path, bool markChanged = false);
|
||||||
bool pathIsValid();
|
bool pathIsValid();
|
||||||
|
|
||||||
std::string expandString(std::string input);
|
std::string expandString(std::string input);
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <signal_path/signal_path.h>
|
#include <signal_path/signal_path.h>
|
||||||
#include <wavreader.h>
|
#include <wavreader.h>
|
||||||
#include <core.h>
|
#include <core.h>
|
||||||
|
#include <options.h>
|
||||||
#include <gui/widgets/file_select.h>
|
#include <gui/widgets/file_select.h>
|
||||||
|
|
||||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||||
@ -17,12 +18,17 @@ SDRPP_MOD_INFO {
|
|||||||
/* Max instances */ 1
|
/* Max instances */ 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ConfigManager config;
|
||||||
|
|
||||||
class FileSourceModule : public ModuleManager::Instance {
|
class FileSourceModule : public ModuleManager::Instance {
|
||||||
public:
|
public:
|
||||||
FileSourceModule(std::string name) : fileSelect("", {"Wav IQ Files (*.wav)", "*.wav", "All Files", "*"}) {
|
FileSourceModule(std::string name) : fileSelect("", {"Wav IQ Files (*.wav)", "*.wav", "All Files", "*"}) {
|
||||||
this->name = name;
|
this->name = name;
|
||||||
|
|
||||||
|
config.aquire();
|
||||||
|
fileSelect.setPath(config.conf["path"], true);
|
||||||
|
config.release();
|
||||||
|
|
||||||
handler.ctx = this;
|
handler.ctx = this;
|
||||||
handler.selectHandler = menuSelected;
|
handler.selectHandler = menuSelected;
|
||||||
handler.deselectHandler = menuDeselected;
|
handler.deselectHandler = menuDeselected;
|
||||||
@ -105,6 +111,9 @@ private:
|
|||||||
core::setInputSampleRate(_this->sampleRate);
|
core::setInputSampleRate(_this->sampleRate);
|
||||||
}
|
}
|
||||||
catch (std::exception e) {}
|
catch (std::exception e) {}
|
||||||
|
config.aquire();
|
||||||
|
config.conf["path"] = _this->fileSelect.path;
|
||||||
|
config.release(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +166,11 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
MOD_EXPORT void _INIT_() {
|
MOD_EXPORT void _INIT_() {
|
||||||
// Do your one time init here
|
json def = json({});
|
||||||
|
def["path"] = "";
|
||||||
|
config.setPath(options::opts.root + "/file_source_config.json");
|
||||||
|
config.load(def);
|
||||||
|
config.enableAutoSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
MOD_EXPORT void* _CREATE_INSTANCE_(std::string name) {
|
MOD_EXPORT void* _CREATE_INSTANCE_(std::string name) {
|
||||||
@ -169,5 +182,6 @@ MOD_EXPORT void _DELETE_INSTANCE_(void* instance) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MOD_EXPORT void _END_() {
|
MOD_EXPORT void _END_() {
|
||||||
// Do your one shutdown here
|
config.disableAutoSave();
|
||||||
|
config.save();
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user