1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-02-22 02:20:47 +01:00

Remove all Qt5 < 5.15 workarounds.

Qt 5.15 is now the minimal required Qt version.
This commit is contained in:
Martin Tůma 2025-02-19 00:20:18 +01:00
parent 2ab7bff3f8
commit 5d2465cffc
16 changed files with 22 additions and 140 deletions

View File

@ -8,7 +8,7 @@ on:
jobs: jobs:
build: build:
name: GPXSee name: GPXSee
runs-on: ubuntu-20.04 runs-on: ubuntu-22.04
strategy: strategy:
matrix: matrix:
config: ['release', 'debug'] config: ['release', 'debug']

View File

@ -29,8 +29,8 @@ GPS log file formats.
## Build ## Build
Build requirements: Build requirements:
* Qt5 >= 5.11 or Qt6 >= 6.2 (Android builds require Qt6) * Qt5 >= 5.15 or Qt6 >= 6.2 (Android builds require Qt6)
* C++11 or newer compiler (tested: msvc2019, gcc 7.5.0, clang/Apple LLVM version * C++11 or newer compiler (tested: msvc2022, gcc 11, clang/Apple LLVM version
10.0.0) 10.0.0)
Build steps: Build steps:

View File

@ -5,7 +5,6 @@ unix:!macx:!android {
} }
VERSION = 13.36 VERSION = 13.36
QT += core \ QT += core \
gui \ gui \
gui-private \ gui-private \

View File

@ -73,9 +73,7 @@ App::App(int &argc, char **argv) : QApplication(argc, argv)
#if defined(Q_OS_WIN32) || defined(Q_OS_MAC) #if defined(Q_OS_WIN32) || defined(Q_OS_MAC)
QIcon::setThemeName(APP_NAME); QIcon::setThemeName(APP_NAME);
#endif // Q_OS_WIN32 || Q_OS_MAC #endif // Q_OS_WIN32 || Q_OS_MAC
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
QIcon::setFallbackThemeName(APP_NAME); QIcon::setFallbackThemeName(APP_NAME);
#endif // QT 5.12
_gui = new GUI(); _gui = new GUI();

View File

@ -25,15 +25,6 @@
#define IW(item) ((item)->boundingRect().width()) #define IW(item) ((item)->boundingRect().width())
#define IH(item) ((item)->boundingRect().height()) #define IH(item) ((item)->boundingRect().height())
static inline QPoint POS(QWheelEvent *e)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
return e->pos();
#else // QT 5.15
return e->position().toPoint();
#endif // QT 5.15
}
static inline QPoint POS(QMouseEvent *e) static inline QPoint POS(QMouseEvent *e)
{ {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
@ -393,7 +384,7 @@ void GraphView::wheelEvent(QWheelEvent *e)
return; return;
_angleDelta = _angleDelta % (15 * 8); _angleDelta = _angleDelta % (15 * 8);
QPointF pos = mapToScene(POS(e)); QPointF pos = mapToScene(e->position().toPoint());
QRectF gr(_grid->boundingRect()); QRectF gr(_grid->boundingRect());
QPointF r(pos.x() / gr.width(), pos.y() / gr.height()); QPointF r(pos.x() / gr.width(), pos.y() / gr.height());
@ -404,7 +395,8 @@ void GraphView::wheelEvent(QWheelEvent *e)
QPointF npos(mapFromScene(QPointF(r.x() * ngr.width(), QPointF npos(mapFromScene(QPointF(r.x() * ngr.width(),
r.y() * ngr.height()))); r.y() * ngr.height())));
QScrollBar *sb = horizontalScrollBar(); QScrollBar *sb = horizontalScrollBar();
sb->setSliderPosition(sb->sliderPosition() + npos.x() - POS(e).x()); sb->setSliderPosition(sb->sliderPosition() + npos.x()
- e->position().toPoint().x());
QGraphicsView::wheelEvent(e); QGraphicsView::wheelEvent(e);
} }

View File

