diff --git a/app/main.cpp b/app/main.cpp index f328b2b5f..f3f6ce875 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -22,8 +22,10 @@ #include #include #include +#ifdef __APPLE__ #include #include +#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 diff --git a/sdrbase/commands/command.cpp b/sdrbase/commands/command.cpp index 5036e33a7..ba25ba1a8 100644 --- a/sdrbase/commands/command.cpp +++ b/sdrbase/commands/command.cpp @@ -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 diff --git a/sdrbase/device/deviceuserargs.cpp b/sdrbase/device/deviceuserargs.cpp index e8730b72f..9ba02011b 100644 --- a/sdrbase/device/deviceuserargs.cpp +++ b/sdrbase/device/deviceuserargs.cpp @@ -16,6 +16,7 @@ /////////////////////////////////////////////////////////////////////////////////// #include +#include #include "util/simpleserializer.h" #include "deviceuserargs.h" diff --git a/sdrbase/dsp/glscopesettings.h b/sdrbase/dsp/glscopesettings.h index 7fbcce431..647821f58 100644 --- a/sdrbase/dsp/glscopesettings.h +++ b/sdrbase/dsp/glscopesettings.h @@ -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; diff --git a/sdrbase/dsp/spectrumsettings.cpp b/sdrbase/dsp/spectrumsettings.cpp index e908aaa1a..122981c8c 100644 --- a/sdrbase/dsp/spectrumsettings.cpp +++ b/sdrbase/dsp/spectrumsettings.cpp @@ -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; } diff --git a/sdrbase/mainparser.cpp b/sdrbase/mainparser.cpp index fa96f6033..6ab22f2ce 100644 --- a/sdrbase/mainparser.cpp +++ b/sdrbase/mainparser.cpp @@ -17,7 +17,7 @@ /////////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include #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 - + "\\." + ipRange - + "\\." + ipRange - + "\\." + ipRange + "$"); - QRegExpValidator ipValidator(ipRegex); + QRegularExpression ipRegex ("^" + ipRange + + "\\." + ipRange + + "\\." + ipRange + + "\\." + ipRange + "$"); + QRegularExpressionValidator ipValidator(ipRegex); if (ipValidator.validate(serverAddress, pos) == QValidator::Acceptable) { m_serverAddress = serverAddress; diff --git a/sdrbase/settings/rollupstate.cpp b/sdrbase/settings/rollupstate.cpp index 0c9584471..1c811d68b 100644 --- a/sdrbase/settings/rollupstate.cpp +++ b/sdrbase/settings/rollupstate.cpp @@ -17,6 +17,8 @@ /////////////////////////////////////////////////////////////////////////////////// #include +#include + #include "SWGRollupState.h" #include "rollupstate.h" diff --git a/sdrbase/settings/serializable.h b/sdrbase/settings/serializable.h index 84d1420c8..d5358487e 100644 --- a/sdrbase/settings/serializable.h +++ b/sdrbase/settings/serializable.h @@ -22,7 +22,8 @@ namespace SWGSDRangel { class SWGObject; } -class QStringList; +#include + class Serializable { public: diff --git a/sdrbase/util/ais.cpp b/sdrbase/util/ais.cpp index 461116181..5ce502314 100644 --- a/sdrbase/util/ais.cpp +++ b/sdrbase/util/ais.cpp @@ -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(); diff --git a/sdrbase/util/aprs.cpp b/sdrbase/util/aprs.cpp index e4b1effec..d1191733d 100644 --- a/sdrbase/util/aprs.cpp +++ b/sdrbase/util/aprs.cpp @@ -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 == ' '); } diff --git a/sdrbase/util/aprs.h b/sdrbase/util/aprs.h index 5a20810ef..b2b34a551 100644 --- a/sdrbase/util/aprs.h +++ b/sdrbase/util/aprs.h @@ -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); diff --git a/sdrbase/util/morse.cpp b/sdrbase/util/morse.cpp index e7b4ebaf1..97d4f4509 100644 --- a/sdrbase/util/morse.cpp +++ b/sdrbase/util/morse.cpp @@ -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; } diff --git a/sdrbase/util/openaip.h b/sdrbase/util/openaip.h index 058f6e029..1d4d372d1 100644 --- a/sdrbase/util/openaip.h +++ b/sdrbase/util/openaip.h @@ -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")) diff --git a/sdrbase/util/peakfinder.cpp b/sdrbase/util/peakfinder.cpp index a2c0f8a56..91ddcf44c 100644 --- a/sdrbase/util/peakfinder.cpp +++ b/sdrbase/util/peakfinder.cpp @@ -18,6 +18,8 @@ // along with this program. If not, see . // /////////////////////////////////////////////////////////////////////////////////// +#include + #include "peakfinder.h" PeakFinder::PeakFinder() : diff --git a/sdrbase/util/visa.cpp b/sdrbase/util/visa.cpp index 8699c6179..19f0adc21 100644 --- a/sdrbase/util/visa.cpp +++ b/sdrbase/util/visa.cpp @@ -257,7 +257,7 @@ QList VISA::instruments(QRegularExpression *filter) void *VISA::libraryOpen(const char *filename) { HMODULE module; - module = LoadLibrary ((LPCSTR)filename); + module = LoadLibraryA ((LPCSTR)filename); return module; } diff --git a/sdrbench/parserbench.cpp b/sdrbench/parserbench.cpp index a03fa749e..122c235f9 100644 --- a/sdrbench/parserbench.cpp +++ b/sdrbench/parserbench.cpp @@ -17,7 +17,7 @@ /////////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include #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; diff --git a/sdrgui/channel/channelgui.h b/sdrgui/channel/channelgui.h index aaecd6428..1e482d36a 100644 --- a/sdrgui/channel/channelgui.h +++ b/sdrgui/channel/channelgui.h @@ -21,6 +21,7 @@ #include #include +#include "gui/qtcompatibility.h" #include "gui/framelesswindowresizer.h" #include "export.h" diff --git a/sdrgui/gui/channeladddialog.h b/sdrgui/gui/channeladddialog.h index f0a8fefaa..0d5b5b1cb 100644 --- a/sdrgui/gui/channeladddialog.h +++ b/sdrgui/gui/channeladddialog.h @@ -20,11 +20,11 @@ #define SDRGUI_GUI_CHANNELADDDIALOG_H_ #include +#include #include #include "export.h" -class QStringList; class QAbstractButton; namespace Ui { diff --git a/sdrgui/gui/cwkeyergui.cpp b/sdrgui/gui/cwkeyergui.cpp index fa89aa94e..2d5f9d920 100644 --- a/sdrgui/gui/cwkeyergui.cpp +++ b/sdrgui/gui/cwkeyergui.cpp @@ -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 diff --git a/sdrgui/gui/editcommanddialog.cpp b/sdrgui/gui/editcommanddialog.cpp index 14fe7eef3..5d4ff4c83 100644 --- a/sdrgui/gui/editcommanddialog.cpp +++ b/sdrgui/gui/editcommanddialog.cpp @@ -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 diff --git a/sdrgui/gui/featureadddialog.h b/sdrgui/gui/featureadddialog.h index c2270b3ef..f999b5b21 100644 --- a/sdrgui/gui/featureadddialog.h +++ b/sdrgui/gui/featureadddialog.h @@ -20,11 +20,11 @@ #define SDRGUI_GUI_FEATUREADDDIALOG_H_ #include +#include #include #include "export.h" -class QStringList; class QAbstractButton; namespace Ui { diff --git a/sdrgui/gui/glspectrumgui.cpp b/sdrgui/gui/glspectrumgui.cpp index d14ee6923..4b655bfd9 100644 --- a/sdrgui/gui/glspectrumgui.cpp +++ b/sdrgui/gui/glspectrumgui.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #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; diff --git a/sdrgui/gui/glspectrumview.cpp b/sdrgui/gui/glspectrumview.cpp index 6381eb105..5532a3a28 100644 --- a/sdrgui/gui/glspectrumview.cpp +++ b/sdrgui/gui/glspectrumview.cpp @@ -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() diff --git a/sdrgui/gui/glspectrumview.h b/sdrgui/gui/glspectrumview.h index b14c4fa93..74101b6a9 100644 --- a/sdrgui/gui/glspectrumview.h +++ b/sdrgui/gui/glspectrumview.h @@ -30,6 +30,7 @@ #include #include #include +#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); diff --git a/sdrgui/gui/qtcompatibility.h b/sdrgui/gui/qtcompatibility.h new file mode 100644 index 000000000..c6db2bff8 --- /dev/null +++ b/sdrgui/gui/qtcompatibility.h @@ -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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#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 +typedef QEnterEvent EnterEventType; +#else +#include +typedef QEvent EnterEventType; +#endif + +#endif diff --git a/sdrgui/gui/scaleengine.cpp b/sdrgui/gui/scaleengine.cpp index 68783e20e..5bc755ac4 100644 --- a/sdrgui/gui/scaleengine.cpp +++ b/sdrgui/gui/scaleengine.cpp @@ -17,6 +17,7 @@ /////////////////////////////////////////////////////////////////////////////////// #include +#include #include #include #include "gui/scaleengine.h" diff --git a/sdrgui/gui/spectrummarkersdialog.cpp b/sdrgui/gui/spectrummarkersdialog.cpp index b75c36a7e..dd0f2c324 100644 --- a/sdrgui/gui/spectrummarkersdialog.cpp +++ b/sdrgui/gui/spectrummarkersdialog.cpp @@ -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(); } diff --git a/sdrgui/gui/valuedial.cpp b/sdrgui/gui/valuedial.cpp index 169398fea..9222baa80 100644 --- a/sdrgui/gui/valuedial.cpp +++ b/sdrgui/gui/valuedial.cpp @@ -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; } diff --git a/sdrgui/gui/valuedial.h b/sdrgui/gui/valuedial.h index e6a1e919f..2a467e362 100644 --- a/sdrgui/gui/valuedial.h +++ b/sdrgui/gui/valuedial.h @@ -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; diff --git a/sdrgui/gui/valuedialz.cpp b/sdrgui/gui/valuedialz.cpp index 7dc13da76..948bfe611 100644 --- a/sdrgui/gui/valuedialz.cpp +++ b/sdrgui/gui/valuedialz.cpp @@ -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; } diff --git a/sdrgui/gui/valuedialz.h b/sdrgui/gui/valuedialz.h index 68ce6ba7f..ad3ca6135 100644 --- a/sdrgui/gui/valuedialz.h +++ b/sdrgui/gui/valuedialz.h @@ -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; diff --git a/sdrgui/gui/workspace.h b/sdrgui/gui/workspace.h index a79eeff03..ab4d05b6b 100644 --- a/sdrgui/gui/workspace.h +++ b/sdrgui/gui/workspace.h @@ -20,6 +20,7 @@ #define SDRGUI_GUI_WORKSPACE_H_ #include +#include #include "export.h" #include "featureadddialog.h" @@ -28,7 +29,6 @@ class QHBoxLayout; class QLabel; class QPushButton; -class QStringList; class QMdiArea; class QMdiSubWindow; class QFrame;