mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Added support for HTTP/2
This commit is contained in:
parent
33739acafe
commit
c0e458a437
@ -284,3 +284,4 @@ win32 {
|
|||||||
DEFINES += _USE_MATH_DEFINES
|
DEFINES += _USE_MATH_DEFINES
|
||||||
}
|
}
|
||||||
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||||
|
greaterThan(QT_VERSION, 5.10.0): DEFINES += ENABLE_HTTP2
|
||||||
|
@ -920,6 +920,10 @@ void GUI::openOptions()
|
|||||||
QPixmapCache::setCacheLimit(options.pixmapCache * 1024);
|
QPixmapCache::setCacheLimit(options.pixmapCache * 1024);
|
||||||
if (options.connectionTimeout != _options.connectionTimeout)
|
if (options.connectionTimeout != _options.connectionTimeout)
|
||||||
Downloader::setTimeout(options.connectionTimeout);
|
Downloader::setTimeout(options.connectionTimeout);
|
||||||
|
#ifdef ENABLE_HTTP2
|
||||||
|
if (options.enableHTTP2 != _options.enableHTTP2)
|
||||||
|
Downloader::enableHTTP2(options.enableHTTP2);
|
||||||
|
#endif // ENABLE_HTTP2
|
||||||
|
|
||||||
if (reload)
|
if (reload)
|
||||||
reloadFile();
|
reloadFile();
|
||||||
@ -1755,6 +1759,10 @@ void GUI::writeSettings()
|
|||||||
settings.setValue(POI_RADIUS_SETTING, _options.poiRadius);
|
settings.setValue(POI_RADIUS_SETTING, _options.poiRadius);
|
||||||
if (_options.useOpenGL != USE_OPENGL_DEFAULT)
|
if (_options.useOpenGL != USE_OPENGL_DEFAULT)
|
||||||
settings.setValue(USE_OPENGL_SETTING, _options.useOpenGL);
|
settings.setValue(USE_OPENGL_SETTING, _options.useOpenGL);
|
||||||
|
#ifdef ENABLE_HTTP2
|
||||||
|
if (_options.enableHTTP2 != ENABLE_HTTP2_DEFAULT)
|
||||||
|
settings.setValue(ENABLE_HTTP2_SETTING, _options.enableHTTP2);
|
||||||
|
#endif // ENABLE_HTTP2
|
||||||
if (_options.pixmapCache != PIXMAP_CACHE_DEFAULT)
|
if (_options.pixmapCache != PIXMAP_CACHE_DEFAULT)
|
||||||
settings.setValue(PIXMAP_CACHE_SETTING, _options.pixmapCache);
|
settings.setValue(PIXMAP_CACHE_SETTING, _options.pixmapCache);
|
||||||
if (_options.connectionTimeout != CONNECTION_TIMEOUT_DEFAULT)
|
if (_options.connectionTimeout != CONNECTION_TIMEOUT_DEFAULT)
|
||||||
@ -1987,6 +1995,10 @@ void GUI::readSettings()
|
|||||||
.toInt();
|
.toInt();
|
||||||
_options.useOpenGL = settings.value(USE_OPENGL_SETTING, USE_OPENGL_DEFAULT)
|
_options.useOpenGL = settings.value(USE_OPENGL_SETTING, USE_OPENGL_DEFAULT)
|
||||||
.toBool();
|
.toBool();
|
||||||
|
#ifdef ENABLE_HTTP2
|
||||||
|
_options.enableHTTP2 = settings.value(ENABLE_HTTP2_SETTING,
|
||||||
|
ENABLE_HTTP2_DEFAULT).toBool();
|
||||||
|
#endif // ENABLE_HTTP2
|
||||||
_options.pixmapCache = settings.value(PIXMAP_CACHE_SETTING,
|
_options.pixmapCache = settings.value(PIXMAP_CACHE_SETTING,
|
||||||
PIXMAP_CACHE_DEFAULT).toInt();
|
PIXMAP_CACHE_DEFAULT).toInt();
|
||||||
_options.connectionTimeout = settings.value(CONNECTION_TIMEOUT_SETTING,
|
_options.connectionTimeout = settings.value(CONNECTION_TIMEOUT_SETTING,
|
||||||
@ -2052,6 +2064,9 @@ void GUI::readSettings()
|
|||||||
|
|
||||||
QPixmapCache::setCacheLimit(_options.pixmapCache * 1024);
|
QPixmapCache::setCacheLimit(_options.pixmapCache * 1024);
|
||||||
Downloader::setTimeout(_options.connectionTimeout);
|
Downloader::setTimeout(_options.connectionTimeout);
|
||||||
|
#ifdef ENABLE_HTTP2
|
||||||
|
Downloader::enableHTTP2(_options.enableHTTP2);
|
||||||
|
#endif // ENABLE_HTTP2
|
||||||
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
@ -440,6 +440,10 @@ QWidget *OptionsDialog::createSystemPage()
|
|||||||
{
|
{
|
||||||
_useOpenGL = new QCheckBox(tr("Use OpenGL"));
|
_useOpenGL = new QCheckBox(tr("Use OpenGL"));
|
||||||
_useOpenGL->setChecked(_options->useOpenGL);
|
_useOpenGL->setChecked(_options->useOpenGL);
|
||||||
|
#ifdef ENABLE_HTTP2
|
||||||
|
_enableHTTP2 = new QCheckBox(tr("Enable HTTP/2"));
|
||||||
|
_enableHTTP2->setChecked(_options->enableHTTP2);
|
||||||
|
#endif // ENABLE_HTTP2
|
||||||
|
|
||||||
_pixmapCache = new QSpinBox();
|
_pixmapCache = new QSpinBox();
|
||||||
_pixmapCache->setMinimum(16);
|
_pixmapCache->setMinimum(16);
|
||||||
@ -458,6 +462,9 @@ QWidget *OptionsDialog::createSystemPage()
|
|||||||
formLayout->addRow(tr("Connection timeout:"), _connectionTimeout);
|
formLayout->addRow(tr("Connection timeout:"), _connectionTimeout);
|
||||||
|
|
||||||
QFormLayout *checkboxLayout = new QFormLayout();
|
QFormLayout *checkboxLayout = new QFormLayout();
|
||||||
|
#ifdef ENABLE_HTTP2
|
||||||
|
checkboxLayout->addWidget(_enableHTTP2);
|
||||||
|
#endif // ENABLE_HTTP2
|
||||||
checkboxLayout->addWidget(_useOpenGL);
|
checkboxLayout->addWidget(_useOpenGL);
|
||||||
|
|
||||||
QWidget *systemTab = new QWidget();
|
QWidget *systemTab = new QWidget();
|
||||||
@ -568,6 +575,9 @@ void OptionsDialog::accept()
|
|||||||
_options->poiRadius = poiRadius;
|
_options->poiRadius = poiRadius;
|
||||||
|
|
||||||
_options->useOpenGL = _useOpenGL->isChecked();
|
_options->useOpenGL = _useOpenGL->isChecked();
|
||||||
|
#ifdef ENABLE_HTTP2
|
||||||
|
_options->enableHTTP2 = _enableHTTP2->isChecked();
|
||||||
|
#endif // ENABLE_HTTP2
|
||||||
_options->pixmapCache = _pixmapCache->value();
|
_options->pixmapCache = _pixmapCache->value();
|
||||||
_options->connectionTimeout = _connectionTimeout->value();
|
_options->connectionTimeout = _connectionTimeout->value();
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
|
||||||
|
|
||||||
class ColorBox;
|
class ColorBox;
|
||||||
class StyleComboBox;
|
class StyleComboBox;
|
||||||
class OddSpinBox;
|
class OddSpinBox;
|
||||||
@ -48,6 +49,9 @@ struct Options {
|
|||||||
int poiRadius;
|
int poiRadius;
|
||||||
// System
|
// System
|
||||||
bool useOpenGL;
|
bool useOpenGL;
|
||||||
|
#ifdef ENABLE_HTTP2
|
||||||
|
bool enableHTTP2;
|
||||||
|
#endif // ENABLE_HTTP2
|
||||||
int pixmapCache;
|
int pixmapCache;
|
||||||
int connectionTimeout;
|
int connectionTimeout;
|
||||||
// Print/Export
|
// Print/Export
|
||||||
@ -119,6 +123,9 @@ private:
|
|||||||
QSpinBox *_pixmapCache;
|
QSpinBox *_pixmapCache;
|
||||||
QSpinBox *_connectionTimeout;
|
QSpinBox *_connectionTimeout;
|
||||||
QCheckBox *_useOpenGL;
|
QCheckBox *_useOpenGL;
|
||||||
|
#ifdef ENABLE_HTTP2
|
||||||
|
QCheckBox *_enableHTTP2;
|
||||||
|
#endif // ENABLE_HTTP2
|
||||||
// Print/Export
|
// Print/Export
|
||||||
QRadioButton *_wysiwyg;
|
QRadioButton *_wysiwyg;
|
||||||
QRadioButton *_hires;
|
QRadioButton *_hires;
|
||||||
|
@ -130,6 +130,8 @@
|
|||||||
#define POI_RADIUS_DEFAULT (int)(IMPERIAL_UNITS() ? MIINM : KMINM)
|
#define POI_RADIUS_DEFAULT (int)(IMPERIAL_UNITS() ? MIINM : KMINM)
|
||||||
#define USE_OPENGL_SETTING "useOpenGL"
|
#define USE_OPENGL_SETTING "useOpenGL"
|
||||||
#define USE_OPENGL_DEFAULT false
|
#define USE_OPENGL_DEFAULT false
|
||||||
|
#define ENABLE_HTTP2_SETTING "enableHTTP2"
|
||||||
|
#define ENABLE_HTTP2_DEFAULT true
|
||||||
#define PIXMAP_CACHE_SETTING "pixmapCache"
|
#define PIXMAP_CACHE_SETTING "pixmapCache"
|
||||||
#define PIXMAP_CACHE_DEFAULT 64 /* MB */
|
#define PIXMAP_CACHE_DEFAULT 64 /* MB */
|
||||||
#define CONNECTION_TIMEOUT_SETTING "connectionTimeout"
|
#define CONNECTION_TIMEOUT_SETTING "connectionTimeout"
|
||||||
|
@ -81,6 +81,9 @@ private:
|
|||||||
|
|
||||||
QNetworkAccessManager *Downloader::_manager = 0;
|
QNetworkAccessManager *Downloader::_manager = 0;
|
||||||
int Downloader::_timeout = 30;
|
int Downloader::_timeout = 30;
|
||||||
|
#ifdef ENABLE_HTTP2
|
||||||
|
bool Downloader::_http2 = true;
|
||||||
|
#endif // ENABLE_HTTP2
|
||||||
|
|
||||||
bool Downloader::doDownload(const Download &dl,
|
bool Downloader::doDownload(const Download &dl,
|
||||||
const QByteArray &authorization, const Redirect *redirect)
|
const QByteArray &authorization, const Redirect *redirect)
|
||||||
@ -108,6 +111,10 @@ bool Downloader::doDownload(const Download &dl,
|
|||||||
request.setRawHeader("User-Agent", USER_AGENT);
|
request.setRawHeader("User-Agent", USER_AGENT);
|
||||||
if (!authorization.isNull())
|
if (!authorization.isNull())
|
||||||
request.setRawHeader("Authorization", authorization);
|
request.setRawHeader("Authorization", authorization);
|
||||||
|
#ifdef ENABLE_HTTP2
|
||||||
|
request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute,
|
||||||
|
QVariant(_http2));
|
||||||
|
#endif // ENABLE_HTTP2
|
||||||
|
|
||||||
QNetworkReply *reply = _manager->get(request);
|
QNetworkReply *reply = _manager->get(request);
|
||||||
if (reply && reply->isRunning()) {
|
if (reply && reply->isRunning()) {
|
||||||
|
@ -46,6 +46,9 @@ public:
|
|||||||
void clearErrors() {_errorDownloads.clear();}
|
void clearErrors() {_errorDownloads.clear();}
|
||||||
|
|
||||||
static void setTimeout(int timeout) {_timeout = timeout;}
|
static void setTimeout(int timeout) {_timeout = timeout;}
|
||||||
|
#ifdef ENABLE_HTTP2
|
||||||
|
static void enableHTTP2(bool enable) {_http2 = enable;}
|
||||||
|
#endif // ENABLE_HTTP2
|
||||||
static void setNetworkAccessManager(QNetworkAccessManager *manager)
|
static void setNetworkAccessManager(QNetworkAccessManager *manager)
|
||||||
{_manager = manager;}
|
{_manager = manager;}
|
||||||
|
|
||||||
@ -69,6 +72,9 @@ private:
|
|||||||
QHash<QUrl, int> _errorDownloads;
|
QHash<QUrl, int> _errorDownloads;
|
||||||
|
|
||||||
static int _timeout;
|
static int _timeout;
|
||||||
|
#ifdef ENABLE_HTTP2
|
||||||
|
static bool _http2;
|
||||||
|
#endif // ENABLE_HTTP2
|
||||||
static QNetworkAccessManager *_manager;
|
static QNetworkAccessManager *_manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user