improve autostart from setup file
This commit is contained in:
parent
0c782fc009
commit
cb5f472c47
@ -144,15 +144,7 @@ AppWindow::AppWindow(QWidget *parent)
|
|||||||
// aborted selection
|
// aborted selection
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!filename.endsWith(".setup")) {
|
SaveSetup(filename);
|
||||||
filename.append(".setup");
|
|
||||||
}
|
|
||||||
ofstream file;
|
|
||||||
file.open(filename.toStdString());
|
|
||||||
file << setw(4) << SaveSetup() << endl;
|
|
||||||
file.close();
|
|
||||||
QFileInfo fi(filename);
|
|
||||||
lSetupName.setText("Setup: "+fi.fileName());
|
|
||||||
});
|
});
|
||||||
connect(ui->actionLoad_setup, &QAction::triggered, [=](){
|
connect(ui->actionLoad_setup, &QAction::triggered, [=](){
|
||||||
auto filename = QFileDialog::getOpenFileName(nullptr, "Load setup data", "", "Setup files (*.setup)", nullptr, QFileDialog::DontUseNativeDialog);
|
auto filename = QFileDialog::getOpenFileName(nullptr, "Load setup data", "", "Setup files (*.setup)", nullptr, QFileDialog::DontUseNativeDialog);
|
||||||
@ -243,9 +235,12 @@ AppWindow::AppWindow(QWidget *parent)
|
|||||||
qRegisterMetaType<Protocol::SpectrumAnalyzerResult>("SpectrumAnalyzerResult");
|
qRegisterMetaType<Protocol::SpectrumAnalyzerResult>("SpectrumAnalyzerResult");
|
||||||
qRegisterMetaType<Protocol::AmplitudeCorrectionPoint>("AmplitudeCorrection");
|
qRegisterMetaType<Protocol::AmplitudeCorrectionPoint>("AmplitudeCorrection");
|
||||||
|
|
||||||
|
auto pref = Preferences::getInstance();
|
||||||
|
if(pref.Startup.UseSetupFile) {
|
||||||
|
LoadSetup(pref.Startup.SetupFile);
|
||||||
|
}
|
||||||
// List available devices
|
// List available devices
|
||||||
UpdateDeviceList();
|
UpdateDeviceList();
|
||||||
auto pref = Preferences::getInstance();
|
|
||||||
if(pref.Startup.ConnectToFirstDevice) {
|
if(pref.Startup.ConnectToFirstDevice) {
|
||||||
// at least one device available
|
// at least one device available
|
||||||
ConnectToDevice();
|
ConnectToDevice();
|
||||||
@ -257,9 +252,6 @@ AppWindow::AppWindow(QWidget *parent)
|
|||||||
} else {
|
} else {
|
||||||
InformationBox::setGUI(false);
|
InformationBox::setGUI(false);
|
||||||
}
|
}
|
||||||
if(pref.Startup.UseSetupFile) {
|
|
||||||
LoadSetup(pref.Startup.SetupFile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AppWindow::~AppWindow()
|
AppWindow::~AppWindow()
|
||||||
@ -270,6 +262,10 @@ AppWindow::~AppWindow()
|
|||||||
|
|
||||||
void AppWindow::closeEvent(QCloseEvent *event)
|
void AppWindow::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
|
auto pref = Preferences::getInstance();
|
||||||
|
if(pref.Startup.UseSetupFile && pref.Startup.AutosaveSetupFile) {
|
||||||
|
SaveSetup(pref.Startup.SetupFile);
|
||||||
|
}
|
||||||
vna->shutdown();
|
vna->shutdown();
|
||||||
generator->shutdown();
|
generator->shutdown();
|
||||||
spectrumAnalyzer->shutdown();
|
spectrumAnalyzer->shutdown();
|
||||||
@ -280,7 +276,7 @@ void AppWindow::closeEvent(QCloseEvent *event)
|
|||||||
if(Mode::getActiveMode()) {
|
if(Mode::getActiveMode()) {
|
||||||
Mode::getActiveMode()->deactivate();
|
Mode::getActiveMode()->deactivate();
|
||||||
}
|
}
|
||||||
Preferences::getInstance().store();
|
pref.store();
|
||||||
QMainWindow::closeEvent(event);
|
QMainWindow::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -926,6 +922,19 @@ void AppWindow::FrequencyCalibrationDialog()
|
|||||||
d->exec();
|
d->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppWindow::SaveSetup(QString filename)
|
||||||
|
{
|
||||||
|
if(!filename.endsWith(".setup")) {
|
||||||
|
filename.append(".setup");
|
||||||
|
}
|
||||||
|
ofstream file;
|
||||||
|
file.open(filename.toStdString());
|
||||||
|
file << setw(4) << SaveSetup() << endl;
|
||||||
|
file.close();
|
||||||
|
QFileInfo fi(filename);
|
||||||
|
lSetupName.setText("Setup: "+fi.fileName());
|
||||||
|
}
|
||||||
|
|
||||||
nlohmann::json AppWindow::SaveSetup()
|
nlohmann::json AppWindow::SaveSetup()
|
||||||
{
|
{
|
||||||
nlohmann::json j;
|
nlohmann::json j;
|
||||||
|
@ -61,6 +61,7 @@ private slots:
|
|||||||
void ReceiverCalibrationDialog();
|
void ReceiverCalibrationDialog();
|
||||||
void FrequencyCalibrationDialog();
|
void FrequencyCalibrationDialog();
|
||||||
nlohmann::json SaveSetup();
|
nlohmann::json SaveSetup();
|
||||||
|
void SaveSetup(QString filename);
|
||||||
void LoadSetup(QString filename);
|
void LoadSetup(QString filename);
|
||||||
void LoadSetup(nlohmann::json j);
|
void LoadSetup(nlohmann::json j);
|
||||||
private:
|
private:
|
||||||
|
@ -52,16 +52,19 @@ PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) :
|
|||||||
setDefaultSettingsEnabled(false);
|
setDefaultSettingsEnabled(false);
|
||||||
ui->StartupSetupFile->setEnabled(false);
|
ui->StartupSetupFile->setEnabled(false);
|
||||||
ui->StartupBrowse->setEnabled(false);
|
ui->StartupBrowse->setEnabled(false);
|
||||||
|
ui->StartupStack->setCurrentWidget(ui->StartupPageLastUsed);
|
||||||
});
|
});
|
||||||
connect(ui->StartupSweepDefault, &QPushButton::clicked, [=](){
|
connect(ui->StartupSweepDefault, &QPushButton::clicked, [=](){
|
||||||
setDefaultSettingsEnabled(true);
|
setDefaultSettingsEnabled(true);
|
||||||
ui->StartupSetupFile->setEnabled(false);
|
ui->StartupSetupFile->setEnabled(false);
|
||||||
ui->StartupBrowse->setEnabled(false);
|
ui->StartupBrowse->setEnabled(false);
|
||||||
|
ui->StartupStack->setCurrentWidget(ui->StartupPageDefaultValues);
|
||||||
});
|
});
|
||||||
connect(ui->StartupUseSetupFile, &QPushButton::clicked, [=](){
|
connect(ui->StartupUseSetupFile, &QPushButton::clicked, [=](){
|
||||||
setDefaultSettingsEnabled(false);
|
setDefaultSettingsEnabled(false);
|
||||||
ui->StartupSetupFile->setEnabled(true);
|
ui->StartupSetupFile->setEnabled(true);
|
||||||
ui->StartupBrowse->setEnabled(true);
|
ui->StartupBrowse->setEnabled(true);
|
||||||
|
ui->StartupStack->setCurrentWidget(ui->StartupPageSetupFile);
|
||||||
});
|
});
|
||||||
connect(ui->StartupBrowse, &QPushButton::clicked, [=](){
|
connect(ui->StartupBrowse, &QPushButton::clicked, [=](){
|
||||||
ui->StartupSetupFile->setText(QFileDialog::getOpenFileName(nullptr, "Select startup setup file", "", "Setup files (*.setup)", nullptr, QFileDialog::DontUseNativeDialog));
|
ui->StartupSetupFile->setText(QFileDialog::getOpenFileName(nullptr, "Select startup setup file", "", "Setup files (*.setup)", nullptr, QFileDialog::DontUseNativeDialog));
|
||||||
@ -203,6 +206,7 @@ void PreferencesDialog::setInitialGUIState()
|
|||||||
} else {
|
} else {
|
||||||
ui->StartupSweepDefault->click();
|
ui->StartupSweepDefault->click();
|
||||||
}
|
}
|
||||||
|
ui->StartupAutosaveSetupFile->setChecked(p->Startup.AutosaveSetupFile);
|
||||||
ui->StartupSetupFile->setText(p->Startup.SetupFile);
|
ui->StartupSetupFile->setText(p->Startup.SetupFile);
|
||||||
ui->StartupSweepType->setCurrentText(p->Startup.DefaultSweep.type);
|
ui->StartupSweepType->setCurrentText(p->Startup.DefaultSweep.type);
|
||||||
ui->StartupSweepStart->setValueQuiet(p->Startup.DefaultSweep.f_start);
|
ui->StartupSweepStart->setValueQuiet(p->Startup.DefaultSweep.f_start);
|
||||||
@ -263,6 +267,7 @@ void PreferencesDialog::updateFromGUI()
|
|||||||
p->Startup.RememberSweepSettings = ui->StartupSweepLastUsed->isChecked();
|
p->Startup.RememberSweepSettings = ui->StartupSweepLastUsed->isChecked();
|
||||||
p->Startup.UseSetupFile = ui->StartupUseSetupFile->isChecked();
|
p->Startup.UseSetupFile = ui->StartupUseSetupFile->isChecked();
|
||||||
p->Startup.SetupFile = ui->StartupSetupFile->text();
|
p->Startup.SetupFile = ui->StartupSetupFile->text();
|
||||||
|
p->Startup.AutosaveSetupFile = ui->StartupAutosaveSetupFile->isChecked();
|
||||||
p->Startup.DefaultSweep.type = ui->StartupSweepType->currentText();
|
p->Startup.DefaultSweep.type = ui->StartupSweepType->currentText();
|
||||||
p->Startup.DefaultSweep.f_start = ui->StartupSweepStart->value();
|
p->Startup.DefaultSweep.f_start = ui->StartupSweepStart->value();
|
||||||
p->Startup.DefaultSweep.f_stop = ui->StartupSweepStop->value();
|
p->Startup.DefaultSweep.f_stop = ui->StartupSweepStop->value();
|
||||||
|
@ -33,6 +33,7 @@ public:
|
|||||||
bool ConnectToFirstDevice;
|
bool ConnectToFirstDevice;
|
||||||
bool RememberSweepSettings;
|
bool RememberSweepSettings;
|
||||||
bool UseSetupFile;
|
bool UseSetupFile;
|
||||||
|
bool AutosaveSetupFile;
|
||||||
QString SetupFile;
|
QString SetupFile;
|
||||||
struct {
|
struct {
|
||||||
QString type;
|
QString type;
|
||||||
@ -121,6 +122,7 @@ private:
|
|||||||
{&Startup.RememberSweepSettings, "Startup.RememberSweepSettings", false},
|
{&Startup.RememberSweepSettings, "Startup.RememberSweepSettings", false},
|
||||||
{&Startup.UseSetupFile, "Startup.UseSetupFile", false},
|
{&Startup.UseSetupFile, "Startup.UseSetupFile", false},
|
||||||
{&Startup.SetupFile, "Startup.SetupFile", ""},
|
{&Startup.SetupFile, "Startup.SetupFile", ""},
|
||||||
|
{&Startup.AutosaveSetupFile, "Startup.AutosaveSetupFile", false},
|
||||||
{&Startup.DefaultSweep.type, "Startup.DefaultSweep.type", "Frequency"},
|
{&Startup.DefaultSweep.type, "Startup.DefaultSweep.type", "Frequency"},
|
||||||
{&Startup.DefaultSweep.f_start, "Startup.DefaultSweep.start", 1000000.0},
|
{&Startup.DefaultSweep.f_start, "Startup.DefaultSweep.start", 1000000.0},
|
||||||
{&Startup.DefaultSweep.f_stop, "Startup.DefaultSweep.stop", 6000000000.0},
|
{&Startup.DefaultSweep.f_stop, "Startup.DefaultSweep.stop", 6000000000.0},
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>957</width>
|
<width>936</width>
|
||||||
<height>891</height>
|
<height>951</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -112,7 +112,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0,0,0,0">
|
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0,0">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="StartupSweepLastUsed">
|
<widget class="QRadioButton" name="StartupSweepLastUsed">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -136,13 +136,83 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="StartupUseSetupFile">
|
<widget class="QRadioButton" name="StartupUseSetupFile">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Use setup file:</string>
|
<string>Setup file</string>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="buttonGroup">
|
<attribute name="buttonGroup">
|
||||||
<string notr="true">StartupSweepGroup</string>
|
<string notr="true">StartupSweepGroup</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QStackedWidget" name="StartupStack">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="StartupPageLastUsed">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_18">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_36">
|
||||||
|
<property name="text">
|
||||||
|
<string>The last used sweep settings (e.g. span, bandwidth,...) will be remembered. The graphs, traces and markers will not be remembered and the default configuration for them is used on startup.</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_7">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="StartupPageSetupFile">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_17">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_38">
|
||||||
|
<property name="text">
|
||||||
|
<string>All settings (sweep settings as well as graphs, markers and traces) will be taken from the specified file. If the autosave option is checked, the current state of the GUI is stored in this file during shutdown as well.</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_35">
|
||||||
|
<property name="text">
|
||||||
|
<string>File location:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="StartupSetupFile"/>
|
<widget class="QLineEdit" name="StartupSetupFile"/>
|
||||||
</item>
|
</item>
|
||||||
@ -165,22 +235,41 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<widget class="QCheckBox" name="StartupAutosaveSetupFile">
|
||||||
|
<property name="text">
|
||||||
|
<string>Autosave to this file on shutdown</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_6">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>20</width>
|
||||||
<height>20</height>
|
<height>545</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</widget>
|
||||||
</layout>
|
<widget class="QWidget" name="StartupPageDefaultValues">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_16">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_37">
|
||||||
|
<property name="text">
|
||||||
|
<string>These default values for the sweep settings will be used. The graphs, traces and markers will not be remembered and the default configuration for them is used on startup.</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
@ -569,6 +658,10 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
|
Loading…
Reference in New Issue
Block a user