From 03a3ca423d3d508853fccd0a204e902aea99a4e9 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Mon, 20 Apr 2020 21:10:20 -0700 Subject: [PATCH] Added preliminary mouse scrolling support for the waterfall and plot area. As it stands, scrolling basically rotates the tuning knob. No modifier keys are supported yet, but we'll get there! --- wfmain.cpp | 20 ++++++++++++++++++++ wfmain.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/wfmain.cpp b/wfmain.cpp index c1bcbf7..9e3e093 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -270,6 +270,9 @@ wfmain::wfmain(QWidget *parent) : connect(wf, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, SLOT(handleWFDoubleClick(QMouseEvent*))); connect(plot, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(handlePlotClick(QMouseEvent*))); connect(wf, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(handleWFClick(QMouseEvent*))); + connect(wf, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(handleWFScroll(QWheelEvent*))); + connect(plot, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(handlePlotScroll(QWheelEvent*))); + ui->plot->addGraph(); // primary ui->plot->addGraph(0, 0); // secondary, peaks, same axis as first? @@ -1100,6 +1103,23 @@ void wfmain::handleWFClick(QMouseEvent *me) showStatusBarText(QString("Selected %1 MHz").arg(x)); } +void wfmain::handleWFScroll(QWheelEvent *we) +{ + // The wheel event is typically + // .y() and is +/- 120. + // We will click the dial once for every 120 received. + //QPoint delta = we->angleDelta(); + // The minus is there because it felt more natural that way. + int steps = we->angleDelta().y() / 120; + ui->freqDial->setValue( ui->freqDial->value() - (steps)*ui->freqDial->singleStep() ); +} + +void wfmain::handlePlotScroll(QWheelEvent *we) +{ + int steps = we->angleDelta().y() / 120; + ui->freqDial->setValue( ui->freqDial->value() - (steps)*ui->freqDial->singleStep() ); +} + void wfmain::on_startBtn_clicked() { emit spectOutputEnable(); diff --git a/wfmain.h b/wfmain.h index a5ad8b1..c93b975 100644 --- a/wfmain.h +++ b/wfmain.h @@ -116,6 +116,8 @@ private slots: void handlePlotDoubleClick(QMouseEvent *); void handleWFClick(QMouseEvent *); void handleWFDoubleClick(QMouseEvent *); + void handleWFScroll(QWheelEvent *); + void handlePlotScroll(QWheelEvent *); void runDelayedCommand(); void showStatusBarText(QString text);