17#include "moc_qgsapplication.cpp"
107#include <QFileOpenEvent>
108#include <QMessageBox>
111#include <QProcessEnvironment>
114#include <QThreadPool>
117#include <QLibraryInfo>
118#include <QStandardPaths>
119#include <QRegularExpression>
120#include <QTextStream>
122#include <QAuthenticator>
123#include <QRecursiveMutex>
124#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
125#include <QImageReader>
141#include <netinet/in.h>
147#define SECURITY_WIN32
150#pragma comment( lib, "Secur32.lib" )
154#include "qgsconfig.h"
164#if defined(Q_OS_LINUX)
165#include <sys/sysinfo.h>
168#define CONN_POOL_MAX_CONCURRENT_CONNS 4
170QObject *
ABISYM( QgsApplication::mFileOpenEventReceiver ) =
nullptr;
171bool ABISYM( QgsApplication::mInitialized ) =
false;
172bool ABISYM( QgsApplication::mRunningFromBuildDir ) =
false;
176QgsApplication::ApplicationMembers *QgsApplication::sApplicationMembers =
nullptr;
178int ABISYM( QgsApplication::sMaxThreads ) = -1;
195#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
213 : QApplication( argc, argv, GUIenabled )
215 *sPlatformName() = platformName;
220 if ( platformName != QLatin1String(
"desktop" ) )
222 mApplicationMembers = std::make_unique<ApplicationMembers>();
223 mApplicationMembers->mSettingsRegistryCore->migrateOldSettings();
227 *sProfilePath() = profileFolder;
234 qRegisterMetaType<QgsGeometry::Error>(
"QgsGeometry::Error" );
235 qRegisterMetaType<QgsDatabaseQueryLogEntry>(
"QgsDatabaseQueryLogEntry" );
236 qRegisterMetaType<QgsProcessingFeatureSourceDefinition>(
"QgsProcessingFeatureSourceDefinition" );
237 qRegisterMetaType<QgsProcessingOutputLayerDefinition>(
"QgsProcessingOutputLayerDefinition" );
238 qRegisterMetaType<Qgis::LayoutUnit>(
"Qgis::LayoutUnit" );
239 qRegisterMetaType<QgsUnsetAttributeValue>(
"QgsUnsetAttributeValue" );
240 qRegisterMetaType<QgsFeatureId>(
"QgsFeatureId" );
241 qRegisterMetaType<QgsFields>(
"QgsFields" );
242 qRegisterMetaType<QgsFeatureIds>(
"QgsFeatureIds" );
243 qRegisterMetaType<QgsProperty>(
"QgsProperty" );
244 qRegisterMetaType<QgsFeatureStoreList>(
"QgsFeatureStoreList" );
245 qRegisterMetaType<Qgis::MessageLevel>(
"Qgis::MessageLevel" );
246 qRegisterMetaType<Qgis::BrowserItemState>(
"Qgis::BrowserItemState" );
247 qRegisterMetaType<Qgis::GpsFixStatus>(
"Qgis::GpsFixStatus" );
248 qRegisterMetaType<QgsReferencedRectangle>(
"QgsReferencedRectangle" );
249 qRegisterMetaType<QgsReferencedPointXY>(
"QgsReferencedPointXY" );
250 qRegisterMetaType<QgsReferencedGeometry>(
"QgsReferencedGeometry" );
251 qRegisterMetaType<Qgis::LayoutRenderFlags>(
"Qgis::LayoutRenderFlags" );
252 qRegisterMetaType<QgsStyle::StyleEntity>(
"QgsStyle::StyleEntity" );
253 qRegisterMetaType<QgsCoordinateReferenceSystem>(
"QgsCoordinateReferenceSystem" );
254 qRegisterMetaType<QgsAuthManager::MessageLevel>(
"QgsAuthManager::MessageLevel" );
255 qRegisterMetaType<QgsNetworkRequestParameters>(
"QgsNetworkRequestParameters" );
256 qRegisterMetaType<QgsNetworkReplyContent>(
"QgsNetworkReplyContent" );
257 qRegisterMetaType<QgsFeature>(
"QgsFeature" );
258 qRegisterMetaType<QgsGeometry>(
"QgsGeometry" );
259 qRegisterMetaType<QgsInterval>(
"QgsInterval" );
260 qRegisterMetaType<QgsRectangle>(
"QgsRectangle" );
261 qRegisterMetaType<QgsPointXY>(
"QgsPointXY" );
262 qRegisterMetaType<QgsPoint>(
"QgsPoint" );
263 qRegisterMetaType<QgsDatumTransform::GridDetails>(
"QgsDatumTransform::GridDetails" );
264 qRegisterMetaType<QgsDatumTransform::TransformDetails>(
"QgsDatumTransform::TransformDetails" );
265 qRegisterMetaType<QgsNewsFeedParser::Entry>(
"QgsNewsFeedParser::Entry" );
266 qRegisterMetaType<QgsRectangle>(
"QgsRectangle" );
267 qRegisterMetaType<QgsLocatorResult>(
"QgsLocatorResult" );
268 qRegisterMetaType<QgsGradientColorRamp>(
"QgsGradientColorRamp" );
269 qRegisterMetaType<QgsProcessingModelChildParameterSource>(
"QgsProcessingModelChildParameterSource" );
270#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
273 qRegisterMetaTypeStreamOperators<QgsProcessingModelChildParameterSource>(
"QgsProcessingModelChildParameterSource" );
275 qRegisterMetaType<QgsRemappingSinkDefinition>(
"QgsRemappingSinkDefinition" );
276 qRegisterMetaType<QgsProcessingModelChildDependency>(
"QgsProcessingModelChildDependency" );
277 qRegisterMetaType<QgsTextFormat>(
"QgsTextFormat" );
278#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
279 QMetaType::registerComparators<QgsProcessingModelChildDependency>();
280 QMetaType::registerEqualsComparator<QgsProcessingFeatureSourceDefinition>();
281 QMetaType::registerEqualsComparator<QgsProperty>();
282 QMetaType::registerEqualsComparator<QgsDateTimeRange>();
283 QMetaType::registerEqualsComparator<QgsDateRange>();
284 QMetaType::registerEqualsComparator<QgsUnsetAttributeValue>();
286 qRegisterMetaType<QPainter::CompositionMode>(
"QPainter::CompositionMode" );
287 qRegisterMetaType<QgsDateTimeRange>(
"QgsDateTimeRange" );
288 qRegisterMetaType<QgsDoubleRange>(
"QgsDoubleRange" );
289 qRegisterMetaType<QgsIntRange>(
"QgsIntRange" );
290 qRegisterMetaType<QList<QgsMapLayer *>>(
"QList<QgsMapLayer*>" );
291 qRegisterMetaType<QMap<QNetworkRequest::Attribute, QVariant>>(
"QMap<QNetworkRequest::Attribute,QVariant>" );
292 qRegisterMetaType<QMap<QNetworkRequest::KnownHeaders, QVariant>>(
"QMap<QNetworkRequest::KnownHeaders,QVariant>" );
293 qRegisterMetaType<QList<QNetworkReply::RawHeaderPair>>(
"QList<QNetworkReply::RawHeaderPair>" );
294 qRegisterMetaType< QAuthenticator * >(
"QAuthenticator*" );
295 qRegisterMetaType< QgsGpsInformation >(
"QgsGpsInformation" );
296 qRegisterMetaType< QgsSensorThingsExpansionDefinition >(
"QgsSensorThingsExpansionDefinition" );
302 if (
platform() == QLatin1String(
"desktop" ) )
304 instance()->mApplicationMembers = std::make_unique<ApplicationMembers>();
305 instance()->mApplicationMembers->mSettingsRegistryCore->migrateOldSettings();
308 if ( profileFolder.isEmpty() )
310 if ( getenv(
"QGIS_CUSTOM_CONFIG_PATH" ) )
312 profileFolder = getenv(
"QGIS_CUSTOM_CONFIG_PATH" );
316 profileFolder = QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ).value( 0 );
323 profileFolder = profile->
folder();
327 *sProfilePath() = profileFolder;
329 static std::once_flag sMetaTypesRegistered;
334 if ( ABISYM( mRunningFromBuildDir ) )
337 *sPrefixPath() = QString();
338#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
339 setPluginPath( *sBuildOutputPath() +
'/' + QString( QGIS_PLUGIN_SUBDIR ) +
'/' + *sCfgIntDir() );
341 setPluginPath( *sBuildOutputPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
343 setPkgDataPath( *sBuildOutputPath() + QStringLiteral(
"/data" ) );
344 *sLibraryPath() = *sBuildOutputPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
345#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
346 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/' + *sCfgIntDir() +
'/';
348 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
350#if defined( HAVE_QUICK )
351 *sQmlImportPath() = *sBuildOutputPath() +
'/' + QGIS_QML_SUBDIR +
'/';
356 char *
prefixPath = getenv(
"QGIS_PREFIX_PATH" );
359 if ( sPrefixPath()->isNull() )
361#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
363#elif defined(ANDROID)
365 QDir myDir( QDir::homePath() );
367 QString myPrefix = myDir.absolutePath();
370 QDir myDir( applicationDirPath() );
372 if ( applicationDirPath().contains( QStringLiteral(
"cgi-bin" ) ) )
377 QString myPrefix = myDir.absolutePath();
388 *sConfigPath() = profileFolder +
'/';
397 if ( getenv(
"QGIS_AUTH_DB_DIR_PATH" ) )
400 sAuthDbUri()->clear();
403 if ( getenv(
"QGIS_AUTH_DB_URI" ) )
405 *sAuthDbUri() = getenv(
"QGIS_AUTH_DB_URI" );
409 if ( sAuthDbUri->isEmpty() )
411 *sAuthDbUri() = QStringLiteral(
"QSQLITE://" ) + *sAuthDbDirPath() + QStringLiteral(
"qgis-auth.db" );
415 qputenv(
"QT3D_RENDERER",
"opengl" );
418 QMap<QString, QString> systemEnvVarMap;
419 QString passfile( QStringLiteral(
"QGIS_AUTH_PASSWORD_FILE" ) );
421 const auto systemEnvironment = QProcessEnvironment::systemEnvironment().toStringList();
422 for (
const QString &varStr : systemEnvironment )
424 int pos = varStr.indexOf( QLatin1Char(
'=' ) );
427 QString varStrName = varStr.left( pos );
428 QString varStrValue = varStr.mid( pos + 1 );
429 if ( varStrName != passfile )
431 systemEnvVarMap.insert( varStrName, varStrValue );
434 *sSystemEnvVars() = systemEnvVarMap;
441 QString projLib( QDir::cleanPath(
pkgDataPath().append(
"/proj" ) ) );
442 if ( QFile::exists( projLib ) )
444 currentProjSearchPaths.append( projLib );
448 char **newPaths =
new char *[currentProjSearchPaths.length()];
449 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
451 newPaths[i] = CPLStrdup( currentProjSearchPaths.at( i ).toUtf8().constData() );
453 proj_context_set_search_paths(
nullptr, currentProjSearchPaths.count(), newPaths );
454 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
456 CPLFree( newPaths[i] );
461 QCoreApplication::addLibraryPath(
pluginPath() );
463#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
465 QImageReader::setAllocationLimit( 512 );
476 ABISYM( sMaxThreads ) = -1;
492 if ( !members()->mStyleModel )
493 members()->mStyleModel = std::make_unique<QgsStyleModel>( defaultStyle );
495 ABISYM( mInitialized ) =
true;
499void QgsApplication::installTranslators()
502 if ( mQgisTranslator )
504 removeTranslator( mQgisTranslator.get() );
505 mQgisTranslator.reset( );
510 removeTranslator( mQtTranslator.get() );
511 mQtTranslator.reset( );
514 if ( mQtBaseTranslator )
516 removeTranslator( mQtBaseTranslator.get() );
517 mQtBaseTranslator.reset( );
521 if ( *sTranslation() != QLatin1String(
"C" ) )
523 mQgisTranslator = std::make_unique<QTranslator>(
this );
524 if ( mQgisTranslator->load( QStringLiteral(
"qgis_" ) + *sTranslation(),
i18nPath() ) )
526 installTranslator( mQgisTranslator.get() );
530 QgsDebugMsgLevel( QStringLiteral(
"loading of qgis translation failed %1/qgis_%2" ).arg(
i18nPath(), *sTranslation() ), 2 );
538 QString qtTranslationsPath = QLibraryInfo::location( QLibraryInfo::TranslationsPath );
540 QString prefix = QDir( QString(
"%1/../" ).arg( QApplication::applicationDirPath() ) ).absolutePath();
541 qtTranslationsPath = prefix + qtTranslationsPath.mid( QLibraryInfo::location( QLibraryInfo::PrefixPath ).length() );
544 mQtTranslator = std::make_unique<QTranslator>(
this );
545 if ( mQtTranslator->load( QStringLiteral(
"qt_" ) + *sTranslation(), qtTranslationsPath ) )
547 installTranslator( mQtTranslator.get() );
551 QgsDebugMsgLevel( QStringLiteral(
"loading of qt translation failed %1/qt_%2" ).arg( qtTranslationsPath, *sTranslation() ), 2 );
554 mQtBaseTranslator = std::make_unique<QTranslator>(
this );
555 if ( mQtBaseTranslator->load( QStringLiteral(
"qtbase_" ) + *sTranslation(), qtTranslationsPath ) )
557 installTranslator( mQtBaseTranslator.get() );
561 QgsDebugMsgLevel( QStringLiteral(
"loading of qtbase translation failed %1/qt_%2" ).arg( qtTranslationsPath, *sTranslation() ), 2 );
568 if ( mApplicationMembers )
569 mApplicationMembers->mSettingsRegistryCore->backwardCompatibility();
577void QgsApplication::invalidateCaches()
589 return qobject_cast<QgsApplication *>( QCoreApplication::instance() );
595 if (
event->type() == QEvent::FileOpen )
598 if ( ABISYM( mFileOpenEventReceiver ) )
601 done =
notify( ABISYM( mFileOpenEventReceiver ),
event );
608 sFileOpenEventList()->append(
static_cast<QFileOpenEvent *
>(
event )->file() );
615 done = QApplication::event(
event );
624 if ( thread() == receiver->thread() )
634 done = QApplication::notify( receiver,
event );
638 qCritical() <<
"Caught unhandled QgsException: " << e.
what();
639 if ( qApp->thread() == QThread::currentThread() )
640 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
642 catch ( std::exception &e )
644 qCritical() <<
"Caught unhandled std::exception: " << e.
what();
645 if ( qApp->thread() == QThread::currentThread() )
646 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
650 qCritical() <<
"Caught unhandled unknown exception";
651 if ( qApp->thread() == QThread::currentThread() )
652 QMessageBox::critical( activeWindow(), tr(
"Exception" ), tr(
"unknown exception" ) );
660 return QgsRuntimeProfiler::threadLocalInstance();
666 ABISYM( mFileOpenEventReceiver ) = receiver;
668 if ( sFileOpenEventList()->count() > 0 )
670 const QStringList fileOpenEventList = *sFileOpenEventList();
671 for (
const QString &file : fileOpenEventList )
673 QFileOpenEvent foe( file );
674 QgsApplication::sendEvent( ABISYM( mFileOpenEventReceiver ), &foe );
676 sFileOpenEventList()->clear();
684 if ( sPrefixPath()->endsWith(
"/bin" ) )
686 sPrefixPath()->chop( 4 );
689 if ( useDefaultPaths && !ABISYM( mRunningFromBuildDir ) )
691 setPluginPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
692 setPkgDataPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_DATA_SUBDIR ) );
694 *sLibraryPath() = *sPrefixPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
695 *sLibexecPath() = *sPrefixPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
696#if defined( HAVE_QUICK )
697 *sQmlImportPath() = *sPrefixPath() +
'/' + QGIS_QML_SUBDIR +
'/';
710 QString mySvgPath =
pkgDataPath + QStringLiteral(
"/svg/" );
713 if ( !sDefaultSvgPaths()->contains( mySvgPath ) )
714 *sDefaultSvgPaths() << mySvgPath;
719 *sDefaultSvgPaths() = pathList;
724 QFileInfo fi( authDbDirPath );
725 if ( fi.exists() && fi.isDir() && fi.isWritable() )
727 *sAuthDbDirPath() = fi.canonicalFilePath() + QDir::separator();
734 if ( ABISYM( mRunningFromBuildDir ) )
736 static bool sOnce =
true;
740 ( void ) blockNotifications;
741 qWarning(
"!!! prefix path was requested, but it is not valid - we do not run from installed path !!!" );
747 return *sPrefixPath();
751 return *sPluginPath();
756 if ( sPkgDataPath()->isNull() )
759 return *sPkgDataPath();
764 return QStringLiteral(
":/images/themes/default/" );
769 QDir dir( usersThemes );
777 return defaultThemes;
783 return iconsPath() + QStringLiteral(
"qgis-icon-60x60.png" );
788 return ABISYM( sMaxThreads );
795 if ( QFile::exists( path + iconFile ) )
796 return path + iconFile;
804 const QString cacheKey = ( name.startsWith(
'/' ) ? name.mid( 1 ) : name )
805 + ( fillColor.isValid() ? QStringLiteral(
"_%1" ).arg( fillColor.name( QColor::HexArgb ).mid( 1 ) ) : QString() )
806 + ( strokeColor.isValid() ? QStringLiteral(
"_%1" ).arg( strokeColor.name( QColor::HexArgb ).mid( 1 ) ) : QString() );
808 if ( app && app->mIconCache.contains( cacheKey ) )
809 return app->mIconCache.value( cacheKey );
812 const bool colorBased = fillColor.isValid() || strokeColor.isValid();
814 auto iconFromColoredSvg = [ = ](
const QString & path ) -> QIcon
819 const QString
iconPath = sIconCacheDir()->filePath( cacheKey + QStringLiteral(
".svg" ) );
820 if (
const QDir dir = QFileInfo(
iconPath ).dir(); !dir.exists() )
826 if ( f.open( QFile::WriteOnly | QFile::Truncate ) )
828 f.write( svgContent );
837 return QIcon( f.fileName() );
842 if ( QFile::exists( preferredPath ) )
846 icon = iconFromColoredSvg( preferredPath );
850 icon = QIcon( preferredPath );
853 else if ( QFile::exists( defaultPath ) )
859 icon = iconFromColoredSvg( defaultPath );
863 icon = QIcon( defaultPath );
872 app->mIconCache.insert( cacheKey, icon );
879 if ( app && app->mCursorCache.contains( cursor ) )
880 return app->mCursorCache.value( cursor );
891 name = QStringLiteral(
"mZoomIn.svg" );
896 name = QStringLiteral(
"mZoomOut.svg" );
903 name = QStringLiteral(
"mIdentify.svg" );
906 name = QStringLiteral(
"mCrossHair.svg" );
909 name = QStringLiteral(
"mCapturePoint.svg" );
912 name = QStringLiteral(
"mSelect.svg" );
919 name = QStringLiteral(
"mSampler.svg" );
924 Q_ASSERT( ! name.isEmpty( ) );
926 QIcon icon =
getThemeIcon( QStringLiteral(
"cursors" ) + QDir::separator() + name );
929 if ( ! icon.isNull( ) )
933 cursorIcon = QCursor( icon.pixmap( std::ceil( scale * 32 ), std::ceil( scale * 32 ) ), std::ceil( scale * activeX ), std::ceil( scale * activeY ) );
936 app->mCursorCache.insert( cursor, cursorIcon );
943 const QString preferredPath =
activeThemePath() + QDir::separator() + name;
945 const QString path = QFile::exists( preferredPath ) ? preferredPath : defaultPath;
946 if ( foreColor.isValid() || backColor.isValid() )
948 bool fitsInCache =
false;
949 const QImage image =
svgCache()->
svgAsImage( path, size, backColor, foreColor, 1, 1, fitsInCache );
950 return QPixmap::fromImage( image );
953 return QPixmap( path );
963 static QString appPath;
964 if ( appPath.isNull() )
966 if ( QCoreApplication::instance() )
968 appPath = applicationDirPath();
972 qWarning(
"Application path not initialized" );
976 if ( !appPath.isNull() || getenv(
"QGIS_PREFIX_PATH" ) )
978 QString prefix = getenv(
"QGIS_PREFIX_PATH" ) ? getenv(
"QGIS_PREFIX_PATH" ) : appPath;
983 static const QStringList paths { QStringList() << QString() << QStringLiteral(
"/.." ) << QStringLiteral(
"/bin" ) << QStringLiteral(
"/../../.." ) };
984 for (
const QString &path : paths )
986 f.setFileName( prefix + path +
"/qgisbuildpath.txt" );
990 if ( f.exists() && f.open( QIODevice::ReadOnly ) )
992 ABISYM( mRunningFromBuildDir ) =
true;
993 *sBuildSourcePath() = f.readLine().trimmed();
994 *sBuildOutputPath() = f.readLine().trimmed();
996 QgsDebugMsgLevel( QStringLiteral(
"- source directory: %1" ).arg( sBuildSourcePath()->toUtf8().constData() ), 4 );
997 QgsDebugMsgLevel( QStringLiteral(
"- output directory of the build: %1" ).arg( sBuildOutputPath()->toUtf8().constData() ), 4 );
998#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
999 *sCfgIntDir() = prefix.split(
'/', Qt::SkipEmptyParts ).last();
1000 qDebug(
"- cfg: %s", sCfgIntDir()->toUtf8().constData() );
1006 if ( getenv(
"QGIS_PREFIX_PATH" ) )
1012 QDir dir( QDir::homePath() );
1017#if defined(Q_OS_MACOS)
1019#elif defined(Q_OS_WIN)
1024 QDir dir( appPath );
1026 if ( appPath.contains( QStringLiteral(
"cgi-bin" ) ) )
1036 if ( ABISYM( mRunningFromBuildDir ) )
1037 return *sBuildOutputPath() + QStringLiteral(
"/data" );
1039 return prefixPath +
'/' + QStringLiteral( QGIS_DATA_SUBDIR );
1044 return *sThemeName();
1054 qApp->setStyleSheet( QString() );
1058 QString path = themes.value(
themeName );
1059 QString stylesheetname = path +
"/style.qss";
1061 QFile file( stylesheetname );
1062 QFile variablesfile( path +
"/variables.qss" );
1064 QFileInfo variableInfo( variablesfile );
1066 if ( !file.open( QIODevice::ReadOnly ) || ( variableInfo.exists() && !variablesfile.open( QIODevice::ReadOnly ) ) )
1071 QString styledata = file.readAll();
1072 styledata.replace( QLatin1String(
"@theme_path" ), path );
1074 if ( variableInfo.exists() )
1076 QTextStream in( &variablesfile );
1077 while ( !in.atEnd() )
1079 QString line = in.readLine();
1081 if ( line.startsWith(
'@' ) )
1083 int index = line.indexOf(
':' );
1084 QString name = line.mid( 0, index );
1085 QString value = line.mid( index + 1, line.length() );
1086 styledata.replace( name, value );
1089 variablesfile.close();
1097 const static QRegularExpression regex( QStringLiteral(
"(?<=[\\s:])([0-9\\.]+)(?=em)" ) );
1098 QRegularExpressionMatch match = regex.match( styledata, index );
1099 while ( match.hasMatch() )
1101 index = match.capturedStart();
1102 styledata.remove( index, match.captured( 0 ).length() );
1104 styledata.insert( index, number );
1105 index += number.length();
1106 match = regex.match( styledata, index );
1110 qApp->setStyleSheet( styledata );
1112 QFile palettefile( path +
"/palette.txt" );
1113 QFileInfo paletteInfo( palettefile );
1114 if ( paletteInfo.exists() && palettefile.open( QIODevice::ReadOnly ) )
1116 QPalette
pal = qApp->palette();
1117 QTextStream in( &palettefile );
1118 while ( !in.atEnd() )
1120 QString line = in.readLine();
1121 QStringList parts = line.split(
':' );
1122 if ( parts.count() == 2 )
1124 int role = parts.at( 0 ).trimmed().toInt();
1126 pal.setColor(
static_cast< QPalette::ColorRole
>( role ), color );
1129 palettefile.close();
1130 qApp->setPalette(
pal );
1139 QHash<QString, QString> mapping;
1140 mapping.insert( QStringLiteral(
"default" ), QString() );
1141 const auto constPaths = paths;
1142 for (
const QString &path : constPaths )
1144 QDir folder( path );
1145 QFileInfoList styleFiles = folder.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
1146 const auto constStyleFiles = styleFiles;
1147 for (
const QFileInfo &info : constStyleFiles )
1149 QFileInfo styleFile( info.absoluteFilePath() +
"/style.qss" );
1150 if ( !styleFile.exists() )
1153 QString name = info.baseName();
1154 QString path = info.absoluteFilePath();
1155 mapping.insert( name, path );
1163 return pkgDataPath() + QStringLiteral(
"/doc/AUTHORS" );
1168 return pkgDataPath() + QStringLiteral(
"/doc/CONTRIBUTORS" );
1172 return pkgDataPath() + QStringLiteral(
"/doc/developersmap.html" );
1177 return pkgDataPath() + QStringLiteral(
"/doc/SPONSORS" );
1182 return pkgDataPath() + QStringLiteral(
"/doc/DONORS" );
1187 return pkgDataPath() + QStringLiteral(
"/doc/TRANSLATORS" );
1192 return pkgDataPath() + QStringLiteral(
"/doc/LICENSE" );
1197 if ( ABISYM( mRunningFromBuildDir ) )
1198 return *sBuildOutputPath() + QStringLiteral(
"/i18n/" );
1200 return pkgDataPath() + QStringLiteral(
"/i18n/" );
1205 return pkgDataPath() + QStringLiteral(
"/resources/metadata-ISO/" );
1210 return pkgDataPath() + QStringLiteral(
"/resources/qgis.db" );
1215 return *sConfigPath();
1225 return *sAuthDbDirPath() + QStringLiteral(
"qgis-auth.db" );
1230 return *sAuthDbUri();
1235 return QStringLiteral(
":/images/splash/" );
1240 return pkgDataPath() + QStringLiteral(
"/images/icons/" );
1245 if ( ABISYM( mRunningFromBuildDir ) )
1247 QString tempCopy = QDir::tempPath() +
"/srs6.db";
1249 if ( !QFile( tempCopy ).exists() )
1252 if ( !f.copy( tempCopy ) )
1254 qFatal(
"Could not create temporary copy" );
1262 return pkgDataPath() + QStringLiteral(
"/resources/srs.db" );
1269 members()->mSvgPathCacheValid =
false;
1274 static QReadWriteLock lock;
1278 if ( members()->mSvgPathCacheValid )
1280 return members()->mSvgPathCache;
1291 for (
const QString &path : pathList )
1293 if ( !paths.contains( path ) )
1294 paths.append( path );
1296 for (
const QString &path : std::as_const( *sDefaultSvgPaths() ) )
1298 if ( !paths.contains( path ) )
1299 paths.append( path );
1301 members()->mSvgPathCache = paths;
1316 return *sSystemEnvVars();
1326 const thread_local QRegularExpression regexp( QRegularExpression::anchoredPattern( QStringLiteral(
"^[A-Za-z][A-Za-z0-9\\._-]*" ) ) );
1332 if ( !sUserName()->isEmpty() )
1333 return *sUserName();
1336 TCHAR name [ UNLEN + 1 ];
1337 DWORD size = UNLEN + 1;
1339 if ( GetUserName( ( TCHAR * )name, &size ) )
1341#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
1342 *sUserName() = QString::fromLocal8Bit( name );
1344 *sUserName() = QString::fromWCharArray( name );
1349#elif QT_CONFIG(process)
1352 process.start( QStringLiteral(
"whoami" ), QStringList() );
1353 process.waitForFinished();
1354 *sUserName() = process.readAllStandardOutput().trimmed();
1357 if ( !sUserName()->isEmpty() )
1358 return *sUserName();
1361 *sUserName() = qgetenv(
"USER" );
1362 if ( !sUserName()->isEmpty() )
1363 return *sUserName();
1366 *sUserName() = qgetenv(
"USERNAME" );
1367 return *sUserName();
1372 if ( !sUserFullName()->isEmpty() )
1373 return *sUserFullName();
1376 TCHAR name [ UNLEN + 1 ];
1377 DWORD size = UNLEN + 1;
1380 if ( GetUserNameEx( NameDisplay, ( TCHAR * )name, &size ) )
1382#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
1383 *sUserFullName() = QString::fromLocal8Bit( name );
1385 *sUserFullName() = QString::fromWCharArray( name );
1390 if ( sUserFullName()->isEmpty() )
1392#elif defined(Q_OS_ANDROID) || defined(__MINGW32__)
1393 *sUserFullName() = QStringLiteral(
"Not available" );
1395 struct passwd *p = getpwuid( getuid() );
1399 QString gecosName = QString( p->pw_gecos );
1400 *sUserFullName() = gecosName.left( gecosName.indexOf(
',', 0 ) );
1405 return *sUserFullName();
1410#if defined(Q_OS_ANDROID)
1411 return QLatin1String(
"android" );
1412#elif defined(Q_OS_MAC)
1413 return QLatin1String(
"osx" );
1414#elif defined(Q_OS_WIN)
1415 return QLatin1String(
"windows" );
1416#elif defined(Q_OS_LINUX)
1417 return QStringLiteral(
"linux" );
1418#elif defined(Q_OS_FREEBSD)
1419 return QStringLiteral(
"freebsd" );
1420#elif defined(Q_OS_OPENBSD)
1421 return QStringLiteral(
"openbsd" );
1422#elif defined(Q_OS_NETBSD)
1423 return QStringLiteral(
"netbsd" );
1424#elif defined(Q_OS_UNIX)
1425 return QLatin1String(
"unix" );
1427 return QLatin1String(
"unknown" );
1434 return static_cast<int>( CPLGetUsablePhysicalRAM() / 1048576 );
1439 return *sPlatformName();
1444 if ( !sApplicationFullName()->isEmpty() )
1445 return *sApplicationFullName();
1448 *sApplicationFullName() = qgetenv(
"QGIS_APPLICATION_FULL_NAME" );
1449 if ( !sApplicationFullName()->isEmpty() )
1450 return *sApplicationFullName();
1454 *sApplicationFullName() = settings.
value(
1455 QStringLiteral(
"/qgis/application_full_name" ),
1456 QStringLiteral(
"%1 %2" ).arg( applicationName(),
platform() )
1458 return *sApplicationFullName();
1467 if (
locale.startsWith( QLatin1String(
"en" ), Qt::CaseInsensitive ) )
1476 return QLocale().name().left( 2 );
1482 QLocale::setDefault(
locale );
1493 return pkgDataPath() + QStringLiteral(
"/resources/symbology-style.xml" );
1498 return pkgDataPath() + QStringLiteral(
"/resources/themes" );
1503 return pkgDataPath() + QStringLiteral(
"/resources/server/" );
1508 return *sLibraryPath();
1513 return *sLibexecPath();
1518 return *sQmlImportPath();
1523 return ( htonl( 1 ) == 1 ) ?
XDR :
NDR;
1530 init( *sProfilePath() );
1555 if (
auto *lInstance =
instance() )
1557 if ( !lInstance->mAuthManager )
1561 return lInstance->mAuthManager;
1566 if ( !sAuthManager )
1568 return sAuthManager;
1581 QThreadPool::globalInstance()->waitForDone();
1584 if (
auto *lInstance =
instance() )
1585 delete lInstance->mAuthManager;
1587 delete sAuthManager;
1590 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1596 if ( QgsProject::sProject )
1604 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1607 if ( QgsProviderRegistry::exists() )
1616 GDALDestroyDriverManager();
1621 QString myEnvironmentVar( getenv(
"QGIS_PREFIX_PATH" ) );
1622 QString myState = tr(
"QgsApplication state:\n"
1623 " - QGIS_PREFIX_PATH env var: %1\n"
1625 " - Plugin Path: %3\n"
1626 " - Package Data Path: %4\n"
1627 " - Active Theme Name: %5\n"
1628 " - Active Theme Path: %6\n"
1629 " - Default Theme Path: %7\n"
1630 " - SVG Search Paths: %8\n"
1631 " - User DB Path: %9\n"
1632 " - Auth DB Path: %10\n" )
1633 .arg( myEnvironmentVar,
1640 svgPaths().join( tr(
"\n ",
"match indentation of application state" ) ),
1653 QColor myColor1( Qt::lightGray );
1654 QColor myColor2 = myColor1;
1655 myColor2 = myColor2.lighter( 110 );
1657 myStyle = QStringLiteral(
".overview{"
1659 " font-weight: bold;"
1662 " background: white;"
1664 " font-family: 'Lato', 'Open Sans', 'Lucida Grande', 'Segoe UI', 'Arial', sans-serif;"
1667 "h1{ background-color: #F6F6F6;"
1669 " font-size: x-large; "
1670 " font-weight: normal;"
1671 " background: none;"
1672 " padding: 0.75em 0 0;"
1674 " line-height: 3em;"
1676 "h2{ background-color: #F6F6F6;"
1678 " font-size: medium; "
1679 " font-weight: normal;"
1680 " background: none;"
1681 " padding: 0.75em 0 0;"
1683 " line-height: 1.1em;"
1685 "h3{ background-color: #F6F6F6;"
1687 " font-weight: bold;"
1688 " font-size: large;"
1689 " text-align: left;"
1690 " border-bottom: 5px solid #DCEB5C;"
1692 "h4{ background-color: #F6F6F6;"
1694 " font-weight: bold;"
1695 " font-size: medium;"
1696 " text-align: left;"
1698 "h5{ background-color: #F6F6F6;"
1700 " font-weight: bold;"
1701 " font-size: small;"
1702 " text-align: left;"
1704 "a{ color: #729FCF;"
1705 " font-family: arial,sans-serif;"
1707 "label{ background-color: #FFFFCC;"
1708 " border: 1px solid black;"
1710 " padding: 0px 3px; "
1711 " font-size: small;"
1714 " font-weight: bold;"
1719 " border-top: 1px solid black;"
1721 ".list-view .highlight {"
1722 " text-align: left;"
1725 " padding-right: 15px;"
1726 " padding-left: 20px;"
1727 " font-weight: bold;"
1729 ".tabular-view .odd-row {"
1730 " background-color: #f9f9f9;"
1733 " font-weight: bold;"
1734 " padding-top:25px;"
1738 switch ( styleSheetType )
1741 myStyle += QStringLiteral(
1743 " border-collapse: collapse;"
1746 ".tabular-view th, .tabular-view td { "
1747 " border:1px solid black;"
1752 myStyle += QStringLiteral(
1757 "table.tabular-view, table.list-view { "
1758 " border-collapse: collapse;"
1759 " table-layout:fixed;"
1760 " width: 100% !important;"
1765 " line-height: inherit;"
1768 " word-wrap: break-word; "
1769 " vertical-align: top;"
1772 ".list-view th:first-child, .list-view td:first-child {"
1775 ".list-view.highlight { "
1776 " padding-left: inherit; "
1779 ".tabular-view th:first-child, .tabular-view td:first-child { "
1783 ".tabular-view th.strong { "
1784 " background-color: #eee; "
1787 ".tabular-view th, .tabular-view td { "
1788 " border: 1px solid #eee;"
1799 if ( 0 >= OGRGetDriverCount() )
1807 QString aPathUrl = aPath;
1808 QString tPathUrl = targetPath;
1809#if defined( Q_OS_WIN )
1810 const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
1812 aPathUrl.replace(
'\\',
'/' );
1813 if ( aPathUrl.startsWith(
"//" ) )
1816 aPathUrl =
"\\\\" + aPathUrl.mid( 2 );
1819 tPathUrl.replace(
'\\',
'/' );
1820 if ( tPathUrl.startsWith(
"//" ) )
1823 tPathUrl =
"\\\\" + tPathUrl.mid( 2 );
1826 const Qt::CaseSensitivity cs = Qt::CaseSensitive;
1829 QStringList targetElems = tPathUrl.split(
'/', Qt::SkipEmptyParts );
1830 QStringList aPathElems = aPathUrl.split(
'/', Qt::SkipEmptyParts );
1832 targetElems.removeAll( QStringLiteral(
"." ) );
1833 aPathElems.removeAll( QStringLiteral(
"." ) );
1837 while ( !aPathElems.isEmpty() &&
1838 !targetElems.isEmpty() &&
1839 aPathElems[0].compare( targetElems[0], cs ) == 0 )
1841 aPathElems.removeFirst();
1842 targetElems.removeFirst();
1852 if ( !targetElems.isEmpty() )
1855 for (
int i = 0; i < targetElems.size(); i++ )
1857 aPathElems.insert( 0, QStringLiteral(
".." ) );
1864 aPathElems.insert( 0, QStringLiteral(
"." ) );
1867 return aPathElems.join( QLatin1Char(
'/' ) );
1873 if ( !rpath.startsWith( QLatin1String(
"./" ) ) && !rpath.startsWith( QLatin1String(
"../" ) ) )
1878 QString rPathUrl = rpath;
1879 QString targetPathUrl = targetPath;
1881#if defined(Q_OS_WIN)
1882 rPathUrl.replace(
'\\',
'/' );
1883 targetPathUrl.replace(
'\\',
'/' );
1885 bool uncPath = targetPathUrl.startsWith(
"//" );
1888 QStringList srcElems = rPathUrl.split(
'/', Qt::SkipEmptyParts );
1889 QStringList targetElems = targetPathUrl.split(
'/', Qt::SkipEmptyParts );
1891#if defined(Q_OS_WIN)
1894 targetElems.insert( 0,
"" );
1895 targetElems.insert( 0,
"" );
1900 targetElems << srcElems;
1901 targetElems.removeAll( QStringLiteral(
"." ) );
1905 while ( ( pos = targetElems.indexOf( QLatin1String(
".." ) ) ) > 0 )
1908 targetElems.removeAt( pos - 1 );
1909 targetElems.removeAt( pos - 1 );
1912#if !defined(Q_OS_WIN)
1914 targetElems.prepend( QString() );
1917 return targetElems.join( QLatin1Char(
'/' ) );
1922 return *sBuildSourcePath();
1927 return *sBuildOutputPath();
1930#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
1931QString QgsApplication::cfgIntDir()
1933 return *sCfgIntDir();
1939 if ( sGdalSkipList()->contains( driver ) || driver.isEmpty() )
1943 *sGdalSkipList() << driver;
1949 if ( !sGdalSkipList()->contains( driver ) )
1953 int myPos = sGdalSkipList()->indexOf( driver );
1956 sGdalSkipList()->removeAt( myPos );
1963 return *sGdalSkipList();
1967 const QStringList &deferredSkippedGdalDrivers )
1981 QString joinedList, delimiter;
1982 if ( settings.
contains( QStringLiteral(
"gdal/skipDrivers" ) ) )
1984 joinedList = settings.
value( QStringLiteral(
"gdal/skipDrivers" ), QString() ).toString();
1985 delimiter = QStringLiteral(
"," );
1989 joinedList = settings.
value( QStringLiteral(
"gdal/skipList" ), QString() ).toString();
1990 delimiter = QStringLiteral(
" " );
1993 if ( !joinedList.isEmpty() )
1995 myList = joinedList.split( delimiter );
1997 *sGdalSkipList() = myList;
2003 return *sDeferredSkippedGdalDrivers();
2008 sGdalSkipList()->removeDuplicates();
2009 QStringList realDisabledDriverList;
2010 for (
const auto &driverName : *sGdalSkipList() )
2012 if ( !sDeferredSkippedGdalDrivers()->contains( driverName ) )
2013 realDisabledDriverList << driverName;
2015 QString myDriverList = realDisabledDriverList.join(
',' );
2016 QgsDebugMsgLevel( QStringLiteral(
"Gdal Skipped driver list set to:" ), 2 );
2018 CPLSetConfigOption(
"GDAL_SKIP", myDriverList.toUtf8() );
2025 QDir myDir( folder );
2026 if ( !myDir.exists() )
2028 myDir.mkpath( folder );
2034void QgsApplication::copyPath(
const QString &src,
const QString &dst )
2037 if ( ! dir.exists() )
2040 const auto subDirectories = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot );
2041 for (
const QString &d : subDirectories )
2043 QString dst_path = dst + QDir::separator() + d;
2044 dir.mkpath( dst_path );
2045 copyPath( src + QDir::separator() + d, dst_path );
2048 const auto files = dir.entryList( QDir::Files );
2049 for (
const QString &f : files )
2051 QFile::copy( src + QDir::separator() + f, dst + QDir::separator() + f );
2060 QVariantMap variables;
2064 QStringList childKeys = settings.
childKeys();
2065 for ( QStringList::const_iterator it = childKeys.constBegin(); it != childKeys.constEnd(); ++it )
2068 variables.insert( name, settings.
value( name ) );
2078 QVariantMap::const_iterator it = variables.constBegin();
2081 for ( ; it != variables.constEnd(); ++it )
2083 settings.
setValue( it.key(), it.value() );
2094 settings.
setValue( QStringLiteral(
"variables/" ) + name, value );
2101 QFontMetrics fm( ( QFont() ) );
2102 const double scale = 1.1 * standardSize / 24;
2103 int scaledIconSize =
static_cast< int >( std::floor( std::max(
Qgis::UI_SCALE_FACTOR * fm.height() * scale,
static_cast< double >( standardSize ) ) ) );
2104 if ( applyDevicePixelRatio )
2106 if ( QWidget *activeWindow = QApplication::activeWindow() )
2107 scaledIconSize *= ( activeWindow->screen() ? QApplication::activeWindow()->screen()->devicePixelRatio() : 1 );
2109 return scaledIconSize;
2122 app->installTranslators();
2128 return *sTranslation();
2138 ApplicationMembers *appMembers = members();
2139 if ( appMembers->mNullRepresentation.isNull() )
2141 appMembers->mNullRepresentation =
QgsSettings().
value( QStringLiteral(
"qgis/nullValue" ), QStringLiteral(
"NULL" ) ).toString();
2143 return appMembers->mNullRepresentation;
2148 ApplicationMembers *appMembers = members();
2162 return members()->mActionScopeRegistry.get();
2171 QDir myDir( myPamPath );
2172 if ( !myDir.exists() )
2174 myDir.mkpath( myPamPath );
2177#if defined(Q_OS_WIN)
2178 CPLSetConfigOption(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() );
2182 int myChangeFlag = 0;
2183 setenv(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag );
2190 if ( !qgisPrivateDbFile.exists() )
2194 QFile masterFile( qgisMasterDbFileName );
2200 bool isDbFileCopied = masterFile.copy( qgisPrivateDbFile.fileName() );
2202 if ( !isDbFileCopied )
2206 *errorMessage = tr(
"[ERROR] Can not make qgis.db private copy" );
2211 QFile::Permissions perms = QFile( qgisPrivateDbFile.fileName() ).permissions();
2212 if ( !( perms & QFile::WriteOwner ) )
2214 if ( !qgisPrivateDbFile.setPermissions( perms | QFile::WriteOwner ) )
2218 *errorMessage = tr(
"Can not make '%1' user writable" ).arg( qgisPrivateDbFile.fileName() );
2232 *errorMessage = tr(
"Could not open qgis.db" );
2237 char *errmsg =
nullptr;
2238 int res = sqlite3_exec( database.get(),
"SELECT srs_id FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2239 if ( res != SQLITE_OK )
2241 sqlite3_free( errmsg );
2244 if ( sqlite3_exec( database.get(),
2245 "DROP INDEX IF EXISTS idx_srsauthid;"
2246 "CREATE TABLE tbl_srs ("
2247 "srs_id INTEGER PRIMARY KEY,"
2248 "description text NOT NULL,"
2249 "projection_acronym text NOT NULL,"
2250 "ellipsoid_acronym NOT NULL,"
2251 "parameters text NOT NULL,"
2253 "auth_name varchar,"
2255 "is_geo integer NOT NULL,"
2256 "deprecated boolean,"
2258 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2262 *errorMessage = tr(
"Creation of missing tbl_srs in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2264 sqlite3_free( errmsg );
2271 res = sqlite3_exec( database.get(),
"SELECT wkt FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2272 if ( res != SQLITE_OK )
2275 sqlite3_free( errmsg );
2276 if ( sqlite3_exec( database.get(),
2277 "DROP INDEX IF EXISTS idx_srsauthid;"
2278 "DROP TABLE IF EXISTS tbl_srs_bak;"
2279 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2280 "CREATE TABLE tbl_srs ("
2281 "srs_id INTEGER PRIMARY KEY,"
2282 "description text NOT NULL,"
2283 "projection_acronym text NOT NULL,"
2284 "ellipsoid_acronym NOT NULL,"
2285 "parameters text NOT NULL,"
2287 "auth_name varchar,"
2289 "is_geo integer NOT NULL,"
2290 "deprecated boolean,"
2292 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2293 "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;"
2294 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2298 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2300 sqlite3_free( errmsg );
2306 res = sqlite3_exec( database.get(),
"SELECT acronym FROM tbl_projection LIMIT 0",
nullptr,
nullptr, &errmsg );
2307 if ( res != SQLITE_OK )
2309 sqlite3_free( errmsg );
2312 if ( sqlite3_exec( database.get(),
2313 "CREATE TABLE tbl_projection ("
2314 "acronym varchar(20) NOT NULL PRIMARY KEY,"
2315 "name varchar(255) NOT NULL default '',"
2316 "notes varchar(255) NOT NULL default '',"
2317 "parameters varchar(255) NOT NULL default ''"
2318 ")",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2322 *errorMessage = tr(
"Creation of missing tbl_projection in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2324 sqlite3_free( errmsg );
2329 res = sqlite3_exec( database.get(),
"SELECT epsg FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2330 if ( res == SQLITE_OK )
2333 if ( sqlite3_exec( database.get(),
2334 "DROP INDEX IF EXISTS idx_srsauthid;"
2335 "DROP TABLE IF EXISTS tbl_srs_bak;"
2336 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2337 "CREATE TABLE tbl_srs ("
2338 "srs_id INTEGER PRIMARY KEY,"
2339 "description text NOT NULL,"
2340 "projection_acronym text NOT NULL,"
2341 "ellipsoid_acronym NOT NULL,"
2342 "parameters text NOT NULL,"
2344 "auth_name varchar,"
2346 "is_geo integer NOT NULL,"
2347 "deprecated boolean,"
2349 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2350 "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;"
2351 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2355 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2357 sqlite3_free( errmsg );
2363 sqlite3_free( errmsg );
2366 if ( sqlite3_exec( database.get(),
"DROP VIEW vw_srs",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2368 QgsDebugError( QStringLiteral(
"vw_srs didn't exists in private qgis.db: %1" ).arg( errmsg ) );
2371 if ( sqlite3_exec( database.get(),
2372 "CREATE VIEW vw_srs AS"
2374 " a.description AS description"
2375 ",a.srs_id AS srs_id"
2376 ",a.is_geo AS is_geo"
2377 ",coalesce(b.name,a.projection_acronym) AS name"
2378 ",a.parameters AS parameters"
2379 ",a.auth_name AS auth_name"
2380 ",a.auth_id AS auth_id"
2381 ",a.deprecated AS deprecated"
2383 " LEFT OUTER JOIN tbl_projection b ON a.projection_acronym=b.acronym"
2384 " ORDER BY coalesce(b.name,a.projection_acronym),a.description",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2388 *errorMessage = tr(
"Update of view in private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2390 sqlite3_free( errmsg );
2402 if ( maxThreads < 1 || maxThreads > QThread::idealThreadCount() )
2417 QThreadPool::globalInstance()->setMaxThreadCount(
maxThreads );
2418 QgsDebugMsgLevel( QStringLiteral(
"set QThreadPool max thread count to %1" ).arg( QThreadPool::globalInstance()->maxThreadCount() ), 2 );
2423 return members()->mTaskManager.get();
2428 return members()->mSettingsRegistryCore.get();
2433 return members()->mColorSchemeRegistry.get();
2438 return members()->mPaintEffectRegistry.get();
2443 return members()->mRendererRegistry.get();
2448 return members()->mRasterRendererRegistry.get();
2453 return members()->mPointCloudRendererRegistry.get();
2458 return members()->mTiledSceneRendererRegistry.get();
2463 if (
auto *lInstance =
instance() )
2465 if ( !
instance()->mDataItemProviderRegistry )
2467 lInstance->mDataItemProviderRegistry = std::make_unique<QgsDataItemProviderRegistry>();
2469 return lInstance->mDataItemProviderRegistry.get();
2475 if ( !sDataItemProviderRegistry )
2477 return sDataItemProviderRegistry;
2483 return members()->mCrsRegistry.get();
2488 return members()->mSvgCache.get();
2493 return members()->mImageCache.get();
2498 return members()->mSourceCache.get();
2503 return members()->mNetworkContentFetcherRegistry.get();
2508 return members()->mValidityCheckRegistry.get();
2513 return members()->mSymbolLayerRegistry.get();
2518 return members()->mCalloutRegistry.get();
2523 return members()->mLayoutItemRegistry.get();
2528 return members()->mAnnotationItemRegistry.get();
2533 return members()->mSensorRegistry.get();
2538 return members()->mGpsConnectionRegistry.get();
2543 return members()->mGpsBabelFormatRegistry.get();
2548 return members()->mPluginLayerRegistry.get();
2553 return members()->mClassificationMethodRegistry.get();
2558 return members()->mBookmarkManager.get();
2563 return members()->mTileDownloadManager.get();
2568 return members()->mRecentStyleHandler.get();
2573 return members()->mQueryLogger.get();
2578 return members()->mStyleModel.get();
2583 return members()->mFontManager.get();
2588 return members()->mMessageLog.get();
2593 return members()->mProcessingRegistry.get();
2598 return members()->mConnectionRegistry.get();
2603 return members()->mLayerMetadataProviderRegistry.get();
2608 return members()->mPageSizeRegistry.get();
2613 return members()->mAnnotationRegistry.get();
2618 return members()->mNumericFormatRegistry.get();
2623 return members()->mFieldFormatterRegistry.get();
2628 return members()->m3DRendererRegistry.get();
2633 return members()->m3DSymbolRegistry.get();
2638 return members()->mScaleBarRendererRegistry.get();
2643 return members()->mLabelingEngineRuleRegistry.get();
2648 return members()->mProjectStorageRegistry.get();
2653 return members()->mExternalStorageRegistry.get();
2658 return members()->mProfileSourceRegistry.get();
2663 return members()->mLocalizedDataPathRegistry.get();
2666QgsApplication::ApplicationMembers::ApplicationMembers()
2670 mSettingsRegistryCore = std::make_unique<QgsSettingsRegistryCore>();
2671 mLocalizedDataPathRegistry = std::make_unique<QgsLocalizedDataPathRegistry>();
2672 mMessageLog = std::make_unique<QgsMessageLog>();
2676 profiler->
start( tr(
"Create query logger" ) );
2677 mQueryLogger = std::make_unique<QgsDatabaseQueryLog>();
2681 profiler->
start( tr(
"Setup coordinate reference system registry" ) );
2682 mCrsRegistry = std::make_unique<QgsCoordinateReferenceSystemRegistry>();
2686 profiler->
start( tr(
"Create connection registry" ) );
2687 mConnectionRegistry = std::make_unique<QgsConnectionRegistry>();
2691 profiler->
start( tr(
"Create project storage registry" ) );
2692 mProjectStorageRegistry = std::make_unique<QgsProjectStorageRegistry>();
2696 profiler->
start( tr(
"Create layer metadata provider registry" ) );
2697 mLayerMetadataProviderRegistry = std::make_unique<QgsLayerMetadataProviderRegistry>();
2701 profiler->
start( tr(
"Create font manager" ) );
2702 mFontManager = std::make_unique<QgsFontManager>();
2706 profiler->
start( tr(
"Setup task manager" ) );
2707 mTaskManager = std::make_unique<QgsTaskManager>();
2711 profiler->
start( tr(
"Setup action scope registry" ) );
2712 mActionScopeRegistry = std::make_unique<QgsActionScopeRegistry>();
2716 profiler->
start( tr(
"Setup numeric formats" ) );
2717 mNumericFormatRegistry = std::make_unique<QgsNumericFormatRegistry>();
2721 profiler->
start( tr(
"Setup field formats" ) );
2722 mFieldFormatterRegistry = std::make_unique<QgsFieldFormatterRegistry>();
2726 profiler->
start( tr(
"Setup SVG cache" ) );
2727 mSvgCache = std::make_unique<QgsSvgCache>();
2731 profiler->
start( tr(
"Setup image cache" ) );
2732 mImageCache = std::make_unique<QgsImageCache>();
2736 profiler->
start( tr(
"Setup source cache" ) );
2737 mSourceCache = std::make_unique<QgsSourceCache>();
2741 profiler->
start( tr(
"Setup color scheme registry" ) );
2742 mColorSchemeRegistry = std::make_unique<QgsColorSchemeRegistry>();
2746 profiler->
start( tr(
"Setup paint effect" ) );
2747 mPaintEffectRegistry = std::make_unique<QgsPaintEffectRegistry>();
2751 profiler->
start( tr(
"Setup symbol layer registry" ) );
2752 mSymbolLayerRegistry = std::make_unique<QgsSymbolLayerRegistry>();
2756 profiler->
start( tr(
"Recent style handler" ) );
2757 mRecentStyleHandler = std::make_unique<QgsRecentStyleHandler>();
2761 profiler->
start( tr(
"Setup callout registry" ) );
2762 mCalloutRegistry = std::make_unique<QgsCalloutRegistry>();
2766 profiler->
start( tr(
"Setup renderer registry" ) );
2767 mRendererRegistry = std::make_unique<QgsRendererRegistry>();
2771 profiler->
start( tr(
"Setup raster renderer registry" ) );
2772 mRasterRendererRegistry = std::make_unique<QgsRasterRendererRegistry>();
2776 profiler->
start( tr(
"Setup point cloud renderer registry" ) );
2777 mPointCloudRendererRegistry = std::make_unique<QgsPointCloudRendererRegistry>();
2781 profiler->
start( tr(
"Setup tiled scene renderer registry" ) );
2782 mTiledSceneRendererRegistry = std::make_unique<QgsTiledSceneRendererRegistry>();
2786 profiler->
start( tr(
"Setup GPS registry" ) );
2787 mGpsConnectionRegistry = std::make_unique<QgsGpsConnectionRegistry>();
2791 profiler->
start( tr(
"Setup GPSBabel format registry" ) );
2792 mGpsBabelFormatRegistry = std::make_unique<QgsBabelFormatRegistry>();
2796 profiler->
start( tr(
"Setup plugin layer registry" ) );
2797 mPluginLayerRegistry = std::make_unique<QgsPluginLayerRegistry>();
2801 profiler->
start( tr(
"Setup Processing registry" ) );
2802 mProcessingRegistry = std::make_unique<QgsProcessingRegistry>();
2805 mPageSizeRegistry = std::make_unique<QgsPageSizeRegistry>();
2807 profiler->
start( tr(
"Setup layout item registry" ) );
2808 mLayoutItemRegistry = std::make_unique<QgsLayoutItemRegistry>();
2809 mLayoutItemRegistry->populate();
2813 profiler->
start( tr(
"Setup annotation registry" ) );
2814 mAnnotationRegistry = std::make_unique<QgsAnnotationRegistry>();
2818 profiler->
start( tr(
"Setup annotation item registry" ) );
2819 mAnnotationItemRegistry = std::make_unique<QgsAnnotationItemRegistry>();
2820 mAnnotationItemRegistry->populate();
2824 profiler->
start( tr(
"Setup labeling engine rule registry" ) );
2825 mLabelingEngineRuleRegistry = std::make_unique<QgsLabelingEngineRuleRegistry>();
2829 profiler->
start( tr(
"Setup sensor registry" ) );
2830 mSensorRegistry = std::make_unique<QgsSensorRegistry>();
2831 mSensorRegistry->populate();
2835 profiler->
start( tr(
"Setup 3D symbol registry" ) );
2836 m3DSymbolRegistry = std::make_unique<Qgs3DSymbolRegistry>();
2840 profiler->
start( tr(
"Setup 3D renderer registry" ) );
2841 m3DRendererRegistry = std::make_unique<Qgs3DRendererRegistry>();
2845 profiler->
start( tr(
"Setup external storage registry" ) );
2846 mExternalStorageRegistry = std::make_unique<QgsExternalStorageRegistry>();
2850 profiler->
start( tr(
"Setup profile source registry" ) );
2851 mProfileSourceRegistry = std::make_unique<QgsProfileSourceRegistry>();
2855 profiler->
start( tr(
"Setup network content cache" ) );
2856 mNetworkContentFetcherRegistry = std::make_unique<QgsNetworkContentFetcherRegistry>();
2860 profiler->
start( tr(
"Setup layout check registry" ) );
2861 mValidityCheckRegistry = std::make_unique<QgsValidityCheckRegistry>();
2865 profiler->
start( tr(
"Setup classification registry" ) );
2866 mClassificationMethodRegistry = std::make_unique<QgsClassificationMethodRegistry>();
2870 profiler->
start( tr(
"Setup bookmark manager" ) );
2871 mBookmarkManager = std::make_unique<QgsBookmarkManager>(
nullptr );
2875 profiler->
start( tr(
"Setup tile download manager" ) );
2876 mTileDownloadManager = std::make_unique<QgsTileDownloadManager>();
2880 profiler->
start( tr(
"Setup scalebar registry" ) );
2881 mScaleBarRendererRegistry = std::make_unique<QgsScaleBarRendererRegistry>();
2886QgsApplication::ApplicationMembers::~ApplicationMembers()
2889 mStyleModel.reset();
2890 mTileDownloadManager.reset();
2891 mScaleBarRendererRegistry.reset();
2892 mValidityCheckRegistry.reset();
2893 mActionScopeRegistry.reset();
2894 m3DRendererRegistry.reset();
2895 m3DSymbolRegistry.reset();
2896 mAnnotationRegistry.reset();
2897 mColorSchemeRegistry.reset();
2898 mFieldFormatterRegistry.reset();
2899 mGpsConnectionRegistry.reset();
2900 mGpsBabelFormatRegistry.reset();
2901 mMessageLog.reset();
2902 mPaintEffectRegistry.reset();
2903 mPluginLayerRegistry.reset();
2904 mProcessingRegistry.reset();
2905 mPageSizeRegistry.reset();
2906 mAnnotationItemRegistry.reset();
2907 mSensorRegistry.reset();
2908 mLayoutItemRegistry.reset();
2909 mPointCloudRendererRegistry.reset();
2910 mTiledSceneRendererRegistry.reset();
2911 mRasterRendererRegistry.reset();
2912 mRendererRegistry.reset();
2914 mImageCache.reset();
2915 mSourceCache.reset();
2916 mCalloutRegistry.reset();
2917 mRecentStyleHandler.reset();
2918 mLabelingEngineRuleRegistry.reset();
2919 mSymbolLayerRegistry.reset();
2920 mExternalStorageRegistry.reset();
2921 mProfileSourceRegistry.reset();
2922 mTaskManager.reset();
2923 mNetworkContentFetcherRegistry.reset();
2924 mClassificationMethodRegistry.reset();
2925 mNumericFormatRegistry.reset();
2926 mBookmarkManager.reset();
2927 mConnectionRegistry.reset();
2928 mProjectStorageRegistry.reset();
2929 mLayerMetadataProviderRegistry.reset();
2930 mFontManager.reset();
2931 mLocalizedDataPathRegistry.reset();
2932 mCrsRegistry.reset();
2933 mQueryLogger.reset();
2936QgsApplication::ApplicationMembers *QgsApplication::members()
2938 if (
auto *lInstance =
instance() )
2940 return lInstance->mApplicationMembers.get();
2944 static QRecursiveMutex sMemberMutex;
2945 QMutexLocker lock( &sMemberMutex );
2946 if ( !sApplicationMembers )
2947 sApplicationMembers =
new ApplicationMembers();
2948 return sApplicationMembers;
QFlags< SettingsOption > SettingsOptions
static const double UI_SCALE_FACTOR
UI scaling factor.
A registry for available 3D renderers.
Registry of available 3D symbol classes.
The action scope registry is an application wide registry that contains a list of available action sc...
Registry of available annotation item types.
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 QgsLabelingEngineRuleRegistry * labelingEngineRuleRegistry()
Gets the registry of available labeling engine rules.
static void setCustomVariables(const QVariantMap &customVariables)
Custom expression variables for this application.
QString translation() const
Returns the current application translation locale code.
static QString i18nPath()
Returns the path to the translation directory.
static QgsAnnotationItemRegistry * annotationItemRegistry()
Returns the application's annotation item registry, used for annotation item types.
static QString osName()
Returns a string name of the operating system QGIS is running on.
static void registerOgrDrivers()
Register OGR drivers ensuring this only happens once.
static QString sponsorsFilePath()
Returns the path to the sponsors file.
static QgsRecentStyleHandler * recentStyleHandler()
Returns the handler for recently used style items.
endian_t
Constants for endian-ness.
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()
Returns the string used to represent the value NULL throughout QGIS.
static QVariantMap customVariables()
Custom expression variables for this application.
static QgsPointCloudRendererRegistry * pointCloudRendererRegistry()
Returns the application's point cloud renderer registry, used for managing point cloud layer 2D rende...
static QgsPaintEffectRegistry * paintEffectRegistry()
Returns the application's paint effect registry, used for managing paint effects.
static QgsSensorRegistry * sensorRegistry()
Returns the application's sensor registry, used for sensor types.
static QString pluginPath()
Returns the path to the application plugin directory.
static void setUITheme(const QString &themeName)
Set the current UI theme used to style the interface.
static bool createDatabase(QString *errorMessage=nullptr)
initialize qgis.db
static const QgsSettingsEntryBool * settingsLocaleOverrideFlag
Settings entry locale override flag.
static 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.
@ Qt
StyleSheet for Qt GUI widgets (based on QLabel or QTextBrowser), supports basic CSS and Qt extensions...
@ WebBrowser
StyleSheet for embedded browsers (QtWebKit), supports full standard CSS.
static QString translatorsFilePath()
Returns the path to the sponsors file.
static const QgsSettingsEntryString * settingsLocaleGlobalLocale
Settings entry locale global locale.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static void setNullRepresentation(const QString &nullRepresentation)
Sets the string used to represent the value NULL throughout QGIS.
static 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 QgsAuthConfigurationStorageRegistry * authConfigurationStorageRegistry()
Returns the application's authentication configuration storage registry.
static QString prefixPath()
Returns the path to the application prefix directory.
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
static QgsFontManager * fontManager()
Returns the application font manager, which manages available fonts and font installation for the QGI...
static QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
static QgsDatabaseQueryLog * databaseQueryLog()
Returns the database query log.
static QgsMessageLog * messageLog()
Returns the application's message log.
void preNotify(QObject *receiver, QEvent *event, bool *done)
static bool createThemeFolder()
Create the users theme folder.
static QString metadataPath()
Returns the path to the metadata directory.
void localeChanged()
Emitted when project locale has been changed.
static QgsActionScopeRegistry * actionScopeRegistry()
Returns the action scope registry.
static QgsCoordinateReferenceSystemRegistry * coordinateReferenceSystemRegistry()
Returns the application's coordinate reference system (CRS) registry, which handles known CRS definit...
static const char * QGIS_ORGANIZATION_NAME
static QString contributorsFilePath()
Returns the path to the contributors file.
void collectTranslatableObjects(QgsTranslationContext *translationContext)
Emits the signal to collect all the strings of .qgs to be included in ts file.
static QgsSourceCache * sourceCache()
Returns the application's source cache, used for caching embedded and remote source strings as local ...
static QRegularExpression shortNameRegularExpression()
Returns the short name regular expression for line edit validator.
static QgsTaskManager * taskManager()
Returns the application's task manager, used for managing application wide background task handling.
static QgsProfileSourceRegistry * profileSourceRegistry()
Returns registry of available profile source implementations.
static QgsAnnotationRegistry * annotationRegistry()
Returns the application's annotation registry, used for managing annotation types.
static QgsPluginLayerRegistry * pluginLayerRegistry()
Returns the application's plugin layer registry, used for managing plugin layer types.
static QgsClassificationMethodRegistry * classificationMethodRegistry()
Returns the application's classification methods registry, used in graduated renderer.
static QStringList deferredSkippedGdalDrivers()
Returns the list of gdal drivers that have been disabled in the current session, and thus,...
static QString qgisAuthDatabaseUri()
Returns the URI to the user authentication database.
static QString defaultStylePath()
Returns the path to default style (works as a starting point).
static QgsAuthManager * authManager()
Returns the application's authentication manager instance.
static QString qmlImportPath()
Returns the path where QML components are installed for QGIS Quick library.
Cursor
The Cursor enum defines constants for QGIS custom cursors.
@ CrossHair
Precisely identify a point on the canvas.
@ Identify
Identify: obtain information about the object.
@ Select
Select a rectangle.
@ CapturePoint
Select and capture a point or a feature.
@ Sampler
Color/Value picker.
static const QgsSettingsEntryInteger * settingsConnectionPoolMaximumConcurrentConnections
Settings entry to configure the maximum number of concurrent connections within connection pools.
static Q_DECL_DEPRECATED QString qgisAuthDatabaseFilePath()
Returns the path to the user authentication database file: qgis-auth.db.
static QString authorsFilePath()
Returns the path to the authors file.
static QgsBookmarkManager * bookmarkManager()
Returns the application's bookmark manager, used for storing installation-wide bookmarks.
static QString qgisUserDatabaseFilePath()
Returns the path to the user qgis.db file.
static QgsFieldFormatterRegistry * fieldFormatterRegistry()
Gets the registry of available field formatters.
static QString activeThemePath()
Returns the path to the currently active theme directory.
static QString defaultThemesFolder()
Returns the path to default themes folder from install (works as a starting point).
static void 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()
Emitted when the string representing the NULL value is changed.
static QString srsDatabaseFilePath()
Returns the path to the srs.db file.
static QString userThemesFolder()
Returns the path to user's themes folder.
static void registerGdalDriversFromSettings()
Register gdal drivers, excluding the ones mentioned in "gdal/skipList" setting.
static 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.
Registry for authentication configuration storages.
Singleton which offers an interface to manage the authentication configuration database and to utiliz...
QgsAuthConfigurationStorageRegistry * authConfigurationStorageRegistry() const
Returns the authentication configuration storage registry.
void setup(const QString &pluginPath=QString(), const QString &authDatabasePath=QString())
Sets up the authentication manager configuration.
static QgsAuthManager * instance()
Enforce singleton pattern.
Manages storage of a set of bookmarks.
void initialize(const QString &filePath)
Initializes the bookmark manager.
Registry of available callout classes.
Manages all known classification methods.
Registry of color schemes.
void addDefaultSchemes()
Adds all default color schemes to this color scheme.
void initStyleScheme()
Initializes the default random style color scheme for the user.
A registry for saved data provider connections, allowing retrieval of saved connections by name and p...
A registry for known coordinate reference system (CRS) definitions, including any user-defined CRSes.
static void invalidateCache(bool disableCache=false)
Clears the internal cache used to initialize QgsCoordinateReferenceSystem objects.
A registry for data item providers that may add items to the browser tree.
Handles logging of database queries.
static void invalidateCache(bool disableCache=false)
Clears the internal cache used.
Defines a QGIS exception class.
static void cleanRegisteredFunctions()
Deletes all registered functions whose ownership have been transferred to the expression engine.
Registry of external storage backends used by QgsExternalResourceWidget.
Manages available fonts and font installation for a QGIS instance.
void installUserFonts()
Installs user fonts from the profile/fonts directory as application fonts.
Registers existing GPS connections such that the information is available to all classes and plugins.
A cache for images derived from raster files.
A registry for labeling engine rules.
Registry of available layout item types.
static const QgsSettingsEntryStringList * settingsSearchPathForTemplates
Settings entry search path for templates.
A registry class to hold localized data paths which can be used for basemaps, logos,...
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...
Registry of profile sources used by QgsProfilePlotRenderer.
static QStringList searchPaths()
Returns the current list of Proj file search paths.
Registry of storage backends that QgsProject may use.
static QgsProject * instance()
Returns the QgsProject singleton instance.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
Registry for raster renderers.
A convenience class that simplifies locking and unlocking QReadWriteLocks.
void changeMode(Mode mode)
Change the mode of the lock to mode.
Handles and tracks style items recently used in the QGIS GUI.
Provides a method of recording run time profiles of operations, allowing easy recording of their over...
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.
A registry which manages registered scalebar renderers.
Scoped object for logging of the runtime for a single operation or group of operations.
Registry of available sensor types.
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.
An integer settings entry.
A string list settings entry.
Used for settings introspection and collects all QgsSettingsEntry instances of core.
static QgsSettingsTreeNode * sTreeLocale
static QgsSettingsTreeNode * sTreeSvg
static QgsSettingsTreeNode * sTreeCore
Stores settings for use within QGIS.
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 ...
A database of saved style entities, including symbols, color ramps, text formats and others.
static void cleanDefaultStyle()
Deletes the default style. Only to be used by QgsApplication::exitQgis()
static QgsStyle * defaultStyle(bool initialize=true)
Returns the default application-wide style.
A cache for images / pictures derived from SVG files.
QImage svgAsImage(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, bool &fitsInCache, double fixedAspectRatio=0, bool blocking=false, const QMap< QString, QString > ¶meters=QMap< QString, QString >())
Returns an SVG drawing as a QImage.
QByteArray svgContent(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, double fixedAspectRatio=0, bool blocking=false, const QMap< QString, QString > ¶meters=QMap< QString, QString >(), bool *isMissingImage=nullptr)
Gets the SVG content corresponding to the given path.
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.
A manager for QGIS user profiles.
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.
A registry that keeps a list of QgsAbstractValidityCheck checks which can be used when performing val...
Unique pointer for sqlite3 databases, which automatically closes the database when the pointer goes o...
int open(const QString &path)
Opens the database at the specified file path.
QMap< QString, QString > QgsStringMap
QObject * ABISYM(QgsApplication::mFileOpenEventReceiver)
Q_GLOBAL_STATIC_WITH_ARGS(PalPropertyList, palHiddenProperties,({ static_cast< int >(QgsPalLayerSettings::Property::PositionX), static_cast< int >(QgsPalLayerSettings::Property::PositionY), static_cast< int >(QgsPalLayerSettings::Property::Show), static_cast< int >(QgsPalLayerSettings::Property::LabelRotation), static_cast< int >(QgsPalLayerSettings::Property::Family), static_cast< int >(QgsPalLayerSettings::Property::FontStyle), static_cast< int >(QgsPalLayerSettings::Property::Size), static_cast< int >(QgsPalLayerSettings::Property::Bold), static_cast< int >(QgsPalLayerSettings::Property::Italic), static_cast< int >(QgsPalLayerSettings::Property::Underline), static_cast< int >(QgsPalLayerSettings::Property::Color), static_cast< int >(QgsPalLayerSettings::Property::Strikeout), static_cast< int >(QgsPalLayerSettings::Property::MultiLineAlignment), static_cast< int >(QgsPalLayerSettings::Property::BufferSize), static_cast< int >(QgsPalLayerSettings::Property::BufferDraw), static_cast< int >(QgsPalLayerSettings::Property::BufferColor), static_cast< int >(QgsPalLayerSettings::Property::LabelDistance), static_cast< int >(QgsPalLayerSettings::Property::Hali), static_cast< int >(QgsPalLayerSettings::Property::Vali), static_cast< int >(QgsPalLayerSettings::Property::ScaleVisibility), static_cast< int >(QgsPalLayerSettings::Property::MinScale), static_cast< int >(QgsPalLayerSettings::Property::MaxScale), static_cast< int >(QgsPalLayerSettings::Property::AlwaysShow), static_cast< int >(QgsPalLayerSettings::Property::CalloutDraw), static_cast< int >(QgsPalLayerSettings::Property::LabelAllParts) })) Q_GLOBAL_STATIC_WITH_ARGS(SymbolPropertyList
Q_GLOBAL_STATIC(QReadWriteLock, sDefinitionCacheLock)
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)