1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-10-31 15:07:12 -04: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 <QFontDatabase>
#include <QSysInfo>
#ifdef __APPLE__
#include <QGLFormat>
#include <QSurfaceFormat>
#endif
#include "loggerwithfile.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_ShareOpenGLContexts); // Needed for WebGL in QWebEngineView and MainWindow::openGLVersion
#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);
#endif

View File

@ -150,7 +150,7 @@ QString Command::getKeyLabel() const
else if (m_keyModifiers != Qt::NoModifier)
{
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();
}
else

View File

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

View File

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

View File

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

View File

@ -17,7 +17,7 @@
///////////////////////////////////////////////////////////////////////////////////
#include <QCommandLineOption>
#include <QRegExpValidator>
#include <QRegularExpressionValidator>
#include <QDebug>
#include "mainparser.h"
@ -72,11 +72,11 @@ void MainParser::parse(const QCoreApplication& app)
if (!serverAddress.isEmpty())
{
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 + "$");
QRegExpValidator ipValidator(ipRegex);
QRegularExpressionValidator ipValidator(ipRegex);
if (ipValidator.validate(serverAddress, pos) == QValidator::Acceptable) {
m_serverAddress = serverAddress;

View File

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

View File

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

View File

@ -256,7 +256,7 @@ QString AISMessage::getString(const QByteArray ba, int byteIdx, int bitsLeft, in
if (c < 32) {
c |= 0x40;
}
s.append(c);
s.append(QChar(c));
}
// Remove leading/trailing spaces
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
bool APRSPacket::isLatLongChar(QCharRef c)
bool APRSPacket::isLatLongChar(const QChar c)
{
return (c.isDigit() || c == ' ');
}

View File

@ -461,7 +461,7 @@ private:
int charToInt(QString &s, int idx);
bool parseTime(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 parseDataExension(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]);
if ((c != -1) && (groups[i] != ""))
string.append(c);
string.append(QChar(c));
}
return string;
}

View File

@ -130,7 +130,7 @@ struct SDRBASE_API Airspace {
{
if (xmlReader.readNextStartElement())
{
if (xmlReader.name() == "ASP")
if (xmlReader.name() == QLatin1String("ASP"))
{
Airspace *airspace = new Airspace();
@ -264,9 +264,9 @@ struct SDRBASE_API NavAid {
{
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"))
|| (typeRef == QLatin1String("DME"))
|| (typeRef == QLatin1String("VOR"))

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -344,7 +344,7 @@ void CWKeyerGUI::setKeyLabel(QLabel *label, Qt::Key key, Qt::KeyboardModifiers k
else if (keyModifiers != Qt::NoModifier)
{
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());
}
else

View File

@ -204,7 +204,7 @@ void EditCommandDialog::setKeyLabel()
else if (m_keyModifiers != Qt::NoModifier)
{
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());
}
else

View File

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

View File

@ -23,7 +23,6 @@
#include <QToolTip>
#include <QFileDialog>
#include <QMessageBox>
#include <QDesktopWidget>
#include <QScreen>
#include "gui/glspectrumgui.h"
@ -728,7 +727,7 @@ void GLSpectrumGUI::on_calibration_toggled(bool checked)
void GLSpectrumGUI::on_gotoMarker_currentIndexChanged(int index)
{
if (index == 0) {
if (index <= 0) {
return;
}
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);
}
void GLSpectrumView::enterEvent(QEvent* event)
void GLSpectrumView::enterEvent(EnterEventType* event)
{
m_mouseInside = true;
update();
@ -4463,7 +4463,7 @@ void GLSpectrumView::leaveEvent(QEvent* event)
{
m_mouseInside = false;
update();
QOpenGLWidget::enterEvent(event);
QOpenGLWidget::leaveEvent(event);
}
void GLSpectrumView::tick()

View File

@ -30,6 +30,7 @@
#include <QPoint>
#include <QOpenGLWidget>
#include <QOpenGLDebugLogger>
#include "gui/qtcompatibility.h"
#include "gui/scaleengine.h"
#include "gui/glshadersimple.h"
#include "gui/glshadertextured.h"
@ -465,7 +466,7 @@ private:
bool pointInWaterfallOrSpectrogram(const QPointF &point) const;
bool pointInHistogram(const QPointF &point) const;
void enterEvent(QEvent* event);
void enterEvent(EnterEventType* event);
void leaveEvent(QEvent* event);
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 <QObject>
#include <QFontMetrics>
#include <QDataStream>
#include "gui/scaleengine.h"

View File

@ -841,14 +841,14 @@ void SpectrumMarkersDialog::on_showSelect_currentIndexChanged(int index)
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);
displayHistogramMarker();
}
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);
displayWaterfallMarker();
}

View File

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

View File

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

View File

@ -399,7 +399,7 @@ void ValueDialZ::mouseMoveEvent(QMouseEvent* event)
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;
}

View File

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

View File

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