1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 08:04:49 -05:00

Update sdrbase and sdrgui to support Qt5 and Qt6

This commit is contained in:
Jon Beniston 2022-11-17 14:41:55 +00:00
parent 3b5b222114
commit 2cb2a8d555
32 changed files with 95 additions and 54 deletions

View File

@ -22,8 +22,10 @@
#include <QStyleFactory> #include <QStyleFactory>
#include <QFontDatabase> #include <QFontDatabase>
#include <QSysInfo> #include <QSysInfo>
#ifdef __APPLE__
#include <QGLFormat> #include <QGLFormat>
#include <QSurfaceFormat> #include <QSurfaceFormat>
#endif
#include "loggerwithfile.h" #include "loggerwithfile.h"
#include "mainwindow.h" #include "mainwindow.h"
@ -44,7 +46,7 @@ static int runQtApplication(int argc, char* argv[], qtwebapp::LoggerWithFile *lo
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); // Needed for WebGL in QWebEngineView and MainWindow::openGLVersion QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); // Needed for WebGL in QWebEngineView and MainWindow::openGLVersion
#endif #endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) && (QT_VERSION <= QT_VERSION_CHECK(6, 0, 0))
QApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton); QApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton);
#endif #endif

View File

@ -150,7 +150,7 @@ QString Command::getKeyLabel() const
else if (m_keyModifiers != Qt::NoModifier) else if (m_keyModifiers != Qt::NoModifier)
{ {
QString altGrStr = m_keyModifiers & Qt::GroupSwitchModifier ? "Gr " : ""; QString altGrStr = m_keyModifiers & Qt::GroupSwitchModifier ? "Gr " : "";
int maskedModifiers = (m_keyModifiers & 0x3FFFFFFF) + ((m_keyModifiers & 0x40000000)>>3); int maskedModifiers = ((int) m_keyModifiers & 0x3FFFFFFF) + (((int) m_keyModifiers & 0x40000000)>>3);
return altGrStr + QKeySequence(maskedModifiers, m_key).toString(); return altGrStr + QKeySequence(maskedModifiers, m_key).toString();
} }
else else

View File

@ -16,6 +16,7 @@
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include <QDataStream> #include <QDataStream>
#include <QIODevice>
#include "util/simpleserializer.h" #include "util/simpleserializer.h"
#include "deviceuserargs.h" #include "deviceuserargs.h"

View File

@ -66,7 +66,11 @@ public:
void setColor(QColor color) void setColor(QColor color)
{ {
m_traceColor = color; m_traceColor = color;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
float r,g,b,a;
#else
qreal r,g,b,a; qreal r,g,b,a;
#endif
m_traceColor.getRgbF(&r, &g, &b, &a); m_traceColor.getRgbF(&r, &g, &b, &a);
m_traceColorR = r; m_traceColorR = r;
m_traceColorG = g; m_traceColorG = g;
@ -119,7 +123,11 @@ public:
void setColor(QColor color) void setColor(QColor color)
{ {
m_triggerColor = color; m_triggerColor = color;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
float r,g,b,a;
#else
qreal r,g,b,a; qreal r,g,b,a;
#endif
m_triggerColor.getRgbF(&r, &g, &b, &a); m_triggerColor.getRgbF(&r, &g, &b, &a);
m_triggerColorR = r; m_triggerColorR = r;
m_triggerColorG = g; m_triggerColorG = g;

View File

@ -144,17 +144,8 @@ QByteArray SpectrumSettings::serialize() const
s.writeBlob(111+i, m_waterfallMarkers[i].serialize()); s.writeBlob(111+i, m_waterfallMarkers[i].serialize());
} }
QByteArray dataAnnotation; s.writeList(40, m_annoationMarkers);
QDataStream *stream = new QDataStream(&dataAnnotation, QIODevice::WriteOnly); s.writeList(41, m_calibrationPoints);
(*stream) << m_annoationMarkers;
delete stream;
s.writeBlob(40, dataAnnotation);
QByteArray dataCalibration;
stream = new QDataStream(&dataCalibration, QIODevice::WriteOnly);
(*stream) << m_calibrationPoints;
delete stream;
s.writeBlob(41, dataCalibration);
return s.final(); return s.final();
} }
@ -275,15 +266,8 @@ bool SpectrumSettings::deserialize(const QByteArray& data)
m_waterfallMarkers.back().deserialize(bytetmp); m_waterfallMarkers.back().deserialize(bytetmp);
} }
d.readBlob(40, &bytetmp); d.readList(40, &m_annoationMarkers);
QDataStream *stream = new QDataStream(bytetmp); d.readList(41, &m_calibrationPoints);
(*stream) >> m_annoationMarkers;
delete stream;
d.readBlob(41, &bytetmp);
stream = new QDataStream(bytetmp);
(*stream) >> m_calibrationPoints;
delete stream;
return true; return true;
} }

