kopia lustrzana https://gitlab.com/eliggett/wfview
Scroll test in debug window. Remove later.
rodzic
f1dea9ec6e
commit
2712ada5c7
|
@ -23,6 +23,11 @@ debugWindow::debugWindow(QWidget *parent) :
|
||||||
connect(&queueTimer,SIGNAL(timeout()),this,SLOT(getQueue()));
|
connect(&queueTimer,SIGNAL(timeout()),this,SLOT(getQueue()));
|
||||||
cacheTimer.start();
|
cacheTimer.start();
|
||||||
queueTimer.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()
|
debugWindow::~debugWindow()
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include "cachingqueue.h"
|
#include "cachingqueue.h"
|
||||||
#include "wfviewtypes.h"
|
#include "wfviewtypes.h"
|
||||||
|
#include "scrolltest.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class debugWindow;
|
class debugWindow;
|
||||||
|
|
|
@ -220,6 +220,71 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Scroll test:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="scrolltest" name="scrolltester" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>500</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>500</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="scrollTestLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -247,6 +312,14 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>scrolltest</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>scrolltest.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
#ifndef SCROLLTEST_H
|
||||||
|
#define SCROLLTEST_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QWheelEvent>
|
||||||
|
#include <QFont>
|
||||||
|
#include <QFontMetrics>
|
||||||
|
|
||||||
|
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
|
|
@ -237,6 +237,7 @@ SOURCES += main.cpp\
|
||||||
cwsidetone.cpp \
|
cwsidetone.cpp \
|
||||||
debugwindow.cpp \
|
debugwindow.cpp \
|
||||||
loggingwindow.cpp \
|
loggingwindow.cpp \
|
||||||
|
scrolltest.cpp \
|
||||||
settingswidget.cpp \
|
settingswidget.cpp \
|
||||||
memories.cpp \
|
memories.cpp \
|
||||||
rigcreator.cpp \
|
rigcreator.cpp \
|
||||||
|
@ -295,6 +296,7 @@ HEADERS += wfmain.h \
|
||||||
freqmemory.h \
|
freqmemory.h \
|
||||||
rigcreator.h \
|
rigcreator.h \
|
||||||
rigidentities.h \
|
rigidentities.h \
|
||||||
|
scrolltest.h \
|
||||||
settingswidget.h \
|
settingswidget.h \
|
||||||
sidebandchooser.h \
|
sidebandchooser.h \
|
||||||
spectrumscope.h \
|
spectrumscope.h \
|
||||||
|
|
Ładowanie…
Reference in New Issue