Support for keyboard based control of FlowView (Q,W,E)

This commit is contained in:
Collin Kidder
2015-09-13 17:51:34 -04:00
parent b80b6f1234
commit 4177b8524b
2 changed files with 33 additions and 1 deletions
+32 -1
View File
@@ -10,7 +10,7 @@ FlowViewWindow::FlowViewWindow(const QVector<CANFrame> *frames, QWidget *parent)
QDialog(parent),
ui(new Ui::FlowViewWindow)
{
ui->setupUi(this);
ui->setupUi(this);
readSettings();
@@ -79,6 +79,7 @@ FlowViewWindow::FlowViewWindow(const QVector<CANFrame> *frames, QWidget *parent)
playbackTimer->setInterval(ui->spinPlayback->value()); //set the timer to the default value of the control
installEventFilter(this);
}
void FlowViewWindow::showEvent(QShowEvent* event)
@@ -144,6 +145,36 @@ void FlowViewWindow::writeSettings()
}
}
/*
* Keyboard shortcuts to allow for quick work without needing to move around a mouse.
* E = resume or pause playback
* Q = go back one frame
* W = go forward one frame
*/
bool FlowViewWindow::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::KeyRelease) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
switch (keyEvent->key())
{
case Qt::Key_E:
if (playbackActive) btnPauseClick();
else btnPlayClick();
break;
case Qt::Key_Q:
btnBackOneClick();
break;
case Qt::Key_W:
btnFwdOneClick();
break;
}
return true;
} else {
// standard event processing
return QObject::eventFilter(obj, event);
}
}
void FlowViewWindow::plottableDoubleClick(QCPAbstractPlottable* plottable, QMouseEvent* event)
{
int id = 0;
+1
View File
@@ -64,6 +64,7 @@ private:
void closeEvent(QCloseEvent *event);
void readSettings();
void writeSettings();
bool eventFilter(QObject *obj, QEvent *event);
};
#endif // FLOWVIEWWINDOW_H