View File

@ -17,7 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include <QCommandLineOption> #include <QCommandLineOption>
#include <QRegExpValidator> #include <QRegularExpressionValidator>
#include <QDebug> #include <QDebug>
#include "mainparser.h" #include "mainparser.h"
@ -72,11 +72,11 @@ void MainParser::parse(const QCoreApplication& app)
if (!serverAddress.isEmpty()) if (!serverAddress.isEmpty())
{ {
QString ipRange = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])"; QString ipRange = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])";
QRegExp ipRegex ("^" + ipRange QRegularExpression ipRegex ("^" + ipRange
+ "\\." + ipRange + "\\." + ipRange
+ "\\." + ipRange + "\\." + ipRange
+ "\\." + ipRange + "$"); + "\\." + ipRange + "$");
QRegExpValidator ipValidator(ipRegex); QRegularExpressionValidator ipValidator(ipRegex);
if (ipValidator.validate(serverAddress, pos) == QValidator::Acceptable) { if (ipValidator.validate(serverAddress, pos) == QValidator::Acceptable) {
m_serverAddress = serverAddress; m_serverAddress = serverAddress;

View File

@ -17,6 +17,8 @@
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include <QDataStream> #include <QDataStream>
#include <QIODevice>
#include "SWGRollupState.h" #include "SWGRollupState.h"
#include "rollupstate.h" #include "rollupstate.h"

View File

@ -22,7 +22,8 @@ namespace SWGSDRangel {
class SWGObject; class SWGObject;
} }
class QStringList; #include <QStringList>
class Serializable class Serializable
{ {
public: public:

View File

@ -256,7 +256,7 @@ QString AISMessage::getString(const QByteArray ba, int byteIdx, int bitsLeft, in
if (c < 32) { if (c < 32) {
c |= 0x40; c |= 0x40;
} }
s.append(c); s.append(QChar(c));
} }
// Remove leading/trailing spaces // Remove leading/trailing spaces
s = s.trimmed(); s = s.trimmed();

View File

@ -308,7 +308,7 @@ bool APRSPacket::parseTimeMDHM(QString& info, int& idx)
} }
// Position ambigutiy can be specified by using spaces instead of digits in lats and longs // Position ambigutiy can be specified by using spaces instead of digits in lats and longs
bool APRSPacket::isLatLongChar(QCharRef c) bool APRSPacket::isLatLongChar(const QChar c)
{ {
return (c.isDigit() || c == ' '); return (c.isDigit() || c == ' ');
} }

View File

@ -461,7 +461,7 @@ private:
int charToInt(QString &s, int idx); int charToInt(QString &s, int idx);
bool parseTime(QString& info, int& idx); bool parseTime(QString& info, int& idx);
bool parseTimeMDHM(QString& info, int& idx); bool parseTimeMDHM(QString& info, int& idx);
bool isLatLongChar(QCharRef c); bool isLatLongChar(const QChar c);
bool parsePosition(QString& info, int& idx); bool parsePosition(QString& info, int& idx);
bool parseDataExension(QString& info, int& idx); bool parseDataExension(QString& info, int& idx);
bool parseComment(QString& info, int& idx); bool parseComment(QString& info, int& idx);

View File

@ -197,7 +197,7 @@ QString Morse::toString(QString &morse)
{ {
int c = Morse::toASCII(groups[i]); int c = Morse::toASCII(groups[i]);
if ((c != -1) && (groups[i] != "")) if ((c != -1) && (groups[i] != ""))
string.append(c); string.append(QChar(c));
} }
return string; return string;
} }

View File

