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:
Collin Kidder
2015-07-05 13:27:16 -04:00
parent e8ccb5970f
commit 04e7a570e2
11 changed files with 66 additions and 11 deletions
+5 -2
View File
@@ -9,8 +9,6 @@ FileComparatorWindow::FileComparatorWindow(QWidget *parent) :
{ {
ui->setupUi(this); ui->setupUi(this);
readSettings();
connect(ui->btnFirstFile, SIGNAL(clicked(bool)), this, SLOT(loadFirstFile())); connect(ui->btnFirstFile, SIGNAL(clicked(bool)), this, SLOT(loadFirstFile()));
connect(ui->btnSecondFile, SIGNAL(clicked(bool)), this, SLOT(loadSecondFile())); connect(ui->btnSecondFile, SIGNAL(clicked(bool)), this, SLOT(loadSecondFile()));
connect(ui->btnSaveDetails, SIGNAL(clicked(bool)), this, SLOT(saveDetails())); connect(ui->btnSaveDetails, SIGNAL(clicked(bool)), this, SLOT(saveDetails()));
@@ -24,6 +22,11 @@ FileComparatorWindow::~FileComparatorWindow()
delete ui; delete ui;
} }
void FileComparatorWindow::showEvent(QShowEvent *)
{
readSettings();
}
void FileComparatorWindow::closeEvent(QCloseEvent *event) void FileComparatorWindow::closeEvent(QCloseEvent *event)
{ {
writeSettings(); writeSettings();
+1
View File
@@ -41,6 +41,7 @@ private:
QString secondFilename; QString secondFilename;
void calculateDetails(); void calculateDetails();
void showEvent(QShowEvent *);
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
void readSettings(); void readSettings();
void writeSettings(); void writeSettings();
+28 -6
View File
@@ -83,6 +83,9 @@ FlowViewWindow::FlowViewWindow(const QVector<CANFrame> *frames, QWidget *parent)
void FlowViewWindow::showEvent(QShowEvent* event) void FlowViewWindow::showEvent(QShowEvent* event)
{ {
QDialog::showEvent(event); QDialog::showEvent(event);
readSettings();
refreshIDList(); refreshIDList();
if (ui->listFrameID->count() > 0) if (ui->listFrameID->count() > 0)
{ {
@@ -124,6 +127,8 @@ void FlowViewWindow::readSettings()
{ {
ui->cbTimeGraph->setChecked(true); ui->cbTimeGraph->setChecked(true);
} }
secondsMode = settings.value("Main/TimeSeconds", false).toBool();
} }
void FlowViewWindow::writeSettings() void FlowViewWindow::writeSettings()
@@ -260,7 +265,13 @@ void FlowViewWindow::createGraph(int byteNum)
if (graphByTime) if (graphByTime)
{ {
x[j] = frameCache[j].timestamp; if (secondsMode){
x[j] = (double)(frameCache[j].timestamp) / 1000000.0;
}
else
{
x[j] = frameCache[j].timestamp;
}
} }
else else
{ {
@@ -487,11 +498,22 @@ void FlowViewWindow::updateGraphLocation()
if (end >= frameCache.count()) end = frameCache.count() - 1; if (end >= frameCache.count()) end = frameCache.count() - 1;
if (ui->cbTimeGraph->isChecked()) if (ui->cbTimeGraph->isChecked())
{ {
ui->graphView->xAxis->setRange(frameCache[start].timestamp, frameCache[end].timestamp); if (secondsMode)
ui->graphView->xAxis->setTickStep((frameCache[end].timestamp - frameCache[start].timestamp)/ 3.0); {
ui->graphView->xAxis->setSubTickCount(0); ui->graphView->xAxis->setRange(frameCache[start].timestamp / 1000000.0, frameCache[end].timestamp / 1000000.0);
ui->graphView->xAxis->setNumberFormat("f"); ui->graphView->xAxis->setTickStep((frameCache[end].timestamp - frameCache[start].timestamp)/ 3000000.0);
ui->graphView->xAxis->setNumberPrecision(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 else
{ {
+1
View File
@@ -46,6 +46,7 @@ private:
bool playbackActive; bool playbackActive;
bool playbackForward; bool playbackForward;
static const QColor graphColors[8]; static const QColor graphColors[8];
bool secondsMode;
void refreshIDList(); void refreshIDList();
void updateFrameLabel(); void updateFrameLabel();
+1
View File
@@ -20,6 +20,7 @@ FrameInfoWindow::FrameInfoWindow(const QVector<CANFrame> *frames, QWidget *paren
void FrameInfoWindow::showEvent(QShowEvent* event) void FrameInfoWindow::showEvent(QShowEvent* event)
{ {
QDialog::showEvent(event); QDialog::showEvent(event);
readSettings();
refreshIDList(); refreshIDList();
if (ui->listFrameID->count() > 0) if (ui->listFrameID->count() > 0)
{ {
+5
View File
@@ -84,6 +84,11 @@ FramePlaybackWindow::~FramePlaybackWindow()
delete playbackTimer; delete playbackTimer;
} }
void FramePlaybackWindow::showEvent(QShowEvent *)
{
readSettings();
}
void FramePlaybackWindow::closeEvent(QCloseEvent *event) void FramePlaybackWindow::closeEvent(QCloseEvent *event)
{ {
writeSettings(); writeSettings();
+1
View File
@@ -72,6 +72,7 @@ private:
void updateFrameLabel(); void updateFrameLabel();
void updatePosition(bool forward); void updatePosition(bool forward);
void fillIDHash(SequenceItem &item); void fillIDHash(SequenceItem &item);
void showEvent(QShowEvent *);
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
void readSettings(); void readSettings();
void writeSettings(); void writeSettings();
+1
View File
@@ -72,6 +72,7 @@ GraphingWindow::~GraphingWindow()
void GraphingWindow::showEvent(QShowEvent* event) void GraphingWindow::showEvent(QShowEvent* event)
{ {
QDialog::showEvent(event); QDialog::showEvent(event);
readSettings();
ui->graphingView->replot(); ui->graphingView->replot();
} }
+18 -1
View File
@@ -101,6 +101,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(this, &MainWindow::closeSerialPort, worker, &SerialWorker::closeSerialPort, Qt::QueuedConnection); connect(this, &MainWindow::closeSerialPort, worker, &SerialWorker::closeSerialPort, Qt::QueuedConnection);
connect(this, &MainWindow::startFrameCapturing, worker, &SerialWorker::startFrameCapture); connect(this, &MainWindow::startFrameCapturing, worker, &SerialWorker::startFrameCapture);
connect(this, &MainWindow::stopFrameCapturing, worker, &SerialWorker::stopFrameCapture); connect(this, &MainWindow::stopFrameCapturing, worker, &SerialWorker::stopFrameCapture);
connect(this, &MainWindow::settingsUpdated, worker, &SerialWorker::readSettings);
serialWorkerThread.start(); serialWorkerThread.start();
serialWorkerThread.setPriority(QThread::HighPriority); serialWorkerThread.setPriority(QThread::HighPriority);
@@ -237,6 +238,12 @@ void MainWindow::closeEvent(QCloseEvent *event)
exitApp(); exitApp();
} }
void MainWindow::updateSettings()
{
readUpdateableSettings();
emit settingsUpdated();
}
void MainWindow::readSettings() void MainWindow::readSettings()
{ {
QSettings settings; QSettings settings;
@@ -249,6 +256,12 @@ void MainWindow::readSettings()
{ {
ui->cbAutoScroll->setChecked(true); ui->cbAutoScroll->setChecked(true);
} }
readUpdateableSettings();
}
void MainWindow::readUpdateableSettings()
{
QSettings settings;
useHex = settings.value("Main/UseHex", true).toBool(); useHex = settings.value("Main/UseHex", true).toBool();
model->setHexMode(useHex); model->setHexMode(useHex);
model->setSecondsMode(settings.value("Main/TimeSeconds", false).toBool()); model->setSecondsMode(settings.value("Main/TimeSeconds", false).toBool());
@@ -770,7 +783,11 @@ void MainWindow::gotDeviceInfo(int build, int swCAN)
void MainWindow::showSettingsDialog() void MainWindow::showSettingsDialog()
{ {
if (!settingsDialog) settingsDialog = new MainSettingsDialog(); if (!settingsDialog)
{
settingsDialog = new MainSettingsDialog();
connect(settingsDialog, SIGNAL(finished(int)), this, SLOT(updateSettings()));
}
settingsDialog->show(); settingsDialog->show();
} }
+3
View File
@@ -69,6 +69,7 @@ private slots:
public slots: public slots:
void gotFrames(int, int); void gotFrames(int, int);
void updateSettings();
signals: 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 //-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 framesUpdated(int numFrames); //something has updated the frame list
void settingsUpdated();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
@@ -120,6 +122,7 @@ private:
void updateFileStatus(); void updateFileStatus();
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
void readSettings(); void readSettings();
void readUpdateableSettings();
void writeSettings(); void writeSettings();
}; };
+1 -1
View File
@@ -30,6 +30,7 @@ class SerialWorker : public QObject
public: public:
SerialWorker(CANFrameModel *model, QObject *parent = 0); SerialWorker(CANFrameModel *model, QObject *parent = 0);
~SerialWorker(); ~SerialWorker();
void readSettings();
signals: //we emit signals signals: //we emit signals
void error(const QString &); void error(const QString &);
@@ -72,7 +73,6 @@ private:
int deviceSingleWireMode; int deviceSingleWireMode;
void procRXChar(unsigned char); void procRXChar(unsigned char);
void readSettings();
}; };
#endif // SERIALTHREAD_H #endif // SERIALTHREAD_H