@ -2498,12 +2498,8 @@ QGeoPositionInfoSource *GUI::positionSource(const Options &options)
{ {
QGeoPositionInfoSource *source; QGeoPositionInfoSource *source;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
source = QGeoPositionInfoSource::createSource(options.plugin, this);
#else // QT 5.14
source = QGeoPositionInfoSource::createSource(options.plugin, source = QGeoPositionInfoSource::createSource(options.plugin,
options.pluginParams.value(options.plugin), this); options.pluginParams.value(options.plugin), this);
#endif // QT 5.14
if (source) if (source)
source->setPreferredPositioningMethods( source->setPreferredPositioningMethods(
QGeoPositionInfoSource::SatellitePositioningMethods); QGeoPositionInfoSource::SatellitePositioningMethods);

View File

@ -638,11 +638,7 @@ void MapView::wheelEvent(QWheelEvent *event)
return; return;
_wheelDelta = _wheelDelta % (15 * 8); _wheelDelta = _wheelDelta % (15 * 8);
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
zoom((delta > 0) ? 1 : -1, event->pos(), shift);
#else // QT 5.15
zoom((delta > 0) ? 1 : -1, event->position().toPoint(), shift); zoom((delta > 0) ? 1 : -1, event->position().toPoint(), shift);
#endif // QT 5.15
/* Do not call QGraphicsView::wheelEvent() here as this would shift the /* Do not call QGraphicsView::wheelEvent() here as this would shift the
view ! */ view ! */

View File

@ -676,21 +676,17 @@ QWidget *OptionsDialog::createPositionPage()
_positionPlugin = new QComboBox(); _positionPlugin = new QComboBox();
_positionPlugin->addItems(plugins); _positionPlugin->addItems(plugins);
_positionPlugin->setCurrentIndex(_positionPlugin->findText(_options.plugin)); _positionPlugin->setCurrentIndex(_positionPlugin->findText(_options.plugin));
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
_pluginParameters = new PluginParameters(_positionPlugin->currentText(), _pluginParameters = new PluginParameters(_positionPlugin->currentText(),
_options.pluginParams); _options.pluginParams);
connect(_positionPlugin, &QComboBox::currentTextChanged, _pluginParameters, connect(_positionPlugin, &QComboBox::currentTextChanged, _pluginParameters,
&PluginParameters::setPlugin); &PluginParameters::setPlugin);
#endif // QT 5.14
QFormLayout *pluginLayout = new QFormLayout(); QFormLayout *pluginLayout = new QFormLayout();
pluginLayout->addRow(tr("Plugin:"), _positionPlugin); pluginLayout->addRow(tr("Plugin:"), _positionPlugin);
QVBoxLayout *sourceLayout = new QVBoxLayout(); QVBoxLayout *sourceLayout = new QVBoxLayout();
sourceLayout->addLayout(pluginLayout); sourceLayout->addLayout(pluginLayout);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
sourceLayout->addWidget(_pluginParameters); sourceLayout->addWidget(_pluginParameters);
#endif // QT 5.14
sourceLayout->addStretch(); sourceLayout->addStretch();
QWidget *sourceTab = new QWidget(); QWidget *sourceTab = new QWidget();
@ -1009,9 +1005,7 @@ void OptionsDialog::accept()
_options.hillshadingZFactor = _hillshadingZFactor->value(); _options.hillshadingZFactor = _hillshadingZFactor->value();
_options.plugin = _positionPlugin->currentText(); _options.plugin = _positionPlugin->currentText();
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
_options.pluginParams = _pluginParameters->parameters(); _options.pluginParams = _pluginParameters->parameters();
#endif // QT 5.14
_options.useOpenGL = _useOpenGL->isChecked(); _options.useOpenGL = _useOpenGL->isChecked();
_options.enableHTTP2 = _enableHTTP2->isChecked(); _options.enableHTTP2 = _enableHTTP2->isChecked();

View File

@ -193,9 +193,7 @@ private:
QDoubleSpinBox *_hillshadingZFactor; QDoubleSpinBox *_hillshadingZFactor;
// Position // Position
QComboBox *_positionPlugin; QComboBox *_positionPlugin;
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
PluginParameters *_pluginParameters; PluginParameters *_pluginParameters;
#endif // QT 5.14
// System // System
QSpinBox *_pixmapCache; QSpinBox *_pixmapCache;
QSpinBox *_demCache; QSpinBox *_demCache;

View File

@ -10,13 +10,6 @@
#include "markeritem.h" #include "markeritem.h"
#include "pathitem.h" #include "pathitem.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
#define INTERSECTS intersect
#else // QT 5.15
#define INTERSECTS intersects
#endif // QT 5.15
#define GEOGRAPHICAL_MILE 1855.3248 #define GEOGRAPHICAL_MILE 1855.3248
Units PathItem::_units = Metric; Units PathItem::_units = Metric;
@ -79,14 +72,14 @@ bool PathItem::addSegment(const Coordinates &c1, const Coordinates &c2)
QLineF l(QPointF(c1.lon(), c1.lat()), QPointF(c2.lon() + 360, QLineF l(QPointF(c1.lon(), c1.lat()), QPointF(c2.lon() + 360,
c2.lat())); c2.lat()));
QLineF dl(QPointF(180, -90), QPointF(180, 90)); QLineF dl(QPointF(180, -90), QPointF(180, 90));
l.INTERSECTS(dl, &p); l.intersects(dl, &p);
_painterPath.lineTo(_map->ll2xy(Coordinates(180, p.y()))); _painterPath.lineTo(_map->ll2xy(Coordinates(180, p.y())));
_painterPath.moveTo(_map->ll2xy(Coordinates(-180, p.y()))); _painterPath.moveTo(_map->ll2xy(Coordinates(-180, p.y())));
} else { } else {
QLineF l(QPointF(c1.lon(), c1.lat()), QPointF(c2.lon() - 360, QLineF l(QPointF(c1.lon(), c1.lat()), QPointF(c2.lon() - 360,
c2.lat())); c2.lat()));
QLineF dl(QPointF(-180, -90), QPointF(-180, 90)); QLineF dl(QPointF(-180, -90), QPointF(-180, 90));
l.INTERSECTS(dl, &p); l.intersects(dl, &p);
_painterPath.lineTo(_map->ll2xy(Coordinates(-180, p.y()))); _painterPath.lineTo(_map->ll2xy(Coordinates(-180, p.y())));
_painterPath.moveTo(_map->ll2xy(Coordinates(180, p.y()))); _painterPath.moveTo(_map->ll2xy(Coordinates(180, p.y())));
} }

