100#include <QFileOpenEvent>
101#include <QMessageBox>
104#include <QProcessEnvironment>
107#include <QThreadPool>
110#include <QLibraryInfo>
111#include <QStandardPaths>
112#include <QRegularExpression>
113#include <QTextStream>
115#include <QAuthenticator>
116#include <QRecursiveMutex>
129#include <netinet/in.h>
135#define SECURITY_WIN32
138#pragma comment( lib, "Secur32.lib" )
142#include "qgsconfig.h"
152#if defined(Q_OS_LINUX)
153#include <sys/sysinfo.h>
156#define CONN_POOL_MAX_CONCURRENT_CONNS 4
158QObject *
ABISYM( QgsApplication::mFileOpenEventReceiver ) =
nullptr;
159bool ABISYM( QgsApplication::mInitialized ) =
false;
160bool ABISYM( QgsApplication::mRunningFromBuildDir ) =
false;
164QgsApplication::ApplicationMembers *QgsApplication::sApplicationMembers =
nullptr;
166int ABISYM( QgsApplication::sMaxThreads ) = -1;
183#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
200 : QApplication( argc, argv, GUIenabled )
202 *sPlatformName() = platformName;
204 if ( *sTranslation() != QLatin1String(
"C" ) )
206 mQgisTranslator =
new QTranslator();
207 if ( mQgisTranslator->load( QStringLiteral(
"qgis_" ) + *sTranslation(), i18nPath() ) )
209 installTranslator( mQgisTranslator );
213 QgsDebugMsgLevel( QStringLiteral(
"loading of qgis translation failed %1/qgis_%2" ).arg( i18nPath(), *sTranslation() ), 2 );
221 QString qtTranslationsPath = QLibraryInfo::location( QLibraryInfo::TranslationsPath );
223 QString prefix = QDir( QString(
"%1/../" ).arg( QApplication::applicationDirPath() ) ).absolutePath();
224 qtTranslationsPath = prefix + qtTranslationsPath.mid( QLibraryInfo::location( QLibraryInfo::PrefixPath ).length() );
227 mQtTranslator =
new QTranslator();
228 if ( mQtTranslator->load( QStringLiteral(
"qt_" ) + *sTranslation(), qtTranslationsPath ) )
230 installTranslator( mQtTranslator );
234 QgsDebugMsgLevel( QStringLiteral(
"loading of qt translation failed %1/qt_%2" ).arg( qtTranslationsPath, *sTranslation() ), 2 );
237 mQtBaseTranslator =
new QTranslator();
238 if ( mQtBaseTranslator->load( QStringLiteral(
"qtbase_" ) + *sTranslation(), qtTranslationsPath ) )
240 installTranslator( mQtBaseTranslator );
244 QgsDebugMsgLevel( QStringLiteral(
"loading of qtbase translation failed %1/qt_%2" ).arg( qtTranslationsPath, *sTranslation() ), 2 );
248 mApplicationMembers =
new ApplicationMembers();
250 *sProfilePath() = profileFolder;
257 if ( profileFolder.isEmpty() )
259 if ( getenv(
"QGIS_CUSTOM_CONFIG_PATH" ) )
261 profileFolder = getenv(
"QGIS_CUSTOM_CONFIG_PATH" );
265 profileFolder = QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ).value( 0 );
272 profileFolder = profile->
folder();
276 *sProfilePath() = profileFolder;
278 static std::once_flag sMetaTypesRegistered;
279 std::call_once( sMetaTypesRegistered, []
281 qRegisterMetaType<QgsGeometry::Error>(
"QgsGeometry::Error" );
282 qRegisterMetaType<QgsDatabaseQueryLogEntry>(
"QgsDatabaseQueryLogEntry" );
283 qRegisterMetaType<QgsProcessingFeatureSourceDefinition>(
"QgsProcessingFeatureSourceDefinition" );
284 qRegisterMetaType<QgsProcessingOutputLayerDefinition>(
"QgsProcessingOutputLayerDefinition" );
285 qRegisterMetaType<QgsUnitTypes::LayoutUnit>(
"QgsUnitTypes::LayoutUnit" );
286 qRegisterMetaType<QgsUnsetAttributeValue>(
"QgsUnsetAttributeValue" );
287 qRegisterMetaType<QgsFeatureId>(
"QgsFeatureId" );
288 qRegisterMetaType<QgsFields>(
"QgsFields" );
289 qRegisterMetaType<QgsFeatureIds>(
"QgsFeatureIds" );
290 qRegisterMetaType<QgsProperty>(
"QgsProperty" );
291 qRegisterMetaType<QgsFeatureStoreList>(
"QgsFeatureStoreList" );
292 qRegisterMetaType<Qgis::MessageLevel>(
"Qgis::MessageLevel" );
293 qRegisterMetaType<Qgis::BrowserItemState>(
"Qgis::BrowserItemState" );
294 qRegisterMetaType<Qgis::GpsFixStatus>(
"Qgis::GpsFixStatus" );
295 qRegisterMetaType<QgsReferencedRectangle>(
"QgsReferencedRectangle" );
296 qRegisterMetaType<QgsReferencedPointXY>(
"QgsReferencedPointXY" );
297 qRegisterMetaType<QgsReferencedGeometry>(
"QgsReferencedGeometry" );
298 qRegisterMetaType<QgsLayoutRenderContext::Flags>(
"QgsLayoutRenderContext::Flags" );
299 qRegisterMetaType<QgsStyle::StyleEntity>(
"QgsStyle::StyleEntity" );
300 qRegisterMetaType<QgsCoordinateReferenceSystem>(
"QgsCoordinateReferenceSystem" );
301 qRegisterMetaType<QgsAuthManager::MessageLevel>(
"QgsAuthManager::MessageLevel" );
302 qRegisterMetaType<QgsNetworkRequestParameters>(
"QgsNetworkRequestParameters" );
303 qRegisterMetaType<QgsNetworkReplyContent>(
"QgsNetworkReplyContent" );
304 qRegisterMetaType<QgsFeature>(
"QgsFeature" );
305 qRegisterMetaType<QgsGeometry>(
"QgsGeometry" );
306 qRegisterMetaType<QgsInterval>(
"QgsInterval" );
307 qRegisterMetaType<QgsRectangle>(
"QgsRectangle" );
308 qRegisterMetaType<QgsPointXY>(
"QgsPointXY" );
309 qRegisterMetaType<QgsPoint>(
"QgsPoint" );
310 qRegisterMetaType<QgsDatumTransform::GridDetails>(
"QgsDatumTransform::GridDetails" );
311 qRegisterMetaType<QgsDatumTransform::TransformDetails>(
"QgsDatumTransform::TransformDetails" );
312 qRegisterMetaType<QgsNewsFeedParser::Entry>(
"QgsNewsFeedParser::Entry" );
313 qRegisterMetaType<QgsRectangle>(
"QgsRectangle" );
314 qRegisterMetaType<QgsLocatorResult>(
"QgsLocatorResult" );
315 qRegisterMetaType<QgsGradientColorRamp>(
"QgsGradientColorRamp" );
316 qRegisterMetaType<QgsProcessingModelChildParameterSource>(
"QgsProcessingModelChildParameterSource" );
317#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
320 qRegisterMetaTypeStreamOperators<QgsProcessingModelChildParameterSource>(
"QgsProcessingModelChildParameterSource" );
322 qRegisterMetaType<QgsRemappingSinkDefinition>(
"QgsRemappingSinkDefinition" );
323 qRegisterMetaType<QgsProcessingModelChildDependency>(
"QgsProcessingModelChildDependency" );
324 qRegisterMetaType<QgsTextFormat>(
"QgsTextFormat" );
325#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
326 QMetaType::registerComparators<QgsProcessingModelChildDependency>();
327 QMetaType::registerEqualsComparator<QgsProcessingFeatureSourceDefinition>();
328 QMetaType::registerEqualsComparator<QgsProperty>();
329 QMetaType::registerEqualsComparator<QgsDateTimeRange>();
330 QMetaType::registerEqualsComparator<QgsDateRange>();
331 QMetaType::registerEqualsComparator<QgsUnsetAttributeValue>();
333 qRegisterMetaType<QPainter::CompositionMode>(
"QPainter::CompositionMode" );
334 qRegisterMetaType<QgsDateTimeRange>(
"QgsDateTimeRange" );
335 qRegisterMetaType<QList<QgsMapLayer *>>(
"QList<QgsMapLayer*>" );
336 qRegisterMetaType<QMap<QNetworkRequest::Attribute, QVariant>>(
"QMap<QNetworkRequest::Attribute,QVariant>" );
337 qRegisterMetaType<QMap<QNetworkRequest::KnownHeaders, QVariant>>(
"QMap<QNetworkRequest::KnownHeaders,QVariant>" );
338 qRegisterMetaType<QList<QNetworkReply::RawHeaderPair>>(
"QList<QNetworkReply::RawHeaderPair>" );
339 qRegisterMetaType< QAuthenticator * >(
"QAuthenticator*" );
340 qRegisterMetaType< QgsGpsInformation >(
"QgsGpsInformation" );
345 if ( ABISYM( mRunningFromBuildDir ) )
348 *sPrefixPath() = QString();
349#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
350 setPluginPath( *sBuildOutputPath() +
'/' + QString( QGIS_PLUGIN_SUBDIR ) +
'/' + *sCfgIntDir() );
352 setPluginPath( *sBuildOutputPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
354 setPkgDataPath( *sBuildOutputPath() + QStringLiteral(
"/data" ) );
355 *sLibraryPath() = *sBuildOutputPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
356#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
357 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/' + *sCfgIntDir() +
'/';
359 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
361#if defined( HAVE_QUICK )
362 *sQmlImportPath() = *sBuildOutputPath() +
'/' + QGIS_QML_SUBDIR +
'/';
367 char *
prefixPath = getenv(
"QGIS_PREFIX_PATH" );
370 if ( sPrefixPath()->isNull() )
372#if defined(Q_OS_MACX) || defined(Q_OS_WIN)
374#elif defined(ANDROID)
376 QDir myDir( QDir::homePath() );
378 QString myPrefix = myDir.absolutePath();
381 QDir myDir( applicationDirPath() );
383 if ( applicationDirPath().contains( QStringLiteral(
"cgi-bin" ) ) )
388 QString myPrefix = myDir.absolutePath();
399 *sConfigPath() = profileFolder +
'/';
403 if ( getenv(
"QGIS_AUTH_DB_DIR_PATH" ) )
409 qputenv(
"QT3D_RENDERER",
"opengl" );
412 QMap<QString, QString> systemEnvVarMap;
413 QString passfile( QStringLiteral(
"QGIS_AUTH_PASSWORD_FILE" ) );
415 const auto systemEnvironment = QProcessEnvironment::systemEnvironment().toStringList();
416 for (
const QString &varStr : systemEnvironment )
418 int pos = varStr.indexOf( QLatin1Char(
'=' ) );
421 QString varStrName = varStr.left( pos );
422 QString varStrValue = varStr.mid( pos + 1 );
423 if ( varStrName != passfile )
425 systemEnvVarMap.insert( varStrName, varStrValue );
428 *sSystemEnvVars() = systemEnvVarMap;
435 QString projLib( QDir::cleanPath(
pkgDataPath().append(
"/proj" ) ) );
436 if ( QFile::exists( projLib ) )
438 currentProjSearchPaths.append( projLib );
442 char **newPaths =
new char *[currentProjSearchPaths.length()];
443 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
445 newPaths[i] = CPLStrdup( currentProjSearchPaths.at( i ).toUtf8().constData() );
447 proj_context_set_search_paths(
nullptr, currentProjSearchPaths.count(), newPaths );
448 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
450 CPLFree( newPaths[i] );
455 QCoreApplication::addLibraryPath(
pluginPath() );
465 ABISYM( sMaxThreads ) = -1;
480 if ( !members()->mStyleModel )
483 ABISYM( mInitialized ) =
true;
488 delete mDataItemProviderRegistry;
489 delete mApplicationMembers;
490 delete mQgisTranslator;
491 delete mQtTranslator;
492 delete mQtBaseTranslator;
500void QgsApplication::invalidateCaches()
512 return qobject_cast<QgsApplication *>( QCoreApplication::instance() );
518 if (
event->type() == QEvent::FileOpen )
521 if ( ABISYM( mFileOpenEventReceiver ) )
524 done =
notify( ABISYM( mFileOpenEventReceiver ),
event );
531 sFileOpenEventList()->append(
static_cast<QFileOpenEvent *
>(
event )->file() );
538 done = QApplication::event(
event );
547 if ( thread() == receiver->thread() )
557 done = QApplication::notify( receiver,
event );
561 qCritical() <<
"Caught unhandled QgsException: " << e.
what();
562 if ( qApp->thread() == QThread::currentThread() )
563 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
565 catch ( std::exception &e )
567 qCritical() <<
"Caught unhandled std::exception: " << e.
what();
568 if ( qApp->thread() == QThread::currentThread() )
569 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
573 qCritical() <<
"Caught unhandled unknown exception";
574 if ( qApp->thread() == QThread::currentThread() )
575 QMessageBox::critical( activeWindow(), tr(
"Exception" ), tr(
"unknown exception" ) );
583 return QgsRuntimeProfiler::threadLocalInstance();
589 ABISYM( mFileOpenEventReceiver ) = receiver;
591 if ( sFileOpenEventList()->count() > 0 )
593 const QStringList fileOpenEventList = *sFileOpenEventList();
594 for (
const QString &file : fileOpenEventList )
596 QFileOpenEvent foe( file );
597 QgsApplication::sendEvent( ABISYM( mFileOpenEventReceiver ), &foe );
599 sFileOpenEventList()->clear();
607 if ( sPrefixPath()->endsWith(
"/bin" ) )
609 sPrefixPath()->chop( 4 );
612 if ( useDefaultPaths && !ABISYM( mRunningFromBuildDir ) )
614 setPluginPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
615 setPkgDataPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_DATA_SUBDIR ) );
617 *sLibraryPath() = *sPrefixPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
618 *sLibexecPath() = *sPrefixPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
619#if defined( HAVE_QUICK )
620 *sQmlImportPath() = *sPrefixPath() +
'/' + QGIS_QML_SUBDIR +
'/';
633 QString mySvgPath =
pkgDataPath + QStringLiteral(
"/svg/" );
636 if ( !sDefaultSvgPaths()->contains( mySvgPath ) )
637 *sDefaultSvgPaths() << mySvgPath;
642 *sDefaultSvgPaths() = pathList;
647 QFileInfo fi( authDbDirPath );
648 if ( fi.exists() && fi.isDir() && fi.isWritable() )
650 *sAuthDbDirPath() = fi.canonicalFilePath() + QDir::separator();
657 if ( ABISYM( mRunningFromBuildDir ) )
659 static bool sOnce =
true;
663 ( void ) blockNotifications;
664 qWarning(
"!!! prefix path was requested, but it is not valid - we do not run from installed path !!!" );
670 return *sPrefixPath();
674 return *sPluginPath();
679 if ( sPkgDataPath()->isNull() )
682 return *sPkgDataPath();
687 return QStringLiteral(
":/images/themes/default/" );
692 QDir dir( usersThemes );
700 return defaultThemes;
706 return iconsPath() + QStringLiteral(
"qgis-icon-60x60.png" );
711 return ABISYM( sMaxThreads );
718 if ( QFile::exists( path + iconFile ) )
719 return path + iconFile;
727 const QString cacheKey = ( name.startsWith(
'/' ) ? name.mid( 1 ) : name )
728 + ( fillColor.isValid() ? QStringLiteral(
"_%1" ).arg( fillColor.name( QColor::HexArgb ).mid( 1 ) ) : QString() )
729 + ( strokeColor.isValid() ? QStringLiteral(
"_%1" ).arg( strokeColor.name( QColor::HexArgb ).mid( 1 ) ) : QString() );
731 if ( app && app->mIconCache.contains( cacheKey ) )
732 return app->mIconCache.value( cacheKey );
735 const bool colorBased = fillColor.isValid() || strokeColor.isValid();
737 auto iconFromColoredSvg = [ = ](
const QString & path ) -> QIcon
742 const QString
iconPath = sIconCacheDir()->filePath( cacheKey + QStringLiteral(
".svg" ) );
744 if ( f.open( QFile::WriteOnly | QFile::Truncate ) )
746 f.write( svgContent );
751 QgsDebugMsg( QStringLiteral(
"Could not create colorized icon svg at %1" ).arg(
iconPath ) );
755 return QIcon( f.fileName() );
760 if ( QFile::exists( preferredPath ) )
764 icon = iconFromColoredSvg( preferredPath );
768 icon = QIcon( preferredPath );
771 else if ( QFile::exists( defaultPath ) )
777 icon = iconFromColoredSvg( defaultPath );
781 icon = QIcon( defaultPath );
790 app->mIconCache.insert( cacheKey, icon );
797 if ( app && app->mCursorCache.contains( cursor ) )
798 return app->mCursorCache.value( cursor );
809 name = QStringLiteral(
"mZoomIn.svg" );
814 name = QStringLiteral(
"mZoomOut.svg" );
821 name = QStringLiteral(
"mIdentify.svg" );
824 name = QStringLiteral(
"mCrossHair.svg" );
827 name = QStringLiteral(
"mCapturePoint.svg" );
830 name = QStringLiteral(
"mSelect.svg" );
837 name = QStringLiteral(
"mSampler.svg" );
842 Q_ASSERT( ! name.isEmpty( ) );
844 QIcon icon =
getThemeIcon( QStringLiteral(
"cursors" ) + QDir::separator() + name );
847 if ( ! icon.isNull( ) )
851 cursorIcon = QCursor( icon.pixmap( std::ceil( scale * 32 ), std::ceil( scale * 32 ) ), std::ceil( scale * activeX ), std::ceil( scale * activeY ) );
854 app->mCursorCache.insert( cursor, cursorIcon );
861 const QString preferredPath =
activeThemePath() + QDir::separator() + name;
863 const QString path = QFile::exists( preferredPath ) ? preferredPath : defaultPath;
864 if ( foreColor.isValid() || backColor.isValid() )
866 bool fitsInCache =
false;
867 const QImage image =
svgCache()->
svgAsImage( path, size, backColor, foreColor, 1, 1, fitsInCache );
868 return QPixmap::fromImage( image );
871 return QPixmap( path );
881 static QString appPath;
882 if ( appPath.isNull() )
884 if ( QCoreApplication::instance() )
886 appPath = applicationDirPath();
890 qWarning(
"Application path not initialized" );
894 if ( !appPath.isNull() || getenv(
"QGIS_PREFIX_PATH" ) )
896 QString prefix = getenv(
"QGIS_PREFIX_PATH" ) ? getenv(
"QGIS_PREFIX_PATH" ) : appPath;
901 static const QStringList paths { QStringList() << QString() << QStringLiteral(
"/.." ) << QStringLiteral(
"/bin" ) << QStringLiteral(
"/../../.." ) };
902 for (
const QString &path : paths )
904 f.setFileName( prefix + path +
"/qgisbuildpath.txt" );
908 if ( f.exists() && f.open( QIODevice::ReadOnly ) )
910 ABISYM( mRunningFromBuildDir ) =
true;
911 *sBuildSourcePath() = f.readLine().trimmed();
912 *sBuildOutputPath() = f.readLine().trimmed();
914 QgsDebugMsgLevel( QStringLiteral(
"- source directory: %1" ).arg( sBuildSourcePath()->toUtf8().constData() ), 4 );
915 QgsDebugMsgLevel( QStringLiteral(
"- output directory of the build: %1" ).arg( sBuildOutputPath()->toUtf8().constData() ), 4 );
916#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
917#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
918 *sCfgIntDir() = prefix.split(
'/', QString::SkipEmptyParts ).last();
920 *sCfgIntDir() = prefix.split(
'/', Qt::SkipEmptyParts ).last();
922 qDebug(
"- cfg: %s", sCfgIntDir()->toUtf8().constData() );
928 if ( getenv(
"QGIS_PREFIX_PATH" ) )
934 QDir dir( QDir::homePath() );
939#if defined(Q_OS_MACX)
941#elif defined(Q_OS_WIN)
948 if ( appPath.contains( QStringLiteral(
"cgi-bin" ) ) )
958 if ( ABISYM( mRunningFromBuildDir ) )
959 return *sBuildOutputPath() + QStringLiteral(
"/data" );
961 return prefixPath +
'/' + QStringLiteral( QGIS_DATA_SUBDIR );
966 return *sThemeName();
976 qApp->setStyleSheet( QString() );
980 QString path = themes.value(
themeName );
981 QString stylesheetname = path +
"/style.qss";
983 QFile file( stylesheetname );
984 QFile variablesfile( path +
"/variables.qss" );
986 QFileInfo variableInfo( variablesfile );
988 if ( !file.open( QIODevice::ReadOnly ) || ( variableInfo.exists() && !variablesfile.open( QIODevice::ReadOnly ) ) )
993 QString styledata = file.readAll();
994 styledata.replace( QLatin1String(
"@theme_path" ), path );
996 if ( variableInfo.exists() )
998 QTextStream in( &variablesfile );
999 while ( !in.atEnd() )
1001 QString line = in.readLine();
1003 if ( line.startsWith(
'@' ) )
1005 int index = line.indexOf(
':' );
1006 QString name = line.mid( 0, index );
1007 QString value = line.mid( index + 1, line.length() );
1008 styledata.replace( name, value );
1011 variablesfile.close();
1019 const static QRegularExpression regex( QStringLiteral(
"(?<=[\\s:])([0-9\\.]+)(?=em)" ) );
1020 QRegularExpressionMatch match = regex.match( styledata, index );
1021 while ( match.hasMatch() )
1023 index = match.capturedStart();
1024 styledata.remove( index, match.captured( 0 ).length() );
1026 styledata.insert( index, number );
1027 index += number.length();
1028 match = regex.match( styledata, index );
1032 qApp->setStyleSheet( styledata );
1034 QFile palettefile( path +
"/palette.txt" );
1035 QFileInfo paletteInfo( palettefile );
1036 if ( paletteInfo.exists() && palettefile.open( QIODevice::ReadOnly ) )
1038 QPalette
pal = qApp->palette();
1039 QTextStream in( &palettefile );
1040 while ( !in.atEnd() )
1042 QString line = in.readLine();
1043 QStringList parts = line.split(
':' );
1044 if ( parts.count() == 2 )
1046 int role = parts.at( 0 ).trimmed().toInt();
1048 pal.setColor(
static_cast< QPalette::ColorRole
>( role ), color );
1051 palettefile.close();
1052 qApp->setPalette(
pal );
1061 QHash<QString, QString> mapping;
1062 mapping.insert( QStringLiteral(
"default" ), QString() );
1063 const auto constPaths = paths;
1064 for (
const QString &path : constPaths )
1066 QDir folder( path );
1067 QFileInfoList styleFiles = folder.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
1068 const auto constStyleFiles = styleFiles;
1069 for (
const QFileInfo &info : constStyleFiles )
1071 QFileInfo styleFile( info.absoluteFilePath() +
"/style.qss" );
1072 if ( !styleFile.exists() )
1075 QString name = info.baseName();
1076 QString path = info.absoluteFilePath();
1077 mapping.insert( name, path );
1085 return pkgDataPath() + QStringLiteral(
"/doc/AUTHORS" );
1090 return pkgDataPath() + QStringLiteral(
"/doc/CONTRIBUTORS" );
1094 return pkgDataPath() + QStringLiteral(
"/doc/developersmap.html" );
1099 return pkgDataPath() + QStringLiteral(
"/doc/SPONSORS" );
1104 return pkgDataPath() + QStringLiteral(
"/doc/DONORS" );
1109 return pkgDataPath() + QStringLiteral(
"/doc/TRANSLATORS" );
1114 return pkgDataPath() + QStringLiteral(
"/doc/LICENSE" );
1119 if ( ABISYM( mRunningFromBuildDir ) )
1120 return *sBuildOutputPath() + QStringLiteral(
"/i18n/" );
1122 return pkgDataPath() + QStringLiteral(
"/i18n/" );
1127 return pkgDataPath() + QStringLiteral(
"/resources/metadata-ISO/" );
1132 return pkgDataPath() + QStringLiteral(
"/resources/qgis.db" );
1137 return *sConfigPath();
1147 return *sAuthDbDirPath() + QStringLiteral(
"qgis-auth.db" );
1152 return QStringLiteral(
":/images/splash/" );
1157 return pkgDataPath() + QStringLiteral(
"/images/icons/" );
1162 if ( ABISYM( mRunningFromBuildDir ) )
1164 QString tempCopy = QDir::tempPath() +
"/srs6.db";
1166 if ( !QFile( tempCopy ).exists() )
1169 if ( !f.copy( tempCopy ) )
1171 qFatal(
"Could not create temporary copy" );
1179 return pkgDataPath() + QStringLiteral(
"/resources/srs.db" );
1186 members()->mSvgPathCacheValid =
false;
1191 static QReadWriteLock lock;
1195 if ( members()->mSvgPathCacheValid )
1197 return members()->mSvgPathCache;
1208 for (
const QString &path : pathList )
1210 if ( !paths.contains( path ) )
1211 paths.append( path );
1213 for (
const QString &path : std::as_const( *sDefaultSvgPaths() ) )
1215 if ( !paths.contains( path ) )
1216 paths.append( path );
1218 members()->mSvgPathCache = paths;
1233 return *sSystemEnvVars();
1243 const thread_local QRegularExpression regexp( QRegularExpression::anchoredPattern( QStringLiteral(
"^[A-Za-z][A-Za-z0-9\\._-]*" ) ) );
1249 if ( !sUserName()->isEmpty() )
1250 return *sUserName();
1253 TCHAR name [ UNLEN + 1 ];
1254 DWORD size = UNLEN + 1;
1256 if ( GetUserName( ( TCHAR * )name, &size ) )
1258#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
1259 *sUserName() = QString::fromLocal8Bit( name );
1261 *sUserName() = QString::fromWCharArray( name );
1266#elif QT_CONFIG(process)
1269 process.start( QStringLiteral(
"whoami" ), QStringList() );
1270 process.waitForFinished();
1271 *sUserName() = process.readAllStandardOutput().trimmed();
1274 if ( !sUserName()->isEmpty() )
1275 return *sUserName();
1278 *sUserName() = qgetenv(
"USER" );
1279 if ( !sUserName()->isEmpty() )
1280 return *sUserName();
1283 *sUserName() = qgetenv(
"USERNAME" );
1284 return *sUserName();
1289 if ( !sUserFullName()->isEmpty() )
1290 return *sUserFullName();
1293 TCHAR name [ UNLEN + 1 ];
1294 DWORD size = UNLEN + 1;
1297 if ( GetUserNameEx( NameDisplay, ( TCHAR * )name, &size ) )
1299#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
1300 *sUserFullName() = QString::fromLocal8Bit( name );
1302 *sUserFullName() = QString::fromWCharArray( name );
1307 if ( sUserFullName()->isEmpty() )
1309#elif defined(Q_OS_ANDROID) || defined(__MINGW32__)
1310 *sUserFullName() = QStringLiteral(
"Not available" );
1312 struct passwd *p = getpwuid( getuid() );
1316 QString gecosName = QString( p->pw_gecos );
1317 *sUserFullName() = gecosName.left( gecosName.indexOf(
',', 0 ) );
1322 return *sUserFullName();
1327#if defined(Q_OS_ANDROID)
1328 return QLatin1String(
"android" );
1329#elif defined(Q_OS_MAC)
1330 return QLatin1String(
"osx" );
1331#elif defined(Q_OS_WIN)
1332 return QLatin1String(
"windows" );
1333#elif defined(Q_OS_LINUX)
1334 return QStringLiteral(
"linux" );
1335#elif defined(Q_OS_FREEBSD)
1336 return QStringLiteral(
"freebsd" );
1337#elif defined(Q_OS_OPENBSD)
1338 return QStringLiteral(
"openbsd" );
1339#elif defined(Q_OS_NETBSD)
1340 return QStringLiteral(
"netbsd" );
1341#elif defined(Q_OS_UNIX)
1342 return QLatin1String(
"unix" );
1344 return QLatin1String(
"unknown" );
1350#if defined(Q_OS_ANDROID)
1352#elif defined(Q_OS_MAC)
1354#elif defined(Q_OS_WIN)
1355 MEMORYSTATUSEX memoryStatus;
1356 ZeroMemory( &memoryStatus,
sizeof( MEMORYSTATUSEX ) );
1357 memoryStatus.dwLength =
sizeof( MEMORYSTATUSEX );
1358 if ( GlobalMemoryStatusEx( &memoryStatus ) )
1360 return memoryStatus.ullTotalPhys / ( 1024 * 1024 );
1366#elif defined(Q_OS_LINUX)
1367 constexpr int megabyte = 1024 * 1024;
1370 return si.totalram / megabyte;
1371#elif defined(Q_OS_FREEBSD)
1373#elif defined(Q_OS_OPENBSD)
1375#elif defined(Q_OS_NETBSD)
1377#elif defined(Q_OS_UNIX)
1386 return *sPlatformName();
1391 if ( !sApplicationFullName()->isEmpty() )
1392 return *sApplicationFullName();
1395 *sApplicationFullName() = qgetenv(
"QGIS_APPLICATION_FULL_NAME" );
1396 if ( !sApplicationFullName()->isEmpty() )
1397 return *sApplicationFullName();
1401 *sApplicationFullName() = settings.
value(
1402 QStringLiteral(
"/qgis/application_full_name" ),
1403 QStringLiteral(
"%1 %2" ).arg( applicationName(),
platform() )
1405 return *sApplicationFullName();
1414 if (
locale.startsWith( QLatin1String(
"en" ), Qt::CaseInsensitive ) )
1423 return QLocale().name().left( 2 );
1429 QLocale::setDefault(
locale );
1440 return pkgDataPath() + QStringLiteral(
"/resources/symbology-style.xml" );
1445 return pkgDataPath() + QStringLiteral(
"/resources/themes" );
1450 return pkgDataPath() + QStringLiteral(
"/resources/server/" );
1455 return *sLibraryPath();
1460 return *sLibexecPath();
1465 return *sQmlImportPath();
1470 return ( htonl( 1 ) == 1 ) ?
XDR :
NDR;
1477 init( *sProfilePath() );
1502 if (
auto *lInstance =
instance() )
1504 if ( !lInstance->mAuthManager )
1508 return lInstance->mAuthManager;
1513 if ( !sAuthManager )
1515 return sAuthManager;
1523 QThreadPool::globalInstance()->waitForDone();
1526 if (
auto *lInstance =
instance() )
1527 delete lInstance->mAuthManager;
1529 delete sAuthManager;
1532 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1538 if ( QgsProject::sProject )
1546 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1549 if ( QgsProviderRegistry::exists() )
1558 GDALDestroyDriverManager();
1563 QString myEnvironmentVar( getenv(
"QGIS_PREFIX_PATH" ) );
1564 QString myState = tr(
"Application state:\n"
1565 "QGIS_PREFIX_PATH env var:\t\t%1\n"
1567 "Plugin Path:\t\t%3\n"
1568 "Package Data Path:\t%4\n"
1569 "Active Theme Name:\t%5\n"
1570 "Active Theme Path:\t%6\n"
1571 "Default Theme Path:\t%7\n"
1572 "SVG Search Paths:\t%8\n"
1573 "User DB Path:\t%9\n"
1574 "Auth DB Path:\t%10\n" )
1575 .arg( myEnvironmentVar,
1582 svgPaths().join( tr(
"\n\t\t",
"match indentation of application state" ) ),
1595 QColor myColor1( Qt::lightGray );
1596 QColor myColor2 = myColor1;
1597 myColor2 = myColor2.lighter( 110 );
1599 myStyle = QStringLiteral(
".overview{"
1601 " font-weight: bold;"
1604 " background: white;"
1606 " font-family: 'Lato', 'Open Sans', 'Lucida Grande', 'Segoe UI', 'Arial', sans-serif;"
1609 "h1{ background-color: #F6F6F6;"
1611 " font-size: x-large; "
1612 " font-weight: normal;"
1613 " background: none;"
1614 " padding: 0.75em 0 0;"
1616 " line-height: 3em;"
1618 "h2{ background-color: #F6F6F6;"
1620 " font-size: medium; "
1621 " font-weight: normal;"
1622 " background: none;"
1623 " padding: 0.75em 0 0;"
1625 " line-height: 1.1em;"
1627 "h3{ background-color: #F6F6F6;"
1629 " font-weight: bold;"
1630 " font-size: large;"
1631 " text-align: left;"
1632 " border-bottom: 5px solid #DCEB5C;"
1634 "h4{ background-color: #F6F6F6;"
1636 " font-weight: bold;"
1637 " font-size: medium;"
1638 " text-align: left;"
1640 "h5{ background-color: #F6F6F6;"
1642 " font-weight: bold;"
1643 " font-size: small;"
1644 " text-align: left;"
1646 "a{ color: #729FCF;"
1647 " font-family: arial,sans-serif;"
1649 "label{ background-color: #FFFFCC;"
1650 " border: 1px solid black;"
1652 " padding: 0px 3px; "
1653 " font-size: small;"
1656 " font-weight: bold;"
1661 " border-top: 1px solid black;"
1663 ".list-view .highlight {"
1664 " text-align: left;"
1667 " padding-right: 15px;"
1668 " padding-left: 20px;"
1669 " font-weight: bold;"
1671 ".tabular-view .odd-row {"
1672 " background-color: #f9f9f9;"
1675 " font-weight: bold;"
1676 " padding-top:25px;"
1680 switch ( styleSheetType )
1682 case StyleSheetType::Qt:
1683 myStyle += QStringLiteral(
1685 " border-collapse: collapse;"
1688 ".tabular-view th, .tabular-view td { "
1689 " border:1px solid black;"
1693 case StyleSheetType::WebBrowser:
1694 myStyle += QStringLiteral(
1699 "table.tabular-view, table.list-view { "
1700 " border-collapse: collapse;"
1701 " table-layout:fixed;"
1702 " width: 100% !important;"
1707 " line-height: inherit;"
1710 " word-wrap: break-word; "
1711 " vertical-align: top;"
1714 ".list-view th:first-child, .list-view td:first-child {"
1717 ".list-view.highlight { "
1718 " padding-left: inherit; "
1721 ".tabular-view th:first-child, .tabular-view td:first-child { "
1725 ".tabular-view th.strong { "
1726 " background-color: #eee; "
1729 ".tabular-view th, .tabular-view td { "
1730 " border: 1px solid #eee;"
1741 if ( 0 >= OGRGetDriverCount() )
1749 QString aPathUrl = aPath;
1750 QString tPathUrl = targetPath;
1751#if defined( Q_OS_WIN )
1752 const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
1754 aPathUrl.replace(
'\\',
'/' );
1755 if ( aPathUrl.startsWith(
"//" ) )
1758 aPathUrl =
"\\\\" + aPathUrl.mid( 2 );
1761 tPathUrl.replace(
'\\',
'/' );
1762 if ( tPathUrl.startsWith(
"//" ) )
1765 tPathUrl =
"\\\\" + tPathUrl.mid( 2 );
1768 const Qt::CaseSensitivity cs = Qt::CaseSensitive;
1771#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
1772 QStringList targetElems = tPathUrl.split(
'/', QString::SkipEmptyParts );
1773 QStringList aPathElems = aPathUrl.split(
'/', QString::SkipEmptyParts );
1775 QStringList targetElems = tPathUrl.split(
'/', Qt::SkipEmptyParts );
1776 QStringList aPathElems = aPathUrl.split(
'/', Qt::SkipEmptyParts );
1779 targetElems.removeAll( QStringLiteral(
"." ) );
1780 aPathElems.removeAll( QStringLiteral(
"." ) );
1784 while ( !aPathElems.isEmpty() &&
1785 !targetElems.isEmpty() &&
1786 aPathElems[0].compare( targetElems[0], cs ) == 0 )
1788 aPathElems.removeFirst();
1789 targetElems.removeFirst();
1799 if ( !targetElems.isEmpty() )
1802 for (
int i = 0; i < targetElems.size(); i++ )
1804 aPathElems.insert( 0, QStringLiteral(
".." ) );
1811 aPathElems.insert( 0, QStringLiteral(
"." ) );
1814 return aPathElems.join( QLatin1Char(
'/' ) );
1820 if ( !rpath.startsWith( QLatin1String(
"./" ) ) && !rpath.startsWith( QLatin1String(
"../" ) ) )
1825 QString rPathUrl = rpath;
1826 QString targetPathUrl = targetPath;
1828#if defined(Q_OS_WIN)
1829 rPathUrl.replace(
'\\',
'/' );
1830 targetPathUrl.replace(
'\\',
'/' );
1832 bool uncPath = targetPathUrl.startsWith(
"//" );
1835#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
1836 QStringList srcElems = rPathUrl.split(
'/', QString::SkipEmptyParts );
1837 QStringList targetElems = targetPathUrl.split(
'/', QString::SkipEmptyParts );
1839 QStringList srcElems = rPathUrl.split(
'/', Qt::SkipEmptyParts );
1840 QStringList targetElems = targetPathUrl.split(
'/', Qt::SkipEmptyParts );
1843#if defined(Q_OS_WIN)
1846 targetElems.insert( 0,
"" );
1847 targetElems.insert( 0,
"" );
1852 targetElems << srcElems;
1853 targetElems.removeAll( QStringLiteral(
"." ) );
1857 while ( ( pos = targetElems.indexOf( QLatin1String(
".." ) ) ) > 0 )
1860 targetElems.removeAt( pos - 1 );
1861 targetElems.removeAt( pos - 1 );
1864#if !defined(Q_OS_WIN)
1866 targetElems.prepend( QString() );
1869 return targetElems.join( QLatin1Char(
'/' ) );
1874 return *sBuildSourcePath();
1879 return *sBuildOutputPath();
1882#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
1883QString QgsApplication::cfgIntDir()
1885 return *sCfgIntDir();
1891 if ( sGdalSkipList()->contains( driver ) || driver.isEmpty() )
1895 *sGdalSkipList() << driver;
1901 if ( !sGdalSkipList()->contains( driver ) )
1905 int myPos = sGdalSkipList()->indexOf( driver );
1908 sGdalSkipList()->removeAt( myPos );
1915 return *sGdalSkipList();
1919 const QStringList &deferredSkippedGdalDrivers )
1933 QString joinedList, delimiter;
1934 if ( settings.
contains( QStringLiteral(
"gdal/skipDrivers" ) ) )
1936 joinedList = settings.
value( QStringLiteral(
"gdal/skipDrivers" ), QString() ).toString();
1937 delimiter = QStringLiteral(
"," );
1941 joinedList = settings.
value( QStringLiteral(
"gdal/skipList" ), QString() ).toString();
1942 delimiter = QStringLiteral(
" " );
1945 if ( !joinedList.isEmpty() )
1947 myList = joinedList.split( delimiter );
1949 *sGdalSkipList() = myList;
1955 return *sDeferredSkippedGdalDrivers();
1960 sGdalSkipList()->removeDuplicates();
1961 QStringList realDisabledDriverList;
1962 for (
const auto &driverName : *sGdalSkipList() )
1964 if ( !sDeferredSkippedGdalDrivers()->contains( driverName ) )
1965 realDisabledDriverList << driverName;
1967 QString myDriverList = realDisabledDriverList.join(
',' );
1968 QgsDebugMsgLevel( QStringLiteral(
"Gdal Skipped driver list set to:" ), 2 );
1970 CPLSetConfigOption(
"GDAL_SKIP", myDriverList.toUtf8() );
1977 QDir myDir( folder );
1978 if ( !myDir.exists() )
1980 myDir.mkpath( folder );
1986void QgsApplication::copyPath(
const QString &src,
const QString &dst )
1989 if ( ! dir.exists() )
1992 const auto subDirectories = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot );
1993 for (
const QString &d : subDirectories )
1995 QString dst_path = dst + QDir::separator() + d;
1996 dir.mkpath( dst_path );
1997 copyPath( src + QDir::separator() + d, dst_path );
2000 const auto files = dir.entryList( QDir::Files );
2001 for (
const QString &f : files )
2003 QFile::copy( src + QDir::separator() + f, dst + QDir::separator() + f );
2012 QVariantMap variables;
2016 QStringList childKeys = settings.
childKeys();
2017 for ( QStringList::const_iterator it = childKeys.constBegin(); it != childKeys.constEnd(); ++it )
2020 variables.insert( name, settings.
value( name ) );
2030 QVariantMap::const_iterator it = variables.constBegin();
2033 for ( ; it != variables.constEnd(); ++it )
2035 settings.
setValue( it.key(), it.value() );
2046 settings.
setValue( QStringLiteral(
"variables/" ) + name, value );
2053 QFontMetrics fm( ( QFont() ) );
2054 const double scale = 1.1 * standardSize / 24;
2055 int scaledIconSize =
static_cast< int >( std::floor( std::max(
Qgis::UI_SCALE_FACTOR * fm.height() * scale,
static_cast< double >( standardSize ) ) ) );
2056 if ( applyDevicePixelRatio )
2058 if ( QWidget *activeWindow = QApplication::activeWindow() )
2059 scaledIconSize *= ( activeWindow->screen() ? QApplication::activeWindow()->screen()->devicePixelRatio() : 1 );
2061 return scaledIconSize;
2076 return *sTranslation();
2086 ApplicationMembers *appMembers = members();
2087 if ( appMembers->mNullRepresentation.isNull() )
2089 appMembers->mNullRepresentation =
QgsSettings().
value( QStringLiteral(
"qgis/nullValue" ), QStringLiteral(
"NULL" ) ).toString();
2091 return appMembers->mNullRepresentation;
2096 ApplicationMembers *appMembers = members();
2110 return members()->mActionScopeRegistry;
2119 QDir myDir( myPamPath );
2120 if ( !myDir.exists() )
2122 myDir.mkpath( myPamPath );
2125#if defined(Q_OS_WIN)
2126 CPLSetConfigOption(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() );
2130 int myChangeFlag = 0;
2131 setenv(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag );
2138 if ( !qgisPrivateDbFile.exists() )
2142 QFile masterFile( qgisMasterDbFileName );
2148 bool isDbFileCopied = masterFile.copy( qgisPrivateDbFile.fileName() );
2150 if ( !isDbFileCopied )
2154 *errorMessage = tr(
"[ERROR] Can not make qgis.db private copy" );
2159 QFile::Permissions perms = QFile( qgisPrivateDbFile.fileName() ).permissions();
2160 if ( !( perms & QFile::WriteOwner ) )
2162 if ( !qgisPrivateDbFile.setPermissions( perms | QFile::WriteOwner ) )
2166 *errorMessage = tr(
"Can not make '%1' user writable" ).arg( qgisPrivateDbFile.fileName() );
2180 *errorMessage = tr(
"Could not open qgis.db" );
2185 char *errmsg =
nullptr;
2186 int res = sqlite3_exec( database.get(),
"SELECT srs_id FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2187 if ( res != SQLITE_OK )
2189 sqlite3_free( errmsg );
2192 if ( sqlite3_exec( database.get(),
2193 "DROP INDEX IF EXISTS idx_srsauthid;"
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);",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2210 *errorMessage = tr(
"Creation of missing tbl_srs in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2212 sqlite3_free( errmsg );
2219 res = sqlite3_exec( database.get(),
"SELECT wkt FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2220 if ( res != SQLITE_OK )
2223 sqlite3_free( errmsg );
2224 if ( sqlite3_exec( database.get(),
2225 "DROP INDEX IF EXISTS idx_srsauthid;"
2226 "DROP TABLE IF EXISTS tbl_srs_bak;"
2227 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2228 "CREATE TABLE tbl_srs ("
2229 "srs_id INTEGER PRIMARY KEY,"
2230 "description text NOT NULL,"
2231 "projection_acronym text NOT NULL,"
2232 "ellipsoid_acronym NOT NULL,"
2233 "parameters text NOT NULL,"
2235 "auth_name varchar,"
2237 "is_geo integer NOT NULL,"
2238 "deprecated boolean,"
2240 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2241 "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;"
2242 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2246 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2248 sqlite3_free( errmsg );
2254 res = sqlite3_exec( database.get(),
"SELECT acronym FROM tbl_projection LIMIT 0",
nullptr,
nullptr, &errmsg );
2255 if ( res != SQLITE_OK )
2257 sqlite3_free( errmsg );
2260 if ( sqlite3_exec( database.get(),
2261 "CREATE TABLE tbl_projection ("
2262 "acronym varchar(20) NOT NULL PRIMARY KEY,"
2263 "name varchar(255) NOT NULL default '',"
2264 "notes varchar(255) NOT NULL default '',"
2265 "parameters varchar(255) NOT NULL default ''"
2266 ")",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2270 *errorMessage = tr(
"Creation of missing tbl_projection in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2272 sqlite3_free( errmsg );
2277 res = sqlite3_exec( database.get(),
"SELECT epsg FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2278 if ( res == SQLITE_OK )
2281 if ( sqlite3_exec( database.get(),
2282 "DROP INDEX IF EXISTS idx_srsauthid;"
2283 "DROP TABLE IF EXISTS tbl_srs_bak;"
2284 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2285 "CREATE TABLE tbl_srs ("
2286 "srs_id INTEGER PRIMARY KEY,"
2287 "description text NOT NULL,"
2288 "projection_acronym text NOT NULL,"
2289 "ellipsoid_acronym NOT NULL,"
2290 "parameters text NOT NULL,"
2292 "auth_name varchar,"
2294 "is_geo integer NOT NULL,"
2295 "deprecated boolean,"
2297 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2298 "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;"
2299 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2303 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2305 sqlite3_free( errmsg );
2311 sqlite3_free( errmsg );
2314 if ( sqlite3_exec( database.get(),
"DROP VIEW vw_srs",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2316 QgsDebugMsg( QStringLiteral(
"vw_srs didn't exists in private qgis.db: %1" ).arg( errmsg ) );
2319 if ( sqlite3_exec( database.get(),
2320 "CREATE VIEW vw_srs AS"
2322 " a.description AS description"
2323 ",a.srs_id AS srs_id"
2324 ",a.is_geo AS is_geo"
2325 ",coalesce(b.name,a.projection_acronym) AS name"
2326 ",a.parameters AS parameters"
2327 ",a.auth_name AS auth_name"
2328 ",a.auth_id AS auth_id"
2329 ",a.deprecated AS deprecated"
2331 " LEFT OUTER JOIN tbl_projection b ON a.projection_acronym=b.acronym"
2332 " ORDER BY coalesce(b.name,a.projection_acronym),a.description",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2336 *errorMessage = tr(
"Update of view in private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2338 sqlite3_free( errmsg );
2351 if ( maxThreads < 1 || maxThreads > QThread::idealThreadCount() )
2362 QThreadPool::globalInstance()->setMaxThreadCount(
maxThreads );
2363 QgsDebugMsgLevel( QStringLiteral(
"set QThreadPool max thread count to %1" ).arg( QThreadPool::globalInstance()->maxThreadCount() ), 2 );
2368 return members()->mTaskManager;
2373 return members()->mSettingsRegistryCore;
2378 return members()->mColorSchemeRegistry;
2383 return members()->mPaintEffectRegistry;
2388 return members()->mRendererRegistry;
2393 return members()->mRasterRendererRegistry;
2398 return members()->mPointCloudRendererRegistry;
2403 if (
auto *lInstance =
instance() )
2405 if ( !
instance()->mDataItemProviderRegistry )
2409 return lInstance->mDataItemProviderRegistry;
2415 if ( !sDataItemProviderRegistry )
2417 return sDataItemProviderRegistry;
2423 return members()->mCrsRegistry;
2428 return members()->mSvgCache;
2433 return members()->mImageCache;
2438 return members()->mSourceCache;
2443 return members()->mNetworkContentFetcherRegistry;
2448 return members()->mValidityCheckRegistry;
2453 return members()->mSymbolLayerRegistry;
2458 return members()->mCalloutRegistry;
2463 return members()->mLayoutItemRegistry;
2468 return members()->mAnnotationItemRegistry;
2473 return members()->mGpsConnectionRegistry;
2478 return members()->mGpsBabelFormatRegistry;
2483 return members()->mPluginLayerRegistry;
2488 return members()->mClassificationMethodRegistry;
2493 return members()->mBookmarkManager;
2498 return members()->mTileDownloadManager;
2503 return members()->mRecentStyleHandler;
2508 return members()->mQueryLogger;
2513 return members()->mStyleModel;
2518 return members()->mFontManager;
2523 return members()->mMessageLog;
2528 return members()->mProcessingRegistry;
2533 return members()->mConnectionRegistry;
2538 return members()->mLayerMetadataProviderRegistry;
2543 return members()->mPageSizeRegistry;
2548 return members()->mAnnotationRegistry;
2553 return members()->mNumericFormatRegistry;
2558 return members()->mFieldFormatterRegistry;
2563 return members()->m3DRendererRegistry;
2568 return members()->m3DSymbolRegistry;
2573 return members()->mScaleBarRendererRegistry;
2578 return members()->mProjectStorageRegistry;
2583 return members()->mExternalStorageRegistry;
2588 return members()->mLocalizedDataPathRegistry;
2591QgsApplication::ApplicationMembers::ApplicationMembers()
2601 profiler->
start( tr(
"Create query logger" ) );
2606 profiler->
start( tr(
"Setup coordinate reference system registry" ) );
2611 profiler->
start( tr(
"Create connection registry" ) );
2616 profiler->
start( tr(
"Create project storage registry" ) );
2621 profiler->
start( tr(
"Create metadata provider registry" ) );
2626 profiler->
start( tr(
"Create font manager" ) );
2631 profiler->
start( tr(
"Setup task manager" ) );
2636 profiler->
start( tr(
"Setup action scope registry" ) );
2641 profiler->
start( tr(
"Setup numeric formats" ) );
2646 profiler->
start( tr(
"Setup field formats" ) );
2651 profiler->
start( tr(
"Setup SVG cache" ) );
2656 profiler->
start( tr(
"Setup image cache" ) );
2661 profiler->
start( tr(
"Setup source cache" ) );
2666 profiler->
start( tr(
"Setup color scheme registry" ) );
2671 profiler->
start( tr(
"Setup paint effect" ) );
2676 profiler->
start( tr(
"Setup symbol layer registry" ) );
2681 profiler->
start( tr(
"Recent style handler" ) );
2686 profiler->
start( tr(
"Setup callout registry" ) );
2691 profiler->
start( tr(
"Setup renderer registry" ) );
2696 profiler->
start( tr(
"Setup raster renderer registry" ) );
2701 profiler->
start( tr(
"Setup point cloud renderer registry" ) );
2706 profiler->
start( tr(
"Setup GPS registry" ) );
2711 profiler->
start( tr(
"Setup GPSBabel format registry" ) );
2716 profiler->
start( tr(
"Setup plugin layer registry" ) );
2721 profiler->
start( tr(
"Setup Processing registry" ) );
2727 profiler->
start( tr(
"Setup layout item registry" ) );
2729 mLayoutItemRegistry->populate();
2733 profiler->
start( tr(
"Setup annotation registry" ) );
2734 mAnnotationRegistry =
new QgsAnnotationRegistry();
2738 profiler->
start( tr(
"Setup annotation item registry" ) );
2740 mAnnotationItemRegistry->populate();
2744 profiler->
start( tr(
"Setup 3D symbol registry" ) );
2749 profiler->
start( tr(
"Setup 3D renderer registry" ) );
2754 profiler->
start( tr(
"Setup project storage registry" ) );
2759 profiler->
start( tr(
"Setup layer metadata provider registry" ) );
2764 profiler->
start( tr(
"Setup external storage registry" ) );
2769 profiler->
start( tr(
"Setup network content cache" ) );
2774 profiler->
start( tr(
"Setup layout check registry" ) );
2779 profiler->
start( tr(
"Setup classification registry" ) );
2784 profiler->
start( tr(
"Setup bookmark manager" ) );
2789 profiler->
start( tr(
"Setup tile download manager" ) );
2794 profiler->
start( tr(
"Setup scalebar registry" ) );
2800QgsApplication::ApplicationMembers::~ApplicationMembers()
2803 delete mTileDownloadManager;
2804 delete mScaleBarRendererRegistry;
2805 delete mValidityCheckRegistry;
2806 delete mActionScopeRegistry;
2807 delete m3DRendererRegistry;
2808 delete m3DSymbolRegistry;
2809 delete mAnnotationRegistry;
2810 delete mColorSchemeRegistry;
2811 delete mFieldFormatterRegistry;
2812 delete mGpsConnectionRegistry;
2813 delete mGpsBabelFormatRegistry;
2815 delete mPaintEffectRegistry;
2816 delete mPluginLayerRegistry;
2817 delete mProcessingRegistry;
2818 delete mPageSizeRegistry;
2819 delete mAnnotationItemRegistry;
2820 delete mLayoutItemRegistry;
2821 delete mPointCloudRendererRegistry;
2822 delete mRasterRendererRegistry;
2823 delete mRendererRegistry;
2826 delete mSourceCache;
2827 delete mCalloutRegistry;
2828 delete mRecentStyleHandler;
2829 delete mSymbolLayerRegistry;
2830 delete mExternalStorageRegistry;
2831 delete mTaskManager;
2832 delete mNetworkContentFetcherRegistry;
2833 delete mClassificationMethodRegistry;
2834 delete mNumericFormatRegistry;
2835 delete mBookmarkManager;
2836 delete mConnectionRegistry;
2837 delete mProjectStorageRegistry;
2838 delete mLayerMetadataProviderRegistry;
2839 delete mFontManager;
2840 delete mLocalizedDataPathRegistry;
2841 delete mCrsRegistry;
2842 delete mQueryLogger;
2843 delete mSettingsRegistryCore;
2846QgsApplication::ApplicationMembers *QgsApplication::members()
2848 if (
auto *lInstance =
instance() )
2850 return lInstance->mApplicationMembers;
2854 static QRecursiveMutex sMemberMutex;
2855 QMutexLocker lock( &sMemberMutex );
2856 if ( !sApplicationMembers )
2857 sApplicationMembers =
new ApplicationMembers();
2858 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 const QgsSettingsEntryStringList * settingsSearchPathsForSVG
Settings entry search path for SVG.
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 const QgsSettingsEntryBool * settingsLocaleOverrideFlag
Settings entry locale override flag.
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.
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)
This string is used to represent the value NULL throughout QGIS.
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...
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 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 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 const QgsSettingsEntryBool * settingsLocaleShowGroupSeparator
Settings entry locale show group separator.
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.
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.
A boolean settings entry.
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.
A string list settings entry.
QgsSettingsRegistryCore is used for settings introspection and collects all QgsSettingsEntry instance...
This class is a composition of two QSettings instances:
static QgsSettingsTreeNode * sTreeSvg
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.
static QgsSettingsTreeNode * sTreeLocale
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.
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)