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);
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();
+1
View File
@@ -41,6 +41,7 @@ private:
QString secondFilename;
void calculateDetails();
void showEvent(QShowEvent *);
void closeEvent(QCloseEvent *event);
void readSettings();
void writeSettings();
+22
View File
@@ -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()
@@ -259,9 +264,15 @@ void FlowViewWindow::createGraph(int byteNum)
tempVal = frameCache[j].data[byteNum];
if (graphByTime)
{
if (secondsMode){
x[j] = (double)(frameCache[j].timestamp) / 1000000.0;
}
else
{
x[j] = frameCache[j].timestamp;
}
}
else
{
x[j] = j;
@@ -486,6 +497,16 @@ void FlowViewWindow::updateGraphLocation()
int end = currentPosition + 5;
if (end >= frameCache.count()) end = frameCache.count() - 1;
if (ui->cbTimeGraph->isChecked())
{
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);
@@ -493,6 +514,7 @@ void FlowViewWindow::updateGraphLocation()
ui->graphView->xAxis->setNumberFormat("f");
ui->graphView->xAxis->setNumberPrecision(0);
}
}
else
{
ui->graphView->xAxis->setRange(start, end);
+1
View File
@@ -46,6 +46,7 @@ private:
bool playbackActive;
bool playbackForward;
static const QColor graphColors[8];
bool secondsMode;
void refreshIDList();
void updateFrameLabel();
+1
View File
@@ -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)
{
+5
View File
@@ -84,6 +84,11 @@ FramePlaybackWindow::~FramePlaybackWindow()
delete playbackTimer;
}
void FramePlaybackWindow::showEvent(QShowEvent *)
{
readSettings();
}
void FramePlaybackWindow::closeEvent(QCloseEvent *event)
{
writeSettings();
+1
View File
@@ -72,6 +72,7 @@ private:
void updateFrameLabel();
void updatePosition(bool forward);
void fillIDHash(SequenceItem &item);
void showEvent(QShowEvent *);
void closeEvent(QCloseEvent *event);
void readSettings();
void writeSettings();
+1
View File
@@ -72,6 +72,7 @@ GraphingWindow::~GraphingWindow()
void GraphingWindow::showEvent(QShowEvent* event)
{
QDialog::showEvent(event);
readSettings();
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::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();
}
+3
View File
@@ -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
View File
@@ -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