Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,35 @@ env:
jobs:
build:
strategy:
fail-fast: false
matrix:
os: ['macos-latest', 'ubuntu-22.04', 'ubuntu-20.04']
os: ['macos-latest', 'ubuntu-24.04', 'ubuntu-22.04']
qt: ['qt5', 'qt6']
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Set variables Qt5
run: |
echo "QTPKG_MAC=qt@5" >> $GITHUB_ENV
echo "QTPKG_UBUNTU=qtbase5-dev" >> $GITHUB_ENV
if: matrix.qt == 'qt5'

- name: Set variables Qt6
run: |
echo "QTPKG_MAC=qt@6" >> $GITHUB_ENV
echo "QTPKG_UBUNTU=qt6-base-dev" >> $GITHUB_ENV
if: matrix.qt == 'qt6'

- name: Install dependencies (macOS)
run: brew install fftw liquid-dsp qt@5
run: brew install fftw liquid-dsp ${{ env.QTPKG_MAC }}
if: matrix.os == 'macos-latest'

- name: Install dependencies (Ubuntu)
run: |
sudo apt update
sudo apt install libfftw3-dev libliquid-dev qtbase5-dev
sudo apt install libfftw3-dev libliquid-dev libgl1-mesa-dev ${{ env.QTPKG_UBUNTU }}
if: startsWith(matrix.os, 'ubuntu-')

- name: Create Build Environment
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.6)
cmake_minimum_required(VERSION 3.5)
project(inspectrum CXX)
enable_testing()

Expand Down
24 changes: 17 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ list(APPEND inspectrum_sources
util.cpp
)

find_package(Qt5Widgets REQUIRED)
find_package(Qt5Concurrent REQUIRED)
find_package(Qt6 COMPONENTS Core Concurrent Widgets)
if (NOT Qt6_FOUND)
find_package(Qt5 REQUIRED COMPONENTS Core Concurrent Widgets)
endif()
find_package(FFTW REQUIRED)
find_package(Liquid REQUIRED)

Expand All @@ -65,11 +67,19 @@ include_directories(

add_executable(inspectrum ${EXE_ARGS} ${inspectrum_sources})

target_link_libraries(inspectrum
Qt5::Core Qt5::Widgets Qt5::Concurrent
${FFTW_LIBRARIES}
${LIQUID_LIBRARIES}
)
if (Qt6_FOUND)
target_link_libraries(inspectrum
Qt6::Core Qt6::Widgets Qt6::Concurrent
${FFTW_LIBRARIES}
${LIQUID_LIBRARIES}
)
else()
target_link_libraries(inspectrum
Qt5::Core Qt5::Widgets Qt5::Concurrent
${FFTW_LIBRARIES}
${LIQUID_LIBRARIES}
)
endif()

set(INSTALL_DEFAULT_BINDIR "bin" CACHE STRING "Appended to CMAKE_INSTALL_PREFIX")

Expand Down
30 changes: 19 additions & 11 deletions src/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,24 @@ bool Cursor::pointOverCursor(QPoint point)
return range.contains(fromPoint(point));
}

