108#include <QAuthenticator>
112#include <QFileOpenEvent>
114#include <QImageReader>
115#include <QLibraryInfo>
117#include <QMessageBox>
121#include <QProcessEnvironment>
122#include <QRecursiveMutex>
123#include <QRegularExpression>
125#include <QStandardPaths>
128#include <QTextStream>
129#include <QThreadPool>
131#include "moc_qgsapplication.cpp"
133using namespace Qt::StringLiterals;
141 =
new QgsSettingsEntryVariant( u
"value"_s, sTreeCustomVariables, QVariant(), u
"User-defined custom application variable, keyed by variable name. Available as @-prefixed variables in expressions."_s );
163#include <netinet/in.h>
169#define SECURITY_WIN32
172#pragma comment( lib, "Secur32.lib" )
176#include "qgsconfig.h"
186#if defined( Q_OS_LINUX )
187#include <sys/sysinfo.h>
190#define CONN_POOL_MAX_CONCURRENT_CONNS 4
253QObject *
ABISYM( QgsApplication::mFileOpenEventReceiver ) =
nullptr;
254bool ABISYM( QgsApplication::mInitialized ) =
false;
255bool ABISYM( QgsApplication::mRunningFromBuildDir ) =
false;
261int ABISYM( QgsApplication::sMaxThreads ) = -1;
278#if defined( _MSC_VER ) && !defined( USING_NMAKE ) && !defined( USING_NINJA )
296 : QApplication( argc, argv, GUIenabled )
298 *sPlatformName() = platformName;
303 if ( platformName !=
"desktop"_L1 )
305 mApplicationMembers = std::make_unique<ApplicationMembers>();
308 mApplicationMembers->mSettingsRegistryCore->migrateOldSettings();
317 *sProfilePath() = profileFolder;
323 qRegisterMetaType<QgsGeometry::Error>(
"QgsGeometry::Error" );
324 qRegisterMetaType<QgsDatabaseQueryLogEntry>(
"QgsDatabaseQueryLogEntry" );
325 qRegisterMetaType<QgsProcessingFeatureSourceDefinition>(
"QgsProcessingFeatureSourceDefinition" );
326 qRegisterMetaType<QgsProcessingOutputLayerDefinition>(
"QgsProcessingOutputLayerDefinition" );
327 qRegisterMetaType<Qgis::LayoutUnit>(
"Qgis::LayoutUnit" );
328 qRegisterMetaType<QgsUnsetAttributeValue>(
"QgsUnsetAttributeValue" );
329 qRegisterMetaType<QgsFeatureId>(
"QgsFeatureId" );
330 qRegisterMetaType<QgsFields>(
"QgsFields" );
331 qRegisterMetaType<QgsFeatureIds>(
"QgsFeatureIds" );
332 qRegisterMetaType<QgsProperty>(
"QgsProperty" );
333 qRegisterMetaType<QgsFeatureStoreList>(
"QgsFeatureStoreList" );
334 qRegisterMetaType<Qgis::MessageLevel>(
"Qgis::MessageLevel" );
335 qRegisterMetaType<Qgis::BrowserItemState>(
"Qgis::BrowserItemState" );
336 qRegisterMetaType<Qgis::GpsFixStatus>(
"Qgis::GpsFixStatus" );
337 qRegisterMetaType<QgsReferencedRectangle>(
"QgsReferencedRectangle" );
338 qRegisterMetaType<QgsReferencedPointXY>(
"QgsReferencedPointXY" );
339 qRegisterMetaType<QgsReferencedGeometry>(
"QgsReferencedGeometry" );
340 qRegisterMetaType<Qgis::LayoutRenderFlags>(
"Qgis::LayoutRenderFlags" );
341 qRegisterMetaType<QgsStyle::StyleEntity>(
"QgsStyle::StyleEntity" );
342 qRegisterMetaType<QgsCoordinateReferenceSystem>(
"QgsCoordinateReferenceSystem" );
343 qRegisterMetaType<QgsAuthManager::MessageLevel>(
"QgsAuthManager::MessageLevel" );
344 qRegisterMetaType<QgsNetworkRequestParameters>(
"QgsNetworkRequestParameters" );
345 qRegisterMetaType<QgsNetworkReplyContent>(
"QgsNetworkReplyContent" );
346 qRegisterMetaType<QgsFeature>(
"QgsFeature" );
347 qRegisterMetaType<QgsGeometry>(
"QgsGeometry" );
348 qRegisterMetaType<QgsInterval>(
"QgsInterval" );
349 qRegisterMetaType<QgsRectangle>(
"QgsRectangle" );
350 qRegisterMetaType<QgsPointXY>(
"QgsPointXY" );
351 qRegisterMetaType<QgsPoint>(
"QgsPoint" );
352 qRegisterMetaType<QgsDatumTransform::GridDetails>(
"QgsDatumTransform::GridDetails" );
353 qRegisterMetaType<QgsDatumTransform::TransformDetails>(
"QgsDatumTransform::TransformDetails" );
354 qRegisterMetaType<QgsNewsFeedParser::Entry>(
"QgsNewsFeedParser::Entry" );
355 qRegisterMetaType<QgsRectangle>(
"QgsRectangle" );
356 qRegisterMetaType<QgsLocatorResult>(
"QgsLocatorResult" );
357 qRegisterMetaType<QgsGradientColorRamp>(
"QgsGradientColorRamp" );
358 qRegisterMetaType<QgsProcessingModelChildParameterSource>(
"QgsProcessingModelChildParameterSource" );
359 qRegisterMetaType<QgsRemappingSinkDefinition>(
"QgsRemappingSinkDefinition" );
360 qRegisterMetaType<QgsProcessingModelChildDependency>(
"QgsProcessingModelChildDependency" );
361 qRegisterMetaType<QgsProcessingModelChildAlgorithmResult>(
"QgsProcessingModelChildAlgorithmResult" );
362 qRegisterMetaType<QgsTextFormat>(
"QgsTextFormat" );
363 qRegisterMetaType<QPainter::CompositionMode>(
"QPainter::CompositionMode" );
364 qRegisterMetaType<QgsDateTimeRange>(
"QgsDateTimeRange" );
365 qRegisterMetaType<QgsDoubleRange>(
"QgsDoubleRange" );
366 qRegisterMetaType<QgsIntRange>(
"QgsIntRange" );
367 qRegisterMetaType<QList<QgsMapLayer *>>(
"QList<QgsMapLayer*>" );
368 qRegisterMetaType<QMap<QNetworkRequest::Attribute, QVariant>>(
"QMap<QNetworkRequest::Attribute,QVariant>" );
369 qRegisterMetaType<QMap<QNetworkRequest::KnownHeaders, QVariant>>(
"QMap<QNetworkRequest::KnownHeaders,QVariant>" );
370 qRegisterMetaType<QList<QNetworkReply::RawHeaderPair>>(
"QList<QNetworkReply::RawHeaderPair>" );
371 qRegisterMetaType<QNetworkReply::NetworkError>(
"QNetworkReply::NetworkError" );
372 qRegisterMetaType< QAuthenticator * >(
"QAuthenticator*" );
373 qRegisterMetaType< QgsGpsInformation >(
"QgsGpsInformation" );
374 qRegisterMetaType< QgsSensorThingsExpansionDefinition >(
"QgsSensorThingsExpansionDefinition" );
375 qRegisterMetaType< QTimeZone >(
"QTimeZone" );
376 qRegisterMetaType< QgsSelectiveMaskingSourceSet >(
"QgsSelectiveMaskingSourceSet" );
384 instance()->mApplicationMembers = std::make_unique<ApplicationMembers>();
387 instance()->mApplicationMembers->mSettingsRegistryCore->migrateOldSettings();
395 if ( profileFolder.isEmpty() )
397 if ( getenv(
"QGIS_CUSTOM_CONFIG_PATH" ) )
399 profileFolder = getenv(
"QGIS_CUSTOM_CONFIG_PATH" );
403 profileFolder = QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ).value( 0 );
409 std::unique_ptr< QgsUserProfile > profile = manager.
getProfile();
410 profileFolder = profile->folder();
413 *sProfilePath() = profileFolder;
415 static std::once_flag sMetaTypesRegistered;
420 if ( ABISYM( mRunningFromBuildDir ) )
423 *sPrefixPath() = QString();
424#if defined( _MSC_VER ) && !defined( USING_NMAKE ) && !defined( USING_NINJA )
425 setPluginPath( *sBuildOutputPath() +
'/' + QString( QGIS_PLUGIN_SUBDIR ) +
'/' + *sCfgIntDir() );
427 setPluginPath( *sBuildOutputPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
430 *sLibraryPath() = *sBuildOutputPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
431#if defined( _MSC_VER ) && !defined( USING_NMAKE ) && !defined( USING_NINJA )
432 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/' + *sCfgIntDir() +
'/';
434 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
436#if defined( HAVE_QUICK )
437 *sQmlImportPath() = *sBuildOutputPath() +
'/' + QGIS_QML_SUBDIR +
'/';
442 char *
prefixPath = getenv(
"QGIS_PREFIX_PATH" );
445 if ( sPrefixPath()->isNull() )
447#if defined( Q_OS_WIN ) || defined( Q_OS_MACOS ) && !defined( QGIS_MAC_BUNDLE )
449#elif defined( QGIS_MAC_BUNDLE )
450 QDir myDir( applicationDirPath() +
"/../.."_L1 );
452#elif defined( ANDROID )
454 QDir myDir( QDir::homePath() );
456 QString myPrefix = myDir.absolutePath();
459 QDir myDir( applicationDirPath() );
461 if ( applicationDirPath().contains( u
"cgi-bin"_s ) )
466 QString myPrefix = myDir.absolutePath();
477 *sConfigPath() = profileFolder +
'/';
486 if ( getenv(
"QGIS_AUTH_DB_DIR_PATH" ) )
489 sAuthDbUri()->clear();
492 if ( getenv(
"QGIS_AUTH_DB_URI" ) )
494 *sAuthDbUri() = getenv(
"QGIS_AUTH_DB_URI" );
498 if ( sAuthDbUri->isEmpty() )
500 *sAuthDbUri() = u
"QSQLITE://"_s + *sAuthDbDirPath() + u
"qgis-auth.db"_s;
504 qputenv(
"QT3D_RENDERER",
"opengl" );
507 QMap<QString, QString> systemEnvVarMap;
508 QString passfile( u
"QGIS_AUTH_PASSWORD_FILE"_s );
510 const auto systemEnvironment = QProcessEnvironment::systemEnvironment().toStringList();
511 for (
const QString &varStr : systemEnvironment )
513 int pos = varStr.indexOf(
'='_L1 );
516 QString varStrName = varStr.left( pos );
517 QString varStrValue = varStr.mid( pos + 1 );
518 if ( varStrName != passfile )
520 systemEnvVarMap.insert( varStrName, varStrValue );
523 *sSystemEnvVars() = systemEnvVarMap;
530 const QString projData( QDir::cleanPath(
pkgDataPath().append(
"/proj" ) ) );
531 if ( QFile::exists( projData ) )
533 qputenv(
"PROJ_DATA", projData.toUtf8() );
534 currentProjSearchPaths.append( projData );
538 char **newPaths =
new char *[currentProjSearchPaths.length()];
539 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
541 newPaths[i] = CPLStrdup( currentProjSearchPaths.at( i ).toUtf8().constData() );
543 proj_context_set_search_paths(
nullptr, currentProjSearchPaths.count(), newPaths );
544 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
546 CPLFree( newPaths[i] );
551 QCoreApplication::addLibraryPath(
pluginPath() );
554 QImageReader::setAllocationLimit( 512 );
564 ABISYM( sMaxThreads ) = -1;
576 if ( !members()->mStyleModel )
577 members()->mStyleModel = std::make_unique<QgsStyleModel>( defaultStyle );
595 ABISYM( mInitialized ) =
true;
599void QgsApplication::installTranslators()
602 if ( mQgisTranslator )
604 removeTranslator( mQgisTranslator.get() );
605 mQgisTranslator.reset();
609 removeTranslator( mQtTranslator.get() );
610 mQtTranslator.reset();
612 if ( mQtBaseTranslator )
614 removeTranslator( mQtBaseTranslator.get() );
615 mQtBaseTranslator.reset();
618 if ( *sTranslation() !=
"C"_L1 )
620 mQgisTranslator = std::make_unique<QTranslator>(
this );
621 if ( mQgisTranslator->load( u
"qgis_"_s + *sTranslation(),
i18nPath() ) )
623 installTranslator( mQgisTranslator.get() );
635 QString qtTranslationsPath = QLibraryInfo::path( QLibraryInfo::TranslationsPath );
637 QString prefix = QDir( QString(
"%1/../" ).arg( QApplication::applicationDirPath() ) ).absolutePath();
638 qtTranslationsPath = prefix + qtTranslationsPath.mid( QLibraryInfo::location( QLibraryInfo::PrefixPath ).length() );
641 mQtTranslator = std::make_unique<QTranslator>(
this );
642 if ( mQtTranslator->load( u
"qt_"_s + *sTranslation(), qtTranslationsPath ) )
644 installTranslator( mQtTranslator.get() );
648 QgsDebugMsgLevel( u
"loading of qt translation failed %1/qt_%2"_s.arg( qtTranslationsPath, *sTranslation() ), 2 );
651 mQtBaseTranslator = std::make_unique<QTranslator>(
this );
652 if ( mQtBaseTranslator->load( u
"qtbase_"_s + *sTranslation(), qtTranslationsPath ) )
654 installTranslator( mQtBaseTranslator.get() );
658 QgsDebugMsgLevel( u
"loading of qtbase translation failed %1/qt_%2"_s.arg( qtTranslationsPath, *sTranslation() ), 2 );
665 if ( mApplicationMembers )
669 mApplicationMembers->mSettingsRegistryCore->backwardCompatibility();
673 QgsDebugError( u
"An error occurred while performing backwards compatibility for settings: %1"_s.arg( e.
what() ) );
683void QgsApplication::invalidateCaches()
695 return qobject_cast<QgsApplication *>( QCoreApplication::instance() );
701 if (
event->type() == QEvent::FileOpen )
704 if ( ABISYM( mFileOpenEventReceiver ) )
707 done =
notify( ABISYM( mFileOpenEventReceiver ),
event );
714 sFileOpenEventList()->append(
static_cast<QFileOpenEvent *
>(
event )->file() );
721 done = QApplication::event(
event );
730 if ( thread() == receiver->thread() )
740 done = QApplication::notify( receiver,
event );
744 qCritical() <<
"Caught unhandled QgsException: " << e.
what();
745 if ( qApp->thread() == QThread::currentThread() )
746 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
748 catch ( std::exception &e )
750 qCritical() <<
"Caught unhandled std::exception: " << e.
what();
751 if ( qApp->thread() == QThread::currentThread() )
752 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
756 qCritical() <<
"Caught unhandled unknown exception";
757 if ( qApp->thread() == QThread::currentThread() )
758 QMessageBox::critical( activeWindow(), tr(
"Exception" ), tr(
"unknown exception" ) );
766 return QgsRuntimeProfiler::threadLocalInstance();
772 ABISYM( mFileOpenEventReceiver ) = receiver;
774 if ( sFileOpenEventList()->count() > 0 )
776 const QStringList fileOpenEventList = *sFileOpenEventList();
777 for (
const QString &file : fileOpenEventList )
779 QFileOpenEvent foe( file );
780 QgsApplication::sendEvent( ABISYM( mFileOpenEventReceiver ), &foe );
782 sFileOpenEventList()->clear();
789#if defined( Q_OS_WIN )
790 if ( sPrefixPath()->endsWith(
"/bin" ) )
792 sPrefixPath()->chop( 4 );
795 if ( useDefaultPaths && !ABISYM( mRunningFromBuildDir ) )
797 setPluginPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
798 setPkgDataPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_DATA_SUBDIR ) );
800 *sLibraryPath() = *sPrefixPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
801 *sLibexecPath() = *sPrefixPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
802#if defined( HAVE_QUICK )
803 *sQmlImportPath() = *sPrefixPath() +
'/' + QGIS_QML_SUBDIR +
'/';
819 if ( !sDefaultSvgPaths()->contains( mySvgPath ) )
820 *sDefaultSvgPaths() << mySvgPath;
825 *sDefaultSvgPaths() = pathList;
830 QFileInfo fi( authDbDirPath );
831 if ( fi.exists() && fi.isDir() && fi.isWritable() )
833 *sAuthDbDirPath() = fi.canonicalFilePath() + QDir::separator();
840 if ( ABISYM( mRunningFromBuildDir ) )
842 static bool sOnce =
true;
846 ( void ) blockNotifications;
847 qWarning(
"!!! prefix path was requested, but it is not valid - we do not run from installed path !!!" );
853 return *sPrefixPath();
857 return *sPluginPath();
862 if ( sPkgDataPath()->isNull() )
865 return *sPkgDataPath();
870 return u
":/images/themes/default/"_s;
875 QDir dir( usersThemes );
883 return defaultThemes;
889 return iconsPath() + u
"qgis-icon-60x60.png"_s;
894 return ABISYM( sMaxThreads );
901 if ( QFile::exists( path + iconFile ) )
902 return path + iconFile;
910 const QString
cacheKey = ( name.startsWith(
'/' ) ? name.mid( 1 ) : name )
911 + ( fillColor.isValid() ? u
"_%1"_s.arg( fillColor.name( QColor::HexArgb ).mid( 1 ) ) : QString() )
912 + ( strokeColor.isValid() ? u
"_%1"_s.arg( strokeColor.name( QColor::HexArgb ).mid( 1 ) ) : QString() );
914 if ( app && app->mIconCache.contains(
cacheKey ) )
915 return app->mIconCache.value(
cacheKey );
918 const bool colorBased = fillColor.isValid() || strokeColor.isValid();
920 auto iconFromColoredSvg = [fillColor, strokeColor,
cacheKey](
const QString &path ) -> QIcon {
925 if (
const QDir dir = QFileInfo(
iconPath ).dir(); !dir.exists() )
931 if ( f.open( QFile::WriteOnly | QFile::Truncate ) )
933 f.write( svgContent );
942 return QIcon( f.fileName() );
947 if ( QFile::exists( preferredPath ) )
951 icon = iconFromColoredSvg( preferredPath );
955 icon = QIcon( preferredPath );
958 else if ( QFile::exists( defaultPath ) )
964 icon = iconFromColoredSvg( defaultPath );
968 icon = QIcon( defaultPath );
977 app->mIconCache.insert(
cacheKey, icon );
984 if ( app && app->mCursorCache.contains( cursor ) )
985 return app->mCursorCache.value( cursor );
996 name = u
"mZoomIn.svg"_s;
1001 name = u
"mZoomOut.svg"_s;
1008 name = u
"mIdentify.svg"_s;
1011 name = u
"mCrossHair.svg"_s;
1014 name = u
"mCapturePoint.svg"_s;
1017 name = u
"mSelect.svg"_s;
1024 name = u
"mSampler.svg"_s;
1029 Q_ASSERT( !name.isEmpty() );
1031 QIcon icon =
getThemeIcon( u
"cursors"_s + QDir::separator() + name );
1034 if ( !icon.isNull() )
1038 cursorIcon = QCursor( icon.pixmap( std::ceil( scale * 32 ), std::ceil( scale * 32 ) ), std::ceil( scale * activeX ), std::ceil( scale * activeY ) );
1041 app->mCursorCache.insert( cursor, cursorIcon );
1048 const QString preferredPath =
activeThemePath() + QDir::separator() + name;
1050 const QString path = QFile::exists( preferredPath ) ? preferredPath : defaultPath;
1051 if ( foreColor.isValid() || backColor.isValid() )
1053 bool fitsInCache =
false;
1054 const QImage image =
svgCache()->
svgAsImage( path, size, backColor, foreColor, 1, 1, fitsInCache );
1055 return QPixmap::fromImage( image );
1058 return QPixmap( path );
1068 static QString appPath;
1069 if ( appPath.isNull() )
1071 if ( QCoreApplication::instance() )
1073 appPath = applicationDirPath();
1077 qWarning(
"Application path not initialized" );
1081 if ( !appPath.isNull() || getenv(
"QGIS_PREFIX_PATH" ) )
1083 QString prefix = getenv(
"QGIS_PREFIX_PATH" ) ? getenv(
"QGIS_PREFIX_PATH" ) : appPath;
1088 static const QStringList paths { QStringList() << QString() << u
"/.."_s << u
"/bin"_s << u
"/../../.."_s };
1089 for (
const QString &path : paths )
1091 f.setFileName( prefix + path +
"/qgisbuildpath.txt" );
1095 if ( f.exists() && f.open( QIODevice::ReadOnly ) )
1097 ABISYM( mRunningFromBuildDir ) =
true;
1098 *sBuildSourcePath() = f.readLine().trimmed();
1099 *sBuildOutputPath() = f.readLine().trimmed();
1101 QgsDebugMsgLevel( u
"- source directory: %1"_s.arg( sBuildSourcePath()->toUtf8().constData() ), 4 );
1102 QgsDebugMsgLevel( u
"- output directory of the build: %1"_s.arg( sBuildOutputPath()->toUtf8().constData() ), 4 );
1103#if defined( _MSC_VER ) && !defined( USING_NMAKE ) && !defined( USING_NINJA )
1104 *sCfgIntDir() = prefix.split(
'/', Qt::SkipEmptyParts ).last();
1105 qDebug(
"- cfg: %s", sCfgIntDir()->toUtf8().constData() );
1111 if ( getenv(
"QGIS_PREFIX_PATH" ) )
1115#if defined( ANDROID )
1117 QDir dir( QDir::homePath() );
1122#if defined( Q_OS_MACOS ) && defined( QGIS_MAC_BUNDLE )
1124 QDir dir( appPath +
"/../.."_L1 );
1126#elif defined( Q_OS_MACOS )
1128#elif defined( Q_OS_WIN )
1133 QDir dir( appPath );
1135 if ( appPath.contains( u
"cgi-bin"_s ) )
1145 if ( ABISYM( mRunningFromBuildDir ) )
1146 return *sBuildOutputPath() + u
"/data"_s;
1148 return prefixPath +
'/' + QStringLiteral( QGIS_DATA_SUBDIR );
1153 return *sThemeName();
1160 if (
themeName ==
"default"_L1 || path.isEmpty() )
1163 qApp->setStyleSheet( QString() );
1168 QFile file( path +
"/style.qss" );
1169 QFile variablesfile( path +
"/variables.qss" );
1170 QFileInfo variableInfo( variablesfile );
1172 if ( !file.open( QIODevice::ReadOnly ) || ( variableInfo.exists() && !variablesfile.open( QIODevice::ReadOnly ) ) )
1174 qApp->setStyleSheet( QString() );
1179 QFile palettefile( path +
"/palette.txt" );
1180 QFileInfo paletteInfo( palettefile );
1181 if ( paletteInfo.exists() && palettefile.open( QIODevice::ReadOnly ) )
1183 QPalette
pal = qApp->palette();
1184 QTextStream in( &palettefile );
1185 while ( !in.atEnd() )
1187 QString line = in.readLine();
1188 QStringList parts = line.split(
':' );
1189 if ( parts.count() == 2 )
1191 int role = parts.at( 0 ).trimmed().toInt();
1193 pal.setColor(
static_cast< QPalette::ColorRole
>( role ), color );
1196 palettefile.close();
1197 qApp->setPalette(
pal );
1200 QString styledata = file.readAll();
1201 styledata.replace(
"@theme_path"_L1, path );
1203 if ( variableInfo.exists() )
1205 QTextStream in( &variablesfile );
1206 while ( !in.atEnd() )
1208 QString line = in.readLine();
1210 if ( line.startsWith(
'@' ) )
1212 int index = line.indexOf(
':' );
1213 QString name = line.mid( 0, index );
1214 QString value = line.mid( index + 1, line.length() );
1215 styledata.replace( name, value );
1218 variablesfile.close();
1226 const thread_local QRegularExpression regex( u
"(?<=[\\s:])([0-9\\.]+)(?=em)"_s );
1227 QRegularExpressionMatch match = regex.match( styledata, index );
1228 while ( match.hasMatch() )
1230 index = match.capturedStart();
1231 styledata.remove( index, match.captured( 0 ).length() );
1233 styledata.insert( index, number );
1234 index += number.length();
1235 match = regex.match( styledata, index );
1239 qApp->setStyleSheet( styledata );
1248 mapping.insert( u
"default"_s, QString() );
1284 if ( ABISYM( mRunningFromBuildDir ) )
1285 return *sBuildOutputPath() + u
"/i18n/"_s;
1292 return pkgDataPath() + u
"/resources/metadata-ISO/"_s;
1302 return *sConfigPath();
1312 return *sAuthDbDirPath() + u
"qgis-auth.db"_s;
1317 return *sAuthDbUri();
1322 return u
":/images/splash/"_s;
1332 if ( ABISYM( mRunningFromBuildDir ) )
1334 QString tempCopy = QDir::tempPath() +
"/srs.db";
1336 if ( !QFile( tempCopy ).exists() )
1339 if ( !f.copy( tempCopy ) )
1341 qFatal(
"Could not create temporary copy" );
1364 for (
const QString &configuredPath : std::as_const( configuredPaths ) )
1366 const QString path = QDir::cleanPath( QDir( configuredPath ).absolutePath() );
1367 if ( !paths.contains( path ) )
1368 paths.append( path );
1381 members()->mSvgPathCacheValid =
false;
1386 static QReadWriteLock lock;
1390 if ( members()->mSvgPathCacheValid )
1392 return members()->mSvgPathCache;
1403 for (
const QString &path : pathList )
1405 if ( !paths.contains( path ) )
1406 paths.append( path );
1408 for (
const QString &path : std::as_const( *sDefaultSvgPaths() ) )
1410 if ( !paths.contains( path ) )
1411 paths.append( path );
1413 members()->mSvgPathCache = paths;
1428 return *sSystemEnvVars();
1438 const thread_local QRegularExpression regexp( QRegularExpression::anchoredPattern( u
"^[A-Za-z][A-Za-z0-9\\._-]*"_s ) );
1444 if ( !sUserName()->isEmpty() )
1445 return *sUserName();
1448 TCHAR name[UNLEN + 1];
1449 DWORD size = UNLEN + 1;
1451 if ( GetUserName( ( TCHAR * ) name, &size ) )
1453 *sUserName() = QString::fromWCharArray( name );
1457#elif QT_CONFIG( process )
1460 process.start( u
"whoami"_s, QStringList() );
1461 process.waitForFinished();
1462 *sUserName() = process.readAllStandardOutput().trimmed();
1465 if ( !sUserName()->isEmpty() )
1466 return *sUserName();
1469 *sUserName() = qgetenv(
"USER" );
1470 if ( !sUserName()->isEmpty() )
1471 return *sUserName();
1474 *sUserName() = qgetenv(
"USERNAME" );
1475 return *sUserName();
1480 if ( !sUserFullName()->isEmpty() )
1481 return *sUserFullName();
1484 TCHAR name[UNLEN + 1];
1485 DWORD size = UNLEN + 1;
1488 if ( GetUserNameEx( NameDisplay, ( TCHAR * ) name, &size ) )
1490 *sUserFullName() = QString::fromWCharArray( name );
1494 if ( sUserFullName()->isEmpty() )
1496#elif defined( Q_OS_ANDROID ) || defined( __MINGW32__ )
1497 *sUserFullName() = u
"Not available"_s;
1499 struct passwd *p = getpwuid( getuid() );
1503 QString gecosName = QString( p->pw_gecos );
1504 *sUserFullName() = gecosName.left( gecosName.indexOf(
',', 0 ) );
1509 return *sUserFullName();
1514#if defined( Q_OS_ANDROID )
1515 return "android"_L1;
1516#elif defined( Q_OS_MAC )
1518#elif defined( Q_OS_WIN )
1519 return "windows"_L1;
1520#elif defined( Q_OS_LINUX )
1522#elif defined( Q_OS_FREEBSD )
1523 return u
"freebsd"_s;
1524#elif defined( Q_OS_OPENBSD )
1525 return u
"openbsd"_s;
1526#elif defined( Q_OS_NETBSD )
1528#elif defined( Q_OS_UNIX )
1531 return "unknown"_L1;
1538 return static_cast<int>( CPLGetUsablePhysicalRAM() / 1048576 );
1543 return *sPlatformName();
1548 if ( !sApplicationFullName()->isEmpty() )
1549 return *sApplicationFullName();
1552 *sApplicationFullName() = qgetenv(
"QGIS_APPLICATION_FULL_NAME" );
1553 if ( !sApplicationFullName()->isEmpty() )
1554 return *sApplicationFullName();
1558 if ( !storedFullName.isEmpty() )
1559 *sApplicationFullName() = storedFullName;
1561 *sApplicationFullName() = u
"%1 %2"_s.arg( applicationName(),
platform() );
1562 return *sApplicationFullName();
1571 if (
locale.startsWith(
"en"_L1, Qt::CaseInsensitive ) )
1580 return QLocale().name().left( 2 );
1586 QLocale::setDefault(
locale );
1597 return pkgDataPath() + u
"/resources/symbology-style.xml"_s;
1612 return *sLibraryPath();
1617 return *sLibexecPath();
1622 return *sQmlImportPath();
1627 return ( htonl( 1 ) == 1 ) ?
XDR :
NDR;
1634 init( *sProfilePath() );
1658 if (
auto *lInstance =
instance() )
1660 if ( !lInstance->mAuthManager )
1664 return lInstance->mAuthManager;
1669 if ( !sAuthManager )
1671 return sAuthManager;
1684 QThreadPool::globalInstance()->waitForDone();
1687 if (
auto *lInstance =
instance() )
1688 delete lInstance->mAuthManager;
1690 delete sAuthManager;
1693 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1699 if ( QgsProject::sProject )
1707 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1710 if ( QgsProviderRegistry::exists() )
1721 if ( GDALDumpOpenDatasets( stdin ) == 0 )
1724 GDALDestroyDriverManager();
1727 QgsDebugMsgLevel( u
"Skipping call to GDALDestroyDriverManager() due to still opened datasets"_s, 5 );
1732 QString myEnvironmentVar( getenv(
"QGIS_PREFIX_PATH" ) );
1735 "QgsApplication state:\n"
1736 " - QGIS_PREFIX_PATH env var: %1\n"
1738 " - Plugin Path: %3\n"
1739 " - Package Data Path: %4\n"
1740 " - Active Theme Name: %5\n"
1741 " - Active Theme Path: %6\n"
1742 " - Default Theme Path: %7\n"
1743 " - SVG Search Paths: %8\n"
1744 " - User DB Path: %9\n"
1745 " - Auth DB Path: %10\n"
1759 QColor myColor1( Qt::lightGray );
1760 QColor myColor2 = myColor1;
1761 myColor2 = myColor2.lighter( 110 );
1763 myStyle = QStringLiteral(
1766 " font-weight: bold;"
1769 " background: white;"
1771 " font-family: 'Lato', 'Open Sans', 'Lucida Grande', 'Segoe UI', 'Arial', sans-serif;"
1774 "h1{ background-color: #F6F6F6;"
1776 " font-size: x-large; "
1777 " font-weight: normal;"
1778 " background: none;"
1779 " padding: 0.75em 0 0;"
1781 " line-height: 3em;"
1783 "h2{ background-color: #F6F6F6;"
1785 " font-size: medium; "
1786 " font-weight: normal;"
1787 " background: none;"
1788 " padding: 0.75em 0 0;"
1790 " line-height: 1.1em;"
1792 "h3{ background-color: #F6F6F6;"
1794 " font-weight: bold;"
1795 " font-size: large;"
1796 " text-align: left;"
1797 " border-bottom: 5px solid #DCEB5C;"
1799 "h4{ background-color: #F6F6F6;"
1801 " font-weight: bold;"
1802 " font-size: medium;"
1803 " text-align: left;"
1805 "h5{ background-color: #F6F6F6;"
1807 " font-weight: bold;"
1808 " font-size: small;"
1809 " text-align: left;"
1811 "a{ color: #729FCF;"
1812 " font-family: arial,sans-serif;"
1814 "label{ background-color: #FFFFCC;"
1815 " border: 1px solid black;"
1817 " padding: 0px 3px; "
1818 " font-size: small;"
1821 " font-weight: bold;"
1826 " border-top: 1px solid black;"
1828 ".list-view .highlight {"
1829 " text-align: left;"
1832 " padding-right: 15px;"
1833 " padding-left: 20px;"
1834 " font-weight: bold;"
1836 ".tabular-view .odd-row {"
1837 " background-color: #f9f9f9;"
1840 " font-weight: bold;"
1841 " padding-top:25px;"
1846 switch ( styleSheetType )
1849 myStyle += QStringLiteral(
1851 " border-collapse: collapse;"
1854 ".tabular-view th, .tabular-view td { "
1855 " border:1px solid black;"
1861 myStyle += QStringLiteral(
1866 "table.tabular-view, table.list-view { "
1867 " border-collapse: collapse;"
1868 " table-layout:fixed;"
1869 " width: 100% !important;"
1874 " line-height: inherit;"
1877 " word-wrap: break-word; "
1878 " vertical-align: top;"
1881 ".list-view th:first-child, .list-view td:first-child {"
1884 ".list-view.highlight { "
1885 " padding-left: inherit; "
1888 ".tabular-view th:first-child, .tabular-view td:first-child { "
1892 ".tabular-view th.strong { "
1893 " background-color: #eee; "
1896 ".tabular-view th, .tabular-view td { "
1897 " border: 1px solid #eee;"
1908 if ( 0 >= OGRGetDriverCount() )
1916 QString aPathUrl = aPath;
1917 QString tPathUrl = targetPath;
1918#if defined( Q_OS_WIN )
1919 const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
1921 aPathUrl.replace(
'\\',
'/' );
1922 if ( aPathUrl.startsWith(
"//" ) )
1925 aPathUrl =
"\\\\" + aPathUrl.mid( 2 );
1928 tPathUrl.replace(
'\\',
'/' );
1929 if ( tPathUrl.startsWith(
"//" ) )
1932 tPathUrl =
"\\\\" + tPathUrl.mid( 2 );
1935 const Qt::CaseSensitivity cs = Qt::CaseSensitive;
1938 QStringList targetElems = tPathUrl.split(
'/', Qt::SkipEmptyParts );
1939 QStringList aPathElems = aPathUrl.split(
'/', Qt::SkipEmptyParts );
1941 targetElems.removeAll( u
"."_s );
1942 aPathElems.removeAll( u
"."_s );
1946 while ( !aPathElems.isEmpty() && !targetElems.isEmpty() && aPathElems[0].compare( targetElems[0], cs ) == 0 )
1948 aPathElems.removeFirst();
1949 targetElems.removeFirst();
1959 if ( !targetElems.isEmpty() )
1962 for (
int i = 0; i < targetElems.size(); i++ )
1964 aPathElems.insert( 0, u
".."_s );
1971 aPathElems.insert( 0, u
"."_s );
1974 return aPathElems.join(
'/'_L1 );
1980 if ( !rpath.startsWith(
"./"_L1 ) && !rpath.startsWith(
"../"_L1 ) )
1985 QString rPathUrl = rpath;
1986 QString targetPathUrl = targetPath;
1988#if defined( Q_OS_WIN )
1989 rPathUrl.replace(
'\\',
'/' );
1990 targetPathUrl.replace(
'\\',
'/' );
1992 bool uncPath = targetPathUrl.startsWith(
"//" );
1995 QStringList srcElems = rPathUrl.split(
'/', Qt::SkipEmptyParts );
1996 QStringList targetElems = targetPathUrl.split(
'/', Qt::SkipEmptyParts );
1998#if defined( Q_OS_WIN )
2001 targetElems.insert( 0,
"" );
2002 targetElems.insert( 0,
"" );
2007 targetElems << srcElems;
2008 targetElems.removeAll( u
"."_s );
2012 while ( ( pos = targetElems.indexOf(
".."_L1 ) ) > 0 )
2015 targetElems.removeAt( pos - 1 );
2016 targetElems.removeAt( pos - 1 );
2019#if !defined( Q_OS_WIN )
2021 targetElems.prepend( QString() );
2024 return targetElems.join(
'/'_L1 );
2029 return *sBuildSourcePath();
2034 return *sBuildOutputPath();
2037#if defined( _MSC_VER ) && !defined( USING_NMAKE ) && !defined( USING_NINJA )
2038QString QgsApplication::cfgIntDir()
2040 return *sCfgIntDir();
2046 if ( sGdalSkipList()->contains( driver ) || driver.isEmpty() )
2050 *sGdalSkipList() << driver;
2056 if ( !sGdalSkipList()->contains( driver ) )
2060 int myPos = sGdalSkipList()->indexOf( driver );
2063 sGdalSkipList()->removeAt( myPos );
2070 return *sGdalSkipList();
2091 return *sDeferredSkippedGdalDrivers();
2096 sGdalSkipList()->removeDuplicates();
2097 QStringList realDisabledDriverList;
2098 for (
const auto &driverName : *sGdalSkipList() )
2100 if ( !sDeferredSkippedGdalDrivers()->contains( driverName ) )
2101 realDisabledDriverList << driverName;
2103 QString myDriverList = realDisabledDriverList.join(
',' );
2106 CPLSetConfigOption(
"GDAL_SKIP", myDriverList.toUtf8() );
2113 QDir myDir( folder );
2114 if ( !myDir.exists() )
2116 myDir.mkpath( folder );
2122void QgsApplication::copyPath(
const QString &src,
const QString &dst )
2125 if ( !dir.exists() )
2128 const auto subDirectories = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot );
2129 for (
const QString &d : subDirectories )
2131 QString dst_path = dst + QDir::separator() + d;
2132 dir.mkpath( dst_path );
2133 copyPath( src + QDir::separator() + d, dst_path );
2136 const auto files = dir.entryList( QDir::Files );
2137 for (
const QString &f : files )
2139 QFile::copy( src + QDir::separator() + f, dst + QDir::separator() + f );
2145 QVariantMap variables;
2148 for (
const QString &name : names )
2159 for (
auto it = variables.constBegin(); it != variables.constEnd(); ++it )
2176 return instance()->mTemporarilyTrustedProjectFolders;
2181 instance()->mTemporarilyTrustedProjectFolders = trustedProjectsFolders;
2186 return instance()->mTemporarilyUntrustedProjectFolders;
2191 instance()->mTemporarilyUntrustedProjectFolders = untrustedProjectsFolders;
2196 QFontMetrics fm( ( QFont() ) );
2197 const double scale = 1.1 * standardSize / 24;
2198 int scaledIconSize =
static_cast< int >( std::floor( std::max(
Qgis::UI_SCALE_FACTOR * fm.height() * scale,
static_cast< double >( standardSize ) ) ) );
2199 if ( applyDevicePixelRatio )
2201 if ( QWidget *activeWindow = QApplication::activeWindow() )
2202 scaledIconSize *= ( activeWindow->screen() ? QApplication::activeWindow()->screen()->devicePixelRatio() : 1 );
2204 return scaledIconSize;
2217 app->installTranslators();
2223 return *sTranslation();
2257 return members()->mActionScopeRegistry.get();
2266 QDir myDir( myPamPath );
2267 if ( !myDir.exists() )
2269 myDir.mkpath( myPamPath );
2272#if defined( Q_OS_WIN )
2273 CPLSetConfigOption(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() );
2277 int myChangeFlag = 0;
2278 setenv(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag );
2285 if ( !qgisPrivateDbFile.exists() )
2289 QFile masterFile( qgisMasterDbFileName );
2295 bool isDbFileCopied = masterFile.copy( qgisPrivateDbFile.fileName() );
2297 if ( !isDbFileCopied )
2301 *errorMessage = tr(
"[ERROR] Can not make qgis.db private copy" );
2306 QFile::Permissions perms = QFile( qgisPrivateDbFile.fileName() ).permissions();
2307 if ( !( perms & QFile::WriteOwner ) )
2309 if ( !qgisPrivateDbFile.setPermissions( perms | QFile::WriteOwner ) )
2313 *errorMessage = tr(
"Can not make '%1' user writable" ).arg( qgisPrivateDbFile.fileName() );
2327 *errorMessage = tr(
"Could not open qgis.db" );
2332 char *errmsg =
nullptr;
2333 int res = sqlite3_exec( database.get(),
"SELECT srs_id FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2334 if ( res != SQLITE_OK )
2336 sqlite3_free( errmsg );
2341 "DROP INDEX IF EXISTS idx_srsauthid;"
2342 "CREATE TABLE tbl_srs ("
2343 "srs_id INTEGER PRIMARY KEY,"
2344 "description text NOT NULL,"
2345 "projection_acronym text NOT NULL,"
2346 "ellipsoid_acronym NOT NULL,"
2347 "parameters text NOT NULL,"
2349 "auth_name varchar,"
2351 "is_geo integer NOT NULL,"
2352 "deprecated boolean,"
2354 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);",
2363 *errorMessage = tr(
"Creation of missing tbl_srs in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2365 sqlite3_free( errmsg );
2372 res = sqlite3_exec( database.get(),
"SELECT wkt FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2373 if ( res != SQLITE_OK )
2376 sqlite3_free( errmsg );
2379 "DROP INDEX IF EXISTS idx_srsauthid;"
2380 "DROP TABLE IF EXISTS tbl_srs_bak;"
2381 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2382 "CREATE TABLE tbl_srs ("
2383 "srs_id INTEGER PRIMARY KEY,"
2384 "description text NOT NULL,"
2385 "projection_acronym text NOT NULL,"
2386 "ellipsoid_acronym NOT NULL,"
2387 "parameters text NOT NULL,"
2389 "auth_name varchar,"
2391 "is_geo integer NOT NULL,"
2392 "deprecated boolean,"
2394 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2395 "INSERT INTO tbl_srs(srs_id,description,projection_acronym,ellipsoid_acronym,parameters,srid,auth_name,auth_id,is_geo,deprecated) SELECT "
2396 "srs_id,description,projection_acronym,ellipsoid_acronym,parameters,srid,'','',is_geo,0 FROM tbl_srs_bak;"
2397 "DROP TABLE tbl_srs_bak",
2406 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2408 sqlite3_free( errmsg );
2414 res = sqlite3_exec( database.get(),
"SELECT acronym FROM tbl_projection LIMIT 0",
nullptr,
nullptr, &errmsg );
2415 if ( res != SQLITE_OK )
2417 sqlite3_free( errmsg );
2422 "CREATE TABLE tbl_projection ("
2423 "acronym varchar(20) NOT NULL PRIMARY KEY,"
2424 "name varchar(255) NOT NULL default '',"
2425 "notes varchar(255) NOT NULL default '',"
2426 "parameters varchar(255) NOT NULL default ''"
2436 *errorMessage = tr(
"Creation of missing tbl_projection in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2438 sqlite3_free( errmsg );
2443 res = sqlite3_exec( database.get(),
"SELECT epsg FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2444 if ( res == SQLITE_OK )
2449 "DROP INDEX IF EXISTS idx_srsauthid;"
2450 "DROP TABLE IF EXISTS tbl_srs_bak;"
2451 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2452 "CREATE TABLE tbl_srs ("
2453 "srs_id INTEGER PRIMARY KEY,"
2454 "description text NOT NULL,"
2455 "projection_acronym text NOT NULL,"
2456 "ellipsoid_acronym NOT NULL,"
2457 "parameters text NOT NULL,"
2459 "auth_name varchar,"
2461 "is_geo integer NOT NULL,"
2462 "deprecated boolean,"
2464 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2465 "INSERT INTO tbl_srs(srs_id,description,projection_acronym,ellipsoid_acronym,parameters,srid,auth_name,auth_id,is_geo,deprecated) SELECT "
2466 "srs_id,description,projection_acronym,ellipsoid_acronym,parameters,srid,'','',is_geo,0 FROM tbl_srs_bak;"
2467 "DROP TABLE tbl_srs_bak",
2476 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2478 sqlite3_free( errmsg );
2484 sqlite3_free( errmsg );
2487 if ( sqlite3_exec( database.get(),
"DROP VIEW vw_srs",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2489 QgsDebugError( u
"vw_srs didn't exists in private qgis.db: %1"_s.arg( errmsg ) );
2494 "CREATE VIEW vw_srs AS"
2496 " a.description AS description"
2497 ",a.srs_id AS srs_id"
2498 ",a.is_geo AS is_geo"
2499 ",coalesce(b.name,a.projection_acronym) AS name"
2500 ",a.parameters AS parameters"
2501 ",a.auth_name AS auth_name"
2502 ",a.auth_id AS auth_id"
2503 ",a.deprecated AS deprecated"
2505 " LEFT OUTER JOIN tbl_projection b ON a.projection_acronym=b.acronym"
2506 " ORDER BY coalesce(b.name,a.projection_acronym),a.description",
2515 *errorMessage = tr(
"Update of view in private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2517 sqlite3_free( errmsg );
2544 QThreadPool::globalInstance()->setMaxThreadCount(
maxThreads );
2545 QgsDebugMsgLevel( u
"set QThreadPool max thread count to %1"_s.arg( QThreadPool::globalInstance()->maxThreadCount() ), 2 );
2550 return members()->mTaskManager.get();
2555 return members()->mSettingsRegistryCore.get();
2560 return members()->mColorSchemeRegistry.get();
2565 return members()->mPaintEffectRegistry.get();
2570 return members()->mRendererRegistry.get();
2575 return members()->mRasterRendererRegistry.get();
2580 return members()->mPointCloudRendererRegistry.get();
2585 return members()->mTiledSceneRendererRegistry.get();
2590 if (
auto *lInstance =
instance() )
2592 if ( !
instance()->mDataItemProviderRegistry )
2594 lInstance->mDataItemProviderRegistry = std::make_unique<QgsDataItemProviderRegistry>();
2596 return lInstance->mDataItemProviderRegistry.get();
2602 if ( !sDataItemProviderRegistry )
2604 return sDataItemProviderRegistry;
2610 return members()->mCrsRegistry.get();
2615 return members()->mSvgCache.get();
2620 return members()->mImageCache.get();
2625 return members()->mSourceCache.get();
2630 return members()->mNetworkContentFetcherRegistry.get();
2635 return members()->mValidityCheckRegistry.get();
2640 return members()->mSymbolLayerRegistry.get();
2645 return members()->mCalloutRegistry.get();
2650 return members()->mLayoutItemRegistry.get();
2655 return members()->mAnnotationItemRegistry.get();
2660 return members()->mSensorRegistry.get();
2665 return members()->mPlotRegistry.get();
2670 return members()->mGpsConnectionRegistry.get();
2675 return members()->mGpsBabelFormatRegistry.get();
2680 return members()->mPluginLayerRegistry.get();
2685 return members()->mClassificationMethodRegistry.get();
2690 return members()->mBookmarkManager.get();
2695 return members()->mTileDownloadManager.
get();
2700 return members()->mRecentStyleHandler.get();
2705 return members()->mQueryLogger.get();
2710 return members()->mStyleModel.get();
2715 return members()->mFontManager.get();
2720 return members()->mMessageLog.get();
2725 return members()->mProcessingRegistry.get();
2730 return members()->mConnectionRegistry.get();
2735 return members()->mLayerMetadataProviderRegistry.get();
2740 return members()->mPageSizeRegistry.get();
2745 return members()->mAnnotationRegistry.get();
2750 return members()->mApplicationThemeRegistry.get();
2755 return members()->mNumericFormatRegistry.get();
2760 return members()->mFieldFormatterRegistry.get();
2765 return members()->m3DRendererRegistry.get();
2770 return members()->m3DSymbolRegistry.get();
2775 return members()->mMaterialRegistry.get();
2780 return members()->mScaleBarRendererRegistry.get();
2785 return members()->mLabelingEngineRuleRegistry.get();
2790 return members()->mSymbolConverterRegistry.get();
2795 return members()->mProjectStorageRegistry.get();
2800 return members()->mExternalStorageRegistry.get();
2805 return members()->mProfileSourceRegistry.get();
2810 return members()->mLocalizedDataPathRegistry.get();
2823 profiler->start( tr(
"Create query logger" ) );
2824 mQueryLogger = std::make_unique<QgsDatabaseQueryLog>();
2828 profiler->start( tr(
"Setup coordinate reference system registry" ) );
2829 mCrsRegistry = std::make_unique<QgsCoordinateReferenceSystemRegistry>();
2833 profiler->start( tr(
"Create connection registry" ) );
2838 profiler->start( tr(
"Create project storage registry" ) );
2843 profiler->start( tr(
"Create layer metadata provider registry" ) );
2848 profiler->start( tr(
"Create font manager" ) );
2853 profiler->start( tr(
"Setup task manager" ) );
2858 profiler->start( tr(
"Setup action scope registry" ) );
2863 profiler->start( tr(
"Setup numeric formats" ) );
2868 profiler->start( tr(
"Setup field formats" ) );
2873 profiler->start( tr(
"Setup SVG cache" ) );
2874 mSvgCache = std::make_unique<QgsSvgCache>();
2878 profiler->start( tr(
"Setup image cache" ) );
2883 profiler->start( tr(
"Setup source cache" ) );
2888 profiler->start( tr(
"Setup color scheme registry" ) );
2893 profiler->start( tr(
"Setup paint effect" ) );
2898 profiler->start( tr(
"Setup symbol layer registry" ) );
2903 profiler->start( tr(
"Recent style handler" ) );
2908 profiler->start( tr(
"Setup callout registry" ) );
2913 profiler->start( tr(
"Setup renderer registry" ) );
2918 profiler->start( tr(
"Setup raster renderer registry" ) );
2923 profiler->start( tr(
"Setup point cloud renderer registry" ) );
2928 profiler->start( tr(
"Setup tiled scene renderer registry" ) );
2933 profiler->start( tr(
"Setup GPS registry" ) );
2938 profiler->start( tr(
"Setup GPSBabel format registry" ) );
2943 profiler->start( tr(
"Setup plugin layer registry" ) );
2948 profiler->start( tr(
"Setup Processing registry" ) );
2954 profiler->start( tr(
"Setup layout item registry" ) );
2960 profiler->start( tr(
"Setup annotation registry" ) );
2965 profiler->start( tr(
"Setup application theme registry" ) );
2970 profiler->start( tr(
"Setup annotation item registry" ) );
2976 profiler->start( tr(
"Setup labeling engine rule registry" ) );
2981 profiler->start( tr(
"Setup symbol converter registry" ) );
2987 profiler->start( tr(
"Setup sensor registry" ) );
2993 profiler->start( tr(
"Setup plot registry" ) );
2999 profiler->start( tr(
"Setup 3D material registry" ) );
3005 profiler->start( tr(
"Setup 3D symbol registry" ) );
3010 profiler->start( tr(
"Setup 3D renderer registry" ) );
3015 profiler->start( tr(
"Setup external storage registry" ) );
3020 profiler->start( tr(
"Setup profile source registry" ) );
3025 profiler->start( tr(
"Setup network content cache" ) );
3030 profiler->start( tr(
"Setup layout check registry" ) );
3035 profiler->start( tr(
"Setup classification registry" ) );
3040 profiler->start( tr(
"Setup bookmark manager" ) );
3045 profiler->start( tr(
"Setup tile download manager" ) );
3050 profiler->start( tr(
"Setup scalebar registry" ) );
3112 if (
auto *lInstance =
instance() )
3114 return lInstance->mApplicationMembers.get();
3118 static QRecursiveMutex sMemberMutex;
3119 QMutexLocker lock( &sMemberMutex );
3120 if ( !sApplicationMembers )
3121 sApplicationMembers =
new ApplicationMembers();
3122 return sApplicationMembers;
QFlags< SettingsOption > SettingsOptions
static const double UI_SCALE_FACTOR
UI scaling factor.
A registry for available 3D renderers.
Registry of available 3D symbol classes.
The action scope registry is an application wide registry that contains a list of available action sc...
Registry of available annotation item types.
Registry of user interface themes.
QHash< QString, QString > themeFolders() const
Returns a map of user interface theme names and folders.
QString themeFolder(const QString &name) const
Returns the user interface theme folder for a matching name.
static QString resolvePkgPath()
Calculate the application pkg path.
static int scaleIconSize(int standardSize, bool applyDevicePixelRatio=false)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...
static void restoreGdalDriver(const QString &driver)
Sets the GDAL_SKIP environment variable to exclude the specified driver and then calls GDALDriverMana...
static const QgsSettingsEntryString * settingsApplicationFullName
static QgsLabelingEngineRuleRegistry * labelingEngineRuleRegistry()
Gets the registry of available labeling engine rules.
static void setCustomVariables(const QVariantMap &customVariables)
Custom expression variables for this application.
QString translation() const
Returns the current application translation locale code.
static QString i18nPath()
Returns the path to the translation directory.
static QgsAnnotationItemRegistry * annotationItemRegistry()
Returns the application's annotation item registry, used for annotation item types.
static QString osName()
Returns a string name of the operating system QGIS is running on.
static void registerOgrDrivers()
Register OGR drivers ensuring this only happens once.
static QString sponsorsFilePath()
Returns the path to the sponsors file.
static QgsRecentStyleHandler * recentStyleHandler()
Returns the handler for recently used style items.
endian_t
Constants for endian-ness.
@ XDR
Network, or big-endian, byte order.
@ NDR
Little-endian byte order.
static QString qgisMasterDatabaseFilePath()
Returns the path to the master qgis.db file.
static void skipGdalDriver(const QString &driver)
Sets the GDAL_SKIP environment variable to include the specified driver and then calls GDALDriverMana...
static QString defaultThemePath()
Returns the path to the default theme directory.
static QgsPageSizeRegistry * pageSizeRegistry()
Returns the application's page size registry, used for managing layout page sizes.
static QgsValidityCheckRegistry * validityCheckRegistry()
Returns the application's validity check registry, used for managing validity checks.
static QgsDataItemProviderRegistry * dataItemProviderRegistry()
Returns the application's data item provider registry, which keeps a list of data item providers that...
static QString userStylePath()
Returns the path to user's style.
static QString platform()
Returns the QGIS platform name, e.g., "desktop", "server", "qgis_process" or "external" (for external...
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers,...
static QgsLayerMetadataProviderRegistry * layerMetadataProviderRegistry()
Returns registry of available layer metadata provider implementations.
static QgsSymbolConverterRegistry * symbolConverterRegistry()
Gets the registry of available symbol converters.
static QgsConnectionRegistry * connectionRegistry()
Returns the application's connection registry, used for managing saved data provider connections.
static void exitQgis()
deletes provider registry and map layer registry
static void setPluginPath(const QString &pluginPath)
Alters plugin path - used by 3rd party apps.
static const QgsSettingsEntryStringList * settingsSearchPathsForSVG
Settings entry search path for SVG.
void themeChanged()
Emitted when the application theme has changed.
static QPixmap getThemePixmap(const QString &name, const QColor &foreColor=QColor(), const QColor &backColor=QColor(), int size=16)
Helper to get a theme icon as a pixmap.
static QString nullRepresentation()
Returns the string used to represent the value NULL throughout QGIS.
static QVariantMap customVariables()
Custom expression variables for this application.
static QgsPointCloudRendererRegistry * pointCloudRendererRegistry()
Returns the application's point cloud renderer registry, used for managing point cloud layer 2D rende...
static QgsPaintEffectRegistry * paintEffectRegistry()
Returns the application's paint effect registry, used for managing paint effects.
static QgsSensorRegistry * sensorRegistry()
Returns the application's sensor registry, used for sensor types.
static QString pluginPath()
Returns the path to the application plugin directory.
static void setUITheme(const QString &themeName)
Set the current UI theme used to style the interface.
static bool createDatabase(QString *errorMessage=nullptr)
initialize qgis.db
static const QgsSettingsEntryBool * settingsLocaleOverrideFlag
Settings entry locale override flag.
static void setTemporarilyUntrustedProjectsFolders(const QStringList &untrustedProjectsFolders)
Sets the list of projects and folders that have been temporarily determined as untrusted by the user.
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
static int systemMemorySizeMb()
Returns the size of the system memory (RAM) in megabytes.
static void setLocale(const QLocale &locale)
Sets the QGIS locale - used mainly by 3rd party apps and tests.
static void init(QString profileFolder=QString())
This method initializes paths etc for QGIS.
static const QgsSettingsEntryString * settingsNullRepresentation
static void setThemeName(const QString &themeName)
Set the active theme to the specified theme.
void customVariablesChanged()
Emitted whenever a custom global variable changes.
static QString buildSourcePath()
Returns path to the source directory.
static QString buildOutputPath()
Returns path to the build output directory.
bool notify(QObject *receiver, QEvent *event) override
Catch exceptions when sending event to receiver.
static int maxThreads()
Gets maximum concurrent thread count.
static QgsColorSchemeRegistry * colorSchemeRegistry()
Returns the application's color scheme registry, used for managing color schemes.
static QgsSettingsTreeNamedListNode * sTreeCustomVariables
static QgsApplication * instance()
Returns the singleton instance of the QgsApplication.
static QString reportStyleSheet(QgsApplication::StyleSheetType styleSheetType=QgsApplication::StyleSheetType::Qt)
Returns a css style sheet for reports, the styleSheetType argument determines what type of stylesheet...
static QString pkgDataPath()
Returns the common root path of all application data directories.
static QgsScaleBarRendererRegistry * scaleBarRendererRegistry()
Gets the registry of available scalebar renderers.
static QgsLayoutItemRegistry * layoutItemRegistry()
Returns the application's layout item registry, used for layout item types.
static void setFileOpenEventReceiver(QObject *receiver)
Sets the FileOpen event receiver.
static QgsSymbolLayerRegistry * symbolLayerRegistry()
Returns the application's symbol layer registry, used for managing symbol layers.
static QStringList projectTemplatePaths()
Returns the paths to project templates.
static QgsRasterRendererRegistry * rasterRendererRegistry()
Returns the application's raster renderer registry, used for managing raster layer renderers.
static void applyGdalSkippedDrivers()
Apply the skipped drivers list to gdal.
static void setMaxThreads(int maxThreads)
Set maximum concurrent thread count.
static QgsNumericFormatRegistry * numericFormatRegistry()
Gets the registry of available numeric formats.
static QgsNetworkContentFetcherRegistry * networkContentFetcherRegistry()
Returns the application's network content registry used for fetching temporary files during QGIS sess...
static QgsProjectStorageRegistry * projectStorageRegistry()
Returns registry of available project storage implementations.
static QString licenceFilePath()
Returns the path to the licence file.
static QString libexecPath()
Returns the path with utility executables (help viewer, crssync, ...).
static QStringList skippedGdalDrivers()
Returns the list of gdal drivers that should be skipped (based on GDAL_SKIP environment variable).
StyleSheetType
The StyleSheetType enum represents the stylesheet type that a widget supports.
@ Qt
StyleSheet for Qt GUI widgets (based on QLabel or QTextBrowser), supports basic CSS and Qt extensions...
@ WebBrowser
StyleSheet for embedded browsers (QtWebKit), supports full standard CSS.
static QString translatorsFilePath()
Returns the path to the sponsors file.
static const QgsSettingsEntryString * settingsLocaleGlobalLocale
Settings entry locale global locale.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static void setNullRepresentation(const QString &nullRepresentation)
Sets the string used to represent the value NULL throughout QGIS.
static QStringList temporarilyTrustedProjectsFolders()
Returns the list of projects and folders that have been temporarily determined as trusted by the user...
static QString applicationFullName()
Returns the QGIS application full name.
static QgsGpsConnectionRegistry * gpsConnectionRegistry()
Returns the application's GPS connection registry, used for managing GPS connections.
static QString locale()
Returns the QGIS locale.
static QgsImageCache * imageCache()
Returns the application's image cache, used for caching resampled versions of raster images.
static QStringList svgPaths()
Returns the paths to svg directories.
static void initQgis()
loads providers
static QString showSettings()
Convenience function to get a summary of the paths used in this application instance useful for debug...
static const QgsSettingsEntryStringList * settingsProjectTemplatePaths
Settings entry search path for project templates.
bool event(QEvent *event) override
Watch for QFileOpenEvent.
static void setPkgDataPath(const QString &pkgDataPath)
Alters pkg data path - used by 3rd party apps.
static QString absolutePathToRelativePath(const QString &apath, const QString &targetPath)
Converts absolute path to path relative to target.
static const QgsSettingsEntryString * settingsLocaleUserLocale
Settings entry locale user locale.
static QgsRuntimeProfiler * profiler()
Returns the application runtime profiler.
~QgsApplication() override
static QgsLocalizedDataPathRegistry * localizedDataPathRegistry()
Returns the registry of data repositories These are used as paths for basemaps, logos,...
static const char * QGIS_APPLICATION_NAME
static QgsTileDownloadManager * tileDownloadManager()
Returns the application's tile download manager, used for download of map tiles when rendering.
static const char * QGIS_ORGANIZATION_DOMAIN
static QMap< QString, QString > systemEnvVars()
Returns the system environment variables passed to application.
static void setAuthDatabaseDirPath(const QString &authDbDirPath)
Alters authentication data base directory path - used by 3rd party apps.
static const QgsSettingsEntryStringList * settingsSkippedGdalDrivers
static QgsAuthConfigurationStorageRegistry * authConfigurationStorageRegistry()
Returns the application's authentication configuration storage registry.
static QString prefixPath()
Returns the path to the application prefix directory.
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
static QgsFontManager * fontManager()
Returns the application font manager, which manages available fonts and font installation for the QGI...
static QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
static QgsDatabaseQueryLog * databaseQueryLog()
Returns the database query log.
static QgsMessageLog * messageLog()
Returns the application's message log.
void preNotify(QObject *receiver, QEvent *event, bool *done)
static bool createThemeFolder()
Create the users theme folder.
static QString metadataPath()
Returns the path to the metadata directory.
void localeChanged()
Emitted when project locale has been changed.
static QgsActionScopeRegistry * actionScopeRegistry()
Returns the action scope registry.
static QgsCoordinateReferenceSystemRegistry * coordinateReferenceSystemRegistry()
Returns the application's coordinate reference system (CRS) registry, which handles known CRS definit...
static const char * QGIS_ORGANIZATION_NAME
static QString contributorsFilePath()
Returns the path to the contributors file.
void collectTranslatableObjects(QgsTranslationContext *translationContext)
Emits the signal to collect all the strings of .qgs to be included in ts file.
static QgsSourceCache * sourceCache()
Returns the application's source cache, used for caching embedded and remote source strings as local ...
static QStringList temporarilyUntrustedProjectsFolders()
Returns the list of projects and folders that have been temporarily determined as untrusted by the us...
static QRegularExpression shortNameRegularExpression()
Returns the short name regular expression for line edit validator.
static QgsTaskManager * taskManager()
Returns the application's task manager, used for managing application wide background task handling.
static QgsProfileSourceRegistry * profileSourceRegistry()
Returns registry of available profile source implementations.
static QgsAnnotationRegistry * annotationRegistry()
Returns the application's annotation registry, used for managing annotation types.
static QgsPluginLayerRegistry * pluginLayerRegistry()
Returns the application's plugin layer registry, used for managing plugin layer types.
static QgsClassificationMethodRegistry * classificationMethodRegistry()
Returns the application's classification methods registry, used in graduated renderer.
static QStringList deferredSkippedGdalDrivers()
Returns the list of gdal drivers that have been disabled in the current session, and thus,...
static QString qgisAuthDatabaseUri()
Returns the URI to the user authentication database.
static QString defaultStylePath()
Returns the path to default style (works as a starting point).
static QgsAuthManager * authManager()
Returns the application's authentication manager instance.
static QString qmlImportPath()
Returns the path where QML components are installed for QGIS Quick library.
static QgsApplicationThemeRegistry * applicationThemeRegistry()
Returns the application's theme registry, used for styling the user interface.
QgsApplication(int &argc, char **argv, bool GUIenabled, const QString &profileFolder=QString(), const QString &platformName="external")
Constructor for QgsApplication.
Cursor
The Cursor enum defines constants for QGIS custom cursors.
@ CrossHair
Precisely identify a point on the canvas.
@ Identify
Identify: obtain information about the object.
@ Select
Select a rectangle.
@ CapturePoint
Select and capture a point or a feature.
@ Sampler
Color/Value picker.
static const QgsSettingsEntryInteger * settingsConnectionPoolMaximumConcurrentConnections
Settings entry to configure the maximum number of concurrent connections within connection pools.
static Q_DECL_DEPRECATED QString qgisAuthDatabaseFilePath()
Returns the path to the user authentication database file: qgis-auth.db.
static QString authorsFilePath()
Returns the path to the authors file.
static QgsBookmarkManager * bookmarkManager()
Returns the application's bookmark manager, used for storing installation-wide bookmarks.
static QString qgisUserDatabaseFilePath()
Returns the path to the user qgis.db file.
static QgsFieldFormatterRegistry * fieldFormatterRegistry()
Gets the registry of available field formatters.
static QString activeThemePath()
Returns the path to the currently active theme directory.
static QString defaultThemesFolder()
Returns the path to default themes folder from install (works as a starting point).
static void setTemporarilyTrustedProjectsFolders(const QStringList &trustedProjectsFolders)
Sets the list of projects and folders that have been temporarily determined as trusted by the user.
static void setSkippedGdalDrivers(const QStringList &skippedGdalDrivers, const QStringList &deferredSkippedGdalDrivers)
Sets the list of gdal drivers that should be disabled (skippedGdalDrivers), but excludes for now the ...
static void setProjectTemplatePaths(const QStringList &projectTemplatePaths)
Sets the paths to project templates.
static QgsRendererRegistry * rendererRegistry()
Returns the application's renderer registry, used for managing vector layer renderers.
static QgsMaterialRegistry * materialRegistry()
Returns registry of available 3D materials.
static void setTranslation(const QString &translation)
Set translation locale code.
static QgsCalloutRegistry * calloutRegistry()
Returns the application's callout registry, used for managing callout types.
static void setPrefixPath(const QString &prefixPath, bool useDefaultPaths=false)
Alters prefix path - used by 3rd party apps.
static QgsStyleModel * defaultStyleModel()
Returns a shared QgsStyleModel containing the default style library (see QgsStyle::defaultStyle()).
static QString relativePathToAbsolutePath(const QString &rpath, const QString &targetPath)
Converts path relative to target to an absolute path.
static void setSvgPaths(const QStringList &svgPaths)
Sets the paths to svg directories and invalidates the svg path list cache.
static QgsBabelFormatRegistry * gpsBabelFormatRegistry()
Returns the application's GPSBabel format registry, used for managing GPSBabel formats.
static endian_t endian()
Returns whether this machine uses big or little endian.
int maxConcurrentConnectionsPerPool() const
The maximum number of concurrent connections per connections pool.
static void setCustomVariable(const QString &name, const QVariant &value)
Set a single custom expression variable.
void requestForTranslatableObjects(QgsTranslationContext *translationContext)
Emitted when project strings which require translation are being collected for inclusion in a ....
static QString iconsPath()
Returns the path to the icons image directory.
static Qgs3DSymbolRegistry * symbol3DRegistry()
Returns registry of available 3D symbols.
static QgsExternalStorageRegistry * externalStorageRegistry()
Returns registry of available external storage implementations.
static QHash< QString, QString > uiThemes()
All themes found in ~/.qgis3/themes folder.
static QString splashPath()
Returns the path to the splash screen image directory.
static QString donorsFilePath()
Returns the path to the donors file.
static QString themeName()
Set the active theme to the specified theme.
void nullRepresentationChanged()
Emitted when the string representing the NULL value is changed.
static QString srsDatabaseFilePath()
Returns the path to the srs.db file.
static QString userThemesFolder()
Returns the path to user's themes folder.
static void registerGdalDriversFromSettings()
Register gdal drivers, excluding the ones mentioned in "gdal/skipList" setting.
static QgsPlotRegistry * plotRegistry()
Returns the application's plot registry, used for plot types.
static Qgs3DRendererRegistry * renderer3DRegistry()
Returns registry of available 3D renderers.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
static QgsTiledSceneRendererRegistry * tiledSceneRendererRegistry()
Returns the application's tiled scene renderer registry, used for managing tiled scene layer 2D rende...
static void setDefaultSvgPaths(const QStringList &pathList)
Alters default svg paths - used by 3rd party apps.
static QString libraryPath()
Returns the path containing qgis_core, qgis_gui, qgispython (and other) libraries.
static QStringList layoutTemplatePaths()
Returns the paths to layout template directories.
static const QgsSettingsEntryBool * settingsLocaleShowGroupSeparator
Settings entry locale show group separator.
static QString userFullName()
Returns the user's operating system login account full display name.
static Q_DECL_DEPRECATED QgsSettingsRegistryCore * settingsRegistryCore()
Returns the application's settings registry, used for managing application settings.
static QString serverResourcesPath()
Returns the path to the server resources directory.
static QString appIconPath()
Gets application icon.
static QStringList defaultProjectTemplatePaths()
Returns the default project template paths.
static QString userLoginName()
Returns the user's operating system login account name.
static const QgsSettingsEntryVariant * settingsCustomVariable
Registry for authentication configuration storages.
Singleton which offers an interface to manage the authentication configuration database and to utiliz...
QgsAuthConfigurationStorageRegistry * authConfigurationStorageRegistry() const
Returns the authentication configuration storage registry.
void setup(const QString &pluginPath=QString(), const QString &authDatabasePath=QString())
Sets up the authentication manager configuration.
static QgsAuthManager * instance()
Enforce singleton pattern.
Manages storage of a set of bookmarks.
void initialize(const QString &filePath)
Initializes the bookmark manager.
Registry of available callout classes.
Manages all known classification methods.
Registry of color schemes.
void addDefaultSchemes()
Adds all default color schemes to this color scheme.
void setProject(QgsProject *project)
Sets the project associated with the registry, used to provide the "Project colors" scheme.
void initStyleScheme()
Initializes the default random style color scheme for the user.
A registry for saved data provider connections, allowing retrieval of saved connections by name and p...
A registry for known coordinate reference system (CRS) definitions, including any user-defined CRSes.
static void invalidateCache(bool disableCache=false)
Clears the internal cache used to initialize QgsCoordinateReferenceSystem objects.
A registry for data item providers that may add items to the browser tree.
Handles logging of database queries.
static void invalidateCache(bool disableCache=false)
Clears the internal cache used.
Defines a QGIS exception class.
static void cleanRegisteredFunctions()
Deletes all registered functions whose ownership have been transferred to the expression engine.
static const FunctionListSnapshot getFunctionsSnapshot()
Returns a thread-safe snapshot of all registered functions.
Registry of external storage backends used by QgsExternalResourceWidget.
Manages available fonts and font installation for a QGIS instance.
void installUserFonts()
Installs user fonts from the profile/fonts directory as application fonts.
Registers existing GPS connections such that the information is available to all classes and plugins.
A cache for images derived from raster files.
A registry for labeling engine rules.
Registry of available layout item types.
static const QgsSettingsEntryStringList * settingsSearchPathForTemplates
Settings entry search path for templates.
A registry class to hold localized data paths which can be used for basemaps, logos,...
Registry of available 3d material settings classes.
Temporarily blocks the application QgsMessageLog (see QgsApplication::messageLog()) from emitting the...
Interface for logging messages from QGIS in GUI independent way.
static QgsNetworkAccessManager * instance(Qt::ConnectionType connectionType=Qt::BlockingQueuedConnection)
Returns a pointer to the active QgsNetworkAccessManager for the current thread.
Registry for temporary fetched files.
A registry for known page sizes.
Registry of available paint effects.
Registry of available plot types.
A registry of plugin layers types.
Registry of 2D renderers for point clouds.
void loadStyles()
Loads all saved styles from the configuration file.
Registry for various processing components, including providers, algorithms and various parameters an...
QgsProcessingDefaultStyleRegistry * defaultStyleRegistry() const
Returns the default style registry, responsible for styling layers generated by Processing tools.
Registry of profile sources used by QgsProfilePlotRenderer.
static QStringList searchPaths()
Returns the current list of Proj file search paths.
Registry of storage backends that QgsProject may use.
static QgsProject * instance()
Returns the QgsProject singleton instance.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
Registry for raster renderers.
A convenience class that simplifies locking and unlocking QReadWriteLocks.
void changeMode(Mode mode)
Change the mode of the lock to mode.
Handles and tracks style items recently used in the QGIS GUI.
Provides a method of recording run time profiles of operations, allowing easy recording of their over...
A registry which manages registered scalebar renderers.
Scoped object for logging of the runtime for a single operation or group of operations.
Registry of available sensor types.
A boolean settings entry.
An integer settings entry.
A string list settings entry.
A variant settings entry.
Custom exception class for settings related exceptions.
Used for settings introspection and collects all QgsSettingsEntry instances of core.
A named list tree node for the settings tree to help organizing and introspecting the tree.
static QgsSettingsTreeNode * sTreeApp
static QgsSettingsTreeNode * sTreeLocale
static QgsSettingsTreeNode * sTreeGdal
static QgsSettingsTreeNode * sTreeSvg
static QgsSettingsTreeNode * sTreeProject
static QgsSettingsTreeNode * sTreeQgis
static QgsSettingsTreeNode * sTreeCore
A cache for source strings that returns a local file path containing the source content.
A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle ...
A database of saved style entities, including symbols, color ramps, text formats and others.
static void cleanDefaultStyle()
Deletes the default style. Only to be used by QgsApplication::exitQgis().
static QgsStyle * defaultStyle(bool initialize=true)
Returns the default application-wide style.
A cache for images / pictures derived from SVG files.
QImage svgAsImage(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, bool &fitsInCache, double fixedAspectRatio=0, bool blocking=false, const QMap< QString, QString > ¶meters=QMap< QString, QString >())
Returns an SVG drawing as a QImage.
QByteArray svgContent(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, double fixedAspectRatio=0, bool blocking=false, const QMap< QString, QString > ¶meters=QMap< QString, QString >(), bool *isMissingImage=nullptr)
Gets the SVG content corresponding to the given path.
A registry of known symbol converters.
Registry of available symbol layer classes.
static QColor decodeColor(const QString &str)
Decodes a string to a color.
Task manager for managing a set of long-running QgsTask tasks.
Tile download manager handles downloads of map tiles for the purpose of map rendering.
QgsTileDownloadManagerReply * get(const QNetworkRequest &request)
Starts a request.
Registry of 2D renderers for tiled scenes.
Used for the collecting of strings from projects for translation and creation of ts files.
A manager for QGIS user profiles.
std::unique_ptr< QgsUserProfile > getProfile(const QString &defaultProfile="default", bool createNew=true, bool initSettings=true)
Returns the profile from the given root profile location.
static QString resolveProfilesFolder(const QString &basePath=QString())
Resolves the profiles folder for the given path.
A registry that keeps a list of QgsAbstractValidityCheck checks which can be used when performing val...
Unique pointer for sqlite3 databases, which automatically closes the database when the pointer goes o...
int open(const QString &path)
Opens the database at the specified file path.
QMap< QString, QString > QgsStringMap
QObject * ABISYM(QgsApplication::mFileOpenEventReceiver)
Q_GLOBAL_STATIC_WITH_ARGS(PalPropertyList, palHiddenProperties,({ static_cast< int >(QgsPalLayerSettings::Property::PositionX), static_cast< int >(QgsPalLayerSettings::Property::PositionY), static_cast< int >(QgsPalLayerSettings::Property::Show), static_cast< int >(QgsPalLayerSettings::Property::LabelRotation), static_cast< int >(QgsPalLayerSettings::Property::Family), static_cast< int >(QgsPalLayerSettings::Property::FontStyle), static_cast< int >(QgsPalLayerSettings::Property::Size), static_cast< int >(QgsPalLayerSettings::Property::Bold), static_cast< int >(QgsPalLayerSettings::Property::Italic), static_cast< int >(QgsPalLayerSettings::Property::Underline), static_cast< int >(QgsPalLayerSettings::Property::Color), static_cast< int >(QgsPalLayerSettings::Property::Strikeout), static_cast< int >(QgsPalLayerSettings::Property::MultiLineAlignment), static_cast< int >(QgsPalLayerSettings::Property::BufferSize), static_cast< int >(QgsPalLayerSettings::Property::BufferDraw), static_cast< int >(QgsPalLayerSettings::Property::BufferColor), static_cast< int >(QgsPalLayerSettings::Property::LabelDistance), static_cast< int >(QgsPalLayerSettings::Property::Hali), static_cast< int >(QgsPalLayerSettings::Property::Vali), static_cast< int >(QgsPalLayerSettings::Property::ScaleVisibility), static_cast< int >(QgsPalLayerSettings::Property::MinScale), static_cast< int >(QgsPalLayerSettings::Property::MaxScale), static_cast< int >(QgsPalLayerSettings::Property::AlwaysShow), static_cast< int >(QgsPalLayerSettings::Property::CalloutDraw), static_cast< int >(QgsPalLayerSettings::Property::LabelAllParts) })) Q_GLOBAL_STATIC_WITH_ARGS(SymbolPropertyList
const QString cacheKey(const QString &pathIn)
Q_GLOBAL_STATIC(QReadWriteLock, sDefinitionCacheLock)
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
std::unique_ptr< QgsBookmarkManager > mBookmarkManager
std::unique_ptr< QgsRasterRendererRegistry > mRasterRendererRegistry
std::unique_ptr< QgsProcessingRegistry > mProcessingRegistry
std::unique_ptr< QgsTaskManager > mTaskManager
std::unique_ptr< QgsAnnotationRegistry > mAnnotationRegistry
std::unique_ptr< QgsCoordinateReferenceSystemRegistry > mCrsRegistry
std::unique_ptr< QgsGpsConnectionRegistry > mGpsConnectionRegistry
std::unique_ptr< QgsLabelingEngineRuleRegistry > mLabelingEngineRuleRegistry
std::unique_ptr< QgsPointCloudRendererRegistry > mPointCloudRendererRegistry
std::unique_ptr< QgsRendererRegistry > mRendererRegistry
std::unique_ptr< Qgs3DSymbolRegistry > m3DSymbolRegistry
std::unique_ptr< QgsPlotRegistry > mPlotRegistry
std::unique_ptr< QgsApplicationThemeRegistry > mApplicationThemeRegistry
QString mNullRepresentation
std::unique_ptr< QgsRecentStyleHandler > mRecentStyleHandler
std::unique_ptr< QgsClassificationMethodRegistry > mClassificationMethodRegistry
std::unique_ptr< QgsSensorRegistry > mSensorRegistry
std::unique_ptr< QgsPluginLayerRegistry > mPluginLayerRegistry
std::unique_ptr< QgsDatabaseQueryLog > mQueryLogger
std::unique_ptr< QgsScaleBarRendererRegistry > mScaleBarRendererRegistry
std::unique_ptr< QgsNumericFormatRegistry > mNumericFormatRegistry
std::unique_ptr< QgsLayoutItemRegistry > mLayoutItemRegistry
std::unique_ptr< QgsTiledSceneRendererRegistry > mTiledSceneRendererRegistry
std::unique_ptr< QgsStyleModel > mStyleModel
std::unique_ptr< QgsAnnotationItemRegistry > mAnnotationItemRegistry
std::unique_ptr< QgsImageCache > mImageCache
std::unique_ptr< Qgs3DRendererRegistry > m3DRendererRegistry
std::unique_ptr< QgsCalloutRegistry > mCalloutRegistry
std::unique_ptr< QgsSourceCache > mSourceCache
std::unique_ptr< QgsFontManager > mFontManager
std::unique_ptr< QgsSettingsRegistryCore > mSettingsRegistryCore
std::unique_ptr< QgsSymbolConverterRegistry > mSymbolConverterRegistry
std::unique_ptr< QgsPageSizeRegistry > mPageSizeRegistry
std::unique_ptr< QgsExternalStorageRegistry > mExternalStorageRegistry
std::unique_ptr< QgsProfileSourceRegistry > mProfileSourceRegistry
std::unique_ptr< QgsSvgCache > mSvgCache
std::unique_ptr< QgsPaintEffectRegistry > mPaintEffectRegistry
std::unique_ptr< QgsColorSchemeRegistry > mColorSchemeRegistry
std::unique_ptr< QgsActionScopeRegistry > mActionScopeRegistry
std::unique_ptr< QgsBabelFormatRegistry > mGpsBabelFormatRegistry
std::unique_ptr< QgsMaterialRegistry > mMaterialRegistry
std::unique_ptr< QgsTileDownloadManager > mTileDownloadManager
std::unique_ptr< QgsValidityCheckRegistry > mValidityCheckRegistry
std::unique_ptr< QgsNetworkContentFetcherRegistry > mNetworkContentFetcherRegistry
std::unique_ptr< QgsConnectionRegistry > mConnectionRegistry
std::unique_ptr< QgsFieldFormatterRegistry > mFieldFormatterRegistry
std::unique_ptr< QgsProjectStorageRegistry > mProjectStorageRegistry
std::unique_ptr< QgsMessageLog > mMessageLog
QStringList mSvgPathCache
std::unique_ptr< QgsLocalizedDataPathRegistry > mLocalizedDataPathRegistry
std::unique_ptr< QgsLayerMetadataProviderRegistry > mLayerMetadataProviderRegistry
std::unique_ptr< QgsSymbolLayerRegistry > mSymbolLayerRegistry