30 void QgsServerSettings::initSettings()
    37                              QStringLiteral( 
"Override the default path for user configuration" ),
    43   mSettings[ sOptPath.
envVar ] = sOptPath;
    48                              QStringLiteral( 
"Activate/Deactivate parallel rendering for WMS getMap request" ),
    49                              QStringLiteral( 
"/qgis/parallel_rendering" ),
    54   mSettings[ sParRend.
envVar ] = sParRend;
    59                                 QStringLiteral( 
"Number of threads to use when parallel rendering is activated" ),
    60                                 QStringLiteral( 
"/qgis/max_threads" ),
    65   mSettings[ sMaxThreads.
envVar ] = sMaxThreads;
    70                               QStringLiteral( 
"Log level" ),
    76   mSettings[ sLogLevel.
envVar ] = sLogLevel;
    81                              QStringLiteral( 
"Log file" ),
    87   mSettings[ sLogFile.
envVar ] = sLogFile;
    92                                QStringLiteral( 
"Activate/Deactivate logging to stderr" ),
    98   mSettings[ sLogStderr.
envVar ] = sLogStderr;
   103                              QStringLiteral( 
"QGIS project file" ),
   109   mSettings[ sProject.
envVar ] = sProject;
   114                                     QStringLiteral( 
"Specify the maximum number of cached layers" ),
   120   mSettings[ sMaxCacheLayers.
envVar ] = sMaxCacheLayers;
   125                               QStringLiteral( 
"Specify the cache directory" ),
   126                               QStringLiteral( 
"/cache/directory" ),
   131   mSettings[ sCacheDir.
envVar ] = sCacheDir;
   136                                QStringLiteral( 
"Specify the cache size" ),
   137                                QStringLiteral( 
"/cache/size" ),
   139                                QVariant( 50 * 1024 * 1024 ),
   142   mSettings[ sCacheSize.
envVar ] = sCacheSize;
   147                                           QStringLiteral( 
"Override system locale" ),
   148                                           QStringLiteral( 
"/locale/userLocale" ),
   153   mSettings[ sOverrideSystemLocale.
envVar ] = sOverrideSystemLocale;
   158                                         QStringLiteral( 
"Show group (thousands) separator" ),
   159                                         QStringLiteral( 
"/locale/showGroupSeparator" ),
   164   mSettings[ sShowGroupSeparator.
envVar ] = sShowGroupSeparator;
   169                                QStringLiteral( 
"Maximum height for a WMS request. The lower one of this and the project configuration is used." ),
   170                                QStringLiteral( 
"/qgis/max_wms_height" ),
   175   mSettings[ sMaxHeight.
envVar ] = sMaxHeight;
   180                               QStringLiteral( 
"Maximum width for a WMS request. The most conservative between this and the project one is used" ),
   181                               QStringLiteral( 
"/qgis/max_wms_width" ),
   186   mSettings[ sMaxWidth.
envVar ] = sMaxWidth;
   191                                            QStringLiteral( 
"Base directory where HTML templates and static assets (e.g. images, js and css files) are searched for" ),
   192                                            QStringLiteral( 
"/qgis/server_api_resources_directory" ),
   198   mSettings[ sApiResourcesDirectory.
envVar ] = sApiResourcesDirectory;
   203                                      QStringLiteral( 
"Maximum value for \"limit\" in a features request, defaults to 10000" ),
   204                                      QStringLiteral( 
"/qgis/server_api_wfs3_max_limit" ),
   210   mSettings[ sApiWfs3MaxLimit.
envVar ] = sApiWfs3MaxLimit;
   220   QMap<QgsServerSettingsEnv::EnvVar, QString> env = getEnv();
   232   const QMetaEnum metaEnum( QMetaEnum::fromType<QgsServerSettingsEnv::EnvVar>() );
   233   const int value = metaEnum.keyToValue( envVarName.toStdString().c_str() );
   237     const QString envValue( getenv( envVarName.toStdString().c_str() ) );
   245 QMap<QgsServerSettingsEnv::EnvVar, QString> QgsServerSettings::getEnv()
 const   247   QMap<QgsServerSettingsEnv::EnvVar, QString> env;
   249   const QMetaEnum metaEnum( QMetaEnum::fromType<QgsServerSettingsEnv::EnvVar>() );
   250   for ( 
int i = 0; i < metaEnum.keyCount(); i++ )
   262     return mSettings[ envVar ].defaultVal;
   266     return mSettings[ envVar ].val;
   270 void QgsServerSettings::loadQSettings( 
const QString &envOptPath )
 const   272   if ( ! envOptPath.isEmpty() )
   274     QSettings::setDefaultFormat( QSettings::IniFormat );
   275     QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, envOptPath );
   279 void QgsServerSettings::prioritize( 
const QMap<QgsServerSettingsEnv::EnvVar, QString> &env )
   286     if ( ! env.value( e ).isEmpty() )
   288       varValue.setValue( env.value( e ) );
   291     if ( ! varValue.isNull() && varValue.canConvert( s.
type ) )
   296     else if ( ! s.
iniKey.isEmpty() && QSettings().contains( s.
iniKey ) && QSettings().value( s.
iniKey ).canConvert( s.
type ) )
   309     if ( s.
type == QVariant::String && s.
val.toString().isEmpty() )
   321   const QMetaEnum metaEnumSrc( QMetaEnum::fromType<QgsServerSettingsEnv::Source>() );
   322   const QMetaEnum metaEnumEnv( QMetaEnum::fromType<QgsServerSettingsEnv::EnvVar>() );
   327     const QString src = metaEnumSrc.valueToKey( s.src );
   328     const QString var = metaEnumEnv.valueToKey( s.envVar );
   330     const QString msg = 
