diff --git a/debugwindow.cpp b/debugwindow.cpp index 37deb5f..582251c 100644 --- a/debugwindow.cpp +++ b/debugwindow.cpp @@ -23,6 +23,11 @@ debugWindow::debugWindow(QWidget *parent) : connect(&queueTimer,SIGNAL(timeout()),this,SLOT(getQueue())); cacheTimer.start(); queueTimer.start(); + + connect(ui->scrolltester, &scrolltest::haveRawClicksXY, + [=](const int x, const int y) { + ui->scrollTestLabel->setText(QString("X: %1, Y: %2").arg(x).arg(y)); + }); } debugWindow::~debugWindow() diff --git a/debugwindow.h b/debugwindow.h index c8d0dda..08c0d08 100644 --- a/debugwindow.h +++ b/debugwindow.h @@ -10,6 +10,7 @@ #include "cachingqueue.h" #include "wfviewtypes.h" +#include "scrolltest.h" namespace Ui { class debugWindow; diff --git a/debugwindow.ui b/debugwindow.ui index 04a646a..7eb8930 100644 --- a/debugwindow.ui +++ b/debugwindow.ui @@ -220,6 +220,71 @@ + + + + 10 + + + 10 + + + 10 + + + 10 + + + + + Scroll test: + + + + + + + + 0 + 0 + + + + + 500 + 0 + + + + + 500 + 16777215 + + + + + + + + TextLabel + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + @@ -247,6 +312,14 @@ + + + scrolltest + QWidget +
scrolltest.h
+ 1 +
+
diff --git a/scrolltest.cpp b/scrolltest.cpp new file mode 100644 index 0000000..bb38b62 --- /dev/null +++ b/scrolltest.cpp @@ -0,0 +1,56 @@ +#include "scrolltest.h" + +scrolltest::scrolltest(QWidget *parent) + : QWidget{parent} +{ +} + + +void scrolltest::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + widgetWindowHeight = this->height(); + + fontSize = 12; + + painter.setRenderHint(QPainter::SmoothPixmapTransform); + painter.setFont(QFont(this->fontInfo().family(), fontSize)); + painter.setWindow(QRect(0, 0, this->width(), widgetWindowHeight)); + + painter.setPen(Qt::red); + painter.drawText(0,widgetWindowHeight, resultText ); +} + +void scrolltest::wheelEvent(QWheelEvent *we) +{ + int clicksX = we->angleDelta().x(); + int clicksY = we->angleDelta().y(); + + if(abs(clicksX) > maxX) + maxX = clicksX; + + if(abs(clicksY) > maxY) + maxY = clicksY; + + if( (clicksX !=0) && (abs(clicksX) < minX)) + minX = abs(clicksX); + + if( (clicksY !=0) && (abs(clicksY) < minY)) + minY = abs(clicksY); + + resultText = QString("X: %1, Y: %2, maxX: %3, maxY: %4") + .arg(clicksX).arg(clicksY).arg(maxX).arg(maxY); + + if(minX != 999999) + resultText.append(QString(", minX: %1").arg(minX)); + + if(minY != 999999) + resultText.append(QString(", minY: %1").arg(minY)); + + //QFontMetrics fm(this->font()); + //int neededWidth = fm.horizontalAdvance(resultText); + //this->resize(this->height(), neededWidth); + + emit haveRawClicksXY(clicksX, clicksY); + update(); +} diff --git a/scrolltest.h b/scrolltest.h new file mode 100644 index 0000000..edc2f94 --- /dev/null +++ b/scrolltest.h @@ -0,0 +1,37 @@ +#ifndef SCROLLTEST_H +#define SCROLLTEST_H + +#include +#include +#include +#include +#include + +class scrolltest : public QWidget +{ + Q_OBJECT + + int widgetWindowHeight; + int fontSize = 12; + int rawClicksY; + int rawClicksX; + QString resultText = "SCROLL"; + + int maxX=0; + int maxY=0; + int minX=999999; + int minY=999999; + +public: + explicit scrolltest(QWidget *parent = nullptr); + +public slots: + //void mouseMoveEvent(QMouseEvent *event); + void wheelEvent(QWheelEvent *event); + void paintEvent(QPaintEvent *event); + +signals: + void haveRawClicksXY(int x, int y); +}; + +#endif // SCROLLTEST_H diff --git a/wfview.pro b/wfview.pro index 98ea6dd..0d47d58 100644 --- a/wfview.pro +++ b/wfview.pro @@ -237,6 +237,7 @@ SOURCES += main.cpp\ cwsidetone.cpp \ debugwindow.cpp \ loggingwindow.cpp \ + scrolltest.cpp \ settingswidget.cpp \ memories.cpp \ rigcreator.cpp \ @@ -295,6 +296,7 @@ HEADERS += wfmain.h \ freqmemory.h \ rigcreator.h \ rigidentities.h \ + scrolltest.h \ settingswidget.h \ sidebandchooser.h \ spectrumscope.h \