Skip to content

Commit

Permalink
Integrated help into the system. Most all the sub-screens that are ac…
Browse files Browse the repository at this point in the history
…tually complete

and working have integrated help now. Press F1 to bring up help for a given window.
  • Loading branch information
collin80 committed Dec 1, 2017
1 parent e112609 commit e48a7db
Show file tree
Hide file tree
Showing 39 changed files with 528 additions and 13 deletions.
11 changes: 7 additions & 4 deletions SavvyCAN.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand All @@ -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 +=

Expand Down
21 changes: 21 additions & 0 deletions bisectwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "mainwindow.h"
#include "framefileio.h"
#include "helpwindow.h"

#include <QDebug>
#include <algorithm>
Expand All @@ -23,10 +24,12 @@ BisectWindow::BisectWindow(const QVector<CANFrame> *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;
}

Expand All @@ -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<QKeyEvent *>(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;
Expand Down
1 change: 1 addition & 0 deletions bisectwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private slots:

void refreshIDList();
void refreshFrameNumbers();
bool eventFilter(QObject *obj, QEvent *event);
};

#endif // BISECTWINDOW_H
Expand Down
23 changes: 21 additions & 2 deletions connections/connectionwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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());
Expand All @@ -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<QKeyEvent *>(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;
Expand Down
1 change: 1 addition & 0 deletions connections/connectionwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ private slots:
void saveConnections();
void showEvent(QShowEvent *);
void closeEvent(QCloseEvent *event);
bool eventFilter(QObject *obj, QEvent *event);
void readSettings();
void writeSettings();
};
Expand Down
21 changes: 21 additions & 0 deletions frameplaybackwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QMenu>
#include <QSettings>
#include "connections/canconmanager.h"
#include "helpwindow.h"

/*
* Notes about new functionality:
Expand Down Expand Up @@ -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<QKeyEvent *>(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;
Expand Down
1 change: 1 addition & 0 deletions frameplaybackwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private slots:
void readSettings();
void writeSettings();
void calculateWhichBus();
bool eventFilter(QObject *obj, QEvent *event);
};

#endif // FRAMEPLAYBACKWINDOW_H
21 changes: 21 additions & 0 deletions framesenderwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QFileDialog>
#include <QDebug>
#include "mainwindow.h"
#include "helpwindow.h"
#include "connections/canconmanager.h"

/*
Expand Down Expand Up @@ -51,16 +52,36 @@ FrameSenderWindow::FrameSenderWindow(const QVector<CANFrame> *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<QKeyEvent *>(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();
Expand Down
1 change: 1 addition & 0 deletions framesenderwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ private slots:
void processCellChange(int line, int col);
void buildFrameCache();
void processIncomingFrame(CANFrame *frame);
bool eventFilter(QObject *obj, QEvent *event);
};

#endif // FRAMESENDERWINDOW_H
94 changes: 94 additions & 0 deletions helpwindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#include <QDebug>
#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;
}
*/
31 changes: 31 additions & 0 deletions helpwindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef HELPWINDOW_H
#define HELPWINDOW_H

#include <QDialog>
#include <QtHelp>

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
Loading

0 comments on commit e48a7db

Please sign in to comment.