102#include <QFileOpenEvent>
103#include <QMessageBox>
106#include <QProcessEnvironment>
109#include <QThreadPool>
112#include <QLibraryInfo>
113#include <QStandardPaths>
114#include <QRegularExpression>
115#include <QTextStream>
117#include <QAuthenticator>
118#include <QRecursiveMutex>
131#include <netinet/in.h>
137#define SECURITY_WIN32
140#pragma comment( lib, "Secur32.lib" )
144#include "qgsconfig.h"
154#if defined(Q_OS_LINUX)
155#include <sys/sysinfo.h>
158#define CONN_POOL_MAX_CONCURRENT_CONNS 4
160QObject *
ABISYM( QgsApplication::mFileOpenEventReceiver ) =
nullptr;
161bool ABISYM( QgsApplication::mInitialized ) =
false;
162bool ABISYM( QgsApplication::mRunningFromBuildDir ) =
false;
166QgsApplication::ApplicationMembers *QgsApplication::sApplicationMembers =
nullptr;
168int ABISYM( QgsApplication::sMaxThreads ) = -1;
185#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
202 : QApplication( argc, argv, GUIenabled )
204 *sPlatformName() = platformName;
209 if ( platformName != QLatin1String(
"desktop" ) )
211 mApplicationMembers =
new ApplicationMembers();
212 mApplicationMembers->mSettingsRegistryCore->migrateOldSettings();
216 *sProfilePath() = profileFolder;
224 if (
platform() == QLatin1String(
"desktop" ) )
226 instance()->mApplicationMembers =
new ApplicationMembers();
227 instance()->mApplicationMembers->mSettingsRegistryCore->migrateOldSettings();
230 if ( profileFolder.isEmpty() )
232 if ( getenv(
"QGIS_CUSTOM_CONFIG_PATH" ) )
234 profileFolder = getenv(
"QGIS_CUSTOM_CONFIG_PATH" );
238 profileFolder = QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ).value( 0 );
245 profileFolder = profile->
folder();
249 *sProfilePath() = profileFolder;
251 static std::once_flag sMetaTypesRegistered;
252 std::call_once( sMetaTypesRegistered, []
254 qRegisterMetaType<QgsGeometry::Error>(
"QgsGeometry::Error" );
255 qRegisterMetaType<QgsDatabaseQueryLogEntry>(
"QgsDatabaseQueryLogEntry" );
256 qRegisterMetaType<QgsProcessingFeatureSourceDefinition>(
"QgsProcessingFeatureSourceDefinition" );
257 qRegisterMetaType<QgsProcessingOutputLayerDefinition>(
"QgsProcessingOutputLayerDefinition" );
258 qRegisterMetaType<Qgis::LayoutUnit>(
"Qgis::LayoutUnit" );
259 qRegisterMetaType<QgsUnsetAttributeValue>(
"QgsUnsetAttributeValue" );
260 qRegisterMetaType<QgsFeatureId>(
"QgsFeatureId" );
261 qRegisterMetaType<QgsFields>(
"QgsFields" );
262 qRegisterMetaType<QgsFeatureIds>(
"QgsFeatureIds" );
263 qRegisterMetaType<QgsProperty>(
"QgsProperty" );
264 qRegisterMetaType<QgsFeatureStoreList>(
"QgsFeatureStoreList" );
265 qRegisterMetaType<Qgis::MessageLevel>(
"Qgis::MessageLevel" );
266 qRegisterMetaType<Qgis::BrowserItemState>(
"Qgis::BrowserItemState" );
267 qRegisterMetaType<Qgis::GpsFixStatus>(
"Qgis::GpsFixStatus" );
268 qRegisterMetaType<QgsReferencedRectangle>(
"QgsReferencedRectangle" );
269 qRegisterMetaType<QgsReferencedPointXY>(
"QgsReferencedPointXY" );
270 qRegisterMetaType<QgsReferencedGeometry>(
"QgsReferencedGeometry" );
271 qRegisterMetaType<QgsLayoutRenderContext::Flags>(
"QgsLayoutRenderContext::Flags" );
272 qRegisterMetaType<QgsStyle::StyleEntity>(
"QgsStyle::StyleEntity" );
273 qRegisterMetaType<QgsCoordinateReferenceSystem>(
"QgsCoordinateReferenceSystem" );
274 qRegisterMetaType<QgsAuthManager::MessageLevel>(
"QgsAuthManager::MessageLevel" );
275 qRegisterMetaType<QgsNetworkRequestParameters>(
"QgsNetworkRequestParameters" );
276 qRegisterMetaType<QgsNetworkReplyContent>(
"QgsNetworkReplyContent" );
277 qRegisterMetaType<QgsFeature>(
"QgsFeature" );
278 qRegisterMetaType<QgsGeometry>(
"QgsGeometry" );
279 qRegisterMetaType<QgsInterval>(
"QgsInterval" );
280 qRegisterMetaType<QgsRectangle>(
"QgsRectangle" );
281 qRegisterMetaType<QgsPointXY>(
"QgsPointXY" );
282 qRegisterMetaType<QgsPoint>(
"QgsPoint" );
283 qRegisterMetaType<QgsDatumTransform::GridDetails>(
"QgsDatumTransform::GridDetails" );
284 qRegisterMetaType<QgsDatumTransform::TransformDetails>(
"QgsDatumTransform::TransformDetails" );
285 qRegisterMetaType<QgsNewsFeedParser::Entry>(
"QgsNewsFeedParser::Entry" );
286 qRegisterMetaType<QgsRectangle>(
"QgsRectangle" );
287 qRegisterMetaType<QgsLocatorResult>(
"QgsLocatorResult" );
288 qRegisterMetaType<QgsGradientColorRamp>(
"QgsGradientColorRamp" );
289 qRegisterMetaType<QgsProcessingModelChildParameterSource>(
"QgsProcessingModelChildParameterSource" );
290#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
293 qRegisterMetaTypeStreamOperators<QgsProcessingModelChildParameterSource>(
"QgsProcessingModelChildParameterSource" );
295 qRegisterMetaType<QgsRemappingSinkDefinition>(
"QgsRemappingSinkDefinition" );
296 qRegisterMetaType<QgsProcessingModelChildDependency>(
"QgsProcessingModelChildDependency" );
297 qRegisterMetaType<QgsTextFormat>(
"QgsTextFormat" );
298#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
299 QMetaType::registerComparators<QgsProcessingModelChildDependency>();
300 QMetaType::registerEqualsComparator<QgsProcessingFeatureSourceDefinition>();
301 QMetaType::registerEqualsComparator<QgsProperty>();
302 QMetaType::registerEqualsComparator<QgsDateTimeRange>();
303 QMetaType::registerEqualsComparator<QgsDateRange>();
304 QMetaType::registerEqualsComparator<QgsUnsetAttributeValue>();
306 qRegisterMetaType<QPainter::CompositionMode>(
"QPainter::CompositionMode" );
307 qRegisterMetaType<QgsDateTimeRange>(
"QgsDateTimeRange" );
308 qRegisterMetaType<QgsDoubleRange>(
"QgsDoubleRange" );
309 qRegisterMetaType<QgsIntRange>(
"QgsIntRange" );
310 qRegisterMetaType<QList<QgsMapLayer *>>(
"QList<QgsMapLayer*>" );
311 qRegisterMetaType<QMap<QNetworkRequest::Attribute, QVariant>>(
"QMap<QNetworkRequest::Attribute,QVariant>" );
312 qRegisterMetaType<QMap<QNetworkRequest::KnownHeaders, QVariant>>(
"QMap<QNetworkRequest::KnownHeaders,QVariant>" );
313 qRegisterMetaType<QList<QNetworkReply::RawHeaderPair>>(
"QList<QNetworkReply::RawHeaderPair>" );
314 qRegisterMetaType< QAuthenticator * >(
"QAuthenticator*" );
315 qRegisterMetaType< QgsGpsInformation >(
"QgsGpsInformation" );
320 if ( ABISYM( mRunningFromBuildDir ) )
323 *sPrefixPath() = QString();
324#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
325 setPluginPath( *sBuildOutputPath() +
'/' + QString( QGIS_PLUGIN_SUBDIR ) +
'/' + *sCfgIntDir() );
327 setPluginPath( *sBuildOutputPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
329 setPkgDataPath( *sBuildOutputPath() + QStringLiteral(
"/data" ) );
330 *sLibraryPath() = *sBuildOutputPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
331#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
332 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/' + *sCfgIntDir() +
'/';
334 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
336#if defined( HAVE_QUICK )
337 *sQmlImportPath() = *sBuildOutputPath() +
'/' + QGIS_QML_SUBDIR +
'/';
342 char *
prefixPath = getenv(
"QGIS_PREFIX_PATH" );
345 if ( sPrefixPath()->isNull() )
347#if defined(Q_OS_MACX) || defined(Q_OS_WIN)
349#elif defined(ANDROID)
351 QDir myDir( QDir::homePath() );
353 QString myPrefix = myDir.absolutePath();
356 QDir myDir( applicationDirPath() );
358 if ( applicationDirPath().contains( QStringLiteral(
"cgi-bin" ) ) )
363 QString myPrefix = myDir.absolutePath();
374 *sConfigPath() = profileFolder +
'/';
378 if ( getenv(
"QGIS_AUTH_DB_DIR_PATH" ) )
384 qputenv(
"QT3D_RENDERER",
"opengl" );
387 QMap<QString, QString> systemEnvVarMap;
388 QString passfile( QStringLiteral(
"QGIS_AUTH_PASSWORD_FILE" ) );
390 const auto systemEnvironment = QProcessEnvironment::systemEnvironment().toStringList();
391 for (
const QString &varStr : systemEnvironment )
393 int pos = varStr.indexOf( QLatin1Char(
'=' ) );
396 QString varStrName = varStr.left( pos );
397 QString varStrValue = varStr.mid( pos + 1 );
398 if ( varStrName != passfile )
400 systemEnvVarMap.insert( varStrName, varStrValue );
403 *sSystemEnvVars() = systemEnvVarMap;
410 QString projLib( QDir::cleanPath(
pkgDataPath().append(
"/proj" ) ) );
411 if ( QFile::exists( projLib ) )
413 currentProjSearchPaths.append( projLib );
417 char **newPaths =
new char *[currentProjSearchPaths.length()];
418 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
420 newPaths[i] = CPLStrdup( currentProjSearchPaths.at( i ).toUtf8().constData() );
422 proj_context_set_search_paths(
nullptr, currentProjSearchPaths.count(), newPaths );
423 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
425 CPLFree( newPaths[i] );
430 QCoreApplication::addLibraryPath(
pluginPath() );
440 ABISYM( sMaxThreads ) = -1;
456 if ( !members()->mStyleModel )
459 ABISYM( mInitialized ) =
true;
463void QgsApplication::installTranslators()
466 if ( mQgisTranslator )
468 removeTranslator( mQgisTranslator );
469 delete mQgisTranslator;
470 mQgisTranslator =
nullptr;
474 removeTranslator( mQtTranslator );
475 delete mQtTranslator;
476 mQtTranslator =
nullptr;
478 if ( mQtBaseTranslator )
480 removeTranslator( mQtBaseTranslator );
481 delete mQtBaseTranslator;
482 mQtBaseTranslator =
nullptr;
485 if ( *sTranslation() != QLatin1String(
"C" ) )
487 mQgisTranslator =
new QTranslator(
this );
488 if ( mQgisTranslator->load( QStringLiteral(
"qgis_" ) + *sTranslation(),
i18nPath() ) )
490 installTranslator( mQgisTranslator );
494 QgsDebugMsgLevel( QStringLiteral(
"loading of qgis translation failed %1/qgis_%2" ).arg(
i18nPath(), *sTranslation() ), 2 );
502 QString qtTranslationsPath = QLibraryInfo::location( QLibraryInfo::TranslationsPath );
504 QString prefix = QDir( QString(
"%1/../" ).arg( QApplication::applicationDirPath() ) ).absolutePath();
505 qtTranslationsPath = prefix + qtTranslationsPath.mid( QLibraryInfo::location( QLibraryInfo::PrefixPath ).length() );
508 mQtTranslator =
new QTranslator(
this );
509 if ( mQtTranslator->load( QStringLiteral(
"qt_" ) + *sTranslation(), qtTranslationsPath ) )
511 installTranslator( mQtTranslator );
515 QgsDebugMsgLevel( QStringLiteral(
"loading of qt translation failed %1/qt_%2" ).arg( qtTranslationsPath, *sTranslation() ), 2 );
518 mQtBaseTranslator =
new QTranslator(
this );
519 if ( mQtBaseTranslator->load( QStringLiteral(
"qtbase_" ) + *sTranslation(), qtTranslationsPath ) )
521 installTranslator( mQtBaseTranslator );
525 QgsDebugMsgLevel( QStringLiteral(
"loading of qtbase translation failed %1/qt_%2" ).arg( qtTranslationsPath, *sTranslation() ), 2 );
532 if ( mApplicationMembers )
533 mApplicationMembers->mSettingsRegistryCore->backwardCompatibility();
535 delete mDataItemProviderRegistry;
536 delete mApplicationMembers;
537 delete mQgisTranslator;
538 delete mQtTranslator;
539 delete mQtBaseTranslator;
547void QgsApplication::invalidateCaches()
559 return qobject_cast<QgsApplication *>( QCoreApplication::instance() );
565 if (
event->type() == QEvent::FileOpen )
568 if ( ABISYM( mFileOpenEventReceiver ) )
571 done =
notify( ABISYM( mFileOpenEventReceiver ),
event );
578 sFileOpenEventList()->append(
static_cast<QFileOpenEvent *
>(
event )->file() );
585 done = QApplication::event(
event );
594 if ( thread() == receiver->thread() )
604 done = QApplication::notify( receiver,
event );
608 qCritical() <<
"Caught unhandled QgsException: " << e.
what();
609 if ( qApp->thread() == QThread::currentThread() )
610 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
612 catch ( std::exception &e )
614 qCritical() <<
"Caught unhandled std::exception: " << e.
what();
615 if ( qApp->thread() == QThread::currentThread() )
616 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
620 qCritical() <<
"Caught unhandled unknown exception";
621 if ( qApp->thread() == QThread::currentThread() )
622 QMessageBox::critical( activeWindow(), tr(
"Exception" ), tr(
"unknown exception" ) );
630 return QgsRuntimeProfiler::threadLocalInstance();
636 ABISYM( mFileOpenEventReceiver ) = receiver;
638 if ( sFileOpenEventList()->count() > 0 )
640 const QStringList fileOpenEventList = *sFileOpenEventList();
641 for (
const QString &file : fileOpenEventList )
643 QFileOpenEvent foe( file );
644 QgsApplication::sendEvent( ABISYM( mFileOpenEventReceiver ), &foe );
646 sFileOpenEventList()->clear();
654 if ( sPrefixPath()->endsWith(
"/bin" ) )
656 sPrefixPath()->chop( 4 );
659 if ( useDefaultPaths && !ABISYM( mRunningFromBuildDir ) )
661 setPluginPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
662 setPkgDataPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_DATA_SUBDIR ) );
664 *sLibraryPath() = *sPrefixPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
665 *sLibexecPath() = *sPrefixPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
666#if defined( HAVE_QUICK )
667 *sQmlImportPath() = *sPrefixPath() +
'/' + QGIS_QML_SUBDIR +
'/';
680 QString mySvgPath =
pkgDataPath + QStringLiteral(
"/svg/" );
683 if ( !sDefaultSvgPaths()->contains( mySvgPath ) )
684 *sDefaultSvgPaths() << mySvgPath;
689 *sDefaultSvgPaths() = pathList;
694 QFileInfo fi( authDbDirPath );
695 if ( fi.exists() && fi.isDir() && fi.isWritable() )
697 *sAuthDbDirPath() = fi.canonicalFilePath() + QDir::separator();
704 if ( ABISYM( mRunningFromBuildDir ) )
706 static bool sOnce =
true;
710 ( void ) blockNotifications;
711 qWarning(
"!!! prefix path was requested, but it is not valid - we do not run from installed path !!!" );
717 return *sPrefixPath();
721 return *sPluginPath();
726 if ( sPkgDataPath()->isNull() )
729 return *sPkgDataPath();
734 return QStringLiteral(
":/images/themes/default/" );
739 QDir dir( usersThemes );
747 return defaultThemes;
753 return iconsPath() + QStringLiteral(
"qgis-icon-60x60.png" );
758 return ABISYM( sMaxThreads );
765 if ( QFile::exists( path + iconFile ) )
766 return path + iconFile;
774 const QString cacheKey = ( name.startsWith(
'/' ) ? name.mid( 1 ) : name )
775 + ( fillColor.isValid() ? QStringLiteral(
"_%1" ).arg( fillColor.name( QColor::HexArgb ).mid( 1 ) ) : QString() )
776 + ( strokeColor.isValid() ? QStringLiteral(
"_%1" ).arg( strokeColor.name( QColor::HexArgb ).mid( 1 ) ) : QString() );
778 if ( app && app->mIconCache.contains( cacheKey ) )
779 return app->mIconCache.value( cacheKey );
782 const bool colorBased = fillColor.isValid() || strokeColor.isValid();
784 auto iconFromColoredSvg = [ = ](
const QString & path ) -> QIcon
789 const QString
iconPath = sIconCacheDir()->filePath( cacheKey + QStringLiteral(
".svg" ) );
790 if (
const QDir dir = QFileInfo(
iconPath ).dir(); !dir.exists() )
796 if ( f.open( QFile::WriteOnly | QFile::Truncate ) )
798 f.write( svgContent );
807 return QIcon( f.fileName() );
812 if ( QFile::exists( preferredPath ) )
816 icon = iconFromColoredSvg( preferredPath );
820 icon = QIcon( preferredPath );
823 else if ( QFile::exists( defaultPath ) )
829 icon = iconFromColoredSvg( defaultPath );
833 icon = QIcon( defaultPath );
842 app->mIconCache.insert( cacheKey, icon );
849 if ( app && app->mCursorCache.contains( cursor ) )
850 return app->mCursorCache.value( cursor );
861 name = QStringLiteral(
"mZoomIn.svg" );
866 name = QStringLiteral(
"mZoomOut.svg" );
873 name = QStringLiteral(
"mIdentify.svg" );
876 name = QStringLiteral(
"mCrossHair.svg" );
879 name = QStringLiteral(
"mCapturePoint.svg" );
882 name = QStringLiteral(
"mSelect.svg" );
889 name = QStringLiteral(
"mSampler.svg" );
894 Q_ASSERT( ! name.isEmpty( ) );
896 QIcon icon =
getThemeIcon( QStringLiteral(
"cursors" ) + QDir::separator() + name );
899 if ( ! icon.isNull( ) )
903 cursorIcon = QCursor( icon.pixmap( std::ceil( scale * 32 ), std::ceil( scale * 32 ) ), std::ceil( scale * activeX ), std::ceil( scale * activeY ) );
906 app->mCursorCache.insert( cursor, cursorIcon );
913 const QString preferredPath =
activeThemePath() + QDir::separator() + name;
915 const QString path = QFile::exists( preferredPath ) ? preferredPath : defaultPath;
916 if ( foreColor.isValid() || backColor.isValid() )
918 bool fitsInCache =
false;
919 const QImage image =
svgCache()->
svgAsImage( path, size, backColor, foreColor, 1, 1, fitsInCache );
920 return QPixmap::fromImage( image );
923 return QPixmap( path );
933 static QString appPath;
934 if ( appPath.isNull() )
936 if ( QCoreApplication::instance() )
938 appPath = applicationDirPath();
942 qWarning(
"Application path not initialized" );
946 if ( !appPath.isNull() || getenv(
"QGIS_PREFIX_PATH" ) )
948 QString prefix = getenv(
"QGIS_PREFIX_PATH" ) ? getenv(
"QGIS_PREFIX_PATH" ) : appPath;
953 static const QStringList paths { QStringList() << QString() << QStringLiteral(
"/.." ) << QStringLiteral(
"/bin" ) << QStringLiteral(
"/../../.." ) };
954 for (
const QString &path : paths )
956 f.setFileName( prefix + path +
"/qgisbuildpath.txt" );
960 if ( f.exists() && f.open( QIODevice::ReadOnly ) )
962 ABISYM( mRunningFromBuildDir ) =
true;
963 *sBuildSourcePath() = f.readLine().trimmed();
964 *sBuildOutputPath() = f.readLine().trimmed();
966 QgsDebugMsgLevel( QStringLiteral(
"- source directory: %1" ).arg( sBuildSourcePath()->toUtf8().constData() ), 4 );
967 QgsDebugMsgLevel( QStringLiteral(
"- output directory of the build: %1" ).arg( sBuildOutputPath()->toUtf8().constData() ), 4 );
968#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
969 *sCfgIntDir() = prefix.split(
'/', Qt::SkipEmptyParts ).last();
970 qDebug(
"- cfg: %s", sCfgIntDir()->toUtf8().constData() );
976 if ( getenv(
"QGIS_PREFIX_PATH" ) )
982 QDir dir( QDir::homePath() );
987#if defined(Q_OS_MACX)
989#elif defined(Q_OS_WIN)
996 if ( appPath.contains( QStringLiteral(
"cgi-bin" ) ) )
1006 if ( ABISYM( mRunningFromBuildDir ) )
1007 return *sBuildOutputPath() + QStringLiteral(
"/data" );
1009 return prefixPath +
'/' + QStringLiteral( QGIS_DATA_SUBDIR );
1014 return *sThemeName();
1024 qApp->setStyleSheet( QString() );
1028 QString path = themes.value(
themeName );
1029 QString stylesheetname = path +
"/style.qss";
1031 QFile file( stylesheetname );
1032 QFile variablesfile( path +
"/variables.qss" );
1034 QFileInfo variableInfo( variablesfile );
1036 if ( !file.open( QIODevice::ReadOnly ) || ( variableInfo.exists() && !variablesfile.open( QIODevice::ReadOnly ) ) )
1041 QString styledata = file.readAll();
1042 styledata.replace( QLatin1String(
"@theme_path" ), path );
1044 if ( variableInfo.exists() )
1046 QTextStream in( &variablesfile );
1047 while ( !in.atEnd() )
1049 QString line = in.readLine();
1051 if ( line.startsWith(
'@' ) )
1053 int index = line.indexOf(
':' );
1054 QString name = line.mid( 0, index );
1055 QString value = line.mid( index + 1, line.length() );
1056 styledata.replace( name, value );
1059 variablesfile.close();
1067 const static QRegularExpression regex( QStringLiteral(
"(?<=[\\s:])([0-9\\.]+)(?=em)" ) );
1068 QRegularExpressionMatch match = regex.match( styledata, index );
1069 while ( match.hasMatch() )
1071 index = match.capturedStart();
1072 styledata.remove( index, match.captured( 0 ).length() );
1074 styledata.insert( index, number );
1075 index += number.length();
1076 match = regex.match( styledata, index );
1080 qApp->setStyleSheet( styledata );
1082 QFile palettefile( path +
"/palette.txt" );
1083 QFileInfo paletteInfo( palettefile );
1084 if ( paletteInfo.exists() && palettefile.open( QIODevice::ReadOnly ) )
1086 QPalette
pal = qApp->palette();
1087 QTextStream in( &palettefile );
1088 while ( !in.atEnd() )
1090 QString line = in.readLine();
1091 QStringList parts = line.split(
':' );
1092 if ( parts.count() == 2 )
1094 int role = parts.at( 0 ).trimmed().toInt();
1096 pal.setColor(
static_cast< QPalette::ColorRole
>( role ), color );
1099 palettefile.close();
1100 qApp->setPalette(
pal );
1109 QHash<QString, QString> mapping;
1110 mapping.insert( QStringLiteral(
"default" ), QString() );
1111 const auto constPaths = paths;
1112 for (
const QString &path : constPaths )
1114 QDir folder( path );
1115 QFileInfoList styleFiles = folder.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
1116 const auto constStyleFiles = styleFiles;
1117 for (
const QFileInfo &info : constStyleFiles )
1119 QFileInfo styleFile( info.absoluteFilePath() +
"/style.qss" );
1120 if ( !styleFile.exists() )
1123 QString name = info.baseName();
1124 QString path = info.absoluteFilePath();
1125 mapping.insert( name, path );
1133 return pkgDataPath() + QStringLiteral(
"/doc/AUTHORS" );
1138 return pkgDataPath() + QStringLiteral(
"/doc/CONTRIBUTORS" );
1142 return pkgDataPath() + QStringLiteral(
"/doc/developersmap.html" );
1147 return pkgDataPath() + QStringLiteral(
"/doc/SPONSORS" );
1152 return pkgDataPath() + QStringLiteral(
"/doc/DONORS" );
1157 return pkgDataPath() + QStringLiteral(
"/doc/TRANSLATORS" );
1162 return pkgDataPath() + QStringLiteral(
"/doc/LICENSE" );
1167 if ( ABISYM( mRunningFromBuildDir ) )
1168 return *sBuildOutputPath() + QStringLiteral(
"/i18n/" );
1170 return pkgDataPath() + QStringLiteral(
"/i18n/" );
1175 return pkgDataPath() + QStringLiteral(
"/resources/metadata-ISO/" );
1180 return pkgDataPath() + QStringLiteral(
"/resources/qgis.db" );
1185 return *sConfigPath();
1195 return *sAuthDbDirPath() + QStringLiteral(
"qgis-auth.db" );
1200 return QStringLiteral(
":/images/splash/" );
1205 return pkgDataPath() + QStringLiteral(
"/images/icons/" );
1210 if ( ABISYM( mRunningFromBuildDir ) )
1212 QString tempCopy = QDir::tempPath() +
"/srs6.db";
1214 if ( !QFile( tempCopy ).exists() )
1217 if ( !f.copy( tempCopy ) )
1219 qFatal(
"Could not create temporary copy" );
1227 return pkgDataPath() + QStringLiteral(
"/resources/srs.db" );
1234 members()->mSvgPathCacheValid =
false;
1239 static QReadWriteLock lock;
1243 if ( members()->mSvgPathCacheValid )
1245 return members()->mSvgPathCache;
1256 for (
const QString &path : pathList )
1258 if ( !paths.contains( path ) )
1259 paths.append( path );
1261 for (
const QString &path : std::as_const( *sDefaultSvgPaths() ) )
1263 if ( !paths.contains( path ) )
1264 paths.append( path );
1266 members()->mSvgPathCache = paths;
1281 return *sSystemEnvVars();
1291 const thread_local QRegularExpression regexp( QRegularExpression::anchoredPattern( QStringLiteral(
"^[A-Za-z][A-Za-z0-9\\._-]*" ) ) );
1297 if ( !sUserName()->isEmpty() )
1298 return *sUserName();
1301 TCHAR name [ UNLEN + 1 ];
1302 DWORD size = UNLEN + 1;
1304 if ( GetUserName( ( TCHAR * )name, &size ) )
1306#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
1307 *sUserName() = QString::fromLocal8Bit( name );
1309 *sUserName() = QString::fromWCharArray( name );
1314#elif QT_CONFIG(process)
1317 process.start( QStringLiteral(
"whoami" ), QStringList() );
1318 process.waitForFinished();
1319 *sUserName() = process.readAllStandardOutput().trimmed();
1322 if ( !sUserName()->isEmpty() )
1323 return *sUserName();
1326 *sUserName() = qgetenv(
"USER" );
1327 if ( !sUserName()->isEmpty() )
1328 return *sUserName();
1331 *sUserName() = qgetenv(
"USERNAME" );
1332 return *sUserName();
1337 if ( !sUserFullName()->isEmpty() )
1338 return *sUserFullName();
1341 TCHAR name [ UNLEN + 1 ];
1342 DWORD size = UNLEN + 1;
1345 if ( GetUserNameEx( NameDisplay, ( TCHAR * )name, &size ) )
1347#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
1348 *sUserFullName() = QString::fromLocal8Bit( name );
1350 *sUserFullName() = QString::fromWCharArray( name );
1355 if ( sUserFullName()->isEmpty() )
1357#elif defined(Q_OS_ANDROID) || defined(__MINGW32__)
1358 *sUserFullName() = QStringLiteral(
"Not available" );
1360 struct passwd *p = getpwuid( getuid() );
1364 QString gecosName = QString( p->pw_gecos );
1365 *sUserFullName() = gecosName.left( gecosName.indexOf(
',', 0 ) );
1370 return *sUserFullName();
1375#if defined(Q_OS_ANDROID)
1376 return QLatin1String(
"android" );
1377#elif defined(Q_OS_MAC)
1378 return QLatin1String(
"osx" );
1379#elif defined(Q_OS_WIN)
1380 return QLatin1String(
"windows" );
1381#elif defined(Q_OS_LINUX)
1382 return QStringLiteral(
"linux" );
1383#elif defined(Q_OS_FREEBSD)
1384 return QStringLiteral(
"freebsd" );
1385#elif defined(Q_OS_OPENBSD)
1386 return QStringLiteral(
"openbsd" );
1387#elif defined(Q_OS_NETBSD)
1388 return QStringLiteral(
"netbsd" );
1389#elif defined(Q_OS_UNIX)
1390 return QLatin1String(
"unix" );
1392 return QLatin1String(
"unknown" );
1398#if defined(Q_OS_ANDROID)
1400#elif defined(Q_OS_MAC)
1402#elif defined(Q_OS_WIN)
1403 MEMORYSTATUSEX memoryStatus;
1404 ZeroMemory( &memoryStatus,
sizeof( MEMORYSTATUSEX ) );
1405 memoryStatus.dwLength =
sizeof( MEMORYSTATUSEX );
1406 if ( GlobalMemoryStatusEx( &memoryStatus ) )
1408 return memoryStatus.ullTotalPhys / ( 1024 * 1024 );
1414#elif defined(Q_OS_LINUX)
1415 constexpr int megabyte = 1024 * 1024;
1418 return si.totalram / megabyte;
1419#elif defined(Q_OS_FREEBSD)
1421#elif defined(Q_OS_OPENBSD)
1423#elif defined(Q_OS_NETBSD)
1425#elif defined(Q_OS_UNIX)
1434 return *sPlatformName();
1439 if ( !sApplicationFullName()->isEmpty() )
1440 return *sApplicationFullName();
1443 *sApplicationFullName() = qgetenv(
"QGIS_APPLICATION_FULL_NAME" );
1444 if ( !sApplicationFullName()->isEmpty() )
1445 return *sApplicationFullName();
1449 *sApplicationFullName() = settings.
value(
1450 QStringLiteral(
"/qgis/application_full_name" ),
1451 QStringLiteral(
"%1 %2" ).arg( applicationName(),
platform() )
1453 return *sApplicationFullName();
1462 if (
locale.startsWith( QLatin1String(
"en" ), Qt::CaseInsensitive ) )
1471 return QLocale().name().left( 2 );
1477 QLocale::setDefault(
locale );
1488 return pkgDataPath() + QStringLiteral(
"/resources/symbology-style.xml" );
1493 return pkgDataPath() + QStringLiteral(
"/resources/themes" );
1498 return pkgDataPath() + QStringLiteral(
"/resources/server/" );
1503 return *sLibraryPath();
1508 return *sLibexecPath();
1513 return *sQmlImportPath();
1518 return ( htonl( 1 ) == 1 ) ?
XDR :
NDR;
1525 init( *sProfilePath() );
1550 if (
auto *lInstance =
instance() )
1552 if ( !lInstance->mAuthManager )
1556 return lInstance->mAuthManager;
1561 if ( !sAuthManager )
1563 return sAuthManager;
1571 QThreadPool::globalInstance()->waitForDone();
1574 if (
auto *lInstance =
instance() )
1575 delete lInstance->mAuthManager;
1577 delete sAuthManager;
1580 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1586 if ( QgsProject::sProject )
1594 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1597 if ( QgsProviderRegistry::exists() )
1606 GDALDestroyDriverManager();
1611 QString myEnvironmentVar( getenv(
"QGIS_PREFIX_PATH" ) );
1612 QString myState = tr(
"Application state:\n"
1613 "QGIS_PREFIX_PATH env var:\t\t%1\n"
1615 "Plugin Path:\t\t%3\n"
1616 "Package Data Path:\t%4\n"
1617 "Active Theme Name:\t%5\n"
1618 "Active Theme Path:\t%6\n"
1619 "Default Theme Path:\t%7\n"
1620 "SVG Search Paths:\t%8\n"
1621 "User DB Path:\t%9\n"
1622 "Auth DB Path:\t%10\n" )
1623 .arg( myEnvironmentVar,
1630 svgPaths().join( tr(
"\n\t\t",
"match indentation of application state" ) ),
1643 QColor myColor1( Qt::lightGray );
1644 QColor myColor2 = myColor1;
1645 myColor2 = myColor2.lighter( 110 );
1647 myStyle = QStringLiteral(
".overview{"
1649 " font-weight: bold;"
1652 " background: white;"
1654 " font-family: 'Lato', 'Open Sans', 'Lucida Grande', 'Segoe UI', 'Arial', sans-serif;"
1657 "h1{ background-color: #F6F6F6;"
1659 " font-size: x-large; "
1660 " font-weight: normal;"
1661 " background: none;"
1662 " padding: 0.75em 0 0;"
1664 " line-height: 3em;"
1666 "h2{ background-color: #F6F6F6;"
1668 " font-size: medium; "
1669 " font-weight: normal;"
1670 " background: none;"
1671 " padding: 0.75em 0 0;"
1673 " line-height: 1.1em;"
1675 "h3{ background-color: #F6F6F6;"
1677 " font-weight: bold;"
1678 " font-size: large;"
1679 " text-align: left;"
1680 " border-bottom: 5px solid #DCEB5C;"
1682 "h4{ background-color: #F6F6F6;"
1684 " font-weight: bold;"
1685 " font-size: medium;"
1686 " text-align: left;"
1688 "h5{ background-color: #F6F6F6;"
1690 " font-weight: bold;"
1691 " font-size: small;"
1692 " text-align: left;"
1694 "a{ color: #729FCF;"
1695 " font-family: arial,sans-serif;"
1697 "label{ background-color: #FFFFCC;"
1698 " border: 1px solid black;"
1700 " padding: 0px 3px; "
1701 " font-size: small;"
1704 " font-weight: bold;"
1709 " border-top: 1px solid black;"
1711 ".list-view .highlight {"
1712 " text-align: left;"
1715 " padding-right: 15px;"
1716 " padding-left: 20px;"
1717 " font-weight: bold;"
1719 ".tabular-view .odd-row {"
1720 " background-color: #f9f9f9;"
1723 " font-weight: bold;"
1724 " padding-top:25px;"
1728 switch ( styleSheetType )
1730 case StyleSheetType::Qt:
1731 myStyle += QStringLiteral(
1733 " border-collapse: collapse;"
1736 ".tabular-view th, .tabular-view td { "
1737 " border:1px solid black;"
1741 case StyleSheetType::WebBrowser:
1742 myStyle += QStringLiteral(
1747 "table.tabular-view, table.list-view { "
1748 " border-collapse: collapse;"
1749 " table-layout:fixed;"
1750 " width: 100% !important;"
1755 " line-height: inherit;"
1758 " word-wrap: break-word; "
1759 " vertical-align: top;"
1762 ".list-view th:first-child, .list-view td:first-child {"
1765 ".list-view.highlight { "
1766 " padding-left: inherit; "
1769 ".tabular-view th:first-child, .tabular-view td:first-child { "
1773 ".tabular-view th.strong { "
1774 " background-color: #eee; "
1777 ".tabular-view th, .tabular-view td { "
1778 " border: 1px solid #eee;"
1789 if ( 0 >= OGRGetDriverCount() )
1797 QString aPathUrl = aPath;
1798 QString tPathUrl = targetPath;
1799#if defined( Q_OS_WIN )
1800 const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
1802 aPathUrl.replace(
'\\',
'/' );
1803 if ( aPathUrl.startsWith(
"//" ) )
1806 aPathUrl =
"\\\\" + aPathUrl.mid( 2 );
1809 tPathUrl.replace(
'\\',
'/' );
1810 if ( tPathUrl.startsWith(
"//" ) )
1813 tPathUrl =
"\\\\" + tPathUrl.mid( 2 );
1816 const Qt::CaseSensitivity cs = Qt::CaseSensitive;
1819 QStringList targetElems = tPathUrl.split(
'/', Qt::SkipEmptyParts );
1820 QStringList aPathElems = aPathUrl.split(
'/', Qt::SkipEmptyParts );
1822 targetElems.removeAll( QStringLiteral(
"." ) );
1823 aPathElems.removeAll( QStringLiteral(
"." ) );
1827 while ( !aPathElems.isEmpty() &&
1828 !targetElems.isEmpty() &&
1829 aPathElems[0].compare( targetElems[0], cs ) == 0 )
1831 aPathElems.removeFirst();
1832 targetElems.removeFirst();
1842 if ( !targetElems.isEmpty() )
1845 for (
int i = 0; i < targetElems.size(); i++ )
1847 aPathElems.insert( 0, QStringLiteral(
".." ) );
1854 aPathElems.insert( 0, QStringLiteral(
"." ) );
1857 return aPathElems.join( QLatin1Char(
'/' ) );
1863 if ( !rpath.startsWith( QLatin1String(
"./" ) ) && !rpath.startsWith( QLatin1String(
"../" ) ) )
1868 QString rPathUrl = rpath;
1869 QString targetPathUrl = targetPath;
1871#if defined(Q_OS_WIN)
1872 rPathUrl.replace(
'\\',
'/' );
1873 targetPathUrl.replace(
'\\',
'/' );
1875 bool uncPath = targetPathUrl.startsWith(
"//" );
1878 QStringList srcElems = rPathUrl.split(
'/', Qt::SkipEmptyParts );
1879 QStringList targetElems = targetPathUrl.split(
'/', Qt::SkipEmptyParts );
1881#if defined(Q_OS_WIN)
1884 targetElems.insert( 0,
"" );
1885 targetElems.insert( 0,
"" );
1890 targetElems << srcElems;
1891 targetElems.removeAll( QStringLiteral(
"." ) );
1895 while ( ( pos = targetElems.indexOf( QLatin1String(
".." ) ) ) > 0 )
1898 targetElems.removeAt( pos - 1 );
1899 targetElems.removeAt( pos - 1 );
1902#if !defined(Q_OS_WIN)
1904 targetElems.prepend( QString() );
1907 return targetElems.join( QLatin1Char(
'/' ) );
1912 return *sBuildSourcePath();
1917 return *sBuildOutputPath();
1920#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
1921QString QgsApplication::cfgIntDir()
1923 return *sCfgIntDir();
1929 if ( sGdalSkipList()->contains( driver ) || driver.isEmpty() )
1933 *sGdalSkipList() << driver;
1939 if ( !sGdalSkipList()->contains( driver ) )
1943 int myPos = sGdalSkipList()->indexOf( driver );
1946 sGdalSkipList()->removeAt( myPos );
1953 return *sGdalSkipList();
1957 const QStringList &deferredSkippedGdalDrivers )
1971 QString joinedList, delimiter;
1972 if ( settings.
contains( QStringLiteral(
"gdal/skipDrivers" ) ) )
1974 joinedList = settings.
value( QStringLiteral(
"gdal/skipDrivers" ), QString() ).toString();
1975 delimiter = QStringLiteral(
"," );
1979 joinedList = settings.
value( QStringLiteral(
"gdal/skipList" ), QString() ).toString();
1980 delimiter = QStringLiteral(
" " );
1983 if ( !joinedList.isEmpty() )
1985 myList = joinedList.split( delimiter );
1987 *sGdalSkipList() = myList;
1993 return *sDeferredSkippedGdalDrivers();
1998 sGdalSkipList()->removeDuplicates();
1999 QStringList realDisabledDriverList;
2000 for (
const auto &driverName : *sGdalSkipList() )
2002 if ( !sDeferredSkippedGdalDrivers()->contains( driverName ) )
2003 realDisabledDriverList << driverName;
2005 QString myDriverList = realDisabledDriverList.join(
',' );
2006 QgsDebugMsgLevel( QStringLiteral(
"Gdal Skipped driver list set to:" ), 2 );
2008 CPLSetConfigOption(
"GDAL_SKIP", myDriverList.toUtf8() );
2015 QDir myDir( folder );
2016 if ( !myDir.exists() )
2018 myDir.mkpath( folder );
2024void QgsApplication::copyPath(
const QString &src,
const QString &dst )
2027 if ( ! dir.exists() )
2030 const auto subDirectories = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot );
2031 for (
const QString &d : subDirectories )
2033 QString dst_path = dst + QDir::separator() + d;
2034 dir.mkpath( dst_path );
2035 copyPath( src + QDir::separator() + d, dst_path );
2038 const auto files = dir.entryList( QDir::Files );
2039 for (
const QString &f :
files )
2041 QFile::copy( src + QDir::separator() + f, dst + QDir::separator() + f );
2050 QVariantMap variables;
2054 QStringList childKeys = settings.
childKeys();
2055 for ( QStringList::const_iterator it = childKeys.constBegin(); it != childKeys.constEnd(); ++it )
2058 variables.insert( name, settings.
value( name ) );
2068 QVariantMap::const_iterator it = variables.constBegin();
2071 for ( ; it != variables.constEnd(); ++it )
2073 settings.
setValue( it.key(), it.value() );
2084 settings.
setValue( QStringLiteral(
"variables/" ) + name, value );
2091 QFontMetrics fm( ( QFont() ) );
2092 const double scale = 1.1 * standardSize / 24;
2093 int scaledIconSize =
static_cast< int >( std::floor( std::max(
Qgis::UI_SCALE_FACTOR * fm.height() * scale,
static_cast< double >( standardSize ) ) ) );
2094 if ( applyDevicePixelRatio )
2096 if ( QWidget *activeWindow = QApplication::activeWindow() )
2097 scaledIconSize *= ( activeWindow->screen() ? QApplication::activeWindow()->screen()->devicePixelRatio() : 1 );
2099 return scaledIconSize;
2112 app->installTranslators();
2118 return *sTranslation();
2128 ApplicationMembers *appMembers = members();
2129 if ( appMembers->mNullRepresentation.isNull() )
2131 appMembers->mNullRepresentation =
QgsSettings().
value( QStringLiteral(
"qgis/nullValue" ), QStringLiteral(
"NULL" ) ).toString();
2133 return appMembers->mNullRepresentation;
2138 ApplicationMembers *appMembers = members();
2152 return members()->mActionScopeRegistry;
2161 QDir myDir( myPamPath );
2162 if ( !myDir.exists() )
2164 myDir.mkpath( myPamPath );
2167#if defined(Q_OS_WIN)
2168 CPLSetConfigOption(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() );
2172 int myChangeFlag = 0;
2173 setenv(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag );
2180 if ( !qgisPrivateDbFile.exists() )
2184 QFile masterFile( qgisMasterDbFileName );
2190 bool isDbFileCopied = masterFile.copy( qgisPrivateDbFile.fileName() );
2192 if ( !isDbFileCopied )
2196 *errorMessage = tr(
"[ERROR] Can not make qgis.db private copy" );
2201 QFile::Permissions perms = QFile( qgisPrivateDbFile.fileName() ).permissions();
2202 if ( !( perms & QFile::WriteOwner ) )
2204 if ( !qgisPrivateDbFile.setPermissions( perms | QFile::WriteOwner ) )
2208 *errorMessage = tr(
"Can not make '%1' user writable" ).arg( qgisPrivateDbFile.fileName() );
2222 *errorMessage = tr(
"Could not open qgis.db" );
2227 char *errmsg =
nullptr;
2228 int res = sqlite3_exec( database.get(),
"SELECT srs_id FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2229 if ( res != SQLITE_OK )
2231 sqlite3_free( errmsg );
2234 if ( sqlite3_exec( database.get(),
2235 "DROP INDEX IF EXISTS idx_srsauthid;"
2236 "CREATE TABLE tbl_srs ("
2237 "srs_id INTEGER PRIMARY KEY,"
2238 "description text NOT NULL,"
2239 "projection_acronym text NOT NULL,"
2240 "ellipsoid_acronym NOT NULL,"
2241 "parameters text NOT NULL,"
2243 "auth_name varchar,"
2245 "is_geo integer NOT NULL,"
2246 "deprecated boolean,"
2248 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2252 *errorMessage = tr(
"Creation of missing tbl_srs in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2254 sqlite3_free( errmsg );
2261 res = sqlite3_exec( database.get(),
"SELECT wkt FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2262 if ( res != SQLITE_OK )
2265 sqlite3_free( errmsg );
2266 if ( sqlite3_exec( database.get(),
2267 "DROP INDEX IF EXISTS idx_srsauthid;"
2268 "DROP TABLE IF EXISTS tbl_srs_bak;"
2269 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2270 "CREATE TABLE tbl_srs ("
2271 "srs_id INTEGER PRIMARY KEY,"
2272 "description text NOT NULL,"
2273 "projection_acronym text NOT NULL,"
2274 "ellipsoid_acronym NOT NULL,"
2275 "parameters text NOT NULL,"
2277 "auth_name varchar,"
2279 "is_geo integer NOT NULL,"
2280 "deprecated boolean,"
2282 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2283 "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;"
2284 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2288 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2290 sqlite3_free( errmsg );
2296 res = sqlite3_exec( database.get(),
"SELECT acronym FROM tbl_projection LIMIT 0",
nullptr,
nullptr, &errmsg );
2297 if ( res != SQLITE_OK )
2299 sqlite3_free( errmsg );
2302 if ( sqlite3_exec( database.get(),
2303 "CREATE TABLE tbl_projection ("
2304 "acronym varchar(20) NOT NULL PRIMARY KEY,"
2305 "name varchar(255) NOT NULL default '',"
2306 "notes varchar(255) NOT NULL default '',"
2307 "parameters varchar(255) NOT NULL default ''"
2308 ")",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2312 *errorMessage = tr(
"Creation of missing tbl_projection in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2314 sqlite3_free( errmsg );
2319 res = sqlite3_exec( database.get(),
"SELECT epsg FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2320 if ( res == SQLITE_OK )
2323 if ( sqlite3_exec( database.get(),
2324 "DROP INDEX IF EXISTS idx_srsauthid;"
2325 "DROP TABLE IF EXISTS tbl_srs_bak;"
2326 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2327 "CREATE TABLE tbl_srs ("
2328 "srs_id INTEGER PRIMARY KEY,"
2329 "description text NOT NULL,"
2330 "projection_acronym text NOT NULL,"
2331 "ellipsoid_acronym NOT NULL,"
2332 "parameters text NOT NULL,"
2334 "auth_name varchar,"
2336 "is_geo integer NOT NULL,"
2337 "deprecated boolean,"
2339 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2340 "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;"
2341 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2345 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2347 sqlite3_free( errmsg );
2353 sqlite3_free( errmsg );
2356 if ( sqlite3_exec( database.get(),
"DROP VIEW vw_srs",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2358 QgsDebugError( QStringLiteral(
"vw_srs didn't exists in private qgis.db: %1" ).arg( errmsg ) );
2361 if ( sqlite3_exec( database.get(),
2362 "CREATE VIEW vw_srs AS"
2364 " a.description AS description"
2365 ",a.srs_id AS srs_id"
2366 ",a.is_geo AS is_geo"
2367 ",coalesce(b.name,a.projection_acronym) AS name"
2368 ",a.parameters AS parameters"
2369 ",a.auth_name AS auth_name"
2370 ",a.auth_id AS auth_id"
2371 ",a.deprecated AS deprecated"
2373 " LEFT OUTER JOIN tbl_projection b ON a.projection_acronym=b.acronym"
2374 " ORDER BY coalesce(b.name,a.projection_acronym),a.description",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2378 *errorMessage = tr(
"Update of view in private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2380 sqlite3_free( errmsg );
2392 if ( maxThreads < 1 || maxThreads > QThread::idealThreadCount() )
2407 QThreadPool::globalInstance()->setMaxThreadCount(
maxThreads );
2408 QgsDebugMsgLevel( QStringLiteral(
"set QThreadPool max thread count to %1" ).arg( QThreadPool::globalInstance()->maxThreadCount() ), 2 );
2413 return members()->mTaskManager;
2418 return members()->mSettingsRegistryCore;
2423 return members()->mColorSchemeRegistry;
2428 return members()->mPaintEffectRegistry;
2433 return members()->mRendererRegistry;
2438 return members()->mRasterRendererRegistry;
2443 return members()->mPointCloudRendererRegistry;
2448 return members()->mTiledSceneRendererRegistry;
2453 if (
auto *lInstance =
instance() )
2455 if ( !
instance()->mDataItemProviderRegistry )
2459 return lInstance->mDataItemProviderRegistry;
2465 if ( !sDataItemProviderRegistry )
2467 return sDataItemProviderRegistry;
2473 return members()->mCrsRegistry;
2478 return members()->mSvgCache;
2483 return members()->mImageCache;
2488 return members()->mSourceCache;
2493 return members()->mNetworkContentFetcherRegistry;
2498 return members()->mValidityCheckRegistry;
2503 return members()->mSymbolLayerRegistry;
2508 return members()->mCalloutRegistry;
2513 return members()->mLayoutItemRegistry;
2518 return members()->mAnnotationItemRegistry;
2523 return members()->mSensorRegistry;
2528 return members()->mGpsConnectionRegistry;
2533 return members()->mGpsBabelFormatRegistry;
2538 return members()->mPluginLayerRegistry;
2543 return members()->mClassificationMethodRegistry;
2548 return members()->mBookmarkManager;
2553 return members()->mTileDownloadManager;
2558 return members()->mRecentStyleHandler;
2563 return members()->mQueryLogger;
2568 return members()->mStyleModel;
2573 return members()->mFontManager;
2578 return members()->mMessageLog;
2583 return members()->mProcessingRegistry;
2588 return members()->mConnectionRegistry;
2593 return members()->mLayerMetadataProviderRegistry;
2598 return members()->mPageSizeRegistry;
2603 return members()->mAnnotationRegistry;
2608 return members()->mNumericFormatRegistry;
2613 return members()->mFieldFormatterRegistry;
2618 return members()->m3DRendererRegistry;
2623 return members()->m3DSymbolRegistry;
2628 return members()->mScaleBarRendererRegistry;
2633 return members()->mProjectStorageRegistry;
2638 return members()->mExternalStorageRegistry;
2643 return members()->mLocalizedDataPathRegistry;
2646QgsApplication::ApplicationMembers::ApplicationMembers()
2656 profiler->
start( tr(
"Create query logger" ) );
2661 profiler->
start( tr(
"Setup coordinate reference system registry" ) );
2666 profiler->
start( tr(
"Create connection registry" ) );
2671 profiler->
start( tr(
"Create project storage registry" ) );
2676 profiler->
start( tr(
"Create layer metadata provider registry" ) );
2681 profiler->
start( tr(
"Create font manager" ) );
2686 profiler->
start( tr(
"Setup task manager" ) );
2691 profiler->
start( tr(
"Setup action scope registry" ) );
2696 profiler->
start( tr(
"Setup numeric formats" ) );
2701 profiler->
start( tr(
"Setup field formats" ) );
2706 profiler->
start( tr(
"Setup SVG cache" ) );
2711 profiler->
start( tr(
"Setup image cache" ) );
2716 profiler->
start( tr(
"Setup source cache" ) );
2721 profiler->
start( tr(
"Setup color scheme registry" ) );
2726 profiler->
start( tr(
"Setup paint effect" ) );
2731 profiler->
start( tr(
"Setup symbol layer registry" ) );
2736 profiler->
start( tr(
"Recent style handler" ) );
2741 profiler->
start( tr(
"Setup callout registry" ) );
2746 profiler->
start( tr(
"Setup renderer registry" ) );
2751 profiler->
start( tr(
"Setup raster renderer registry" ) );
2756 profiler->
start( tr(
"Setup point cloud renderer registry" ) );
2761 profiler->
start( tr(
"Setup tiled scene renderer registry" ) );
2766 profiler->
start( tr(
"Setup GPS registry" ) );
2771 profiler->
start( tr(
"Setup GPSBabel format registry" ) );
2776 profiler->
start( tr(
"Setup plugin layer registry" ) );
2781 profiler->
start( tr(
"Setup Processing registry" ) );
2787 profiler->
start( tr(
"Setup layout item registry" ) );
2789 mLayoutItemRegistry->populate();
2793 profiler->
start( tr(
"Setup annotation registry" ) );
2794 mAnnotationRegistry =
new QgsAnnotationRegistry();
2798 profiler->
start( tr(
"Setup annotation item registry" ) );
2800 mAnnotationItemRegistry->populate();
2804 profiler->
start( tr(
"Setup sensor registry" ) );
2806 mSensorRegistry->populate();
2810 profiler->
start( tr(
"Setup 3D symbol registry" ) );
2815 profiler->
start( tr(
"Setup 3D renderer registry" ) );
2820 profiler->
start( tr(
"Setup external storage registry" ) );
2825 profiler->
start( tr(
"Setup network content cache" ) );
2830 profiler->
start( tr(
"Setup layout check registry" ) );
2835 profiler->
start( tr(
"Setup classification registry" ) );
2840 profiler->
start( tr(
"Setup bookmark manager" ) );
2845 profiler->
start( tr(
"Setup tile download manager" ) );
2850 profiler->
start( tr(
"Setup scalebar registry" ) );
2856QgsApplication::ApplicationMembers::~ApplicationMembers()
2859 delete mTileDownloadManager;
2860 delete mScaleBarRendererRegistry;
2861 delete mValidityCheckRegistry;
2862 delete mActionScopeRegistry;
2863 delete m3DRendererRegistry;
2864 delete m3DSymbolRegistry;
2865 delete mAnnotationRegistry;
2866 delete mColorSchemeRegistry;
2867 delete mFieldFormatterRegistry;
2868 delete mGpsConnectionRegistry;
2869 delete mGpsBabelFormatRegistry;
2871 delete mPaintEffectRegistry;
2872 delete mPluginLayerRegistry;
2873 delete mProcessingRegistry;
2874 delete mPageSizeRegistry;
2875 delete mAnnotationItemRegistry;
2876 delete mSensorRegistry;
2877 delete mLayoutItemRegistry;
2878 delete mPointCloudRendererRegistry;
2879 delete mTiledSceneRendererRegistry;
2880 delete mRasterRendererRegistry;
2881 delete mRendererRegistry;
2884 delete mSourceCache;
2885 delete mCalloutRegistry;
2886 delete mRecentStyleHandler;
2887 delete mSymbolLayerRegistry;
2888 delete mExternalStorageRegistry;
2889 delete mTaskManager;
2890 delete mNetworkContentFetcherRegistry;
2891 delete mClassificationMethodRegistry;
2892 delete mNumericFormatRegistry;
2893 delete mBookmarkManager;
2894 delete mConnectionRegistry;
2895 delete mProjectStorageRegistry;
2896 delete mLayerMetadataProviderRegistry;
2897 delete mFontManager;
2898 delete mLocalizedDataPathRegistry;
2899 delete mCrsRegistry;
2900 delete mQueryLogger;
2901 delete mSettingsRegistryCore;
2904QgsApplication::ApplicationMembers *QgsApplication::members()
2906 if (
auto *lInstance =
instance() )
2908 return lInstance->mApplicationMembers;
2912 static QRecursiveMutex sMemberMutex;
2913 QMutexLocker lock( &sMemberMutex );
2914 if ( !sApplicationMembers )
2915 sApplicationMembers =
new ApplicationMembers();
2916 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 QgsSensorRegistry * sensorRegistry()
Returns the application's sensor registry, used for sensor types.
static QString pluginPath()
Returns the path to the application plugin directory.
static void setUITheme(const QString &themeName)
Set the current UI theme used to style the interface.
static bool createDatabase(QString *errorMessage=nullptr)
initialize qgis.db
static const QgsSettingsEntryBool * settingsLocaleOverrideFlag
Settings entry locale override flag.
static 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 QgsTiledSceneRendererRegistry * tiledSceneRendererRegistry()
Returns the application's tiled scene renderer registry, used for managing tiled scene layer 2D rende...
static void setDefaultSvgPaths(const QStringList &pathList)
Alters default svg paths - used by 3rd party apps.
static QString libraryPath()
Returns the path containing qgis_core, qgis_gui, qgispython (and other) libraries.
static QStringList layoutTemplatePaths()
Returns the paths to layout template directories.
static const QgsSettingsEntryBool * settingsLocaleShowGroupSeparator
Settings entry locale show group separator.
static QString userFullName()
Returns the user's operating system login account full display name.
static Q_DECL_DEPRECATED QgsSettingsRegistryCore * settingsRegistryCore()
Returns the application's settings registry, used for managing application settings.
static QString serverResourcesPath()
Returns the path to the server resources directory.
static QString appIconPath()
Gets application icon.
static 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...
void setup(const QString &pluginPath=QString(), const QString &authDatabasePath=QString())
Sets up the authentication manager configuration.
static QgsAuthManager * instance()
Enforce singleton pattern.
Manages storage of a set of bookmarks.
void initialize(const QString &filePath)
Initializes the bookmark manager.
Registry of available callout classes.
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 start(const QString &name, const QString &group="startup", const QString &id=QString())
Start a profile event with the given name.
void end(const QString &group="startup")
End the current profile event.
The QgsScaleBarRendererRegistry manages registered scalebar renderers.
Scoped object for logging of the runtime for a single operation or group of operations.
Registry of available sensor types.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
bool setValue(const T &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
A boolean settings entry.
A string list settings entry.
QgsSettingsRegistryCore is used for settings introspection and collects all QgsSettingsEntry instance...
static QgsSettingsTreeNode * sTreeLocale
static QgsSettingsTreeNode * sTreeSvg
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(bool initialize=true)
Returns the default application-wide style.
A cache for images / pictures derived from SVG files.
QImage svgAsImage(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, bool &fitsInCache, double fixedAspectRatio=0, bool blocking=false, const QMap< QString, QString > ¶meters=QMap< QString, QString >())
Returns an SVG drawing as a QImage.
QByteArray svgContent(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, double fixedAspectRatio=0, bool blocking=false, const QMap< QString, QString > ¶meters=QMap< QString, QString >(), bool *isMissingImage=nullptr)
Gets the SVG content corresponding to the given path.
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.
Registry of 2D renderers for tiled scenes.
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,({ static_cast< int >(QgsPalLayerSettings::Property::PositionX), static_cast< int >(QgsPalLayerSettings::Property::PositionY), static_cast< int >(QgsPalLayerSettings::Property::Show), static_cast< int >(QgsPalLayerSettings::Property::LabelRotation), static_cast< int >(QgsPalLayerSettings::Property::Family), static_cast< int >(QgsPalLayerSettings::Property::FontStyle), static_cast< int >(QgsPalLayerSettings::Property::Size), static_cast< int >(QgsPalLayerSettings::Property::Bold), static_cast< int >(QgsPalLayerSettings::Property::Italic), static_cast< int >(QgsPalLayerSettings::Property::Underline), static_cast< int >(QgsPalLayerSettings::Property::Color), static_cast< int >(QgsPalLayerSettings::Property::Strikeout), static_cast< int >(QgsPalLayerSettings::Property::MultiLineAlignment), static_cast< int >(QgsPalLayerSettings::Property::BufferSize), static_cast< int >(QgsPalLayerSettings::Property::BufferDraw), static_cast< int >(QgsPalLayerSettings::Property::BufferColor), static_cast< int >(QgsPalLayerSettings::Property::LabelDistance), static_cast< int >(QgsPalLayerSettings::Property::Hali), static_cast< int >(QgsPalLayerSettings::Property::Vali), static_cast< int >(QgsPalLayerSettings::Property::ScaleVisibility), static_cast< int >(QgsPalLayerSettings::Property::MinScale), static_cast< int >(QgsPalLayerSettings::Property::MaxScale), static_cast< int >(QgsPalLayerSettings::Property::AlwaysShow), static_cast< int >(QgsPalLayerSettings::Property::CalloutDraw), static_cast< int >(QgsPalLayerSettings::Property::LabelAllParts) })) Q_GLOBAL_STATIC_WITH_ARGS(SymbolPropertyList
Q_GLOBAL_STATIC(QReadWriteLock, sDefinitionCacheLock)
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)