From 9302c18c33575f694cc14af6a9af1a652ba62cd3 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Thu, 30 Nov 2017 21:02:16 -0500 Subject: [PATCH] Integrated help into the system. Most all the sub-screens that are actually complete and working have integrated help now. Press F1 to bring up help for a given window. --- SavvyCAN.pro | 11 ++-- bisectwindow.cpp | 21 +++++++ bisectwindow.h | 1 + connections/connectionwindow.cpp | 23 +++++++- connections/connectionwindow.h | 1 + frameplaybackwindow.cpp | 21 +++++++ frameplaybackwindow.h | 1 + framesenderwindow.cpp | 21 +++++++ framesenderwindow.h | 1 + helpwindow.cpp | 94 ++++++++++++++++++++++++++++++++ helpwindow.h | 31 +++++++++++ helpwindow.ui | 24 ++++++++ mainsettingsdialog.cpp | 22 ++++++++ mainsettingsdialog.h | 1 + mainwindow.cpp | 23 ++++++++ mainwindow.h | 1 + re/discretestatewindow.cpp | 21 +++++++ re/discretestatewindow.h | 1 + re/filecomparatorwindow.cpp | 23 +++++++- re/filecomparatorwindow.h | 1 + re/flowviewwindow.cpp | 4 ++ re/frameinfowindow.cpp | 21 +++++++ re/frameinfowindow.h | 1 + re/fuzzingwindow.cpp | 21 +++++++ re/fuzzingwindow.h | 1 + re/graphingwindow.cpp | 4 ++ re/isotp_interpreterwindow.cpp | 21 +++++++ re/isotp_interpreterwindow.h | 1 + re/newgraphdialog.cpp | 22 ++++++++ re/newgraphdialog.h | 2 + re/rangestatewindow.cpp | 22 ++++++++ re/rangestatewindow.h | 1 + re/sniffer/snifferwindow.cpp | 21 ++++++- re/sniffer/snifferwindow.h | 1 + re/udsscanwindow.cpp | 21 +++++++ re/udsscanwindow.h | 1 + scriptingwindow.cpp | 31 +++++++++-- scriptingwindow.h | 1 + signalviewerwindow.cpp | 1 + 39 files changed, 528 insertions(+), 13 deletions(-) create mode 100644 helpwindow.cpp create mode 100644 helpwindow.h create mode 100644 helpwindow.ui diff --git a/SavvyCAN.pro b/SavvyCAN.pro index 1ccb096..b9507cf 100644 --- a/SavvyCAN.pro +++ b/SavvyCAN.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT = core gui printsupport qml serialbus serialport widgets +QT = core gui printsupport qml serialbus serialport widgets help CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT @@ -63,7 +63,8 @@ SOURCES += main.cpp\ bus_protocols/j1939_handler.cpp \ bus_protocols/uds_handler.cpp \ jsedit.cpp \ - frameplaybackobject.cpp + frameplaybackobject.cpp \ + helpwindow.cpp HEADERS += mainwindow.h \ can_structs.h \ @@ -117,7 +118,8 @@ HEADERS += mainwindow.h \ bus_protocols/uds_handler.h \ bus_protocols/isotp_message.h \ jsedit.h \ - frameplaybackobject.h + frameplaybackobject.h \ + helpwindow.h FORMS += ui/candatagrid.ui \ ui/connectionwindow.ui \ @@ -143,7 +145,8 @@ FORMS += ui/candatagrid.ui \ ui/snifferwindow.ui \ ui/udsscanwindow.ui \ ui/bisectwindow.ui \ - ui/signalviewerwindow.ui + ui/signalviewerwindow.ui \ + helpwindow.ui DISTFILES += diff --git a/bisectwindow.cpp b/bisectwindow.cpp index 50c0400..fc01e76 100644 --- a/bisectwindow.cpp +++ b/bisectwindow.cpp @@ -3,6 +3,7 @@ #include "mainwindow.h" #include "framefileio.h" +#include "helpwindow.h" #include #include @@ -23,10 +24,12 @@ BisectWindow::BisectWindow(const QVector *frames, QWidget *parent) : connect(ui->slidePercentage, &QSlider::sliderReleased, this, &BisectWindow::updatePercentText); connect(ui->editFrameNumber, &QLineEdit::editingFinished, this, &BisectWindow::updateFrameNumSlider); connect(ui->editPercentage, &QLineEdit::editingFinished, this, &BisectWindow::updatePercentSlider); + installEventFilter(this); } BisectWindow::~BisectWindow() { + removeEventFilter(this); delete ui; } @@ -39,6 +42,24 @@ void BisectWindow::showEvent(QShowEvent* event) updatePercentText(); } +bool BisectWindow::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) + { + case Qt::Key_F1: + HelpWindow::getRef()->showHelp("bisector.html"); + break; + } + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } + return false; +} + void BisectWindow::refreshIDList() { int id; diff --git a/bisectwindow.h b/bisectwindow.h index 77f3ebc..a308428 100644 --- a/bisectwindow.h +++ b/bisectwindow.h @@ -39,6 +39,7 @@ private: void refreshIDList(); void refreshFrameNumbers(); + bool eventFilter(QObject *obj, QEvent *event); }; #endif // BISECTWINDOW_H diff --git a/connections/connectionwindow.cpp b/connections/connectionwindow.cpp index 6e9bd69..492a7aa 100644 --- a/connections/connectionwindow.cpp +++ b/connections/connectionwindow.cpp @@ -3,13 +3,12 @@ #include "connectionwindow.h" #include "mainwindow.h" +#include "helpwindow.h" #include "ui_connectionwindow.h" #include "connections/canconfactory.h" #include "connections/canconmanager.h" #include "canbus.h" - - ConnectionWindow::ConnectionWindow(QWidget *parent) : QDialog(parent), ui(new Ui::ConnectionWindow) @@ -88,6 +87,7 @@ void ConnectionWindow::showEvent(QShowEvent* event) { QDialog::showEvent(event); qDebug() << "Show connectionwindow"; + installEventFilter(this); readSettings(); ui->tableConnections->selectRow(0); currentRowChanged(ui->tableConnections->currentIndex(), ui->tableConnections->currentIndex()); @@ -97,9 +97,28 @@ void ConnectionWindow::showEvent(QShowEvent* event) void ConnectionWindow::closeEvent(QCloseEvent *event) { Q_UNUSED(event); + removeEventFilter(this); writeSettings(); } +bool ConnectionWindow::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) + { + case Qt::Key_F1: + HelpWindow::getRef()->showHelp("connectionwindow.html"); + break; + } + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } + return false; +} + void ConnectionWindow::readSettings() { QSettings settings; diff --git a/connections/connectionwindow.h b/connections/connectionwindow.h index 104cbab..24bd0a8 100644 --- a/connections/connectionwindow.h +++ b/connections/connectionwindow.h @@ -80,6 +80,7 @@ private: void saveConnections(); void showEvent(QShowEvent *); void closeEvent(QCloseEvent *event); + bool eventFilter(QObject *obj, QEvent *event); void readSettings(); void writeSettings(); }; diff --git a/frameplaybackwindow.cpp b/frameplaybackwindow.cpp index a44d661..7d74e24 100644 --- a/frameplaybackwindow.cpp +++ b/frameplaybackwindow.cpp @@ -5,6 +5,7 @@ #include #include #include "connections/canconmanager.h" +#include "helpwindow.h" /* * Notes about new functionality: @@ -93,14 +94,34 @@ FramePlaybackWindow::~FramePlaybackWindow() void FramePlaybackWindow::showEvent(QShowEvent *) { readSettings(); + installEventFilter(this); } void FramePlaybackWindow::closeEvent(QCloseEvent *event) { Q_UNUSED(event); + removeEventFilter(this); writeSettings(); } +bool FramePlaybackWindow::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) + { + case Qt::Key_F1: + HelpWindow::getRef()->showHelp("playbackwindow.html"); + break; + } + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } + return false; +} + void FramePlaybackWindow::readSettings() { QSettings settings; diff --git a/frameplaybackwindow.h b/frameplaybackwindow.h index 996ac55..64bb149 100644 --- a/frameplaybackwindow.h +++ b/frameplaybackwindow.h @@ -66,6 +66,7 @@ private: void readSettings(); void writeSettings(); void calculateWhichBus(); + bool eventFilter(QObject *obj, QEvent *event); }; #endif // FRAMEPLAYBACKWINDOW_H diff --git a/framesenderwindow.cpp b/framesenderwindow.cpp index 1108e20..4061e5e 100644 --- a/framesenderwindow.cpp +++ b/framesenderwindow.cpp @@ -5,6 +5,7 @@ #include #include #include "mainwindow.h" +#include "helpwindow.h" #include "connections/canconmanager.h" /* @@ -51,16 +52,36 @@ FrameSenderWindow::FrameSenderWindow(const QVector *frames, QWidget *p intervalTimer->start(); elapsedTimer.start(); + installEventFilter(this); } FrameSenderWindow::~FrameSenderWindow() { + removeEventFilter(this); delete ui; intervalTimer->stop(); delete intervalTimer; } +bool FrameSenderWindow::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) + { + case Qt::Key_F1: + HelpWindow::getRef()->showHelp("customsender.html"); + break; + } + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } + return false; +} + void FrameSenderWindow::createBlankRow() { int row = ui->tableSender->rowCount(); diff --git a/framesenderwindow.h b/framesenderwindow.h index 57642e8..fada888 100644 --- a/framesenderwindow.h +++ b/framesenderwindow.h @@ -53,6 +53,7 @@ private: void processCellChange(int line, int col); void buildFrameCache(); void processIncomingFrame(CANFrame *frame); + bool eventFilter(QObject *obj, QEvent *event); }; #endif // FRAMESENDERWINDOW_H diff --git a/helpwindow.cpp b/helpwindow.cpp new file mode 100644 index 0000000..a07eb5d --- /dev/null +++ b/helpwindow.cpp @@ -0,0 +1,94 @@ +#include +#include "helpwindow.h" +#include "ui_helpwindow.h" + +HelpWindow* HelpWindow::self = 0; + +HelpWindow::HelpWindow(QWidget *parent) : + QDialog(parent), + ui(new Ui::HelpWindow) +{ + ui->setupUi(this); + + m_helpEngine = new QHelpEngineCore("SavvyCAN.qhc", this); + if (!m_helpEngine->setupData()) { + delete m_helpEngine; + m_helpEngine = 0; + qDebug() << "Could not load help file!"; + } + + readSettings(); +} + +HelpWindow::~HelpWindow() +{ + writeSettings(); + delete ui; +} + +void HelpWindow::closeEvent(QCloseEvent *event) +{ + Q_UNUSED(event); + writeSettings(); +} + +void HelpWindow::readSettings() +{ + QSettings settings; + if (settings.value("Main/SaveRestorePositions", false).toBool()) + { + resize(settings.value("HelpViewer/WindowSize", QSize(600, 700)).toSize()); + move(settings.value("HelpViewer/WindowPos", QPoint(50, 50)).toPoint()); + } +} + +void HelpWindow::writeSettings() +{ + QSettings settings; + + if (settings.value("Main/SaveRestorePositions", false).toBool()) + { + settings.setValue("HelpViewer/WindowSize", size()); + settings.setValue("HelpViewer/WindowPos", pos()); + } +} + +HelpWindow* HelpWindow::getRef() +{ + if (!self) + { + self = new HelpWindow(); + } + + return self; +} + +void HelpWindow::showHelp(QString help) +{ + if (m_helpEngine) { + qDebug() << "Searching for " << help; + QByteArray helpData = m_helpEngine->fileData(QUrl("qthelp://org.sphinx.savvycan.181/doc/" + help)); + ui->textHelp->setText(helpData); + } + else + { + qDebug() << "Help engine not loaded!"; + } + + readSettings(); + self->show(); +} +/* + +QVariant HelpBrowser::loadResource(int type, const QUrl &name) +{ +QByteArray ba; +if (type < 4 && m_helpEngine) { + QUrl url(name); + if (name.isRelative()) + url = source().resolved(url); + ba = m_helpEngine->fileData(url); +} +return ba; +} +*/ diff --git a/helpwindow.h b/helpwindow.h new file mode 100644 index 0000000..b5a9ef0 --- /dev/null +++ b/helpwindow.h @@ -0,0 +1,31 @@ +#ifndef HELPWINDOW_H +#define HELPWINDOW_H + +#include +#include + +namespace Ui { +class HelpWindow; +} + +class HelpWindow : public QDialog +{ + Q_OBJECT + +public: + explicit HelpWindow(QWidget *parent = 0); + ~HelpWindow(); + void showHelp(QString help); + static HelpWindow *getRef(); + +private: + void readSettings(); + void writeSettings(); + void closeEvent(QCloseEvent *event); + + Ui::HelpWindow *ui; + static HelpWindow *self; + QHelpEngineCore *m_helpEngine; +}; + +#endif // HELPWINDOW_H diff --git a/helpwindow.ui b/helpwindow.ui new file mode 100644 index 0000000..bef250c --- /dev/null +++ b/helpwindow.ui @@ -0,0 +1,24 @@ + + + HelpWindow + + + + 0 + 0 + 600 + 700 + + + + SavvyCAN Help + + + + + + + + + + diff --git a/mainsettingsdialog.cpp b/mainsettingsdialog.cpp index a6189e9..baf66af 100644 --- a/mainsettingsdialog.cpp +++ b/mainsettingsdialog.cpp @@ -1,5 +1,6 @@ #include "mainsettingsdialog.h" #include "ui_mainsettingsdialog.h" +#include "helpwindow.h" MainSettingsDialog::MainSettingsDialog(QWidget *parent) : QDialog(parent), @@ -73,6 +74,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) : connect(ui->cbUseFiltered, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); connect(ui->lineClockFormat, SIGNAL(editingFinished()), this, SLOT(updateSettings())); connect(ui->cbUseOpenGL, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); + installEventFilter(this); } MainSettingsDialog::~MainSettingsDialog() @@ -84,9 +86,29 @@ MainSettingsDialog::~MainSettingsDialog() void MainSettingsDialog::closeEvent(QCloseEvent *event) { Q_UNUSED(event); + removeEventFilter(this); settings->sync(); } +bool MainSettingsDialog::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) + { + case Qt::Key_F1: + HelpWindow::getRef()->showHelp("preferences.html"); + break; + } + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } + return false; +} + + void MainSettingsDialog::updateSettings() { settings->setValue("Main/UseHex", ui->cbDisplayHex->isChecked()); diff --git a/mainsettingsdialog.h b/mainsettingsdialog.h index 62c24c9..7d375b0 100644 --- a/mainsettingsdialog.h +++ b/mainsettingsdialog.h @@ -27,6 +27,7 @@ private: QSettings *settings; void closeEvent(QCloseEvent *event); + bool eventFilter(QObject *obj, QEvent *event); }; #endif // MAINSETTINGSDIALOG_H diff --git a/mainwindow.cpp b/mainwindow.cpp index 964ed54..fb08d4c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -6,6 +6,7 @@ #include #include "connections/canconmanager.h" #include "connections/connectionwindow.h" +#include "helpwindow.h" #include "utility.h" /* @@ -130,6 +131,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->actionSignal_Viewer, &QAction::triggered, this, &MainWindow::showSignalViewer); connect(ui->actionSave_Continuous_Logfile, &QAction::triggered, this, &MainWindow::handleContinousLogging); + connect(CANConManager::getInstance(), &CANConManager::framesReceived, model, &CANFrameModel::addFrames); lbStatusConnected.setText(tr("Connected to 0 buses")); @@ -171,6 +173,7 @@ MainWindow::MainWindow(QWidget *parent) : connectionWindow = new ConnectionWindow(); connect(this, SIGNAL(suspendCapturing(bool)), connectionWindow, SLOT(setSuspendAll(bool))); + installEventFilter(this); } MainWindow::~MainWindow() @@ -235,10 +238,30 @@ void MainWindow::exitApp() void MainWindow::closeEvent(QCloseEvent *event) { Q_UNUSED(event); + removeEventFilter(this); writeSettings(); exitApp(); } +bool MainWindow::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) + { + case Qt::Key_F1: + HelpWindow::getRef()->showHelp("mainscreen.html"); + break; + } + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } + return false; +} + + void MainWindow::updateSettings() { readUpdateableSettings(); diff --git a/mainwindow.h b/mainwindow.h index fffe39f..5814211 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -176,6 +176,7 @@ private: void killWindow(QDialog *win); void readSettings(); void writeSettings(); + bool eventFilter(QObject *obj, QEvent *event); }; #endif // MAINWINDOW_H diff --git a/re/discretestatewindow.cpp b/re/discretestatewindow.cpp index 82a03c9..5828a4b 100644 --- a/re/discretestatewindow.cpp +++ b/re/discretestatewindow.cpp @@ -1,6 +1,7 @@ #include "discretestatewindow.h" #include "ui_discretestatewindow.h" #include "mainwindow.h" +#include "helpwindow.h" DiscreteStateWindow::DiscreteStateWindow(const QVector *frames, QWidget *parent) : QDialog(parent), @@ -55,10 +56,12 @@ DiscreteStateWindow::DiscreteStateWindow(const QVector *frames, QWidge }); refreshFilterList(); + installEventFilter(this); } DiscreteStateWindow::~DiscreteStateWindow() { + removeEventFilter(this); timer->stop(); for (int i = 0; i < stateFrames.count(); i++) @@ -71,6 +74,24 @@ DiscreteStateWindow::~DiscreteStateWindow() delete ui; } +bool DiscreteStateWindow::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) + { + case Qt::Key_F1: + HelpWindow::getRef()->showHelp("discretestate.html"); + break; + } + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } + return false; +} + void DiscreteStateWindow::typeChanged() { if (ui->rbLogged->isChecked()) diff --git a/re/discretestatewindow.h b/re/discretestatewindow.h index e027cca..8e05ef4 100644 --- a/re/discretestatewindow.h +++ b/re/discretestatewindow.h @@ -53,6 +53,7 @@ private: void refreshFilterList(); void closeEvent(QCloseEvent *event); + bool eventFilter(QObject *obj, QEvent *event); void readSettings(); void writeSettings(); void updateStateLabel(); diff --git a/re/filecomparatorwindow.cpp b/re/filecomparatorwindow.cpp index 9ab25f4..1ce1b85 100644 --- a/re/filecomparatorwindow.cpp +++ b/re/filecomparatorwindow.cpp @@ -1,6 +1,6 @@ #include "filecomparatorwindow.h" #include "ui_filecomparatorwindow.h" - +#include "helpwindow.h" #include FileComparatorWindow::FileComparatorWindow(QWidget *parent) : @@ -16,10 +16,13 @@ FileComparatorWindow::FileComparatorWindow(QWidget *parent) : ui->lblFirstFile->setText(""); ui->lblRefFrames->setText("0"); + + installEventFilter(this); } FileComparatorWindow::~FileComparatorWindow() { + removeEventFilter(this); delete ui; } @@ -34,6 +37,24 @@ void FileComparatorWindow::closeEvent(QCloseEvent *event) writeSettings(); } +bool FileComparatorWindow::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) + { + case Qt::Key_F1: + HelpWindow::getRef()->showHelp("filecomparison.html"); + break; + } + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } + return false; +} + void FileComparatorWindow::readSettings() { QSettings settings; diff --git a/re/filecomparatorwindow.h b/re/filecomparatorwindow.h index 8d678e7..d348255 100644 --- a/re/filecomparatorwindow.h +++ b/re/filecomparatorwindow.h @@ -43,6 +43,7 @@ private: void calculateDetails(); void showEvent(QShowEvent *); void closeEvent(QCloseEvent *event); + bool eventFilter(QObject *obj, QEvent *event); void readSettings(); void writeSettings(); }; diff --git a/re/flowviewwindow.cpp b/re/flowviewwindow.cpp index e3514b1..f0a87a7 100644 --- a/re/flowviewwindow.cpp +++ b/re/flowviewwindow.cpp @@ -1,6 +1,7 @@ #include "flowviewwindow.h" #include "ui_flowviewwindow.h" #include "mainwindow.h" +#include "helpwindow.h" const QColor FlowViewWindow::graphColors[8] = {Qt::blue, Qt::green, Qt::black, Qt::red, //0 1 2 3 Qt::gray, Qt::yellow, Qt::cyan, Qt::darkMagenta}; //4 5 6 7 @@ -193,6 +194,9 @@ bool FlowViewWindow::eventFilter(QObject *obj, QEvent *event) case Qt::Key_Y: btnFwdOneClick(); break; + case Qt::Key_F1: + HelpWindow::getRef()->showHelp("flowview.html"); + break; } return true; } else { diff --git a/re/frameinfowindow.cpp b/re/frameinfowindow.cpp index 53fdae7..b4461b0 100644 --- a/re/frameinfowindow.cpp +++ b/re/frameinfowindow.cpp @@ -1,6 +1,7 @@ #include "frameinfowindow.h" #include "ui_frameinfowindow.h" #include "mainwindow.h" +#include "helpwindow.h" #include FrameInfoWindow::FrameInfoWindow(const QVector *frames, QWidget *parent) : @@ -42,6 +43,7 @@ FrameInfoWindow::FrameInfoWindow(const QVector *frames, QWidget *paren ui->graphHistogram->setAntialiasedElements(QCP::aeNone); } + installEventFilter(this); } void FrameInfoWindow::showEvent(QShowEvent* event) @@ -56,8 +58,27 @@ void FrameInfoWindow::showEvent(QShowEvent* event) } } +bool FrameInfoWindow::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) + { + case Qt::Key_F1: + HelpWindow::getRef()->showHelp("framedetails.html"); + break; + } + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } + return false; +} + FrameInfoWindow::~FrameInfoWindow() { + removeEventFilter(this); delete ui; } diff --git a/re/frameinfowindow.h b/re/frameinfowindow.h index a841de4..0f38edc 100644 --- a/re/frameinfowindow.h +++ b/re/frameinfowindow.h @@ -36,6 +36,7 @@ private: void refreshIDList(); void closeEvent(QCloseEvent *event); + bool eventFilter(QObject *obj, QEvent *event); void readSettings(); void writeSettings(); void dumpNode(QTreeWidgetItem* item, QFile *file, int indent); diff --git a/re/fuzzingwindow.cpp b/re/fuzzingwindow.cpp index 6d96e68..58e6ec0 100644 --- a/re/fuzzingwindow.cpp +++ b/re/fuzzingwindow.cpp @@ -3,6 +3,7 @@ #include "utility.h" #include #include "mainwindow.h" +#include "helpwindow.h" #include "connections/canconmanager.h" FuzzingWindow::FuzzingWindow(const QVector *frames, QWidget *parent) : @@ -41,13 +42,33 @@ FuzzingWindow::FuzzingWindow(const QVector *frames, QWidget *parent) : for (int n = 0; n < numBuses; n++) ui->cbBuses->addItem(QString::number(n)); ui->cbBuses->addItem(tr("All")); + installEventFilter(this); } FuzzingWindow::~FuzzingWindow() { + removeEventFilter(this); delete ui; } +bool FuzzingWindow::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) + { + case Qt::Key_F1: + HelpWindow::getRef()->showHelp("fuzzingwindow.html"); + break; + } + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } + return false; +} + void FuzzingWindow::updatedFrames(int numFrames) { int id; diff --git a/re/fuzzingwindow.h b/re/fuzzingwindow.h index 724d84c..d920bc3 100644 --- a/re/fuzzingwindow.h +++ b/re/fuzzingwindow.h @@ -64,6 +64,7 @@ private: void calcNextID(); void calcNextBitPattern(); void redrawGrid(); + bool eventFilter(QObject *obj, QEvent *event); }; #endif // FUZZINGWINDOW_H diff --git a/re/graphingwindow.cpp b/re/graphingwindow.cpp index 0370071..ec97149 100644 --- a/re/graphingwindow.cpp +++ b/re/graphingwindow.cpp @@ -2,6 +2,7 @@ #include "ui_graphingwindow.h" #include "newgraphdialog.h" #include "mainwindow.h" +#include "helpwindow.h" #include GraphingWindow::GraphingWindow(const QVector *frames, QWidget *parent) : @@ -397,6 +398,9 @@ bool GraphingWindow::eventFilter(QObject *obj, QEvent *event) case Qt::Key_Minus: zoomOut(); break; + case Qt::Key_F1: + HelpWindow::getRef()->showHelp("graphwindow.html"); + break; } return true; } else if (event->type() == QEvent::TouchBegin) diff --git a/re/isotp_interpreterwindow.cpp b/re/isotp_interpreterwindow.cpp index 0393ce6..8fba992 100644 --- a/re/isotp_interpreterwindow.cpp +++ b/re/isotp_interpreterwindow.cpp @@ -1,6 +1,7 @@ #include "isotp_interpreterwindow.h" #include "ui_isotp_interpreterwindow.h" #include "mainwindow.h" +#include "helpwindow.h" ISOTP_InterpreterWindow::ISOTP_InterpreterWindow(const QVector *frames, QWidget *parent) : QDialog(parent), @@ -60,14 +61,34 @@ void ISOTP_InterpreterWindow::showEvent(QShowEvent* event) QDialog::showEvent(event); readSettings(); decoder->updatedFrames(-2); + installEventFilter(this); } void ISOTP_InterpreterWindow::closeEvent(QCloseEvent *event) { Q_UNUSED(event); + removeEventFilter(this); writeSettings(); } +bool ISOTP_InterpreterWindow::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) + { + case Qt::Key_F1: + HelpWindow::getRef()->showHelp("isotp_decoder.html"); + break; + } + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } + return false; +} + void ISOTP_InterpreterWindow::readSettings() { QSettings settings; diff --git a/re/isotp_interpreterwindow.h b/re/isotp_interpreterwindow.h index 753347f..14167de 100644 --- a/re/isotp_interpreterwindow.h +++ b/re/isotp_interpreterwindow.h @@ -43,6 +43,7 @@ private: QHash idFilters; void closeEvent(QCloseEvent *event); + bool eventFilter(QObject *obj, QEvent *event); void readSettings(); void writeSettings(); diff --git a/re/newgraphdialog.cpp b/re/newgraphdialog.cpp index 6807152..0297a39 100644 --- a/re/newgraphdialog.cpp +++ b/re/newgraphdialog.cpp @@ -2,6 +2,7 @@ #include "ui_newgraphdialog.h" #include #include "utility.h" +#include "helpwindow.h" NewGraphDialog::NewGraphDialog(DBCHandler *handler, QWidget *parent) : QDialog(parent), @@ -33,10 +34,13 @@ NewGraphDialog::NewGraphDialog(DBCHandler *handler, QWidget *parent) : dataLen = 1; loadMessages(); + + installEventFilter(this); } NewGraphDialog::~NewGraphDialog() { + removeEventFilter(this); delete ui; } @@ -48,6 +52,24 @@ void NewGraphDialog::showEvent(QShowEvent* event) qDebug() << "S" << ui->gridData->geometry(); } +bool NewGraphDialog::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) + { + case Qt::Key_F1: + HelpWindow::getRef()->showHelp("graphsetup.html"); + break; + } + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } + return false; +} + void NewGraphDialog::addButtonClicked() { accept(); diff --git a/re/newgraphdialog.h b/re/newgraphdialog.h index 85ce74c..365456d 100644 --- a/re/newgraphdialog.h +++ b/re/newgraphdialog.h @@ -32,6 +32,8 @@ private slots: void copySignalToParamsUI(); private: + bool eventFilter(QObject *obj, QEvent *event); + Ui::NewGraphDialog *ui; DBCHandler *dbcHandler; int startBit, dataLen; diff --git a/re/rangestatewindow.cpp b/re/rangestatewindow.cpp index 16d1b4b..511e9ab 100644 --- a/re/rangestatewindow.cpp +++ b/re/rangestatewindow.cpp @@ -2,6 +2,7 @@ #include "ui_rangestatewindow.h" #include "mainwindow.h" #include "utility.h" +#include "helpwindow.h" RangeStateWindow::RangeStateWindow(const QVector *frames, QWidget *parent) : QDialog(parent), @@ -88,14 +89,35 @@ void RangeStateWindow::showEvent(QShowEvent* event) readSettings(); refreshFilterList(); + + installEventFilter(this); } void RangeStateWindow::closeEvent(QCloseEvent *event) { Q_UNUSED(event); + removeEventFilter(this); writeSettings(); } +bool RangeStateWindow::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) + { + case Qt::Key_F1: + HelpWindow::getRef()->showHelp("rangestate.html"); + break; + } + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } + return false; +} + void RangeStateWindow::readSettings() { QSettings settings; diff --git a/re/rangestatewindow.h b/re/rangestatewindow.h index 4f59457..193e052 100644 --- a/re/rangestatewindow.h +++ b/re/rangestatewindow.h @@ -36,6 +36,7 @@ private: void signalsFactory(); bool processSignal(int startBit, int bitLength, int sensitivity, bool bigEndian, bool isSigned); void createGraph(QVector values); + bool eventFilter(QObject *obj, QEvent *event); }; #endif // RANGESTATEWINDOW_H diff --git a/re/sniffer/snifferwindow.cpp b/re/sniffer/snifferwindow.cpp index cab2a88..685a850 100644 --- a/re/sniffer/snifferwindow.cpp +++ b/re/sniffer/snifferwindow.cpp @@ -2,6 +2,7 @@ #include #include "snifferwindow.h" #include "ui_snifferwindow.h" +#include "helpwindow.h" #include "connections/canconmanager.h" SnifferWindow::SnifferWindow(QWidget *parent) : @@ -50,7 +51,7 @@ void SnifferWindow::showEvent(QShowEvent* event) QDialog::showEvent(event); connect(CANConManager::getInstance(), &CANConManager::framesReceived, &mModel, &SnifferModel::update); mTimer.start(); - + installEventFilter(this); qDebug() << "show"; } @@ -69,8 +70,26 @@ void SnifferWindow::closeEvent(QCloseEvent *event) mMap.clear(); /* reset filtering */ mFilter = false; + removeEventFilter(this); } +bool SnifferWindow::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) + { + case Qt::Key_F1: + HelpWindow::getRef()->showHelp("sniffer.html"); + break; + } + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } + return false; +} void SnifferWindow::update() { diff --git a/re/sniffer/snifferwindow.h b/re/sniffer/snifferwindow.h index 2d2cb1d..cebd059 100644 --- a/re/sniffer/snifferwindow.h +++ b/re/sniffer/snifferwindow.h @@ -45,6 +45,7 @@ public slots: private: void filter(bool pFilter); + bool eventFilter(QObject *obj, QEvent *event); Ui::snifferWindow* ui; SnifferModel mModel; diff --git a/re/udsscanwindow.cpp b/re/udsscanwindow.cpp index e138950..619691b 100644 --- a/re/udsscanwindow.cpp +++ b/re/udsscanwindow.cpp @@ -4,6 +4,7 @@ #include "connections/canconmanager.h" #include "bus_protocols/uds_handler.h" #include "utility.h" +#include "helpwindow.h" UDSScanWindow::UDSScanWindow(const QVector *frames, QWidget *parent) : QDialog(parent), @@ -39,16 +40,36 @@ UDSScanWindow::UDSScanWindow(const QVector *frames, QWidget *parent) : int numBuses = CANConManager::getInstance()->getNumBuses(); for (int n = 0; n < numBuses; n++) ui->cbBuses->addItem(QString::number(n)); + installEventFilter(this); } UDSScanWindow::~UDSScanWindow() { + removeEventFilter(this); delete ui; waitTimer->stop(); delete waitTimer; delete udsHandler; } +bool UDSScanWindow::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) + { + case Qt::Key_F1: + HelpWindow::getRef()->showHelp("uds_scanner.html"); + break; + } + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } + return false; +} + void UDSScanWindow::adaptiveToggled() { if (ui->cbAllowAdaptiveOffset->isChecked()) ui->spinReplyOffset->setEnabled(false); diff --git a/re/udsscanwindow.h b/re/udsscanwindow.h index 35629a6..6b7d022 100644 --- a/re/udsscanwindow.h +++ b/re/udsscanwindow.h @@ -51,5 +51,6 @@ private: void sendOnBuses(UDS_MESSAGE frame, int buses); void setupNodes(); void dumpNode(QTreeWidgetItem* item, QFile *file, int indent); + bool eventFilter(QObject *obj, QEvent *event); }; #endif // UDSSCANWINDOW_H diff --git a/scriptingwindow.cpp b/scriptingwindow.cpp index c71c5a1..1ea6e36 100644 --- a/scriptingwindow.cpp +++ b/scriptingwindow.cpp @@ -6,6 +6,7 @@ #include #include "connections/canconmanager.h" +#include "helpwindow.h" ScriptingWindow::ScriptingWindow(const QVector *frames, QWidget *parent) : QDialog(parent), @@ -88,12 +89,37 @@ void ScriptingWindow::updatedValue(int row, int col) } } +void ScriptingWindow::showEvent(QShowEvent* event) +{ + QDialog::showEvent(event); + installEventFilter(this); +} + void ScriptingWindow::closeEvent(QCloseEvent *event) { Q_UNUSED(event); + removeEventFilter(this); writeSettings(); } +bool ScriptingWindow::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) + { + case Qt::Key_F1: + HelpWindow::getRef()->showHelp("scriptingwindow.html"); + break; + } + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } + return false; +} + void ScriptingWindow::readSettings() { QSettings settings; @@ -115,11 +141,6 @@ void ScriptingWindow::writeSettings() } } -void ScriptingWindow::showEvent(QShowEvent* event) -{ - QDialog::showEvent(event); -} - void ScriptingWindow::changeCurrentScript() { ui->tableVariables->clear(); diff --git a/scriptingwindow.h b/scriptingwindow.h index fbdad5a..156a72e 100644 --- a/scriptingwindow.h +++ b/scriptingwindow.h @@ -49,6 +49,7 @@ private: void closeEvent(QCloseEvent *event); void readSettings(); void writeSettings(); + bool eventFilter(QObject *obj, QEvent *event); Ui::ScriptingWindow *ui; JSEdit *editor; diff --git a/signalviewerwindow.cpp b/signalviewerwindow.cpp index 49c2440..e67ab55 100644 --- a/signalviewerwindow.cpp +++ b/signalviewerwindow.cpp @@ -1,5 +1,6 @@ #include "signalviewerwindow.h" #include "ui_signalviewerwindow.h" +#include "helpwindow.h" SignalViewerWindow::SignalViewerWindow(QWidget *parent) : QDialog(parent),