1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-06-27 11:39:16 +02:00

Separated map downloaders, added configurable connection timeouts

This commit is contained in:
2018-04-27 19:31:27 +02:00
parent 62962b5de2
commit 566f3185f9
19 changed files with 103 additions and 138 deletions

View File

@ -3,10 +3,8 @@
#include <QLocale>
#include <QFileOpenEvent>
#include <QNetworkProxyFactory>
#include <QNetworkAccessManager>
#include <QLibraryInfo>
#include "map/wmts.h"
#include "map/wms.h"
#include "map/tileloader.h"
#include "map/downloader.h"
#include "map/ellipsoid.h"
#include "map/gcs.h"
@ -38,10 +36,7 @@ App::App(int &argc, char **argv) : QApplication(argc, argv),
#endif // Q_OS_MAC
QNetworkProxyFactory::setUseSystemConfiguration(true);
Downloader *dl = new Downloader(this);
TileLoader::setDownloader(dl);
WMTS::setDownloader(dl);
WMS::setDownloader(dl);
Downloader::setNetworkAccessManager(new QNetworkAccessManager(this));
OPENGL_SET_SAMPLES(4);
loadDatums();
loadPCSs();

View File

@ -25,6 +25,7 @@
#include "data/data.h"
#include "map/maplist.h"
#include "map/emptymap.h"
#include "map/downloader.h"
#include "config.h"
#include "icons.h"
#include "keys.h"
@ -855,6 +856,8 @@ void GUI::openOptions()
_poi->setRadius(options.poiRadius);
if (options.pixmapCache != _options.pixmapCache)
QPixmapCache::setCacheLimit(options.pixmapCache * 1024);
if (options.connectionTimeout != _options.connectionTimeout)
Downloader::setTimeout(options.connectionTimeout);
if (reload)
reloadFile();
@ -1620,6 +1623,8 @@ void GUI::writeSettings()
settings.setValue(USE_OPENGL_SETTING, _options.useOpenGL);
if (_options.pixmapCache != PIXMAP_CACHE_DEFAULT)
settings.setValue(PIXMAP_CACHE_SETTING, _options.pixmapCache);
if (_options.connectionTimeout != CONNECTION_TIMEOUT_DEFAULT)
settings.setValue(CONNECTION_TIMEOUT_SETTING, _options.connectionTimeout);
if (_options.hiresPrint != HIRES_PRINT_DEFAULT)
settings.setValue(HIRES_PRINT_SETTING, _options.hiresPrint);
if (_options.printName != PRINT_NAME_DEFAULT)
@ -1848,6 +1853,8 @@ void GUI::readSettings()
.toBool();
_options.pixmapCache = settings.value(PIXMAP_CACHE_SETTING,
PIXMAP_CACHE_DEFAULT).toInt();
_options.connectionTimeout = settings.value(CONNECTION_TIMEOUT_SETTING,
CONNECTION_TIMEOUT_DEFAULT).toInt();
_options.hiresPrint = settings.value(HIRES_PRINT_SETTING,
HIRES_PRINT_DEFAULT).toBool();
_options.printName = settings.value(PRINT_NAME_SETTING, PRINT_NAME_DEFAULT)
@ -1907,6 +1914,7 @@ void GUI::readSettings()
_poi->setRadius(_options.poiRadius);
QPixmapCache::setCacheLimit(_options.pixmapCache * 1024);
Downloader::setTimeout(_options.connectionTimeout);
settings.endGroup();
}

View File

@ -431,16 +431,23 @@ QWidget *OptionsDialog::createSystemPage()
_pixmapCache->setSuffix(UNIT_SPACE + tr("MB"));
_pixmapCache->setValue(_options->pixmapCache);
QFormLayout *cacheLayout = new QFormLayout();
cacheLayout->addRow(tr("Image cache size:"), _pixmapCache);
_connectionTimeout = new QSpinBox();
_connectionTimeout->setMinimum(30);
_connectionTimeout->setMaximum(120);
_connectionTimeout->setSuffix(UNIT_SPACE + tr("s"));
_connectionTimeout->setValue(_options->connectionTimeout);
QFormLayout *openGLLayout = new QFormLayout();
openGLLayout->addWidget(_useOpenGL);
QFormLayout *formLayout = new QFormLayout();
formLayout->addRow(tr("Image cache size:"), _pixmapCache);
formLayout->addRow(tr("Connection timeout:"), _connectionTimeout);
QFormLayout *checkboxLayout = new QFormLayout();
checkboxLayout->addWidget(_useOpenGL);
QWidget *systemTab = new QWidget();
QVBoxLayout *systemTabLayout = new QVBoxLayout();
systemTabLayout->addLayout(cacheLayout);
systemTabLayout->addLayout(openGLLayout);
systemTabLayout->addLayout(formLayout);
systemTabLayout->addLayout(checkboxLayout);
systemTabLayout->addStretch();
systemTab->setLayout(systemTabLayout);
@ -545,6 +552,7 @@ void OptionsDialog::accept()
_options->useOpenGL = _useOpenGL->isChecked();
_options->pixmapCache = _pixmapCache->value();
_options->connectionTimeout = _connectionTimeout->value();
_options->hiresPrint = _hires->isChecked();
_options->printName = _name->isChecked();

View File

@ -48,6 +48,7 @@ struct Options {
// System
bool useOpenGL;
int pixmapCache;
int connectionTimeout;
// Print/Export
bool hiresPrint;
bool printName;
@ -113,6 +114,7 @@ private:
QDoubleSpinBox *_poiRadius;
// System
QSpinBox *_pixmapCache;
QSpinBox *_connectionTimeout;
QCheckBox *_useOpenGL;
// Print/Export
QRadioButton *_wysiwyg;

View File

@ -130,6 +130,8 @@
#define USE_OPENGL_DEFAULT false
#define PIXMAP_CACHE_SETTING "pixmapCache"
#define PIXMAP_CACHE_DEFAULT 64 /* MB */
#define CONNECTION_TIMEOUT_SETTING "connectionTimeout"
#define CONNECTION_TIMEOUT_DEFAULT 30 /* s */
#define HIRES_PRINT_SETTING "hiresPrint"
#define HIRES_PRINT_DEFAULT false
#define PRINT_NAME_SETTING "printName"