From 6cb34cb7f583d8c5949a7203695006148b8add47 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 10 Apr 2022 18:49:11 -1000 Subject: [PATCH] Qt6: update the connect calls for QNetworkReply Because of the old connect syntax used the incorrect signal names weren't caught at compile time. To switch to the new syntax we had to make two functions pure virtual in the WebServices class - let's hope I got that right. Signed-off-by: Dirk Hohndel --- core/cloudstorage.cpp | 6 ++++++ core/uploadDiveLogsDE.cpp | 9 ++++++++- core/uploadDiveShare.cpp | 8 +++++++- desktop-widgets/subsurfacewebservices.cpp | 13 +++++++++++-- desktop-widgets/subsurfacewebservices.h | 2 ++ 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/core/cloudstorage.cpp b/core/cloudstorage.cpp index 151014359..82759e101 100644 --- a/core/cloudstorage.cpp +++ b/core/cloudstorage.cpp @@ -37,10 +37,16 @@ QNetworkReply* CloudStorageAuthenticate::backend(const QString& email,const QStr request->setRawHeader("User-Agent", userAgent.toUtf8()); request->setHeader(QNetworkRequest::ContentTypeHeader, "text/plain"); reply = manager()->post(*request, qPrintable(payload)); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + connect(reply, &QNetworkReply::finished, this, &CloudStorageAuthenticate::uploadFinished); + connect(reply, &QNetworkReply::sslErrors, this, &CloudStorageAuthenticate::sslErrors); + connect(reply, &QNetworkReply::errorOccurred, this, &CloudStorageAuthenticate::uploadError); +#else connect(reply, SIGNAL(finished()), this, SLOT(uploadFinished())); connect(reply, SIGNAL(sslErrors(QList)), this, SLOT(sslErrors(QList))); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(uploadError(QNetworkReply::NetworkError))); +#endif return reply; } diff --git a/core/uploadDiveLogsDE.cpp b/core/uploadDiveLogsDE.cpp index c35f85061..ee46a2068 100644 --- a/core/uploadDiveLogsDE.cpp +++ b/core/uploadDiveLogsDE.cpp @@ -255,13 +255,20 @@ void uploadDiveLogsDE::uploadDives(const QString &filename, const QString &useri reply = manager()->post(request, multipart); // connect signals from upload process +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + connect(reply, &QNetworkReply::finished, this, &uploadDiveLogsDE::uploadFinishedSlot); + connect(reply, &QNetworkReply::errorOccurred, this, &uploadDiveLogsDE::uploadErrorSlot); + connect(reply, &QNetworkReply::uploadProgress, this, &uploadDiveLogsDE::updateProgressSlot); + connect(&timeout, &QTimer::timeout, this, &uploadDiveLogsDE::uploadTimeoutSlot); +#else + connect(reply, SIGNAL(finished()), this, SLOT(uploadFinishedSlot())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(uploadErrorSlot(QNetworkReply::NetworkError))); connect(reply, SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(updateProgressSlot(qint64, qint64))); connect(&timeout, SIGNAL(timeout()), this, SLOT(uploadTimeoutSlot())); - +#endif timeout.start(30000); // 30s } diff --git a/core/uploadDiveShare.cpp b/core/uploadDiveShare.cpp index 87c3d0b24..f1b94b097 100644 --- a/core/uploadDiveShare.cpp +++ b/core/uploadDiveShare.cpp @@ -45,13 +45,19 @@ void uploadDiveShare::doUpload(bool selected, const QString &uid, bool noPublic) reply = manager()->put(request, json_data); // connect signals from upload process +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + connect(reply, &QNetworkReply::finished, this, &uploadDiveShare::uploadFinishedSlot); + connect(reply, &QNetworkReply::errorOccurred, this, &uploadDiveShare::uploadErrorSlot); + connect(reply, &QNetworkReply::uploadProgress, this, &uploadDiveShare::updateProgressSlot); + connect(&timeout, &QTimer::timeout, this, &uploadDiveShare::uploadTimeoutSlot); +#else connect(reply, SIGNAL(finished()), this, SLOT(uploadFinishedSlot())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(uploadErrorSlot(QNetworkReply::NetworkError))); connect(reply, SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(updateProgressSlot(qint64, qint64))); connect(&timeout, SIGNAL(timeout()), this, SLOT(uploadTimeoutSlot())); - +#endif timeout.start(30000); // 30s } diff --git a/desktop-widgets/subsurfacewebservices.cpp b/desktop-widgets/subsurfacewebservices.cpp index 80d12c324..b4bce58d8 100644 --- a/desktop-widgets/subsurfacewebservices.cpp +++ b/desktop-widgets/subsurfacewebservices.cpp @@ -107,12 +107,17 @@ void WebServices::updateProgress(qint64 current, qint64 total) void WebServices::connectSignalsForDownload(QNetworkReply *reply) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + connect(reply, &QNetworkReply::finished, this, &WebServices::downloadFinished); + connect(reply, &QNetworkReply::errorOccurred, this, &WebServices::downloadError); + connect(reply, &QNetworkReply::downloadProgress, this, &WebServices::updateProgress); +#else connect(reply, SIGNAL(finished()), this, SLOT(downloadFinished())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError))); connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(updateProgress(qint64, qint64))); - +#endif timeout.start(30000); // 30s } @@ -308,10 +313,14 @@ void DivelogsDeWebServices::startDownload() body.addQueryItem("pass", ui.password->text().replace("+", "%2b")); reply = manager()->post(request, body.query(QUrl::FullyEncoded).toLatin1()); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + connect(reply, &QNetworkReply::finished, this, &DivelogsDeWebServices::listDownloadFinished); + connect(reply, &QNetworkReply::errorOccurred, this, &DivelogsDeWebServices::downloadError); +#else connect(reply, SIGNAL(finished()), this, SLOT(listDownloadFinished())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError))); - +#endif timeout.start(30000); // 30s } diff --git a/desktop-widgets/subsurfacewebservices.h b/desktop-widgets/subsurfacewebservices.h index f9bedefa1..2ef652e7f 100644 --- a/desktop-widgets/subsurfacewebservices.h +++ b/desktop-widgets/subsurfacewebservices.h @@ -26,6 +26,8 @@ slots: virtual void startDownload() = 0; virtual void startUpload() = 0; virtual void buttonClicked(QAbstractButton *button) = 0; + virtual void downloadFinished() = 0; + virtual void downloadError(QNetworkReply::NetworkError error) = 0; void downloadTimedOut(); protected