1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Make the DEM cache configurable

This commit is contained in:
Martin Tůma 2023-03-03 00:04:03 +01:00
parent 3b43e28b03
commit f275938fef
6 changed files with 19 additions and 1 deletions

View File

@ -56,7 +56,6 @@ App::App(int &argc, char **argv) : QApplication(argc, argv)
"QThreadStorage: Thread X exited after QThreadStorage Y destroyed" */
Downloader::setNetworkManager(new QNetworkAccessManager(this));
DEM::setDir(ProgramPaths::demDir());
DEM::setCacheSize(536870912/*512MB*/);
QSurfaceFormat fmt;
fmt.setStencilBufferSize(8);
fmt.setSamples(4);

View File

@ -2416,6 +2416,7 @@ void GUI::writeSettings()
WRITE(useOpenGL, _options.useOpenGL);
WRITE(enableHTTP2, _options.enableHTTP2);
WRITE(pixmapCache, _options.pixmapCache);
WRITE(demCache, _options.demCache);
WRITE(connectionTimeout, _options.connectionTimeout);
WRITE(hiresPrint, _options.hiresPrint);
WRITE(printName, _options.printName);
@ -2697,6 +2698,7 @@ void GUI::readSettings(QString &activeMap, QStringList &disabledPOIs)
_options.useOpenGL = READ(useOpenGL).toBool();
_options.enableHTTP2 = READ(enableHTTP2).toBool();
_options.pixmapCache = READ(pixmapCache).toInt();
_options.demCache = READ(demCache).toInt();
_options.connectionTimeout = READ(connectionTimeout).toInt();
_options.hiresPrint = READ(hiresPrint).toBool();
_options.printName = READ(printName).toBool();
@ -2784,6 +2786,7 @@ void GUI::loadOptions()
Downloader::setTimeout(_options.connectionTimeout);
QPixmapCache::setCacheLimit(_options.pixmapCache * 1024);
DEM::setCacheSize(_options.demCache * 1024);
_poi->setRadius(_options.poiRadius);
@ -2909,6 +2912,8 @@ void GUI::updateOptions(const Options &options)
if (options.pixmapCache != _options.pixmapCache)
QPixmapCache::setCacheLimit(options.pixmapCache * 1024);
if (options.demCache != _options.demCache)
DEM::setCacheSize(options.demCache * 1024);
if (options.connectionTimeout != _options.connectionTimeout)
Downloader::setTimeout(options.connectionTimeout);

View File

@ -723,6 +723,12 @@ QWidget *OptionsDialog::createSystemPage()
_pixmapCache->setSuffix(UNIT_SPACE + tr("MB"));
_pixmapCache->setValue(_options.pixmapCache);
_demCache = new QSpinBox();
_demCache->setMinimum(64);
_demCache->setMaximum(2048);
_demCache->setSuffix(UNIT_SPACE + tr("MB"));
_demCache->setValue(_options.demCache);
_connectionTimeout = new QSpinBox();
_connectionTimeout->setMinimum(30);
_connectionTimeout->setMaximum(120);
@ -740,6 +746,7 @@ QWidget *OptionsDialog::createSystemPage()
#else // Q_OS_MAC
QFormLayout *formLayout = new QFormLayout();
formLayout->addRow(tr("Image cache size:"), _pixmapCache);
formLayout->addRow(tr("DEM cache size:"), _demCache);
formLayout->addRow(tr("Connection timeout:"), _connectionTimeout);
QFormLayout *checkboxLayout = new QFormLayout();
checkboxLayout->addWidget(_enableHTTP2);
@ -932,6 +939,7 @@ void OptionsDialog::accept()
_options.useOpenGL = _useOpenGL->isChecked();
_options.enableHTTP2 = _enableHTTP2->isChecked();
_options.pixmapCache = _pixmapCache->value();
_options.demCache = _demCache->value();
_options.connectionTimeout = _connectionTimeout->value();
_options.dataPath = _dataPath->dir();
_options.mapsPath = _mapsPath->dir();

View File

@ -79,6 +79,7 @@ struct Options {
bool useOpenGL;
bool enableHTTP2;
int pixmapCache;
int demCache;
int connectionTimeout;
QString dataPath;
QString mapsPath;
@ -182,6 +183,7 @@ private:
#endif // QT 5.14
// System
QSpinBox *_pixmapCache;
QSpinBox *_demCache;
QSpinBox *_connectionTimeout;
QCheckBox *_useOpenGL;
QCheckBox *_enableHTTP2;

View File

@ -34,8 +34,10 @@
#ifdef Q_OS_ANDROID
#define PIXMAP_CACHE 256
#define DEM_CACHE 128
#else // Q_OS_ANDROID
#define PIXMAP_CACHE 512
#define DEM_CACHE 256
#endif // Q_OS_ANDROID
@ -243,6 +245,7 @@ SETTING(demPassword, "demPassword", "" );
SETTING(useOpenGL, "useOpenGL", false );
SETTING(enableHTTP2, "enableHTTP2", true );
SETTING(pixmapCache, "pixmapCache", PIXMAP_CACHE );
SETTING(demCache, "demCache", DEM_CACHE );
SETTING(connectionTimeout, "connectionTimeout", 30 );
SETTING(hiresPrint, "hiresPrint", false );
SETTING(printName, "printName", true );

View File

@ -189,6 +189,7 @@ public:
static const Setting useOpenGL;
static const Setting enableHTTP2;
static const Setting pixmapCache;
static const Setting demCache;
static const Setting connectionTimeout;
static const Setting hiresPrint;
static const Setting printName;