mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-18 19:52:09 +01:00
Code cleanup
This commit is contained in:
parent
f9af06267a
commit
24c03fc15b
@ -38,7 +38,6 @@ App::App(int &argc, char **argv) : QApplication(argc, argv),
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
||||
Downloader::setNetworkAccessManager(new QNetworkAccessManager(this));
|
||||
QSettings settings(APP_NAME, APP_NAME);
|
||||
settings.beginGroup(OPTIONS_SETTINGS_GROUP);
|
||||
#ifdef ENABLE_HTTP2
|
||||
|
@ -80,12 +80,17 @@ private:
|
||||
};
|
||||
|
||||
|
||||
QNetworkAccessManager *Downloader::_manager = 0;
|
||||
int Downloader::_timeout = 30;
|
||||
#ifdef ENABLE_HTTP2
|
||||
bool Downloader::_http2 = true;
|
||||
#endif // ENABLE_HTTP2
|
||||
|
||||
QNetworkAccessManager *Downloader::manager()
|
||||
{
|
||||
static QNetworkAccessManager manager;
|
||||
return &manager;
|
||||
}
|
||||
|
||||
bool Downloader::doDownload(const Download &dl,
|
||||
const QByteArray &authorization, const Redirect *redirect)
|
||||
{
|
||||
@ -118,7 +123,7 @@ bool Downloader::doDownload(const Download &dl,
|
||||
QVariant(_http2));
|
||||
#endif // ENABLE_HTTP2
|
||||
|
||||
QNetworkReply *reply = _manager->get(request);
|
||||
QNetworkReply *reply = manager()->get(request);
|
||||
if (reply && reply->isRunning()) {
|
||||
_currentDownloads.insert(url);
|
||||
ReplyTimeout::setTimeout(reply, _timeout);
|
||||
@ -232,6 +237,6 @@ bool Downloader::get(const QList<Download> &list,
|
||||
void Downloader::enableHTTP2(bool enable)
|
||||
{
|
||||
_http2 = enable;
|
||||
_manager->clearConnectionCache();
|
||||
manager()->clearConnectionCache();
|
||||
}
|
||||
#endif // ENABLE_HTTP2
|
||||
|
@ -50,8 +50,6 @@ public:
|
||||
#ifdef ENABLE_HTTP2
|
||||
static void enableHTTP2(bool enable);
|
||||
#endif // ENABLE_HTTP2
|
||||
static void setNetworkAccessManager(QNetworkAccessManager *manager)
|
||||
{_manager = manager;}
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
@ -69,6 +67,8 @@ private:
|
||||
const Redirect *redirect = 0);
|
||||
bool saveToDisk(const QString &filename, QIODevice *data);
|
||||
|
||||
static QNetworkAccessManager *manager();
|
||||
|
||||
QSet<QUrl> _currentDownloads;
|
||||
QHash<QUrl, int> _errorDownloads;
|
||||
|
||||
@ -76,7 +76,6 @@ private:
|
||||
#ifdef ENABLE_HTTP2
|
||||
static bool _http2;
|
||||
#endif // ENABLE_HTTP2
|
||||
static QNetworkAccessManager *_manager;
|
||||
};
|
||||
|
||||
#endif // DOWNLOADER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user