bool Cursor::mouseEvent(QEvent::Type type, QMouseEvent event)
bool Cursor::mouseEvent(QEvent::Type type, QMouseEvent *event)
{
// If the mouse pointer moves over a cursor, display a resize pointer
if (pointOverCursor(event.pos()) && type != QEvent::Leave) {
if (!cursorOverrided) {
cursorOverrided = true;
if (pointOverCursor(event->pos())) {
if (!cursorOverriden) {
cursorOverriden = true;
QApplication::setOverrideCursor(QCursor(cursorShape));
}
// Restore pointer if it moves off the cursor, or leaves the widget
} else if (cursorOverrided) {
cursorOverrided = false;
// Restore pointer if it moves off the cursor
} else if (cursorOverriden) {
cursorOverriden = false;
QApplication::restoreOverrideCursor();
}

// Start dragging on left mouse button press, if over a cursor
if (type == QEvent::MouseButtonPress) {
if (event.button() == Qt::LeftButton) {
if (pointOverCursor(event.pos())) {
if (event->button() == Qt::LeftButton) {
if (pointOverCursor(event->pos())) {
dragging = true;
return true;
}
Expand All @@ -63,20 +63,28 @@ bool Cursor::mouseEvent(QEvent::Type type, QMouseEvent event)
// Update current cursor position if we're dragging
} else if (type == QEvent::MouseMove) {
if (dragging) {
cursorPosition = fromPoint(event.pos());
cursorPosition = fromPoint(event->pos());
emit posChanged();
}

// Stop dragging on left mouse button release
} else if (type == QEvent::MouseButtonRelease) {
if (event.button() == Qt::LeftButton && dragging) {
if (event->button() == Qt::LeftButton && dragging) {
dragging = false;
return true;
}
}
return false;
}

void Cursor::leaveEvent()
{
if (cursorOverriden) {
cursorOverriden = false;
QApplication::restoreOverrideCursor();
}
}

int Cursor::pos()
{
return cursorPosition;
Expand Down
5 changes: 3 additions & 2 deletions src/cursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class Cursor : public QObject
Cursor(Qt::Orientation orientation, Qt::CursorShape mouseCursorShape, QObject * parent);
int pos();
void setPos(int newPos);
bool mouseEvent(QEvent::Type type, QMouseEvent event);
bool mouseEvent(QEvent::Type type, QMouseEvent *event);
void leaveEvent();

signals:
void posChanged();
Expand All @@ -44,6 +45,6 @@ class Cursor : public QObject
Qt::Orientation orientation;
Qt::CursorShape cursorShape;
bool dragging = false;
bool cursorOverrided = false;
bool cursorOverriden = false;
int cursorPosition = 0;
};
29 changes: 20 additions & 9 deletions src/cursors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ bool Cursors::pointWithinDragRegion(QPoint point) {
return range.contains(point.x());
}

bool Cursors::mouseEvent(QEvent::Type type, QMouseEvent event)
bool Cursors::mouseEvent(QEvent::Type type, QMouseEvent *event)
{
if (minCursor->mouseEvent(type, event))
return true;
if (maxCursor->mouseEvent(type, event))
return true;
return true;

// If the mouse pointer is between the cursors, display a resize pointer
if (pointWithinDragRegion(event.pos()) && type != QEvent::Leave) {
if (pointWithinDragRegion(event->pos()) ) {
if (!cursorOverride) {
cursorOverride = true;
QApplication::setOverrideCursor(QCursor(Qt::SizeAllCursor));
Expand All @@ -66,32 +66,43 @@ bool Cursors::mouseEvent(QEvent::Type type, QMouseEvent event)
}
// Start dragging on left mouse button press, if between the cursors
if (type == QEvent::MouseButtonPress) {
if (event.button() == Qt::LeftButton) {
if (pointWithinDragRegion(event.pos())) {
if (event->button() == Qt::LeftButton) {
if (pointWithinDragRegion(event->pos())) {
dragging = true;
dragPos = event.pos();
dragPos = event->pos();
return true;
}
}
// Update both cursor positons if we're dragging
} else if (type == QEvent::MouseMove) {
if (dragging) {
int dx = event.pos().x() - dragPos.x();
int dx = event->pos().x() - dragPos.x();
minCursor->setPos(minCursor->pos() + dx);
maxCursor->setPos(maxCursor->pos() + dx);
dragPos = event.pos();
dragPos = event->pos();
emit cursorsMoved();
}
// Stop dragging on left mouse button release
} else if (type == QEvent::MouseButtonRelease) {
if (event.button() == Qt::LeftButton && dragging) {
if (event->button() == Qt::LeftButton && dragging) {
dragging = false;
return true;
}
}
return false;
}

void Cursors::leaveEvent()
{
minCursor->leaveEvent();
maxCursor->leaveEvent();

if (cursorOverride) {
cursorOverride = false;
QApplication::restoreOverrideCursor();
}
}

void Cursors::paintFront(QPainter &painter, QRect &rect, range_t<size_t> sampleRange)
{
painter.save();
Expand Down
3 changes: 2 additions & 1 deletion src/cursors.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class Cursors : public QObject
public:
Cursors(QObject * parent);
int segments();
bool mouseEvent(QEvent::Type type, QMouseEvent event);
bool mouseEvent(QEvent::Type type, QMouseEvent *event);
void leaveEvent();
void paintFront(QPainter &painter, QRect &rect, range_t<size_t> sampleRange);
range_t<int> selection();
void setSegments(int segments);
Expand Down
4 changes: 3 additions & 1 deletion src/inputsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,9 @@ QJsonObject InputSource::readMetaData(const QString &filename)

auto sigmf_color = sigmf_annotation["presentation:color"].toString();
// SigMF uses the format "#RRGGBBAA" for alpha-channel colors, QT uses "#AARRGGBB"
if ((sigmf_color.at(0) == '#') && (sigmf_color.length()) == 9) {
// Check length first so the empty/short-string case short-circuits before at(0):
// in Qt6 an empty QString has a null data pointer and at(0) would crash.
if ((sigmf_color.length() == 9) && (sigmf_color.at(0) == '#')) {
sigmf_color = "#" + sigmf_color.mid(7,2) + sigmf_color.mid(1,6);
}
auto boxColor = QString::fromStdString("white");
Expand Down
9 changes: 5 additions & 4 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ void MainWindow::openFile(QString fileName)

// Try to parse osmocom_fft filenames and extract the sample rate and center frequency.
// Example file name: "name-f2.411200e+09-s5.000000e+06-t20160807180210.cfile"
QRegExp rx("(.*)-f(.*)-s(.*)-.*\\.cfile");
QRegularExpression rx(QRegularExpression::anchoredPattern("(.*)-f(.*)-s(.*)-.*\\.cfile"));
QString basename = fileName.section('/',-1,-1);

if (rx.exactMatch(basename)) {
QString centerfreq = rx.cap(2);
QString samplerate = rx.cap(3);
auto match = rx.match(basename);
if (match.hasMatch()) {
QString centerfreq = match.captured(2);
QString samplerate = match.captured(3);

std::stringstream ss(samplerate.toUtf8().constData());

Expand Down
7 changes: 6 additions & 1 deletion src/plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@ void Plot::invalidateEvent()

}

bool Plot::mouseEvent(QEvent::Type type, QMouseEvent event)
bool Plot::mouseEvent(QEvent::Type type, QMouseEvent *event)
{
return false;
}

void Plot::leaveEvent()
{

}

std::shared_ptr<AbstractSampleSource> Plot::output()
{
return sampleSource;
Expand Down
3 changes: 2 additions & 1 deletion src/plot.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class Plot : public QObject, public Subscriber
Plot(std::shared_ptr<AbstractSampleSource> src);
~Plot();
void invalidateEvent() override;
virtual bool mouseEvent(QEvent::Type type, QMouseEvent event);
virtual bool mouseEvent(QEvent::Type type, QMouseEvent *event);
virtual void leaveEvent();
virtual std::shared_ptr<AbstractSampleSource> output();
virtual void paintBack(QPainter &painter, QRect &rect, range_t<size_t> sampleRange);
virtual void paintMid(QPainter &painter, QRect &rect, range_t<size_t> sampleRange);
Expand Down
Loading