Fix build on Qt 5.14 and earlier

This commit is contained in:
Cameron Gutman 2020-11-23 20:39:50 -06:00
parent 2ef714f87b
commit d7ca3801be
2 changed files with 16 additions and 1 deletions

View file

@ -40,7 +40,11 @@ void AutoUpdateChecker::start()
// We'll get a callback when this is finished
QUrl url("https://moonlight-stream.org/updates/qt.json");
QNetworkRequest request(url);
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
request.setAttribute(QNetworkRequest::Http2AllowedAttribute, true);
#else
request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, true);
#endif
m_Nam.get(request);
#endif
}

View file

@ -29,8 +29,18 @@ void MappingFetcher::start()
QUrl url("https://moonlight-stream.org/SDL_GameControllerDB/gamecontrollerdb.txt");
QNetworkRequest request(url);
request.setAttribute(QNetworkRequest::Http2AllowedAttribute, true);
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
request.setAttribute(QNetworkRequest::Http2AllowedAttribute, true);
#else
request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, true);
#endif
// Qt 5.12 introduced QNetworkRequest::IfModifiedSinceHeader. We _could_ implement it
// by hand (including QDateTime conversion to the correct string form) for earlier Qt
// versions, but that's a pain and this is just an optimization anyway. We'll do a bit
// of extra work on those legacy Qt versions by fetching the GCDB each time we launch.
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
// Only download the file if it's newer than what we have
QFileInfo existingFileInfo = Path::getCacheFileInfo("gamecontrollerdb.txt");
if (existingFileInfo.exists()) {
@ -41,6 +51,7 @@ void MappingFetcher::start()
Path::deleteCacheFile("gamecontrollerdb.txt");
}
}
#endif
// We'll get a callback when this is finished
m_Nam.get(request);