99#include <QFileOpenEvent>
100#include <QMessageBox>
103#include <QProcessEnvironment>
106#include <QThreadPool>
109#include <QLibraryInfo>
110#include <QStandardPaths>
111#include <QRegularExpression>
112#include <QTextStream>
114#include <QAuthenticator>
115#include <QRecursiveMutex>
118#include <netinet/in.h>
124#define SECURITY_WIN32
127#pragma comment( lib, "Secur32.lib" )
131#include "qgsconfig.h"
141#if defined(Q_OS_LINUX)
142#include <sys/sysinfo.h>
145#define CONN_POOL_MAX_CONCURRENT_CONNS 4
147QObject *
ABISYM( QgsApplication::mFileOpenEventReceiver ) =
nullptr;
148bool ABISYM( QgsApplication::mInitialized ) =
false;
149bool ABISYM( QgsApplication::mRunningFromBuildDir ) =
false;
153QgsApplication::ApplicationMembers *QgsApplication::sApplicationMembers =
nullptr;
155int ABISYM( QgsApplication::sMaxThreads ) = -1;
172#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
188 : QApplication( argc, argv, GUIenabled )
190 *sPlatformName() = platformName;
192 if ( *sTranslation() != QLatin1String(
"C" ) )
194 mQgisTranslator =
new QTranslator();
195 if ( mQgisTranslator->load( QStringLiteral(
"qgis_" ) + *sTranslation(), i18nPath() ) )
197 installTranslator( mQgisTranslator );
201 QgsDebugMsgLevel( QStringLiteral(
"loading of qgis translation failed %1/qgis_%2" ).arg( i18nPath(), *sTranslation() ), 2 );
209 QString qtTranslationsPath = QLibraryInfo::location( QLibraryInfo::TranslationsPath );
211 QString prefix = QDir( QString(
"%1/../" ).arg( QApplication::applicationDirPath() ) ).absolutePath();
212 qtTranslationsPath = prefix + qtTranslationsPath.mid( QLibraryInfo::location( QLibraryInfo::PrefixPath ).length() );
215 mQtTranslator =
new QTranslator();
216 if ( mQtTranslator->load( QStringLiteral(
"qt_" ) + *sTranslation(), qtTranslationsPath ) )
218 installTranslator( mQtTranslator );
222 QgsDebugMsgLevel( QStringLiteral(
"loading of qt translation failed %1/qt_%2" ).arg( qtTranslationsPath, *sTranslation() ), 2 );
225 mQtBaseTranslator =
new QTranslator();
226 if ( mQtBaseTranslator->load( QStringLiteral(
"qtbase_" ) + *sTranslation(), qtTranslationsPath ) )
228 installTranslator( mQtBaseTranslator );
232 QgsDebugMsgLevel( QStringLiteral(
"loading of qtbase translation failed %1/qt_%2" ).arg( qtTranslationsPath, *sTranslation() ), 2 );
236 mApplicationMembers =
new ApplicationMembers();
238 *sProfilePath() = profileFolder;
245 if ( profileFolder.isEmpty() )
247 if ( getenv(
"QGIS_CUSTOM_CONFIG_PATH" ) )
249 profileFolder = getenv(
"QGIS_CUSTOM_CONFIG_PATH" );
253 profileFolder = QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ).value( 0 );
260 profileFolder = profile->
folder();
264 *sProfilePath() = profileFolder;
266 static std::once_flag sMetaTypesRegistered;
267 std::call_once( sMetaTypesRegistered, []
269 qRegisterMetaType<QgsGeometry::Error>(
"QgsGeometry::Error" );
270 qRegisterMetaType<QgsDatabaseQueryLogEntry>(
"QgsDatabaseQueryLogEntry" );
271 qRegisterMetaType<QgsProcessingFeatureSourceDefinition>(
"QgsProcessingFeatureSourceDefinition" );
272 qRegisterMetaType<QgsProcessingOutputLayerDefinition>(
"QgsProcessingOutputLayerDefinition" );
273 qRegisterMetaType<QgsUnitTypes::LayoutUnit>(
"QgsUnitTypes::LayoutUnit" );
274 qRegisterMetaType<QgsUnsetAttributeValue>(
"QgsUnsetAttributeValue" );
275 qRegisterMetaType<QgsFeatureId>(
"QgsFeatureId" );
276 qRegisterMetaType<QgsFields>(
"QgsFields" );
277 qRegisterMetaType<QgsFeatureIds>(
"QgsFeatureIds" );
278 qRegisterMetaType<QgsProperty>(
"QgsProperty" );
279 qRegisterMetaType<QgsFeatureStoreList>(
"QgsFeatureStoreList" );
280 qRegisterMetaType<Qgis::MessageLevel>(
"Qgis::MessageLevel" );
281 qRegisterMetaType<Qgis::BrowserItemState>(
"Qgis::BrowserItemState" );
282 qRegisterMetaType<QgsReferencedRectangle>(
"QgsReferencedRectangle" );
283 qRegisterMetaType<QgsReferencedPointXY>(
"QgsReferencedPointXY" );
284 qRegisterMetaType<QgsReferencedGeometry>(
"QgsReferencedGeometry" );
285 qRegisterMetaType<QgsLayoutRenderContext::Flags>(
"QgsLayoutRenderContext::Flags" );
286 qRegisterMetaType<QgsStyle::StyleEntity>(
"QgsStyle::StyleEntity" );
287 qRegisterMetaType<QgsCoordinateReferenceSystem>(
"QgsCoordinateReferenceSystem" );
288 qRegisterMetaType<QgsAuthManager::MessageLevel>(
"QgsAuthManager::MessageLevel" );
289 qRegisterMetaType<QgsNetworkRequestParameters>(
"QgsNetworkRequestParameters" );
290 qRegisterMetaType<QgsNetworkReplyContent>(
"QgsNetworkReplyContent" );
291 qRegisterMetaType<QgsFeature>(
"QgsFeature" );
292 qRegisterMetaType<QgsGeometry>(
"QgsGeometry" );
293 qRegisterMetaType<QgsInterval>(
"QgsInterval" );
294 qRegisterMetaType<QgsRectangle>(
"QgsRectangle" );
295 qRegisterMetaType<QgsPointXY>(
"QgsPointXY" );
296 qRegisterMetaType<QgsDatumTransform::GridDetails>(
"QgsDatumTransform::GridDetails" );
297 qRegisterMetaType<QgsDatumTransform::TransformDetails>(
"QgsDatumTransform::TransformDetails" );
298 qRegisterMetaType<QgsNewsFeedParser::Entry>(
"QgsNewsFeedParser::Entry" );
299 qRegisterMetaType<QgsRectangle>(
"QgsRectangle" );
300 qRegisterMetaType<QgsLocatorResult>(
"QgsLocatorResult" );
301 qRegisterMetaType<QgsGradientColorRamp>(
"QgsGradientColorRamp" );
302 qRegisterMetaType<QgsProcessingModelChildParameterSource>(
"QgsProcessingModelChildParameterSource" );
303#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
306 qRegisterMetaTypeStreamOperators<QgsProcessingModelChildParameterSource>(
"QgsProcessingModelChildParameterSource" );
308 qRegisterMetaType<QgsRemappingSinkDefinition>(
"QgsRemappingSinkDefinition" );
309 qRegisterMetaType<QgsProcessingModelChildDependency>(
"QgsProcessingModelChildDependency" );
310 qRegisterMetaType<QgsTextFormat>(
"QgsTextFormat" );
311#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
312 QMetaType::registerComparators<QgsProcessingModelChildDependency>();
313 QMetaType::registerEqualsComparator<QgsProcessingFeatureSourceDefinition>();
314 QMetaType::registerEqualsComparator<QgsProperty>();
315 QMetaType::registerEqualsComparator<QgsDateTimeRange>();
316 QMetaType::registerEqualsComparator<QgsDateRange>();
317 QMetaType::registerEqualsComparator<QgsUnsetAttributeValue>();
319 qRegisterMetaType<QPainter::CompositionMode>(
"QPainter::CompositionMode" );
320 qRegisterMetaType<QgsDateTimeRange>(
"QgsDateTimeRange" );
321 qRegisterMetaType<QList<QgsMapLayer *>>(
"QList<QgsMapLayer*>" );
322 qRegisterMetaType<QMap<QNetworkRequest::Attribute, QVariant>>(
"QMap<QNetworkRequest::Attribute,QVariant>" );
323 qRegisterMetaType<QMap<QNetworkRequest::KnownHeaders, QVariant>>(
"QMap<QNetworkRequest::KnownHeaders,QVariant>" );
324 qRegisterMetaType<QList<QNetworkReply::RawHeaderPair>>(
"QList<QNetworkReply::RawHeaderPair>" );
325 qRegisterMetaType< QAuthenticator * >(
"QAuthenticator*" );
330 if ( ABISYM( mRunningFromBuildDir ) )
333 *sPrefixPath() = QString();
334#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
335 setPluginPath( *sBuildOutputPath() +
'/' + QString( QGIS_PLUGIN_SUBDIR ) +
'/' + *sCfgIntDir() );
337 setPluginPath( *sBuildOutputPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
339 setPkgDataPath( *sBuildOutputPath() + QStringLiteral(
"/data" ) );
340 *sLibraryPath() = *sBuildOutputPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
341#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
342 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/' + *sCfgIntDir() +
'/';
344 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
346#if defined( HAVE_QUICK )
347 *sQmlImportPath() = *sBuildOutputPath() +
'/' + QGIS_QML_SUBDIR +
'/';
352 char *
prefixPath = getenv(
"QGIS_PREFIX_PATH" );
355 if ( sPrefixPath()->isNull() )
357#if defined(Q_OS_MACX) || defined(Q_OS_WIN)
359#elif defined(ANDROID)
361 QDir myDir( QDir::homePath() );
363 QString myPrefix = myDir.absolutePath();
366 QDir myDir( applicationDirPath() );
368 if ( applicationDirPath().contains( QStringLiteral(
"cgi-bin" ) ) )
373 QString myPrefix = myDir.absolutePath();
384 *sConfigPath() = profileFolder +
'/';
388 if ( getenv(
"QGIS_AUTH_DB_DIR_PATH" ) )
394 qputenv(
"QT3D_RENDERER",
"opengl" );
397 QMap<QString, QString> systemEnvVarMap;
398 QString passfile( QStringLiteral(
"QGIS_AUTH_PASSWORD_FILE" ) );
400 const auto systemEnvironment = QProcessEnvironment::systemEnvironment().toStringList();
401 for (
const QString &varStr : systemEnvironment )
403 int pos = varStr.indexOf( QLatin1Char(
'=' ) );
406 QString varStrName = varStr.left( pos );
407 QString varStrValue = varStr.mid( pos + 1 );
408 if ( varStrName != passfile )
410 systemEnvVarMap.insert( varStrName, varStrValue );
413 *sSystemEnvVars() = systemEnvVarMap;
420 QString projLib( QDir::cleanPath(
pkgDataPath().append(
"/proj" ) ) );
421 if ( QFile::exists( projLib ) )
423 currentProjSearchPaths.append( projLib );
427 char **newPaths =
new char *[currentProjSearchPaths.length()];
428 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
430 newPaths[i] = CPLStrdup( currentProjSearchPaths.at( i ).toUtf8().constData() );
432 proj_context_set_search_paths(
nullptr, currentProjSearchPaths.count(), newPaths );
433 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
435 CPLFree( newPaths[i] );
440 QCoreApplication::addLibraryPath(
pluginPath() );
450 ABISYM( sMaxThreads ) = -1;
465 if ( !members()->mStyleModel )
468 ABISYM( mInitialized ) =
true;
473 delete mDataItemProviderRegistry;
474 delete mApplicationMembers;
475 delete mQgisTranslator;
476 delete mQtTranslator;
477 delete mQtBaseTranslator;
485void QgsApplication::invalidateCaches()
497 return qobject_cast<QgsApplication *>( QCoreApplication::instance() );
503 if (
event->type() == QEvent::FileOpen )
506 if ( ABISYM( mFileOpenEventReceiver ) )
509 done =
notify( ABISYM( mFileOpenEventReceiver ),
event );
516 sFileOpenEventList()->append(
static_cast<QFileOpenEvent *
>(
event )->file() );
523 done = QApplication::event(
event );
532 if ( thread() == receiver->thread() )
542 done = QApplication::notify( receiver,
event );
546 qCritical() <<
"Caught unhandled QgsException: " << e.
what();
547 if ( qApp->thread() == QThread::currentThread() )
548 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
550 catch ( std::exception &e )
552 qCritical() <<
"Caught unhandled std::exception: " << e.
what();
553 if ( qApp->thread() == QThread::currentThread() )
554 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
558 qCritical() <<
"Caught unhandled unknown exception";
559 if ( qApp->thread() == QThread::currentThread() )
560 QMessageBox::critical( activeWindow(), tr(
"Exception" ), tr(
"unknown exception" ) );
568 return QgsRuntimeProfiler::threadLocalInstance();
574 ABISYM( mFileOpenEventReceiver ) = receiver;
576 if ( sFileOpenEventList()->count() > 0 )
578 const QStringList fileOpenEventList = *sFileOpenEventList();
579 for (
const QString &file : fileOpenEventList )
581 QFileOpenEvent foe( file );
582 QgsApplication::sendEvent( ABISYM( mFileOpenEventReceiver ), &foe );
584 sFileOpenEventList()->clear();
592 if ( sPrefixPath()->endsWith(
"/bin" ) )
594 sPrefixPath()->chop( 4 );
597 if ( useDefaultPaths && !ABISYM( mRunningFromBuildDir ) )
599 setPluginPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
600 setPkgDataPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_DATA_SUBDIR ) );
602 *sLibraryPath() = *sPrefixPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
603 *sLibexecPath() = *sPrefixPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
604#if defined( HAVE_QUICK )
605 *sQmlImportPath() = *sPrefixPath() +
'/' + QGIS_QML_SUBDIR +
'/';
618 QString mySvgPath =
pkgDataPath + QStringLiteral(
"/svg/" );
621 if ( !sDefaultSvgPaths()->contains( mySvgPath ) )
622 *sDefaultSvgPaths() << mySvgPath;
627 *sDefaultSvgPaths() = pathList;
632 QFileInfo fi( authDbDirPath );
633 if ( fi.exists() && fi.isDir() && fi.isWritable() )
635 *sAuthDbDirPath() = fi.canonicalFilePath() + QDir::separator();
642 if ( ABISYM( mRunningFromBuildDir ) )
644 static bool sOnce =
true;
648 ( void ) blockNotifications;
649 qWarning(
"!!! prefix path was requested, but it is not valid - we do not run from installed path !!!" );
655 return *sPrefixPath();
659 return *sPluginPath();
664 if ( sPkgDataPath()->isNull() )
667 return *sPkgDataPath();
672 return QStringLiteral(
":/images/themes/default/" );
677 QDir dir( usersThemes );
685 return defaultThemes;
691 return iconsPath() + QStringLiteral(
"qgis-icon-60x60.png" );
696 return ABISYM( sMaxThreads );
703 if ( QFile::exists( path + iconFile ) )
704 return path + iconFile;
712 const QString cacheKey = ( name.startsWith(
'/' ) ? name.mid( 1 ) : name )
713 + ( fillColor.isValid() ? QStringLiteral(
"_%1" ).arg( fillColor.name( QColor::HexArgb ).mid( 1 ) ) : QString() )
714 + ( strokeColor.isValid() ? QStringLiteral(
"_%1" ).arg( strokeColor.name( QColor::HexArgb ).mid( 1 ) ) : QString() );
716 if ( app && app->mIconCache.contains( cacheKey ) )
717 return app->mIconCache.value( cacheKey );
720 const bool colorBased = fillColor.isValid() || strokeColor.isValid();
722 auto iconFromColoredSvg = [ = ](
const QString & path ) -> QIcon
727 const QString
iconPath = sIconCacheDir()->filePath( cacheKey + QStringLiteral(
".svg" ) );
729 if ( f.open( QFile::WriteOnly | QFile::Truncate ) )
731 f.write( svgContent );
736 QgsDebugMsg( QStringLiteral(
"Could not create colorized icon svg at %1" ).arg(
iconPath ) );
740 return QIcon( f.fileName() );
745 if ( QFile::exists( preferredPath ) )
749 icon = iconFromColoredSvg( preferredPath );
753 icon = QIcon( preferredPath );
756 else if ( QFile::exists( defaultPath ) )
762 icon = iconFromColoredSvg( defaultPath );
766 icon = QIcon( defaultPath );
775 app->mIconCache.insert( cacheKey, icon );
782 if ( app && app->mCursorCache.contains( cursor ) )
783 return app->mCursorCache.value( cursor );
794 name = QStringLiteral(
"mZoomIn.svg" );
799 name = QStringLiteral(
"mZoomOut.svg" );
806 name = QStringLiteral(
"mIdentify.svg" );
809 name = QStringLiteral(
"mCrossHair.svg" );
812 name = QStringLiteral(
"mCapturePoint.svg" );
815 name = QStringLiteral(
"mSelect.svg" );
822 name = QStringLiteral(
"mSampler.svg" );
827 Q_ASSERT( ! name.isEmpty( ) );
829 QIcon icon =
getThemeIcon( QStringLiteral(
"cursors" ) + QDir::separator() + name );
832 if ( ! icon.isNull( ) )
836 cursorIcon = QCursor( icon.pixmap( std::ceil( scale * 32 ), std::ceil( scale * 32 ) ), std::ceil( scale * activeX ), std::ceil( scale * activeY ) );
839 app->mCursorCache.insert( cursor, cursorIcon );
846 const QString preferredPath =
activeThemePath() + QDir::separator() + name;
848 const QString path = QFile::exists( preferredPath ) ? preferredPath : defaultPath;
849 if ( foreColor.isValid() || backColor.isValid() )
851 bool fitsInCache =
false;
852 const QImage image =
svgCache()->
svgAsImage( path, size, backColor, foreColor, 1, 1, fitsInCache );
853 return QPixmap::fromImage( image );
856 return QPixmap( path );
866 static QString appPath;
867 if ( appPath.isNull() )
869 if ( QCoreApplication::instance() )
871 appPath = applicationDirPath();
875 qWarning(
"Application path not initialized" );
879 if ( !appPath.isNull() || getenv(
"QGIS_PREFIX_PATH" ) )
881 QString prefix = getenv(
"QGIS_PREFIX_PATH" ) ? getenv(
"QGIS_PREFIX_PATH" ) : appPath;
886 static const QStringList paths { QStringList() << QString() << QStringLiteral(
"/.." ) << QStringLiteral(
"/bin" ) << QStringLiteral(
"/../../.." ) };
887 for (
const QString &path : paths )
889 f.setFileName( prefix + path +
"/qgisbuildpath.txt" );
893 if ( f.exists() && f.open( QIODevice::ReadOnly ) )
895 ABISYM( mRunningFromBuildDir ) =
true;
896 *sBuildSourcePath() = f.readLine().trimmed();
897 *sBuildOutputPath() = f.readLine().trimmed();
899 QgsDebugMsgLevel( QStringLiteral(
"- source directory: %1" ).arg( sBuildSourcePath()->toUtf8().constData() ), 4 );
900 QgsDebugMsgLevel( QStringLiteral(
"- output directory of the build: %1" ).arg( sBuildOutputPath()->toUtf8().constData() ), 4 );
901#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
902#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
903 *sCfgIntDir() = prefix.split(
'/', QString::SkipEmptyParts ).last();
905 *sCfgIntDir() = prefix.split(
'/', Qt::SkipEmptyParts ).last();
907 qDebug(
"- cfg: %s", sCfgIntDir()->toUtf8().constData() );
913 if ( getenv(
"QGIS_PREFIX_PATH" ) )
919 QDir dir( QDir::homePath() );
924#if defined(Q_OS_MACX)
926#elif defined(Q_OS_WIN)
933 if ( appPath.contains( QStringLiteral(
"cgi-bin" ) ) )
943 if ( ABISYM( mRunningFromBuildDir ) )
944 return *sBuildOutputPath() + QStringLiteral(
"/data" );
946 return prefixPath +
'/' + QStringLiteral( QGIS_DATA_SUBDIR );
951 return *sThemeName();
961 qApp->setStyleSheet( QString() );
965 QString path = themes.value(
themeName );
966 QString stylesheetname = path +
"/style.qss";
968 QFile file( stylesheetname );
969 QFile variablesfile( path +
"/variables.qss" );
971 QFileInfo variableInfo( variablesfile );
973 if ( !file.open( QIODevice::ReadOnly ) || ( variableInfo.exists() && !variablesfile.open( QIODevice::ReadOnly ) ) )
978 QString styledata = file.readAll();
979 styledata.replace( QLatin1String(
"@theme_path" ), path );
981 if ( variableInfo.exists() )
983 QTextStream in( &variablesfile );
984 while ( !in.atEnd() )
986 QString line = in.readLine();
988 if ( line.startsWith(
'@' ) )
990 int index = line.indexOf(
':' );
991 QString name = line.mid( 0, index );
992 QString value = line.mid( index + 1, line.length() );
993 styledata.replace( name, value );
996 variablesfile.close();
1004 const static QRegularExpression regex( QStringLiteral(
"(?<=[\\s:])([0-9\\.]+)(?=em)" ) );
1005 QRegularExpressionMatch match = regex.match( styledata, index );
1006 while ( match.hasMatch() )
1008 index = match.capturedStart();
1009 styledata.remove( index, match.captured( 0 ).length() );
1011 styledata.insert( index, number );
1012 index += number.length();
1013 match = regex.match( styledata, index );
1017 qApp->setStyleSheet( styledata );
1019 QFile palettefile( path +
"/palette.txt" );
1020 QFileInfo paletteInfo( palettefile );
1021 if ( paletteInfo.exists() && palettefile.open( QIODevice::ReadOnly ) )
1023 QPalette
pal = qApp->palette();
1024 QTextStream in( &palettefile );
1025 while ( !in.atEnd() )
1027 QString line = in.readLine();
1028 QStringList parts = line.split(
':' );
1029 if ( parts.count() == 2 )
1031 int role = parts.at( 0 ).trimmed().toInt();
1033 pal.setColor(
static_cast< QPalette::ColorRole
>( role ), color );
1036 palettefile.close();
1037 qApp->setPalette(
pal );
1046 QHash<QString, QString> mapping;
1047 mapping.insert( QStringLiteral(
"default" ), QString() );
1048 const auto constPaths = paths;
1049 for (
const QString &path : constPaths )
1051 QDir folder( path );
1052 QFileInfoList styleFiles = folder.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
1053 const auto constStyleFiles = styleFiles;
1054 for (
const QFileInfo &info : constStyleFiles )
1056 QFileInfo styleFile( info.absoluteFilePath() +
"/style.qss" );
1057 if ( !styleFile.exists() )
1060 QString name = info.baseName();
1061 QString path = info.absoluteFilePath();
1062 mapping.insert( name, path );
1070 return pkgDataPath() + QStringLiteral(
"/doc/AUTHORS" );
1075 return pkgDataPath() + QStringLiteral(
"/doc/CONTRIBUTORS" );
1079 return pkgDataPath() + QStringLiteral(
"/doc/developersmap.html" );
1084 return pkgDataPath() + QStringLiteral(
"/doc/SPONSORS" );
1089 return pkgDataPath() + QStringLiteral(
"/doc/DONORS" );
1094 return pkgDataPath() + QStringLiteral(
"/doc/TRANSLATORS" );
1099 return pkgDataPath() + QStringLiteral(
"/doc/LICENSE" );
1104 if ( ABISYM( mRunningFromBuildDir ) )
1105 return *sBuildOutputPath() + QStringLiteral(
"/i18n/" );
1107 return pkgDataPath() + QStringLiteral(
"/i18n/" );
1112 return pkgDataPath() + QStringLiteral(
"/resources/metadata-ISO/" );
1117 return pkgDataPath() + QStringLiteral(
"/resources/qgis.db" );
1122 return *sConfigPath();
1132 return *sAuthDbDirPath() + QStringLiteral(
"qgis-auth.db" );
1137 return QStringLiteral(
":/images/splash/" );
1142 return pkgDataPath() + QStringLiteral(
"/images/icons/" );
1147 if ( ABISYM( mRunningFromBuildDir ) )
1149 QString tempCopy = QDir::tempPath() +
"/srs6.db";
1151 if ( !QFile( tempCopy ).exists() )
1154 if ( !f.copy( tempCopy ) )
1156 qFatal(
"Could not create temporary copy" );
1164 return pkgDataPath() + QStringLiteral(
"/resources/srs.db" );
1171 members()->mSvgPathCacheValid =
false;
1176 static QReadWriteLock lock;
1180 if ( members()->mSvgPathCacheValid )
1182 return members()->mSvgPathCache;
1193 for (
const QString &path : pathList )
1195 if ( !paths.contains( path ) )
1196 paths.append( path );
1198 for (
const QString &path : std::as_const( *sDefaultSvgPaths() ) )
1200 if ( !paths.contains( path ) )
1201 paths.append( path );
1203 members()->mSvgPathCache = paths;
1218 return *sSystemEnvVars();
1228 const thread_local QRegularExpression regexp( QRegularExpression::anchoredPattern( QStringLiteral(
"^[A-Za-z][A-Za-z0-9\\._-]*" ) ) );
1234 if ( !sUserName()->isEmpty() )
1235 return *sUserName();
1238 TCHAR name [ UNLEN + 1 ];
1239 DWORD size = UNLEN + 1;
1241 if ( GetUserName( ( TCHAR * )name, &size ) )
1243#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
1244 *sUserName() = QString::fromLocal8Bit( name );
1246 *sUserName() = QString::fromWCharArray( name );
1251#elif QT_CONFIG(process)
1254 process.start( QStringLiteral(
"whoami" ), QStringList() );
1255 process.waitForFinished();
1256 *sUserName() = process.readAllStandardOutput().trimmed();
1259 if ( !sUserName()->isEmpty() )
1260 return *sUserName();
1263 *sUserName() = qgetenv(
"USER" );
1264 if ( !sUserName()->isEmpty() )
1265 return *sUserName();
1268 *sUserName() = qgetenv(
"USERNAME" );
1269 return *sUserName();
1274 if ( !sUserFullName()->isEmpty() )
1275 return *sUserFullName();
1278 TCHAR name [ UNLEN + 1 ];
1279 DWORD size = UNLEN + 1;
1282 if ( GetUserNameEx( NameDisplay, ( TCHAR * )name, &size ) )
1284#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
1285 *sUserFullName() = QString::fromLocal8Bit( name );
1287 *sUserFullName() = QString::fromWCharArray( name );
1292 if ( sUserFullName()->isEmpty() )
1294#elif defined(Q_OS_ANDROID) || defined(__MINGW32__)
1295 *sUserFullName() = QStringLiteral(
"Not available" );
1297 struct passwd *p = getpwuid( getuid() );
1301 QString gecosName = QString( p->pw_gecos );
1302 *sUserFullName() = gecosName.left( gecosName.indexOf(
',', 0 ) );
1307 return *sUserFullName();
1312#if defined(Q_OS_ANDROID)
1313 return QLatin1String(
"android" );
1314#elif defined(Q_OS_MAC)
1315 return QLatin1String(
"osx" );
1316#elif defined(Q_OS_WIN)
1317 return QLatin1String(
"windows" );
1318#elif defined(Q_OS_LINUX)
1319 return QStringLiteral(
"linux" );
1320#elif defined(Q_OS_FREEBSD)
1321 return QStringLiteral(
"freebsd" );
1322#elif defined(Q_OS_OPENBSD)
1323 return QStringLiteral(
"openbsd" );
1324#elif defined(Q_OS_NETBSD)
1325 return QStringLiteral(
"netbsd" );
1326#elif defined(Q_OS_UNIX)
1327 return QLatin1String(
"unix" );
1329 return QLatin1String(
"unknown" );
1335#if defined(Q_OS_ANDROID)
1337#elif defined(Q_OS_MAC)
1339#elif defined(Q_OS_WIN)
1340 MEMORYSTATUSEX memoryStatus;
1341 ZeroMemory( &memoryStatus,
sizeof( MEMORYSTATUSEX ) );
1342 memoryStatus.dwLength =
sizeof( MEMORYSTATUSEX );
1343 if ( GlobalMemoryStatusEx( &memoryStatus ) )
1345 return memoryStatus.ullTotalPhys / ( 1024 * 1024 );
1351#elif defined(Q_OS_LINUX)
1352 constexpr int megabyte = 1024 * 1024;
1355 return si.totalram / megabyte;
1356#elif defined(Q_OS_FREEBSD)
1358#elif defined(Q_OS_OPENBSD)
1360#elif defined(Q_OS_NETBSD)
1362#elif defined(Q_OS_UNIX)
1371 return *sPlatformName();
1380 if (
locale.startsWith( QLatin1String(
"en" ), Qt::CaseInsensitive ) )
1389 return QLocale().name().left( 2 );
1395 QLocale::setDefault(
locale );
1406 return pkgDataPath() + QStringLiteral(
"/resources/symbology-style.xml" );
1411 return pkgDataPath() + QStringLiteral(
"/resources/themes" );
1416 return pkgDataPath() + QStringLiteral(
"/resources/server/" );
1421 return *sLibraryPath();
1426 return *sLibexecPath();
1431 return *sQmlImportPath();
1436 return ( htonl( 1 ) == 1 ) ?
XDR :
NDR;
1443 init( *sProfilePath() );
1468 if (
auto *lInstance =
instance() )
1470 if ( !lInstance->mAuthManager )
1474 return lInstance->mAuthManager;
1479 if ( !sAuthManager )
1481 return sAuthManager;
1489 QThreadPool::globalInstance()->waitForDone();
1492 if (
auto *lInstance =
instance() )
1493 delete lInstance->mAuthManager;
1495 delete sAuthManager;
1498 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1504 if ( QgsProject::sProject )
1512 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1515 if ( QgsProviderRegistry::exists() )
1524 GDALDestroyDriverManager();
1529 QString myEnvironmentVar( getenv(
"QGIS_PREFIX_PATH" ) );
1530 QString myState = tr(
"Application state:\n"
1531 "QGIS_PREFIX_PATH env var:\t\t%1\n"
1533 "Plugin Path:\t\t%3\n"
1534 "Package Data Path:\t%4\n"
1535 "Active Theme Name:\t%5\n"
1536 "Active Theme Path:\t%6\n"
1537 "Default Theme Path:\t%7\n"
1538 "SVG Search Paths:\t%8\n"
1539 "User DB Path:\t%9\n"
1540 "Auth DB Path:\t%10\n" )
1541 .arg( myEnvironmentVar,
1548 svgPaths().join( tr(
"\n\t\t",
"match indentation of application state" ) ),
1561 QColor myColor1( Qt::lightGray );
1562 QColor myColor2 = myColor1;
1563 myColor2 = myColor2.lighter( 110 );
1565 myStyle = QStringLiteral(
".overview{"
1567 " font-weight: bold;"
1570 " background: white;"
1572 " font-family: 'Lato', 'Open Sans', 'Lucida Grande', 'Segoe UI', 'Arial', sans-serif;"
1575 "h1{ background-color: #F6F6F6;"
1577 " font-size: x-large; "
1578 " font-weight: normal;"
1579 " background: none;"
1580 " padding: 0.75em 0 0;"
1582 " line-height: 3em;"
1584 "h2{ background-color: #F6F6F6;"
1586 " font-size: medium; "
1587 " font-weight: normal;"
1588 " background: none;"
1589 " padding: 0.75em 0 0;"
1591 " line-height: 1.1em;"
1593 "h3{ background-color: #F6F6F6;"
1595 " font-weight: bold;"
1596 " font-size: large;"
1597 " text-align: left;"
1598 " border-bottom: 5px solid #DCEB5C;"
1600 "h4{ background-color: #F6F6F6;"
1602 " font-weight: bold;"
1603 " font-size: medium;"
1604 " text-align: left;"
1606 "h5{ background-color: #F6F6F6;"
1608 " font-weight: bold;"
1609 " font-size: small;"
1610 " text-align: left;"
1612 "a{ color: #729FCF;"
1613 " font-family: arial,sans-serif;"
1615 "label{ background-color: #FFFFCC;"
1616 " border: 1px solid black;"
1618 " padding: 0px 3px; "
1619 " font-size: small;"
1622 " font-weight: bold;"
1627 " border-top: 1px solid black;"
1629 ".list-view .highlight {"
1630 " text-align: left;"
1633 " padding-right: 15px;"
1634 " padding-left: 20px;"
1635 " font-weight: bold;"
1637 ".tabular-view .odd-row {"
1638 " background-color: #f9f9f9;"
1641 " font-weight: bold;"
1642 " padding-top:25px;"
1646 switch ( styleSheetType )
1649 myStyle += QStringLiteral(
1651 " border-collapse: collapse;"
1654 ".tabular-view th, .tabular-view td { "
1655 " border:1px solid black;"
1660 myStyle += QStringLiteral(
1665 "table.tabular-view, table.list-view { "
1666 " border-collapse: collapse;"
1667 " table-layout:fixed;"
1668 " width: 100% !important;"
1673 " line-height: inherit;"
1676 " word-wrap: break-word; "
1677 " vertical-align: top;"
1680 ".list-view th:first-child, .list-view td:first-child {"
1683 ".list-view.highlight { "
1684 " padding-left: inherit; "
1687 ".tabular-view th:first-child, .tabular-view td:first-child { "
1691 ".tabular-view th.strong { "
1692 " background-color: #eee; "
1695 ".tabular-view th, .tabular-view td { "
1696 " border: 1px solid #eee;"
1707 if ( 0 >= OGRGetDriverCount() )
1715 QString aPathUrl = aPath;
1716 QString tPathUrl = targetPath;
1717#if defined( Q_OS_WIN )
1718 const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
1720 aPathUrl.replace(
'\\',
'/' );
1721 if ( aPathUrl.startsWith(
"//" ) )
1724 aPathUrl =
"\\\\" + aPathUrl.mid( 2 );
1727 tPathUrl.replace(
'\\',
'/' );
1728 if ( tPathUrl.startsWith(
"//" ) )
1731 tPathUrl =
"\\\\" + tPathUrl.mid( 2 );
1734 const Qt::CaseSensitivity cs = Qt::CaseSensitive;
1737#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
1738 QStringList targetElems = tPathUrl.split(
'/', QString::SkipEmptyParts );
1739 QStringList aPathElems = aPathUrl.split(
'/', QString::SkipEmptyParts );
1741 QStringList targetElems = tPathUrl.split(
'/', Qt::SkipEmptyParts );
1742 QStringList aPathElems = aPathUrl.split(
'/', Qt::SkipEmptyParts );
1745 targetElems.removeAll( QStringLiteral(
"." ) );
1746 aPathElems.removeAll( QStringLiteral(
"." ) );
1750 while ( !aPathElems.isEmpty() &&
1751 !targetElems.isEmpty() &&
1752 aPathElems[0].compare( targetElems[0], cs ) == 0 )
1754 aPathElems.removeFirst();
1755 targetElems.removeFirst();
1765 if ( !targetElems.isEmpty() )
1768 for (
int i = 0; i < targetElems.size(); i++ )
1770 aPathElems.insert( 0, QStringLiteral(
".." ) );
1777 aPathElems.insert( 0, QStringLiteral(
"." ) );
1780 return aPathElems.join( QLatin1Char(
'/' ) );
1786 if ( !rpath.startsWith( QLatin1String(
"./" ) ) && !rpath.startsWith( QLatin1String(
"../" ) ) )
1791 QString rPathUrl = rpath;
1792 QString targetPathUrl = targetPath;
1794#if defined(Q_OS_WIN)
1795 rPathUrl.replace(
'\\',
'/' );
1796 targetPathUrl.replace(
'\\',
'/' );
1798 bool uncPath = targetPathUrl.startsWith(
"//" );
1801#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
1802 QStringList srcElems = rPathUrl.split(
'/', QString::SkipEmptyParts );
1803 QStringList targetElems = targetPathUrl.split(
'/', QString::SkipEmptyParts );
1805 QStringList srcElems = rPathUrl.split(
'/', Qt::SkipEmptyParts );
1806 QStringList targetElems = targetPathUrl.split(
'/', Qt::SkipEmptyParts );
1809#if defined(Q_OS_WIN)
1812 targetElems.insert( 0,
"" );
1813 targetElems.insert( 0,
"" );
1818 targetElems << srcElems;
1819 targetElems.removeAll( QStringLiteral(
"." ) );
1823 while ( ( pos = targetElems.indexOf( QLatin1String(
".." ) ) ) > 0 )
1826 targetElems.removeAt( pos - 1 );
1827 targetElems.removeAt( pos - 1 );
1830#if !defined(Q_OS_WIN)
1832 targetElems.prepend( QString() );
1835 return targetElems.join( QLatin1Char(
'/' ) );
1840 return *sBuildSourcePath();
1845 return *sBuildOutputPath();
1848#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
1849QString QgsApplication::cfgIntDir()
1851 return *sCfgIntDir();
1857 if ( sGdalSkipList()->contains( driver ) || driver.isEmpty() )
1861 *sGdalSkipList() << driver;
1867 if ( !sGdalSkipList()->contains( driver ) )
1871 int myPos = sGdalSkipList()->indexOf( driver );
1874 sGdalSkipList()->removeAt( myPos );
1881 return *sGdalSkipList();
1885 const QStringList &deferredSkippedGdalDrivers )
1899 QString joinedList, delimiter;
1900 if ( settings.
contains( QStringLiteral(
"gdal/skipDrivers" ) ) )
1902 joinedList = settings.
value( QStringLiteral(
"gdal/skipDrivers" ), QString() ).toString();
1903 delimiter = QStringLiteral(
"," );
1907 joinedList = settings.
value( QStringLiteral(
"gdal/skipList" ), QString() ).toString();
1908 delimiter = QStringLiteral(
" " );
1911 if ( !joinedList.isEmpty() )
1913 myList = joinedList.split( delimiter );
1915 *sGdalSkipList() = myList;
1921 return *sDeferredSkippedGdalDrivers();
1926 sGdalSkipList()->removeDuplicates();
1927 QStringList realDisabledDriverList;
1928 for (
const auto &driverName : *sGdalSkipList() )
1930 if ( !sDeferredSkippedGdalDrivers()->contains( driverName ) )
1931 realDisabledDriverList << driverName;
1933 QString myDriverList = realDisabledDriverList.join(
',' );
1934 QgsDebugMsgLevel( QStringLiteral(
"Gdal Skipped driver list set to:" ), 2 );
1936 CPLSetConfigOption(
"GDAL_SKIP", myDriverList.toUtf8() );
1943 QDir myDir( folder );
1944 if ( !myDir.exists() )
1946 myDir.mkpath( folder );
1952void QgsApplication::copyPath(
const QString &src,
const QString &dst )
1955 if ( ! dir.exists() )
1958 const auto subDirectories = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot );
1959 for (
const QString &d : subDirectories )
1961 QString dst_path = dst + QDir::separator() + d;
1962 dir.mkpath( dst_path );
1963 copyPath( src + QDir::separator() + d, dst_path );
1966 const auto files = dir.entryList( QDir::Files );
1967 for (
const QString &f :
files )
1969 QFile::copy( src + QDir::separator() + f, dst + QDir::separator() + f );
1978 QVariantMap variables;
1982 QStringList childKeys = settings.
childKeys();
1983 for ( QStringList::const_iterator it = childKeys.constBegin(); it != childKeys.constEnd(); ++it )
1986 variables.insert( name, settings.
value( name ) );
1996 QVariantMap::const_iterator it = variables.constBegin();
1999 for ( ; it != variables.constEnd(); ++it )
2001 settings.
setValue( it.key(), it.value() );
2012 settings.
setValue( QStringLiteral(
"variables/" ) + name, value );
2019 QFontMetrics fm( ( QFont() ) );
2020 const double scale = 1.1 * standardSize / 24;
2021 int scaledIconSize =
static_cast< int >( std::floor( std::max(
Qgis::UI_SCALE_FACTOR * fm.height() * scale,
static_cast< double >( standardSize ) ) ) );
2022 if ( applyDevicePixelRatio )
2024 if ( QWidget *activeWindow = QApplication::activeWindow() )
2025 scaledIconSize *= ( activeWindow->screen() ? QApplication::activeWindow()->screen()->devicePixelRatio() : 1 );
2027 return scaledIconSize;
2042 return *sTranslation();
2052 ApplicationMembers *appMembers = members();
2053 if ( appMembers->mNullRepresentation.isNull() )
2055 appMembers->mNullRepresentation =
QgsSettings().
value( QStringLiteral(
"qgis/nullValue" ), QStringLiteral(
"NULL" ) ).toString();
2057 return appMembers->mNullRepresentation;
2062 ApplicationMembers *appMembers = members();
2076 return members()->mActionScopeRegistry;
2085 QDir myDir( myPamPath );
2086 if ( !myDir.exists() )
2088 myDir.mkpath( myPamPath );
2091#if defined(Q_OS_WIN)
2092 CPLSetConfigOption(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() );
2096 int myChangeFlag = 0;
2097 setenv(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag );
2104 if ( !qgisPrivateDbFile.exists() )
2108 QFile masterFile( qgisMasterDbFileName );
2114 bool isDbFileCopied = masterFile.copy( qgisPrivateDbFile.fileName() );
2116 if ( !isDbFileCopied )
2120 *errorMessage = tr(
"[ERROR] Can not make qgis.db private copy" );
2125 QFile::Permissions perms = QFile( qgisPrivateDbFile.fileName() ).permissions();
2126 if ( !( perms & QFile::WriteOwner ) )
2128 if ( !qgisPrivateDbFile.setPermissions( perms | QFile::WriteOwner ) )
2132 *errorMessage = tr(
"Can not make '%1' user writable" ).arg( qgisPrivateDbFile.fileName() );
2146 *errorMessage = tr(
"Could not open qgis.db" );
2151 char *errmsg =
nullptr;
2152 int res = sqlite3_exec( database.get(),
"SELECT srs_id FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2153 if ( res != SQLITE_OK )
2155 sqlite3_free( errmsg );
2158 if ( sqlite3_exec( database.get(),
2159 "DROP INDEX IF EXISTS idx_srsauthid;"
2160 "CREATE TABLE tbl_srs ("
2161 "srs_id INTEGER PRIMARY KEY,"
2162 "description text NOT NULL,"
2163 "projection_acronym text NOT NULL,"
2164 "ellipsoid_acronym NOT NULL,"
2165 "parameters text NOT NULL,"
2167 "auth_name varchar,"
2169 "is_geo integer NOT NULL,"
2170 "deprecated boolean,"
2172 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2176 *errorMessage = tr(
"Creation of missing tbl_srs in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2178 sqlite3_free( errmsg );
2185 res = sqlite3_exec( database.get(),
"SELECT wkt FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2186 if ( res != SQLITE_OK )
2189 sqlite3_free( errmsg );
2190 if ( sqlite3_exec( database.get(),
2191 "DROP INDEX IF EXISTS idx_srsauthid;"
2192 "DROP TABLE IF EXISTS tbl_srs_bak;"
2193 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2194 "CREATE TABLE tbl_srs ("
2195 "srs_id INTEGER PRIMARY KEY,"
2196 "description text NOT NULL,"
2197 "projection_acronym text NOT NULL,"
2198 "ellipsoid_acronym NOT NULL,"
2199 "parameters text NOT NULL,"
2201 "auth_name varchar,"
2203 "is_geo integer NOT NULL,"
2204 "deprecated boolean,"
2206 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2207 "INSERT INTO tbl_srs(srs_id,description,projection_acronym,ellipsoid_acronym,parameters,srid,auth_name,auth_id,is_geo,deprecated) SELECT srs_id,description,projection_acronym,ellipsoid_acronym,parameters,srid,'','',is_geo,0 FROM tbl_srs_bak;"
2208 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2212 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2214 sqlite3_free( errmsg );
2220 res = sqlite3_exec( database.get(),
"SELECT acronym FROM tbl_projection LIMIT 0",
nullptr,
nullptr, &errmsg );
2221 if ( res != SQLITE_OK )
2223 sqlite3_free( errmsg );
2226 if ( sqlite3_exec( database.get(),
2227 "CREATE TABLE tbl_projection ("
2228 "acronym varchar(20) NOT NULL PRIMARY KEY,"
2229 "name varchar(255) NOT NULL default '',"
2230 "notes varchar(255) NOT NULL default '',"
2231 "parameters varchar(255) NOT NULL default ''"
2232 ")",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2236 *errorMessage = tr(
"Creation of missing tbl_projection in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2238 sqlite3_free( errmsg );
2243 res = sqlite3_exec( database.get(),
"SELECT epsg FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2244 if ( res == SQLITE_OK )
2247 if ( sqlite3_exec( database.get(),
2248 "DROP INDEX IF EXISTS idx_srsauthid;"
2249 "DROP TABLE IF EXISTS tbl_srs_bak;"
2250 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2251 "CREATE TABLE tbl_srs ("
2252 "srs_id INTEGER PRIMARY KEY,"
2253 "description text NOT NULL,"
2254 "projection_acronym text NOT NULL,"
2255 "ellipsoid_acronym NOT NULL,"
2256 "parameters text NOT NULL,"
2258 "auth_name varchar,"
2260 "is_geo integer NOT NULL,"
2261 "deprecated boolean,"
2263 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2264 "INSERT INTO tbl_srs(srs_id,description,projection_acronym,ellipsoid_acronym,parameters,srid,auth_name,auth_id,is_geo,deprecated) SELECT srs_id,description,projection_acronym,ellipsoid_acronym,parameters,srid,'','',is_geo,0 FROM tbl_srs_bak;"
2265 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2269 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2271 sqlite3_free( errmsg );
2277 sqlite3_free( errmsg );
2280 if ( sqlite3_exec( database.get(),
"DROP VIEW vw_srs",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2282 QgsDebugMsg( QStringLiteral(
"vw_srs didn't exists in private qgis.db: %1" ).arg( errmsg ) );
2285 if ( sqlite3_exec( database.get(),
2286 "CREATE VIEW vw_srs AS"
2288 " a.description AS description"
2289 ",a.srs_id AS srs_id"
2290 ",a.is_geo AS is_geo"
2291 ",coalesce(b.name,a.projection_acronym) AS name"
2292 ",a.parameters AS parameters"
2293 ",a.auth_name AS auth_name"
2294 ",a.auth_id AS auth_id"
2295 ",a.deprecated AS deprecated"
2297 " LEFT OUTER JOIN tbl_projection b ON a.projection_acronym=b.acronym"
2298 " ORDER BY coalesce(b.name,a.projection_acronym),a.description",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2302 *errorMessage = tr(
"Update of view in private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2304 sqlite3_free( errmsg );
2316 if ( maxThreads < 1 || maxThreads > QThread::idealThreadCount() )
2331 QThreadPool::globalInstance()->setMaxThreadCount(
maxThreads );
2332 QgsDebugMsgLevel( QStringLiteral(
"set QThreadPool max thread count to %1" ).arg( QThreadPool::globalInstance()->maxThreadCount() ), 2 );
2337 return members()->mTaskManager;
2342 return members()->mSettingsRegistryCore;
2347 return members()->mColorSchemeRegistry;
2352 return members()->mPaintEffectRegistry;
2357 return members()->mRendererRegistry;
2362 return members()->mRasterRendererRegistry;
2367 return members()->mPointCloudRendererRegistry;
2372 if (
auto *lInstance =
instance() )
2374 if ( !
instance()->mDataItemProviderRegistry )
2378 return lInstance->mDataItemProviderRegistry;
2384 if ( !sDataItemProviderRegistry )
2386 return sDataItemProviderRegistry;
2392 return members()->mCrsRegistry;
2397 return members()->mSvgCache;
2402 return members()->mImageCache;
2407 return members()->mSourceCache;
2412 return members()->mNetworkContentFetcherRegistry;
2417 return members()->mValidityCheckRegistry;
2422 return members()->mSymbolLayerRegistry;
2427 return members()->mCalloutRegistry;
2432 return members()->mLayoutItemRegistry;
2437 return members()->mAnnotationItemRegistry;
2442 return members()->mGpsConnectionRegistry;
2447 return members()->mGpsBabelFormatRegistry;
2452 return members()->mPluginLayerRegistry;
2457 return members()->mClassificationMethodRegistry;
2462 return members()->mBookmarkManager;
2467 return members()->mTileDownloadManager;
2472 return members()->mRecentStyleHandler;
2477 return members()->mQueryLogger;
2482 return members()->mStyleModel;
2487 return members()->mFontManager;
2492 return members()->mMessageLog;
2497 return members()->mProcessingRegistry;
2502 return members()->mConnectionRegistry;
2507 return members()->mLayerMetadataProviderRegistry;
2512 return members()->mPageSizeRegistry;
2517 return members()->mAnnotationRegistry;
2522 return members()->mNumericFormatRegistry;
2527 return members()->mFieldFormatterRegistry;
2532 return members()->m3DRendererRegistry;
2537 return members()->m3DSymbolRegistry;
2542 return members()->mScaleBarRendererRegistry;
2547 return members()->mProjectStorageRegistry;
2552 return members()->mExternalStorageRegistry;
2557 return members()->mLocalizedDataPathRegistry;
2560QgsApplication::ApplicationMembers::ApplicationMembers()
2570 profiler->
start( tr(
"Create query logger" ) );
2575 profiler->
start( tr(
"Setup coordinate reference system registry" ) );
2580 profiler->
start( tr(
"Create connection registry" ) );
2585 profiler->
start( tr(
"Create project storage registry" ) );
2590 profiler->
start( tr(
"Create metadata provider registry" ) );
2595 profiler->
start( tr(
"Create font manager" ) );
2600 profiler->
start( tr(
"Setup task manager" ) );
2605 profiler->
start( tr(
"Setup action scope registry" ) );
2610 profiler->
start( tr(
"Setup numeric formats" ) );
2615 profiler->
start( tr(
"Setup field formats" ) );
2620 profiler->
start( tr(
"Setup SVG cache" ) );
2625 profiler->
start( tr(
"Setup image cache" ) );
2630 profiler->
start( tr(
"Setup source cache" ) );
2635 profiler->
start( tr(
"Setup color scheme registry" ) );
2640 profiler->
start( tr(
"Setup paint effect" ) );
2645 profiler->
start( tr(
"Setup symbol layer registry" ) );
2650 profiler->
start( tr(
"Recent style handler" ) );
2655 profiler->
start( tr(
"Setup callout registry" ) );
2660 profiler->
start( tr(
"Setup renderer registry" ) );
2665 profiler->
start( tr(
"Setup raster renderer registry" ) );
2670 profiler->
start( tr(
"Setup point cloud renderer registry" ) );
2675 profiler->
start( tr(
"Setup GPS registry" ) );
2680 profiler->
start( tr(
"Setup GPSBabel format registry" ) );
2685 profiler->
start( tr(
"Setup plugin layer registry" ) );
2690 profiler->
start( tr(
"Setup Processing registry" ) );
2696 profiler->
start( tr(
"Setup layout item registry" ) );
2698 mLayoutItemRegistry->populate();
2702 profiler->
start( tr(
"Setup annotation registry" ) );
2703 mAnnotationRegistry =
new QgsAnnotationRegistry();
2707 profiler->
start( tr(
"Setup annotation item registry" ) );
2709 mAnnotationItemRegistry->populate();
2713 profiler->
start( tr(
"Setup 3D symbol registry" ) );
2718 profiler->
start( tr(
"Setup 3D renderer registry" ) );
2723 profiler->
start( tr(
"Setup project storage registry" ) );
2728 profiler->
start( tr(
"Setup layer metadata provider registry" ) );
2733 profiler->
start( tr(
"Setup external storage registry" ) );
2738 profiler->
start( tr(
"Setup network content cache" ) );
2743 profiler->
start( tr(
"Setup layout check registry" ) );
2748 profiler->
start( tr(
"Setup classification registry" ) );
2753 profiler->
start( tr(
"Setup bookmark manager" ) );
2758 profiler->
start( tr(
"Setup tile download manager" ) );
2763 profiler->
start( tr(
"Setup scalebar registry" ) );
2769QgsApplication::ApplicationMembers::~ApplicationMembers()
2772 delete mTileDownloadManager;
2773 delete mScaleBarRendererRegistry;
2774 delete mValidityCheckRegistry;
2775 delete mActionScopeRegistry;
2776 delete m3DRendererRegistry;
2777 delete m3DSymbolRegistry;
2778 delete mAnnotationRegistry;
2779 delete mColorSchemeRegistry;
2780 delete mFieldFormatterRegistry;
2781 delete mGpsConnectionRegistry;
2782 delete mGpsBabelFormatRegistry;
2784 delete mPaintEffectRegistry;
2785 delete mPluginLayerRegistry;
2786 delete mProcessingRegistry;
2787 delete mPageSizeRegistry;
2788 delete mAnnotationItemRegistry;
2789 delete mLayoutItemRegistry;
2790 delete mPointCloudRendererRegistry;
2791 delete mRasterRendererRegistry;
2792 delete mRendererRegistry;
2795 delete mSourceCache;
2796 delete mCalloutRegistry;
2797 delete mRecentStyleHandler;
2798 delete mSymbolLayerRegistry;
2799 delete mExternalStorageRegistry;
2800 delete mTaskManager;
2801 delete mNetworkContentFetcherRegistry;
2802 delete mClassificationMethodRegistry;
2803 delete mNumericFormatRegistry;
2804 delete mBookmarkManager;
2805 delete mConnectionRegistry;
2806 delete mProjectStorageRegistry;
2807 delete mLayerMetadataProviderRegistry;
2808 delete mFontManager;
2809 delete mLocalizedDataPathRegistry;
2810 delete mCrsRegistry;
2811 delete mQueryLogger;
2812 delete mSettingsRegistryCore;
2815QgsApplication::ApplicationMembers *QgsApplication::members()
2817 if (
auto *lInstance =
instance() )
2819 return lInstance->mApplicationMembers;
2823 static QRecursiveMutex sMemberMutex;
2824 QMutexLocker lock( &sMemberMutex );
2825 if ( !sApplicationMembers )
2826 sApplicationMembers =
new ApplicationMembers();
2827 return sApplicationMembers;
static const double UI_SCALE_FACTOR
UI scaling factor.
Keeps track of 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.
Extends QApplication to provide access to QGIS specific resources such as theme paths,...
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 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.
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 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 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()
This string is 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 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 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 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. Valid only when running from build directory.
static QString buildOutputPath()
Returns path to the build output directory. Valid only when running from build 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 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 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.
@ WebBrowser
StyleSheet for Qt GUI widgets (based on QLabel or QTextBrowser), supports basic CSS and Qt extensions...
static QString translatorsFilePath()
Returns the path to the sponsors file.
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)
This string is used to represent the value NULL throughout QGIS.
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...
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 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 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 QgsSettingsEntryBool settingsLocaleOverrideFlag
Settings entry locale override flag.
static const char * QGIS_ORGANIZATION_NAME
static QString contributorsFilePath()
Returns the path to the contributors file.
static const QgsSettingsEntryStringList settingsSearchPathsForSVG
Settings entry search path for SVG.
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 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 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 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.
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 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 setSkippedGdalDrivers(const QStringList &skippedGdalDrivers, const QStringList &deferredSkippedGdalDrivers)
Sets the list of gdal drivers that should be disabled (skippedGdalDrivers), but excludes for now the ...
static QgsRendererRegistry * rendererRegistry()
Returns the application's renderer registry, used for managing vector layer renderers.
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 QString developersMapFilePath()
Returns the path to the developers map file.
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()
This string is used to represent the value NULL throughout QGIS.
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 Qgs3DRendererRegistry * renderer3DRegistry()
Returns registry of available 3D renderers.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
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 QString userFullName()
Returns the user's operating system login account full display name.
static 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 QString userLoginName()
Returns the user's operating system login account name.
static const QgsSettingsEntryString settingsLocaleUserLocale
Settings entry locale user locale.
Singleton offering an interface to manage the authentication configuration database and to utilize co...
bool init(const QString &pluginPath=QString(), const QString &authDatabasePath=QString())
init initialize QCA, prioritize qca-ossl plugin and optionally set up the authentication database
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.
This class manages all known classification methods.
Registry of color schemes.
void addDefaultSchemes()
Adds all default color schemes to this color 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.
This class keeps a list of 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.
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.
A class to register / unregister existing GPS connections such that the information is available to a...
A cache for images derived from raster files.
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,...
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.
A registry of plugin layers types.
Registry of 2D renderers for point clouds.
Registry for various processing components, including providers, algorithms and various parameters an...
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.
The QgsReadWriteLocker class is a convenience class that simplifies locking and unlocking QReadWriteL...
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...
void end(const QString &group="startup")
End the current profile event.
void start(const QString &name, const QString &group="startup")
Start a profile event with the given name.
The QgsScaleBarRendererRegistry manages registered scalebar renderers.
Scoped object for logging of the runtime for a single operation or group of operations.
bool setValue(const T &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
QgsSettingsRegistryCore is used for settings introspection and collects all QgsSettingsEntry instance...
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
bool contains(const QString &key, QgsSettings::Section section=QgsSettings::NoSection) const
Returns true if there exists a setting called key; returns false otherwise.
void beginGroup(const QString &prefix, QgsSettings::Section section=QgsSettings::NoSection)
Appends prefix to the current group.
QStringList childKeys() const
Returns a list of all top-level keys that can be read using the QSettings object.
void remove(const QString &key, QgsSettings::Section section=QgsSettings::NoSection)
Removes the setting key and any sub-settings of key in a section.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
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 ...
static void cleanDefaultStyle()
Deletes the default style. Only to be used by QgsApplication::exitQgis()
static QgsStyle * defaultStyle()
Returns 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.
Registry of available symbol layer classes.
static QColor decodeColor(const QString &str)
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.
Used for the collecting of strings from projects for translation and creation of ts files.
User profile manager is used to manager list, and manage user profiles on the users machine.
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.
User profile contains information about the user profile folders on the machine.
const QString folder() const
The base folder for the user profile.
This class keeps a list of QgsAbstractValidityCheck checks which can be used when performing validity...
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.
CORE_EXPORT const QStringList files(const QString &zip)
Returns the list of files within a zip file.
QMap< QString, QString > QgsStringMap
QObject * ABISYM(QgsApplication::mFileOpenEventReceiver)
#define CONN_POOL_MAX_CONCURRENT_CONNS
Q_GLOBAL_STATIC_WITH_ARGS(PalPropertyList, palHiddenProperties,({ QgsPalLayerSettings::PositionX, QgsPalLayerSettings::PositionY, QgsPalLayerSettings::Show, QgsPalLayerSettings::LabelRotation, QgsPalLayerSettings::Family, QgsPalLayerSettings::FontStyle, QgsPalLayerSettings::Size, QgsPalLayerSettings::Bold, QgsPalLayerSettings::Italic, QgsPalLayerSettings::Underline, QgsPalLayerSettings::Color, QgsPalLayerSettings::Strikeout, QgsPalLayerSettings::MultiLineAlignment, QgsPalLayerSettings::BufferSize, QgsPalLayerSettings::BufferDraw, QgsPalLayerSettings::BufferColor, QgsPalLayerSettings::LabelDistance, QgsPalLayerSettings::Hali, QgsPalLayerSettings::Vali, QgsPalLayerSettings::ScaleVisibility, QgsPalLayerSettings::MinScale, QgsPalLayerSettings::MaxScale, QgsPalLayerSettings::AlwaysShow, QgsPalLayerSettings::CalloutDraw, QgsPalLayerSettings::LabelAllParts })) Q_GLOBAL_STATIC_WITH_ARGS(SymbolPropertyList
Q_GLOBAL_STATIC(QReadWriteLock, sDefinitionCacheLock)
#define QgsDebugMsgLevel(str, level)