Permalink
Browse files

Save sample rate in settings

Highly likely that subseqent runs of the application will use the same samplerate.
  • Loading branch information...
1 parent 15eefe3 commit 5e332faedc55fe5082cdf8b336dbc440bab83957 Eoin Mcloughlin committed Dec 4, 2016
Showing with 16 additions and 3 deletions.
  1. +2 −0 main.cpp
  2. +8 −2 mainwindow.cpp
  3. +6 −1 spectrogramcontrols.cpp
View
@@ -26,6 +26,8 @@ int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setApplicationName("inspectrum");
+ a.setOrganizationName("inspectrum");
+
MainWindow mainWin;
QCommandLineParser parser;
View
@@ -54,6 +54,7 @@ MainWindow::MainWindow()
// Set defaults after making connections so everything is in sync
dock->setDefaults();
+
}
void MainWindow::openFile(QString fileName)
@@ -85,8 +86,13 @@ void MainWindow::openFile(QString fileName)
void MainWindow::setSampleRate(QString rate)
{
- input->setSampleRate(rate.toInt());
- plots->setSampleRate(rate.toInt());
+ int sampleRate = rate.toInt();
+ input->setSampleRate(sampleRate);
+ plots->setSampleRate(sampleRate);
+
+ // Save the sample rate in settings as we're likely to be opening the same file across multiple runs
+ QSettings settings;
+ settings.setValue("SampleRate", sampleRate);
}
void MainWindow::setSampleRate(int rate)
@@ -21,6 +21,7 @@
#include "spectrogramcontrols.h"
#include <QIntValidator>
#include <QFileDialog>
+#include <QSettings>
#include <QLabel>
#include <cmath>
#include "util.h"
@@ -116,13 +117,17 @@ void SpectrogramControls::cursorsStateChanged(int state)
void SpectrogramControls::setDefaults()
{
- sampleRate->setText("8000000");
fftSizeSlider->setValue(9);
zoomLevelSlider->setValue(0);
powerMaxSlider->setValue(0);
powerMinSlider->setValue(-100);
cursorsCheckBox->setCheckState(Qt::Unchecked);
cursorSymbolsSpinBox->setValue(1);
+
+ // Try to set the sample rate from the last-used value
+ QSettings settings;
+ int savedSampleRate = settings.value("SampleRate", 8000000).toInt();
+ sampleRate->setText(QString::number(savedSampleRate));
}
void SpectrogramControls::fftOrZoomChanged(int value)

0 comments on commit 5e332fa

Please sign in to comment.