View File

@ -9,9 +9,6 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QFormLayout> #include <QFormLayout>
#include <QApplication> #include <QApplication>
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
#include <QDesktopWidget>
#endif // QT 5.15
#include "tooltip.h" #include "tooltip.h"
#include "thumbnail.h" #include "thumbnail.h"
#include "flowlayout.h" #include "flowlayout.h"
@ -184,11 +181,7 @@ bool PopupFrame::eventFilter(QObject *o, QEvent *ev)
void PopupFrame::place(const QPoint &pos, QWidget *w) void PopupFrame::place(const QPoint &pos, QWidget *w)
{ {
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QRect screen = QApplication::desktop()->screenGeometry(w);
#else // QT 5.15
QRect screen = w->screen()->geometry(); QRect screen = w->screen()->geometry();
#endif // QT 5.15
QPoint p(pos.x() + 2, pos.y() + 16); QPoint p(pos.x() + 2, pos.y() + 16);
if (p.x() + width() > screen.x() + screen.width()) if (p.x() + width() > screen.x() + screen.width())

View File

@ -2,13 +2,6 @@
#include "map/gcs.h" #include "map/gcs.h"
#include "twonavparser.h" #include "twonavparser.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
#define SKIP_EMPTY QString::SkipEmptyParts
#else // Qt 5.14
#define SKIP_EMPTY Qt::SkipEmptyParts
#endif
static double lon(const QString &str) static double lon(const QString &str)
{ {
QStringList l(str.split(QChar(0xBA))); QStringList l(str.split(QChar(0xBA)));
@ -123,7 +116,8 @@ bool TwoNavParser::parse(QFile *file, QList<TrackData> &tracks,
}} }}
break; break;
case 'T': case 'T':
{QStringList list(codec.toString(line).split(' ', SKIP_EMPTY)); {QStringList list(codec.toString(line).split(' ',
Qt::SkipEmptyParts));
if (list.size() < 4) { if (list.size() < 4) {
_errorString = "Parse error"; _errorString = "Parse error";
return false; return false;
@ -159,7 +153,8 @@ bool TwoNavParser::parse(QFile *file, QList<TrackData> &tracks,
tracks.last().last().append(t);} tracks.last().last().append(t);}
break; break;
case 'W': case 'W':
{QStringList list(codec.toString(line).split(' ', SKIP_EMPTY)); {QStringList list(codec.toString(line).split(' ',
Qt::SkipEmptyParts));
if (list.size() < 5) { if (list.size() < 5) {
_errorString = "Parse error"; _errorString = "Parse error";
return false; return false;

View File

@ -27,14 +27,6 @@
#define MAX_REDIRECT_LEVEL 5 #define MAX_REDIRECT_LEVEL 5
#define RETRIES 3 #define RETRIES 3
#define ATTR_REDIRECT_POLICY QNetworkRequest::RedirectPolicyAttribute
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
#define ATTR_HTTP2_ALLOWED QNetworkRequest::HTTP2AllowedAttribute
#else // QT 5.15
#define ATTR_HTTP2_ALLOWED QNetworkRequest::Http2AllowedAttribute
#endif // QT 5.15
#define TMP_SUFFIX ".download" #define TMP_SUFFIX ".download"
// QNetworkReply::errorString() returns bullshit, use our own reporting // QNetworkReply::errorString() returns bullshit, use our own reporting
@ -129,31 +121,6 @@ Authorization::Authorization(const QString &username, const QString &password)
_header = HTTPHeader("Authorization", "Basic " + data); _header = HTTPHeader("Authorization", "Basic " + data);
} }
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
NetworkTimeout::NetworkTimeout(int timeout, QNetworkReply *reply)
: QObject(reply), _timeout(timeout)
{
connect(reply, &QIODevice::readyRead, this, &NetworkTimeout::reset);
_timer.start(timeout * 1000, this);
}
void NetworkTimeout::reset()
{
_timer.start(_timeout * 1000, this);
}
void NetworkTimeout::timerEvent(QTimerEvent *ev)
{
if (!_timer.isActive() || ev->timerId() != _timer.timerId())
return;
QNetworkReply *reply = static_cast<QNetworkReply*>(parent());
if (reply->isRunning())
reply->abort();
_timer.stop();
}
#endif // QT 5.15
QNetworkAccessManager *Downloader::_manager = 0; QNetworkAccessManager *Downloader::_manager = 0;
int Downloader::_timeout = 30; int Downloader::_timeout = 30;
bool Downloader::_http2 = true; bool Downloader::_http2 = true;
@ -176,12 +143,10 @@ bool Downloader::doDownload(const Download &dl, const QList<HTTPHeader> &headers
QNetworkRequest request(url); QNetworkRequest request(url);
request.setMaximumRedirectsAllowed(MAX_REDIRECT_LEVEL); request.setMaximumRedirectsAllowed(MAX_REDIRECT_LEVEL);
request.setAttribute(ATTR_REDIRECT_POLICY, request.setAttribute(QNetworkRequest::RedirectPolicyAttribute,
QNetworkRequest::NoLessSafeRedirectPolicy); QNetworkRequest::NoLessSafeRedirectPolicy);
request.setAttribute(ATTR_HTTP2_ALLOWED, QVariant(_http2)); request.setAttribute(QNetworkRequest::Http2AllowedAttribute, QVariant(_http2));
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
request.setTransferTimeout(_timeout * 1000); request.setTransferTimeout(_timeout * 1000);
#endif // QT 5.15
for (int i = 0; i < headers.size(); i++) { for (int i = 0; i < headers.size(); i++) {
const HTTPHeader &hdr = headers.at(i); const HTTPHeader &hdr = headers.at(i);
@ -208,9 +173,6 @@ bool Downloader::doDownload(const Download &dl, const QList<HTTPHeader> &headers
_currentDownloads.insert(url, file); _currentDownloads.insert(url, file);
if (reply->isRunning()) { if (reply->isRunning()) {
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
new NetworkTimeout(_timeout, reply);
#endif // QT 5.15
connect(reply, &QIODevice::readyRead, this, &Downloader::emitReadReady); connect(reply, &QIODevice::readyRead, this, &Downloader::emitReadReady);
connect(reply, &QNetworkReply::finished, this, &Downloader::emitFinished); connect(reply, &QNetworkReply::finished, this, &Downloader::emitFinished);
} else { } else {

View File

@ -3,9 +3,6 @@
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkReply> #include <QNetworkReply>
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
#include <QBasicTimer>
#endif // QT 5.15
#include <QUrl> #include <QUrl>
#include <QList> #include <QList>
#include <QHash> #include <QHash>
@ -41,25 +38,6 @@ private:
HTTPHeader _header; HTTPHeader _header;
}; };
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
class NetworkTimeout : public QObject
{
Q_OBJECT
public:
NetworkTimeout(int timeout, QNetworkReply *reply);
private slots:
void reset();
private:
void timerEvent(QTimerEvent *ev);
QBasicTimer _timer;
int _timeout;
};
#endif // QT 5.15
class Downloader : public QObject class Downloader : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@ -39,9 +39,7 @@ static QPainterPath parallelPath(const QPainterPath &p, double dy)
QVector<QPointF> u(n); QVector<QPointF> u(n);
QPainterPath h; QPainterPath h;
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
h.reserve(p.elementCount()); h.reserve(p.elementCount());
#endif // QT 5.13
for (int k = 0; k < n; k++) { for (int k = 0; k < n; k++) {
qreal c = p.elementAt(k + 1).x - p.elementAt(k).x; qreal c = p.elementAt(k + 1).x - p.elementAt(k).x;
@ -251,12 +249,10 @@ QPainterPath RasterTile::painterPath(const Polygon &polygon, bool curve) const
QPainterPath path; QPainterPath path;
if (curve) { if (curve) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
int size = 0; int size = 0;
for (int i = 0; i < polygon.size(); i++) for (int i = 0; i < polygon.size(); i++)
size += polygon.at(i).size(); size += polygon.at(i).size();
path.reserve(size); path.reserve(size);
#endif // QT 5.13
for (int i = 0; i < polygon.size(); i++) { for (int i = 0; i < polygon.size(); i++) {
const QVector<Coordinates> &subpath = polygon.at(i); const QVector<Coordinates> &subpath = polygon.at(i);

View File

@ -6,16 +6,8 @@
#define MAX_ANGLE 30 #define MAX_ANGLE 30
#define PADDING 2 #define PADDING 2
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
#define INTERSECTS intersect
#else // QT 5.15
#define INTERSECTS intersects
#endif // QT 5.15
static void swap(const QLineF &line, QPointF *p1, QPointF *p2) static void swap(const QLineF &line, QPointF *p1, QPointF *p2)
{ {
QPointF lp1(line.p1()); QPointF lp1(line.p1());
QPointF lp2(line.p2()); QPointF lp2(line.p2());
@ -34,10 +26,10 @@ static bool intersection(const QLineF &line, const QRectF &rect, QPointF *p1,
{ {
QPointF *p = p1; QPointF *p = p1;
if (line.INTERSECTS(QLineF(rect.topLeft(), rect.topRight()), p) if (line.intersects(QLineF(rect.topLeft(), rect.topRight()), p)
== QLineF::BoundedIntersection) == QLineF::BoundedIntersection)
p = p2; p = p2;
if (line.INTERSECTS(QLineF(rect.topLeft(), rect.bottomLeft()), p) if (line.intersects(QLineF(rect.topLeft(), rect.bottomLeft()), p)
== QLineF::BoundedIntersection) { == QLineF::BoundedIntersection) {
if (p == p2) { if (p == p2) {
swap(line, p1, p2); swap(line, p1, p2);
@ -45,7 +37,7 @@ static bool intersection(const QLineF &line, const QRectF &rect, QPointF *p1,
} }
p = p2; p = p2;
} }
if (line.INTERSECTS(QLineF(rect.bottomRight(), rect.bottomLeft()), p) if (line.intersects(QLineF(rect.bottomRight(), rect.bottomLeft()), p)
== QLineF::BoundedIntersection) { == QLineF::BoundedIntersection) {
if (p == p2) { if (p == p2) {
swap(line, p1, p2); swap(line, p1, p2);
@ -53,7 +45,7 @@ static bool intersection(const QLineF &line, const QRectF &rect, QPointF *p1,
} }
p = p2; p = p2;
} }
if (line.INTERSECTS(QLineF(rect.bottomRight(), rect.topRight()), p) if (line.intersects(QLineF(rect.bottomRight(), rect.topRight()), p)
== QLineF::BoundedIntersection) { == QLineF::BoundedIntersection) {
if (p == p2) { if (p == p2) {
swap(line, p1, p2); swap(line, p1, p2);
@ -68,16 +60,16 @@ static bool intersection(const QLineF &line, const QRectF &rect, QPointF *p1,
static bool intersection(const QLineF &line, const QRectF &rect, QPointF *p) static bool intersection(const QLineF &line, const QRectF &rect, QPointF *p)
{ {
if (line.INTERSECTS(QLineF(rect.topLeft(), rect.topRight()), p) if (line.intersects(QLineF(rect.topLeft(), rect.topRight()), p)
== QLineF::BoundedIntersection) == QLineF::BoundedIntersection)
return true; return true;
if (line.INTERSECTS(QLineF(rect.topLeft(), rect.bottomLeft()), p) if (line.intersects(QLineF(rect.topLeft(), rect.bottomLeft()), p)
== QLineF::BoundedIntersection) == QLineF::BoundedIntersection)
return true; return true;
if (line.INTERSECTS(QLineF(rect.bottomRight(), rect.bottomLeft()), p) if (line.intersects(QLineF(rect.bottomRight(), rect.bottomLeft()), p)
== QLineF::BoundedIntersection) == QLineF::BoundedIntersection)
return true; return true;
if (line.INTERSECTS(QLineF(rect.bottomRight(), rect.topRight()), p) if (line.intersects(QLineF(rect.bottomRight(), rect.topRight()), p)
== QLineF::BoundedIntersection) == QLineF::BoundedIntersection)
return true; return true;