31 void QgsServerSettings::initSettings()
38 "Override the default path for user configuration",
44 mSettings[ sOptPath.
envVar ] = sOptPath;
49 "Activate/Deactivate parallel rendering for WMS getMap request",
50 "/qgis/parallel_rendering",
55 mSettings[ sParRend.
envVar ] = sParRend;
60 "Number of threads to use when parallel rendering is activated",
66 mSettings[ sMaxThreads.
envVar ] = sMaxThreads;
77 mSettings[ sLogLevel.
envVar ] = sLogLevel;
88 mSettings[ sLogFile.
envVar ] = sLogFile;
93 "Activate/Deactivate logging to stderr",
99 mSettings[ sLogStderr.
envVar ] = sLogStderr;
110 mSettings[ sProject.
envVar ] = sProject;
115 "Specify the maximum number of cached layers",
121 mSettings[ sMaxCacheLayers.
envVar ] = sMaxCacheLayers;
126 "Specify the cache directory",
132 mSettings[ sCacheDir.
envVar ] = sCacheDir;
137 "Specify the cache size",
140 QVariant( 50 * 1024 * 1024 ),
143 mSettings[ sCacheSize.
envVar ] = sCacheSize;
148 QStringLiteral(
"Override system locale" ),
149 QStringLiteral(
"/locale/userLocale" ),
154 mSettings[ sOverrideSystemLocale.
envVar ] = sOverrideSystemLocale;
159 QStringLiteral(
"Show group (thousands) separator" ),
160 QStringLiteral(
"/locale/showGroupSeparator" ),
165 mSettings[ sShowGroupSeparator.
envVar ] = sShowGroupSeparator;
176 QMap<QgsServerSettingsEnv::EnvVar, QString> env = getEnv();
188 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsServerSettingsEnv::EnvVar>() );
189 const int value = metaEnum.keyToValue( envVarName.toStdString().c_str() );
193 const QString envValue( getenv( envVarName.toStdString().c_str() ) );
201 QMap<QgsServerSettingsEnv::EnvVar, QString> QgsServerSettings::getEnv()
const 203 QMap<QgsServerSettingsEnv::EnvVar, QString> env;
205 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsServerSettingsEnv::EnvVar>() );
206 for (
int i = 0; i < metaEnum.keyCount(); i++ )
218 return mSettings[ envVar ].defaultVal;
222 return mSettings[ envVar ].val;
226 void QgsServerSettings::loadQSettings(
const QString &envOptPath )
const 228 if ( ! envOptPath.isEmpty() )
230 QSettings::setDefaultFormat( QSettings::IniFormat );
231 QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, envOptPath );
235 void QgsServerSettings::prioritize(
const QMap<QgsServerSettingsEnv::EnvVar, QString> &env )
242 if ( ! env.value( e ).isEmpty() )
244 varValue.setValue( env.value( e ) );
247 if ( ! varValue.isNull() && varValue.canConvert( s.
type ) )
252 else if ( ! s.
iniKey.isEmpty() && QSettings().contains( s.
iniKey ) && QSettings().value( s.
iniKey ).canConvert( s.
type ) )
265 if ( s.
type == QVariant::String && s.
val.toString().isEmpty() )
277 const QMetaEnum metaEnumSrc( QMetaEnum::fromType<QgsServerSettingsEnv::Source>() );
278 const QMetaEnum metaEnumEnv( QMetaEnum::fromType<QgsServerSettingsEnv::EnvVar>() );
283 const QString src = metaEnumSrc.valueToKey( s.src );
284 const QString var = metaEnumEnv.valueToKey( s.envVar );
286 const QString msg =
" - " + var +
" / '" + s.iniKey +
"' (" + s.descr +
"): '" + value( s.envVar ).toString() +
"' (read from " + src +
")";
292 const QString msg =
"Ini file used to initialize settings: " +
iniFile();
300 return QSettings().fileName();
QString logFile() const
Returns the log file.
static QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
QString cacheDirectory() const
Returns the cache directory.
int maxCacheLayers() const
Returns the maximum number of cached layers.
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Show group (thousands) separator when formatting numeric values, defaults to FALSE (since QGIS 3...
bool showGroupSeparator() const
Show group (thousand) separator.
QString projectFile() const
Returns the QGS project file to use.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
qint64 cacheSize() const
Returns the cache size.
void logSummary() const
Log a summary of settings currently loaded.
bool logStderr() const
Returns whether logging to stderr is activated.
void load()
Load settings according to current environment variables.
QgsServerSettingsEnv::EnvVar envVar
QString iniFile() const
Returns the ini file loaded by QSetting.
QgsServerSettingsEnv::Source src
QString overrideSystemLocale() const
Overrides system locale.
EnvVar
Environment variables to configure the server.
bool parallelRendering() const
Returns parallel rendering setting.
Qgis::MessageLevel logLevel() const
Returns the log level.
QgsServerSettings()
Constructor.
int maxThreads() const
Returns the maximum number of threads to use.