Update to make it easier to get the sub-windows to respond to changed preferences. Implemented seconds mode in flow view.
This commit is contained in:
@@ -9,8 +9,6 @@ FileComparatorWindow::FileComparatorWindow(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
readSettings();
|
||||
|
||||
connect(ui->btnFirstFile, SIGNAL(clicked(bool)), this, SLOT(loadFirstFile()));
|
||||
connect(ui->btnSecondFile, SIGNAL(clicked(bool)), this, SLOT(loadSecondFile()));
|
||||
connect(ui->btnSaveDetails, SIGNAL(clicked(bool)), this, SLOT(saveDetails()));
|
||||
@@ -24,6 +22,11 @@ FileComparatorWindow::~FileComparatorWindow()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void FileComparatorWindow::showEvent(QShowEvent *)
|
||||
{
|
||||
readSettings();
|
||||
}
|
||||
|
||||
void FileComparatorWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
writeSettings();
|
||||
|
||||
@@ -41,6 +41,7 @@ private:
|
||||
QString secondFilename;
|
||||
|
||||
void calculateDetails();
|
||||
void showEvent(QShowEvent *);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
|
||||
+28
-6
@@ -83,6 +83,9 @@ FlowViewWindow::FlowViewWindow(const QVector<CANFrame> *frames, QWidget *parent)
|
||||
void FlowViewWindow::showEvent(QShowEvent* event)
|
||||
{
|
||||
QDialog::showEvent(event);
|
||||
|
||||
readSettings();
|
||||
|
||||
refreshIDList();
|
||||
if (ui->listFrameID->count() > 0)
|
||||
{
|
||||
@@ -124,6 +127,8 @@ void FlowViewWindow::readSettings()
|
||||
{
|
||||
ui->cbTimeGraph->setChecked(true);
|
||||
}
|
||||
|
||||
secondsMode = settings.value("Main/TimeSeconds", false).toBool();
|
||||
}
|
||||
|
||||
void FlowViewWindow::writeSettings()
|
||||
@@ -260,7 +265,13 @@ void FlowViewWindow::createGraph(int byteNum)
|
||||
|
||||
if (graphByTime)
|
||||
{
|
||||
x[j] = frameCache[j].timestamp;
|
||||
if (secondsMode){
|
||||
x[j] = (double)(frameCache[j].timestamp) / 1000000.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
x[j] = frameCache[j].timestamp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -487,11 +498,22 @@ void FlowViewWindow::updateGraphLocation()
|
||||
if (end >= frameCache.count()) end = frameCache.count() - 1;
|
||||
if (ui->cbTimeGraph->isChecked())
|
||||
{
|
||||
ui->graphView->xAxis->setRange(frameCache[start].timestamp, frameCache[end].timestamp);
|
||||
ui->graphView->xAxis->setTickStep((frameCache[end].timestamp - frameCache[start].timestamp)/ 3.0);
|
||||
ui->graphView->xAxis->setSubTickCount(0);
|
||||
ui->graphView->xAxis->setNumberFormat("f");
|
||||
ui->graphView->xAxis->setNumberPrecision(0);
|
||||
if (secondsMode)
|
||||
{
|
||||
ui->graphView->xAxis->setRange(frameCache[start].timestamp / 1000000.0, frameCache[end].timestamp / 1000000.0);
|
||||
ui->graphView->xAxis->setTickStep((frameCache[end].timestamp - frameCache[start].timestamp)/ 3000000.0);
|
||||
ui->graphView->xAxis->setSubTickCount(0);
|
||||
ui->graphView->xAxis->setNumberFormat("f");
|
||||
ui->graphView->xAxis->setNumberPrecision(6);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->graphView->xAxis->setRange(frameCache[start].timestamp, frameCache[end].timestamp);
|
||||
ui->graphView->xAxis->setTickStep((frameCache[end].timestamp - frameCache[start].timestamp)/ 3.0);
|
||||
ui->graphView->xAxis->setSubTickCount(0);
|
||||
ui->graphView->xAxis->setNumberFormat("f");
|
||||
ui->graphView->xAxis->setNumberPrecision(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -46,6 +46,7 @@ private:
|
||||
bool playbackActive;
|
||||
bool playbackForward;
|
||||
static const QColor graphColors[8];
|
||||
bool secondsMode;
|
||||
|
||||
void refreshIDList();
|
||||
void updateFrameLabel();
|
||||
|
||||
@@ -20,6 +20,7 @@ FrameInfoWindow::FrameInfoWindow(const QVector<CANFrame> *frames, QWidget *paren
|
||||
void FrameInfoWindow::showEvent(QShowEvent* event)
|
||||
{
|
||||
QDialog::showEvent(event);
|
||||
readSettings();
|
||||
refreshIDList();
|
||||
if (ui->listFrameID->count() > 0)
|
||||
{
|
||||
|
||||
@@ -84,6 +84,11 @@ FramePlaybackWindow::~FramePlaybackWindow()
|
||||
delete playbackTimer;
|
||||
}
|
||||
|
||||
void FramePlaybackWindow::showEvent(QShowEvent *)
|
||||
{
|
||||
readSettings();
|
||||
}
|
||||
|
||||
void FramePlaybackWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
writeSettings();
|
||||
|
||||
@@ -71,7 +71,8 @@ private:
|
||||
void refreshIDList();
|
||||
void updateFrameLabel();
|
||||
void updatePosition(bool forward);
|
||||
void fillIDHash(SequenceItem &item);
|
||||
void fillIDHash(SequenceItem &item);
|
||||
void showEvent(QShowEvent *);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
|
||||
@@ -72,6 +72,7 @@ GraphingWindow::~GraphingWindow()
|
||||
void GraphingWindow::showEvent(QShowEvent* event)
|
||||
{
|
||||
QDialog::showEvent(event);
|
||||
readSettings();
|
||||
ui->graphingView->replot();
|
||||
}
|
||||
|
||||
|
||||
+18
-1
@@ -101,6 +101,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
connect(this, &MainWindow::closeSerialPort, worker, &SerialWorker::closeSerialPort, Qt::QueuedConnection);
|
||||
connect(this, &MainWindow::startFrameCapturing, worker, &SerialWorker::startFrameCapture);
|
||||
connect(this, &MainWindow::stopFrameCapturing, worker, &SerialWorker::stopFrameCapture);
|
||||
connect(this, &MainWindow::settingsUpdated, worker, &SerialWorker::readSettings);
|
||||
serialWorkerThread.start();
|
||||
serialWorkerThread.setPriority(QThread::HighPriority);
|
||||
|
||||
@@ -237,6 +238,12 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
exitApp();
|
||||
}
|
||||
|
||||
void MainWindow::updateSettings()
|
||||
{
|
||||
readUpdateableSettings();
|
||||
emit settingsUpdated();
|
||||
}
|
||||
|
||||
void MainWindow::readSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
@@ -249,6 +256,12 @@ void MainWindow::readSettings()
|
||||
{
|
||||
ui->cbAutoScroll->setChecked(true);
|
||||
}
|
||||
readUpdateableSettings();
|
||||
}
|
||||
|
||||
void MainWindow::readUpdateableSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
useHex = settings.value("Main/UseHex", true).toBool();
|
||||
model->setHexMode(useHex);
|
||||
model->setSecondsMode(settings.value("Main/TimeSeconds", false).toBool());
|
||||
@@ -770,7 +783,11 @@ void MainWindow::gotDeviceInfo(int build, int swCAN)
|
||||
|
||||
void MainWindow::showSettingsDialog()
|
||||
{
|
||||
if (!settingsDialog) settingsDialog = new MainSettingsDialog();
|
||||
if (!settingsDialog)
|
||||
{
|
||||
settingsDialog = new MainSettingsDialog();
|
||||
connect(settingsDialog, SIGNAL(finished(int)), this, SLOT(updateSettings()));
|
||||
}
|
||||
settingsDialog->show();
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ private slots:
|
||||
|
||||
public slots:
|
||||
void gotFrames(int, int);
|
||||
void updateSettings();
|
||||
|
||||
|
||||
signals:
|
||||
@@ -81,6 +82,7 @@ signals:
|
||||
|
||||
//-1 = frames cleared, -2 = a new file has been loaded (so all frames are different), otherwise # of new frames
|
||||
void framesUpdated(int numFrames); //something has updated the frame list
|
||||
void settingsUpdated();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
@@ -120,6 +122,7 @@ private:
|
||||
void updateFileStatus();
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void readSettings();
|
||||
void readUpdateableSettings();
|
||||
void writeSettings();
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -30,6 +30,7 @@ class SerialWorker : public QObject
|
||||
public:
|
||||
SerialWorker(CANFrameModel *model, QObject *parent = 0);
|
||||
~SerialWorker();
|
||||
void readSettings();
|
||||
|
||||
signals: //we emit signals
|
||||
void error(const QString &);
|
||||
@@ -72,7 +73,6 @@ private:
|
||||
int deviceSingleWireMode;
|
||||
|
||||
void procRXChar(unsigned char);
|
||||
void readSettings();
|
||||
};
|
||||
|
||||
#endif // SERIALTHREAD_H
|
||||
|
||||
Reference in New Issue
Block a user