"  - " + var + 
" / '" + s.iniKey + 
"' (" + s.descr + 
"): '" + value( s.envVar ).toString() + 
"' (read from " + src + 
")";
   336     const QString msg = 
"Ini file used to initialize settings: " + 
iniFile();
   344   return QSettings().fileName();
 
QString cacheDirectory() const
Returns the cache directory. 
static QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir. 
Maximum width for a WMS request. The most conservative between this and the project one is used (sinc...
qlonglong apiWfs3MaxLimit() const
Returns the server-wide maximum allowed value for "limit" in a features request. 
QString iniFile() const
Returns the ini file loaded by QSetting. 
int wmsMaxWidth() const
Returns the server-wide max width of a WMS GetMap request. 
QString projectFile() const
Returns the QGS project file to use. 
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...
Override system locale (since QGIS 3.8) 
int maxCacheLayers() const
Returns the maximum number of cached layers. 
qint64 cacheSize() const
Returns the cache size. 
bool showGroupSeparator() const
Show group (thousand) separator. 
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). 
QString logFile() const
Returns the log file. 
static QString pkgDataPath()
Returns the common root path of all application data directories. 
int wmsMaxHeight() const
Returns the server-wide max height of a WMS GetMap request. 
bool parallelRendering() const
Returns parallel rendering setting. 
QString overrideSystemLocale() const
Overrides system locale. 
Maximum height for a WMS request. The most conservative between this and the project one is used (sin...
QString apiResourcesDirectory() const
Returns the server-wide base directory where HTML templates and static assets (e.g. 
void load()
Load settings according to current environment variables. 
void logSummary() const
Log a summary of settings currently loaded. 
QgsServerSettingsEnv::EnvVar envVar
QgsServerSettingsEnv::Source src
Qgis::MessageLevel logLevel() const
Returns the log level. 
EnvVar
Environment variables to configure the server. 
int maxThreads() const
Returns the maximum number of threads to use. 
bool logStderr() const
Returns whether logging to stderr is activated. 
Base directory where HTML templates and static assets (e.g. images, js and css files) are searched fo...
QgsServerSettings()
Constructor.