@ -130,7 +130,7 @@ struct SDRBASE_API Airspace {
{ {
if (xmlReader.readNextStartElement()) if (xmlReader.readNextStartElement())
{ {
if (xmlReader.name() == "ASP") if (xmlReader.name() == QLatin1String("ASP"))
{ {
Airspace *airspace = new Airspace(); Airspace *airspace = new Airspace();
@ -264,9 +264,9 @@ struct SDRBASE_API NavAid {
{ {
if (xmlReader.readNextStartElement()) if (xmlReader.readNextStartElement())
{ {
if (xmlReader.name() == "NAVAID") if (xmlReader.name() == QLatin1String("NAVAID"))
{ {
QStringRef typeRef = xmlReader.attributes().value("TYPE"); QStringView typeRef = xmlReader.attributes().value("TYPE");
if ((typeRef == QLatin1String("NDB")) if ((typeRef == QLatin1String("NDB"))
|| (typeRef == QLatin1String("DME")) || (typeRef == QLatin1String("DME"))
|| (typeRef == QLatin1String("VOR")) || (typeRef == QLatin1String("VOR"))

View File

@ -18,6 +18,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // // along with this program. If not, see <http://www.gnu.org/licenses/>. //
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include <algorithm>
#include "peakfinder.h" #include "peakfinder.h"
PeakFinder::PeakFinder() : PeakFinder::PeakFinder() :

View File

@ -257,7 +257,7 @@ QList<VISA::Instrument> VISA::instruments(QRegularExpression *filter)
void *VISA::libraryOpen(const char *filename) void *VISA::libraryOpen(const char *filename)
{ {
HMODULE module; HMODULE module;
module = LoadLibrary ((LPCSTR)filename); module = LoadLibraryA ((LPCSTR)filename);
return module; return module;
} }

View File

@ -17,7 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include <QCommandLineOption> #include <QCommandLineOption>
#include <QRegExpValidator> #include <QRegularExpressionValidator>
#include <QDebug> #include <QDebug>
#include "parserbench.h" #include "parserbench.h"
@ -70,8 +70,8 @@ void ParserBench::parse(const QCoreApplication& app)
QString test = m_parser.value(m_testOption); QString test = m_parser.value(m_testOption);
QString testStr = "([a-z0-9]+)"; QString testStr = "([a-z0-9]+)";
QRegExp ipRegex ("^" + testStr + "$"); QRegularExpression ipRegex ("^" + testStr + "$");
QRegExpValidator ipValidator(ipRegex); QRegularExpressionValidator ipValidator(ipRegex);
if (ipValidator.validate(test, pos) == QValidator::Acceptable) { if (ipValidator.validate(test, pos) == QValidator::Acceptable) {
m_testStr = test; m_testStr = test;

View File

@ -21,6 +21,7 @@
#include <QMdiSubWindow> #include <QMdiSubWindow>
#include <QMap> #include <QMap>
#include "gui/qtcompatibility.h"
#include "gui/framelesswindowresizer.h" #include "gui/framelesswindowresizer.h"
#include "export.h" #include "export.h"

View File

@ -20,11 +20,11 @@
#define SDRGUI_GUI_CHANNELADDDIALOG_H_ #define SDRGUI_GUI_CHANNELADDDIALOG_H_
#include <QDialog> #include <QDialog>
#include <QStringList>
#include <vector> #include <vector>
#include "export.h" #include "export.h"
class QStringList;
class QAbstractButton; class QAbstractButton;
namespace Ui { namespace Ui {

View File

@ -344,7 +344,7 @@ void CWKeyerGUI::setKeyLabel(QLabel *label, Qt::Key key, Qt::KeyboardModifiers k
else if (keyModifiers != Qt::NoModifier) else if (keyModifiers != Qt::NoModifier)
{ {
QString altGrStr = keyModifiers & Qt::GroupSwitchModifier ? "Gr " : ""; QString altGrStr = keyModifiers & Qt::GroupSwitchModifier ? "Gr " : "";
int maskedModifiers = (keyModifiers & 0x3FFFFFFF) + ((keyModifiers & 0x40000000)>>3); int maskedModifiers = ((int) keyModifiers & 0x3FFFFFFF) + (((int) keyModifiers & 0x40000000)>>3);
label->setText(altGrStr + QKeySequence(maskedModifiers, key).toString()); label->setText(altGrStr + QKeySequence(maskedModifiers, key).toString());
} }
else else

View File

@ -204,7 +204,7 @@ void EditCommandDialog::setKeyLabel()
else if (m_keyModifiers != Qt::NoModifier) else if (m_keyModifiers != Qt::NoModifier)
{ {
QString altGrStr = m_keyModifiers & Qt::GroupSwitchModifier ? "Gr " : ""; QString altGrStr = m_keyModifiers & Qt::GroupSwitchModifier ? "Gr " : "";
int maskedModifiers = (m_keyModifiers & 0x3FFFFFFF) + ((m_keyModifiers & 0x40000000)>>3); int maskedModifiers = ((int) m_keyModifiers & 0x3FFFFFFF) + (((int) m_keyModifiers & 0x40000000)>>3);
ui->keyLabel->setText(altGrStr + QKeySequence(maskedModifiers, m_key).toString()); ui->keyLabel->setText(altGrStr + QKeySequence(maskedModifiers, m_key).toString());
} }
else else

View File

@ -20,11 +20,11 @@
#define SDRGUI_GUI_FEATUREADDDIALOG_H_ #define SDRGUI_GUI_FEATUREADDDIALOG_H_
#include <QDialog> #include <QDialog>
#include <QStringList>
#include <vector> #include <vector>
#include "export.h" #include "export.h"
class QStringList;
class QAbstractButton; class QAbstractButton;
namespace Ui { namespace Ui {

View File

@ -23,7 +23,6 @@
#include <QToolTip> #include <QToolTip>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QDesktopWidget>
#include <QScreen> #include <QScreen>
#include "gui/glspectrumgui.h" #include "gui/glspectrumgui.h"
@ -728,7 +727,7 @@ void GLSpectrumGUI::on_calibration_toggled(bool checked)
void GLSpectrumGUI::on_gotoMarker_currentIndexChanged(int index) void GLSpectrumGUI::on_gotoMarker_currentIndexChanged(int index)
{ {
if (index == 0) { if (index <= 0) {
return; return;
} }
int i = 1; int i = 1;

View File

@ -4452,7 +4452,7 @@ bool GLSpectrumView::pointInHistogram(const QPointF &point) const
return (p.x() >= 0) && (p.x() <= 1) && (p.y() >= 0) && (p.y() <= 1); return (p.x() >= 0) && (p.x() <= 1) && (p.y() >= 0) && (p.y() <= 1);
} }
void GLSpectrumView::enterEvent(QEvent* event) void GLSpectrumView::enterEvent(EnterEventType* event)
{ {
m_mouseInside = true; m_mouseInside = true;
update(); update();
@ -4463,7 +4463,7 @@ void GLSpectrumView::leaveEvent(QEvent* event)
{ {
m_mouseInside = false; m_mouseInside = false;
update(); update();
QOpenGLWidget::enterEvent(event); QOpenGLWidget::leaveEvent(event);
} }
void GLSpectrumView::tick() void GLSpectrumView::tick()

View File

@ -30,6 +30,7 @@
#include <QPoint> #include <QPoint>
#include <QOpenGLWidget> #include <QOpenGLWidget>
#include <QOpenGLDebugLogger> #include <QOpenGLDebugLogger>
#include "gui/qtcompatibility.h"
#include "gui/scaleengine.h" #include "gui/scaleengine.h"
#include "gui/glshadersimple.h" #include "gui/glshadersimple.h"
#include "gui/glshadertextured.h" #include "gui/glshadertextured.h"
@ -465,7 +466,7 @@ private:
bool pointInWaterfallOrSpectrogram(const QPointF &point) const; bool pointInWaterfallOrSpectrogram(const QPointF &point) const;
bool pointInHistogram(const QPointF &point) const; bool pointInHistogram(const QPointF &point) const;
void enterEvent(QEvent* event); void enterEvent(EnterEventType* event);
void leaveEvent(QEvent* event); void leaveEvent(QEvent* event);
static QString displayFull(int64_t value); static QString displayFull(int64_t value);

View File

@ -0,0 +1,30 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2022 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRGUI_GUI_QTCOMPATIBILITY_H
#define SDRGUI_GUI_QTCOMPATIBILITY_H
// Widget::enterEvent parameters have different types in QT5 and QT6
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <QEnterEvent>
typedef QEnterEvent EnterEventType;
#else
#include <QEvent>
typedef QEvent EnterEventType;
#endif
#endif

View File

@ -17,6 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include <math.h> #include <math.h>
#include <QObject>
#include <QFontMetrics> #include <QFontMetrics>
#include <QDataStream> #include <QDataStream>
#include "gui/scaleengine.h" #include "gui/scaleengine.h"

View File

@ -841,14 +841,14 @@ void SpectrumMarkersDialog::on_showSelect_currentIndexChanged(int index)
void SpectrumMarkersDialog::updateHistogramMarkersDisplay() void SpectrumMarkersDialog::updateHistogramMarkersDisplay()
{ {
m_histogramMarkerIndex = std::max(m_histogramMarkerIndex, m_histogramMarkers.size() - 1); m_histogramMarkerIndex = std::max(m_histogramMarkerIndex, (int)m_histogramMarkers.size() - 1);
ui->marker->setMaximum(m_histogramMarkers.size() - 1); ui->marker->setMaximum(m_histogramMarkers.size() - 1);
displayHistogramMarker(); displayHistogramMarker();
} }
void SpectrumMarkersDialog::updateWaterfallMarkersDisplay() void SpectrumMarkersDialog::updateWaterfallMarkersDisplay()
{ {
m_waterfallMarkerIndex = std::max(m_waterfallMarkerIndex, m_waterfallMarkers.size() - 1); m_waterfallMarkerIndex = std::max(m_waterfallMarkerIndex, (int)m_waterfallMarkers.size() - 1);
ui->wMarker->setMaximum(m_waterfallMarkers.size() - 1); ui->wMarker->setMaximum(m_waterfallMarkers.size() - 1);
displayWaterfallMarker(); displayWaterfallMarker();
} }

View File

@ -353,7 +353,7 @@ void ValueDial::mouseMoveEvent(QMouseEvent *event)
int i; int i;
i = (event->x() - 1) / m_digitWidth; i = (event->x() - 1) / m_digitWidth;
if (m_text[i] == m_groupSeparator) { if ((i >= m_text.size()) || (m_text[i] == m_groupSeparator)) {
i = -1; i = -1;
} }

View File

@ -57,7 +57,11 @@ private:
int m_animationState; int m_animationState;
QTimer m_animationTimer; QTimer m_animationTimer;
QTimer m_blinkTimer; QTimer m_blinkTimer;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QString m_groupSeparator;
#else
QChar m_groupSeparator; QChar m_groupSeparator;
#endif
ColorMapper m_colorMapper; ColorMapper m_colorMapper;

View File

@ -399,7 +399,7 @@ void ValueDialZ::mouseMoveEvent(QMouseEvent* event)
i = (event->x() - 1) / m_digitWidth; i = (event->x() - 1) / m_digitWidth;
if ((m_text[i] == m_groupSeparator) || (m_text[i] == m_decSeparator)) { if ((i >= m_text.size()) || (m_text[i] == m_groupSeparator) || (m_text[i] == m_decSeparator)) {
i = -1; i = -1;
} }

View File

@ -62,8 +62,13 @@ private:
int m_animationState; int m_animationState;
QTimer m_animationTimer; QTimer m_animationTimer;
QTimer m_blinkTimer; QTimer m_blinkTimer;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QString m_groupSeparator;
QString m_decSeparator;
#else
QChar m_groupSeparator; QChar m_groupSeparator;
QChar m_decSeparator; QChar m_decSeparator;
#endif
ColorMapper m_colorMapper; ColorMapper m_colorMapper;

View File

@ -20,6 +20,7 @@
#define SDRGUI_GUI_WORKSPACE_H_ #define SDRGUI_GUI_WORKSPACE_H_
#include <QDockWidget> #include <QDockWidget>
#include <QStringList>
#include "export.h" #include "export.h"
#include "featureadddialog.h" #include "featureadddialog.h"
@ -28,7 +29,6 @@
class QHBoxLayout; class QHBoxLayout;
class QLabel; class QLabel;
class QPushButton; class QPushButton;
class QStringList;
class QMdiArea; class QMdiArea;
class QMdiSubWindow; class QMdiSubWindow;
class QFrame; class QFrame;