mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-05 14:35:23 +00:00
Add setup file as default startup configuration
This commit is contained in:
parent
3afbf42791
commit
b2ed124240
5 changed files with 85 additions and 22 deletions
|
|
@ -160,23 +160,7 @@ AppWindow::AppWindow(QWidget *parent)
|
|||
// aborted selection
|
||||
return;
|
||||
}
|
||||
ifstream file;
|
||||
file.open(filename.toStdString());
|
||||
if(!file.is_open()) {
|
||||
qWarning() << "Unable to open file:" << filename;
|
||||
return;
|
||||
}
|
||||
nlohmann::json j;
|
||||
try {
|
||||
file >> j;
|
||||
} catch (exception &e) {
|
||||
InformationBox::ShowError("Error", "Failed to parse the setup file (" + QString(e.what()) + ")");
|
||||
qWarning() << "Parsing of setup file failed: " << e.what();
|
||||
}
|
||||
file.close();
|
||||
LoadSetup(j);
|
||||
QFileInfo fi(filename);
|
||||
lSetupName.setText("Setup: "+fi.fileName());
|
||||
LoadSetup(filename);
|
||||
});
|
||||
connect(ui->actionSave_image, &QAction::triggered, [=](){
|
||||
Mode::getActiveMode()->saveSreenshot();
|
||||
|
|
@ -261,7 +245,8 @@ AppWindow::AppWindow(QWidget *parent)
|
|||
|
||||
// List available devices
|
||||
UpdateDeviceList();
|
||||
if(Preferences::getInstance().Startup.ConnectToFirstDevice) {
|
||||
auto pref = Preferences::getInstance();
|
||||
if(pref.Startup.ConnectToFirstDevice) {
|
||||
// at least one device available
|
||||
ConnectToDevice();
|
||||
}
|
||||
|
|
@ -272,6 +257,9 @@ AppWindow::AppWindow(QWidget *parent)
|
|||
} else {
|
||||
InformationBox::setGUI(false);
|
||||
}
|
||||
if(pref.Startup.UseSetupFile) {
|
||||
LoadSetup(pref.Startup.SetupFile);
|
||||
}
|
||||
}
|
||||
|
||||
AppWindow::~AppWindow()
|
||||
|
|
@ -948,6 +936,27 @@ nlohmann::json AppWindow::SaveSetup()
|
|||
return j;
|
||||
}
|
||||
|
||||
void AppWindow::LoadSetup(QString filename)
|
||||
{
|
||||
ifstream file;
|
||||
file.open(filename.toStdString());
|
||||
if(!file.is_open()) {
|
||||
qWarning() << "Unable to open file:" << filename;
|
||||
return;
|
||||
}
|
||||
nlohmann::json j;
|
||||
try {
|
||||
file >> j;
|
||||
} catch (exception &e) {
|
||||
InformationBox::ShowError("Error", "Failed to parse the setup file (" + QString(e.what()) + ")");
|
||||
qWarning() << "Parsing of setup file failed: " << e.what();
|
||||
}
|
||||
file.close();
|
||||
LoadSetup(j);
|
||||
QFileInfo fi(filename);
|
||||
lSetupName.setText("Setup: "+fi.fileName());
|
||||
}
|
||||
|
||||
void AppWindow::LoadSetup(nlohmann::json j)
|
||||
{
|
||||
// auto d = new JSONPickerDialog(j);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue