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>
136#include <netinet/in.h>
142#define SECURITY_WIN32
145#pragma comment( lib, "Secur32.lib" )
149#include "qgsconfig.h"
159#if defined(Q_OS_LINUX)
160#include <sys/sysinfo.h>
163#define CONN_POOL_MAX_CONCURRENT_CONNS 4
165QObject *
ABISYM( QgsApplication::mFileOpenEventReceiver ) =
nullptr;
166bool ABISYM( QgsApplication::mInitialized ) =
false;
167bool ABISYM( QgsApplication::mRunningFromBuildDir ) =
false;
171QgsApplication::ApplicationMembers *QgsApplication::sApplicationMembers =
nullptr;
173int ABISYM( QgsApplication::sMaxThreads ) = -1;
190#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
208 : QApplication( argc, argv, GUIenabled )
210 *sPlatformName() = platformName;
215 if ( platformName != QLatin1String(
"desktop" ) )
217 mApplicationMembers =
new ApplicationMembers();
218 mApplicationMembers->mSettingsRegistryCore->migrateOldSettings();
222 *sProfilePath() = profileFolder;
230 if (
platform() == QLatin1String(
"desktop" ) )
232 instance()->mApplicationMembers =
new ApplicationMembers();
233 instance()->mApplicationMembers->mSettingsRegistryCore->migrateOldSettings();
236 if ( profileFolder.isEmpty() )
238 if ( getenv(
"QGIS_CUSTOM_CONFIG_PATH" ) )
240 profileFolder = getenv(
"QGIS_CUSTOM_CONFIG_PATH" );
244 profileFolder = QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ).value( 0 );
251 profileFolder = profile->
folder();
255 *sProfilePath() = profileFolder;
257 static std::once_flag sMetaTypesRegistered;
258 std::call_once( sMetaTypesRegistered, []
260 qRegisterMetaType<QgsGeometry::Error>(
"QgsGeometry::Error" );
261 qRegisterMetaType<QgsDatabaseQueryLogEntry>(
"QgsDatabaseQueryLogEntry" );
262 qRegisterMetaType<QgsProcessingFeatureSourceDefinition>(
"QgsProcessingFeatureSourceDefinition" );
263 qRegisterMetaType<QgsProcessingOutputLayerDefinition>(
"QgsProcessingOutputLayerDefinition" );
264 qRegisterMetaType<Qgis::LayoutUnit>(
"Qgis::LayoutUnit" );
265 qRegisterMetaType<QgsUnsetAttributeValue>(
"QgsUnsetAttributeValue" );
266 qRegisterMetaType<QgsFeatureId>(
"QgsFeatureId" );
267 qRegisterMetaType<QgsFields>(
"QgsFields" );
268 qRegisterMetaType<QgsFeatureIds>(
"QgsFeatureIds" );
269 qRegisterMetaType<QgsProperty>(
"QgsProperty" );
270 qRegisterMetaType<QgsFeatureStoreList>(
"QgsFeatureStoreList" );
271 qRegisterMetaType<Qgis::MessageLevel>(
"Qgis::MessageLevel" );
272 qRegisterMetaType<Qgis::BrowserItemState>(
"Qgis::BrowserItemState" );
273 qRegisterMetaType<Qgis::GpsFixStatus>(
"Qgis::GpsFixStatus" );
274 qRegisterMetaType<QgsReferencedRectangle>(
"QgsReferencedRectangle" );
275 qRegisterMetaType<QgsReferencedPointXY>(
"QgsReferencedPointXY" );
276 qRegisterMetaType<QgsReferencedGeometry>(
"QgsReferencedGeometry" );
277 qRegisterMetaType<QgsLayoutRenderContext::Flags>(
"QgsLayoutRenderContext::Flags" );
278 qRegisterMetaType<QgsStyle::StyleEntity>(
"QgsStyle::StyleEntity" );
279 qRegisterMetaType<QgsCoordinateReferenceSystem>(
"QgsCoordinateReferenceSystem" );
280 qRegisterMetaType<QgsAuthManager::MessageLevel>(
"QgsAuthManager::MessageLevel" );
281 qRegisterMetaType<QgsNetworkRequestParameters>(
"QgsNetworkRequestParameters" );
282 qRegisterMetaType<QgsNetworkReplyContent>(
"QgsNetworkReplyContent" );
283 qRegisterMetaType<QgsFeature>(
"QgsFeature" );
284 qRegisterMetaType<QgsGeometry>(
"QgsGeometry" );
285 qRegisterMetaType<QgsInterval>(
"QgsInterval" );
286 qRegisterMetaType<QgsRectangle>(
"QgsRectangle" );
287 qRegisterMetaType<QgsPointXY>(
"QgsPointXY" );
288 qRegisterMetaType<QgsPoint>(
"QgsPoint" );
289 qRegisterMetaType<QgsDatumTransform::GridDetails>(
"QgsDatumTransform::GridDetails" );
290 qRegisterMetaType<QgsDatumTransform::TransformDetails>(
"QgsDatumTransform::TransformDetails" );
291 qRegisterMetaType<QgsNewsFeedParser::Entry>(
"QgsNewsFeedParser::Entry" );
292 qRegisterMetaType<QgsRectangle>(
"QgsRectangle" );
293 qRegisterMetaType<QgsLocatorResult>(
"QgsLocatorResult" );
294 qRegisterMetaType<QgsGradientColorRamp>(
"QgsGradientColorRamp" );
295 qRegisterMetaType<QgsProcessingModelChildParameterSource>(
"QgsProcessingModelChildParameterSource" );
296#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
299 qRegisterMetaTypeStreamOperators<QgsProcessingModelChildParameterSource>(
"QgsProcessingModelChildParameterSource" );
301 qRegisterMetaType<QgsRemappingSinkDefinition>(
"QgsRemappingSinkDefinition" );
302 qRegisterMetaType<QgsProcessingModelChildDependency>(
"QgsProcessingModelChildDependency" );
303 qRegisterMetaType<QgsTextFormat>(
"QgsTextFormat" );
304#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
305 QMetaType::registerComparators<QgsProcessingModelChildDependency>();
306 QMetaType::registerEqualsComparator<QgsProcessingFeatureSourceDefinition>();
307 QMetaType::registerEqualsComparator<QgsProperty>();
308 QMetaType::registerEqualsComparator<QgsDateTimeRange>();
309 QMetaType::registerEqualsComparator<QgsDateRange>();
310 QMetaType::registerEqualsComparator<QgsUnsetAttributeValue>();
312 qRegisterMetaType<QPainter::CompositionMode>(
"QPainter::CompositionMode" );
313 qRegisterMetaType<QgsDateTimeRange>(
"QgsDateTimeRange" );
314 qRegisterMetaType<QgsDoubleRange>(
"QgsDoubleRange" );
315 qRegisterMetaType<QgsIntRange>(
"QgsIntRange" );
316 qRegisterMetaType<QList<QgsMapLayer *>>(
"QList<QgsMapLayer*>" );
317 qRegisterMetaType<QMap<QNetworkRequest::Attribute, QVariant>>(
"QMap<QNetworkRequest::Attribute,QVariant>" );
318 qRegisterMetaType<QMap<QNetworkRequest::KnownHeaders, QVariant>>(
"QMap<QNetworkRequest::KnownHeaders,QVariant>" );
319 qRegisterMetaType<QList<QNetworkReply::RawHeaderPair>>(
"QList<QNetworkReply::RawHeaderPair>" );
320 qRegisterMetaType< QAuthenticator * >(
"QAuthenticator*" );
321 qRegisterMetaType< QgsGpsInformation >(
"QgsGpsInformation" );
322 qRegisterMetaType< QgsSensorThingsExpansionDefinition >(
"QgsSensorThingsExpansionDefinition" );
327 if ( ABISYM( mRunningFromBuildDir ) )
330 *sPrefixPath() = QString();
331#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
332 setPluginPath( *sBuildOutputPath() +
'/' + QString( QGIS_PLUGIN_SUBDIR ) +
'/' + *sCfgIntDir() );
334 setPluginPath( *sBuildOutputPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
336 setPkgDataPath( *sBuildOutputPath() + QStringLiteral(
"/data" ) );
337 *sLibraryPath() = *sBuildOutputPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
338#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
339 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/' + *sCfgIntDir() +
'/';
341 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
343#if defined( HAVE_QUICK )
344 *sQmlImportPath() = *sBuildOutputPath() +
'/' + QGIS_QML_SUBDIR +
'/';
349 char *
prefixPath = getenv(
"QGIS_PREFIX_PATH" );
352 if ( sPrefixPath()->isNull() )
354#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
356#elif defined(ANDROID)
358 QDir myDir( QDir::homePath() );
360 QString myPrefix = myDir.absolutePath();
363 QDir myDir( applicationDirPath() );
365 if ( applicationDirPath().contains( QStringLiteral(
"cgi-bin" ) ) )
370 QString myPrefix = myDir.absolutePath();
381 *sConfigPath() = profileFolder +
'/';
390 if ( getenv(
"QGIS_AUTH_DB_DIR_PATH" ) )
393 sAuthDbUri()->clear();
396 if ( getenv(
"QGIS_AUTH_DB_URI" ) )
398 *sAuthDbUri() = getenv(
"QGIS_AUTH_DB_URI" );
402 if ( sAuthDbUri->isEmpty() )
404 *sAuthDbUri() = QStringLiteral(
"QSQLITE://" ) + *sAuthDbDirPath() + QStringLiteral(
"qgis-auth.db" );
408 qputenv(
"QT3D_RENDERER",
"opengl" );
411 QMap<QString, QString> systemEnvVarMap;
412 QString passfile( QStringLiteral(
"QGIS_AUTH_PASSWORD_FILE" ) );
414 const auto systemEnvironment = QProcessEnvironment::systemEnvironment().toStringList();
415 for (
const QString &varStr : systemEnvironment )
417 int pos = varStr.indexOf( QLatin1Char(
'=' ) );
420 QString varStrName = varStr.left( pos );
421 QString varStrValue = varStr.mid( pos + 1 );
422 if ( varStrName != passfile )
424 systemEnvVarMap.insert( varStrName, varStrValue );
427 *sSystemEnvVars() = systemEnvVarMap;
434 QString projLib( QDir::cleanPath(
pkgDataPath().append(
"/proj" ) ) );
435 if ( QFile::exists( projLib ) )
437 currentProjSearchPaths.append( projLib );
441 char **newPaths =
new char *[currentProjSearchPaths.length()];
442 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
444 newPaths[i] = CPLStrdup( currentProjSearchPaths.at( i ).toUtf8().constData() );
446 proj_context_set_search_paths(
nullptr, currentProjSearchPaths.count(), newPaths );
447 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
449 CPLFree( newPaths[i] );
454 QCoreApplication::addLibraryPath(
pluginPath() );
464 ABISYM( sMaxThreads ) = -1;
480 if ( !members()->mStyleModel )
483 ABISYM( mInitialized ) =
true;
487void QgsApplication::installTranslators()
490 if ( mQgisTranslator )
492 removeTranslator( mQgisTranslator );
493 delete mQgisTranslator;
494 mQgisTranslator =
nullptr;
498 removeTranslator( mQtTranslator );
499 delete mQtTranslator;
500 mQtTranslator =
nullptr;
502 if ( mQtBaseTranslator )
504 removeTranslator( mQtBaseTranslator );
505 delete mQtBaseTranslator;
506 mQtBaseTranslator =
nullptr;
509 if ( *sTranslation() != QLatin1String(
"C" ) )
511 mQgisTranslator =
new QTranslator(
this );
512 if ( mQgisTranslator->load( QStringLiteral(
"qgis_" ) + *sTranslation(),
i18nPath() ) )
514 installTranslator( mQgisTranslator );
518 QgsDebugMsgLevel( QStringLiteral(
"loading of qgis translation failed %1/qgis_%2" ).arg(
i18nPath(), *sTranslation() ), 2 );
526 QString qtTranslationsPath = QLibraryInfo::location( QLibraryInfo::TranslationsPath );
528 QString prefix = QDir( QString(
"%1/../" ).arg( QApplication::applicationDirPath() ) ).absolutePath();
529 qtTranslationsPath = prefix + qtTranslationsPath.mid( QLibraryInfo::location( QLibraryInfo::PrefixPath ).length() );
532 mQtTranslator =
new QTranslator(
this );
533 if ( mQtTranslator->load( QStringLiteral(
"qt_" ) + *sTranslation(), qtTranslationsPath ) )
535 installTranslator( mQtTranslator );
539 QgsDebugMsgLevel( QStringLiteral(
"loading of qt translation failed %1/qt_%2" ).arg( qtTranslationsPath, *sTranslation() ), 2 );
542 mQtBaseTranslator =
new QTranslator(
this );
543 if ( mQtBaseTranslator->load( QStringLiteral(
"qtbase_" ) + *sTranslation(), qtTranslationsPath ) )
545 installTranslator( mQtBaseTranslator );
549 QgsDebugMsgLevel( QStringLiteral(
"loading of qtbase translation failed %1/qt_%2" ).arg( qtTranslationsPath, *sTranslation() ), 2 );
556 if ( mApplicationMembers )
557 mApplicationMembers->mSettingsRegistryCore->backwardCompatibility();
559 delete mDataItemProviderRegistry;
560 delete mApplicationMembers;
561 delete mQgisTranslator;
562 delete mQtTranslator;
563 delete mQtBaseTranslator;
571void QgsApplication::invalidateCaches()
583 return qobject_cast<QgsApplication *>( QCoreApplication::instance() );
589 if (
event->type() == QEvent::FileOpen )
592 if ( ABISYM( mFileOpenEventReceiver ) )
595 done =
notify( ABISYM( mFileOpenEventReceiver ),
event );
602 sFileOpenEventList()->append(
static_cast<QFileOpenEvent *
>(
event )->file() );
609 done = QApplication::event(
event );
618 if ( thread() == receiver->thread() )
628 done = QApplication::notify( receiver,
event );
632 qCritical() <<
"Caught unhandled QgsException: " << e.
what();
633 if ( qApp->thread() == QThread::currentThread() )
634 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
636 catch ( std::exception &e )
638 qCritical() <<
"Caught unhandled std::exception: " << e.
what();
639 if ( qApp->thread() == QThread::currentThread() )
640 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
644 qCritical() <<
"Caught unhandled unknown exception";
645 if ( qApp->thread() == QThread::currentThread() )
646 QMessageBox::critical( activeWindow(), tr(
"Exception" ), tr(
"unknown exception" ) );
654 return QgsRuntimeProfiler::threadLocalInstance();
660 ABISYM( mFileOpenEventReceiver ) = receiver;
662 if ( sFileOpenEventList()->count() > 0 )
664 const QStringList fileOpenEventList = *sFileOpenEventList();
665 for (
const QString &file : fileOpenEventList )
667 QFileOpenEvent foe( file );
668 QgsApplication::sendEvent( ABISYM( mFileOpenEventReceiver ), &foe );
670 sFileOpenEventList()->clear();
678 if ( sPrefixPath()->endsWith(
"/bin" ) )
680 sPrefixPath()->chop( 4 );
683 if ( useDefaultPaths && !ABISYM( mRunningFromBuildDir ) )
685 setPluginPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
686 setPkgDataPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_DATA_SUBDIR ) );
688 *sLibraryPath() = *sPrefixPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
689 *sLibexecPath() = *sPrefixPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
690#if defined( HAVE_QUICK )
691 *sQmlImportPath() = *sPrefixPath() +
'/' + QGIS_QML_SUBDIR +
'/';
704 QString mySvgPath =
pkgDataPath + QStringLiteral(
"/svg/" );
707 if ( !sDefaultSvgPaths()->contains( mySvgPath ) )
708 *sDefaultSvgPaths() << mySvgPath;
713 *sDefaultSvgPaths() = pathList;
718 QFileInfo fi( authDbDirPath );
719 if ( fi.exists() && fi.isDir() && fi.isWritable() )
721 *sAuthDbDirPath() = fi.canonicalFilePath() + QDir::separator();
728 if ( ABISYM( mRunningFromBuildDir ) )
730 static bool sOnce =
true;
734 ( void ) blockNotifications;
735 qWarning(
"!!! prefix path was requested, but it is not valid - we do not run from installed path !!!" );
741 return *sPrefixPath();
745 return *sPluginPath();
750 if ( sPkgDataPath()->isNull() )
753 return *sPkgDataPath();
758 return QStringLiteral(
":/images/themes/default/" );
763 QDir dir( usersThemes );
771 return defaultThemes;
777 return iconsPath() + QStringLiteral(
"qgis-icon-60x60.png" );
782 return ABISYM( sMaxThreads );
789 if ( QFile::exists( path + iconFile ) )
790 return path + iconFile;
798 const QString cacheKey = ( name.startsWith(
'/' ) ? name.mid( 1 ) : name )
799 + ( fillColor.isValid() ? QStringLiteral(
"_%1" ).arg( fillColor.name( QColor::HexArgb ).mid( 1 ) ) : QString() )
800 + ( strokeColor.isValid() ? QStringLiteral(
"_%1" ).arg( strokeColor.name( QColor::HexArgb ).mid( 1 ) ) : QString() );
802 if ( app && app->mIconCache.contains( cacheKey ) )
803 return app->mIconCache.value( cacheKey );
806 const bool colorBased = fillColor.isValid() || strokeColor.isValid();
808 auto iconFromColoredSvg = [ = ](
const QString & path ) -> QIcon
813 const QString
iconPath = sIconCacheDir()->filePath( cacheKey + QStringLiteral(
".svg" ) );
814 if (
const QDir dir = QFileInfo(
iconPath ).dir(); !dir.exists() )
820 if ( f.open( QFile::WriteOnly | QFile::Truncate ) )
822 f.write( svgContent );
831 return QIcon( f.fileName() );
836 if ( QFile::exists( preferredPath ) )
840 icon = iconFromColoredSvg( preferredPath );
844 icon = QIcon( preferredPath );
847 else if ( QFile::exists( defaultPath ) )
853 icon = iconFromColoredSvg( defaultPath );
857 icon = QIcon( defaultPath );
866 app->mIconCache.insert( cacheKey, icon );
873 if ( app && app->mCursorCache.contains( cursor ) )
874 return app->mCursorCache.value( cursor );
885 name = QStringLiteral(
"mZoomIn.svg" );
890 name = QStringLiteral(
"mZoomOut.svg" );
897 name = QStringLiteral(
"mIdentify.svg" );
900 name = QStringLiteral(
"mCrossHair.svg" );
903 name = QStringLiteral(
"mCapturePoint.svg" );
906 name = QStringLiteral(
"mSelect.svg" );
913 name = QStringLiteral(
"mSampler.svg" );
918 Q_ASSERT( ! name.isEmpty( ) );
920 QIcon icon =
getThemeIcon( QStringLiteral(
"cursors" ) + QDir::separator() + name );
923 if ( ! icon.isNull( ) )
927 cursorIcon = QCursor( icon.pixmap( std::ceil( scale * 32 ), std::ceil( scale * 32 ) ), std::ceil( scale * activeX ), std::ceil( scale * activeY ) );
930 app->mCursorCache.insert( cursor, cursorIcon );
937 const QString preferredPath =
activeThemePath() + QDir::separator() + name;
939 const QString path = QFile::exists( preferredPath ) ? preferredPath : defaultPath;
940 if ( foreColor.isValid() || backColor.isValid() )
942 bool fitsInCache =
false;
943 const QImage image =
svgCache()->
svgAsImage( path, size, backColor, foreColor, 1, 1, fitsInCache );
944 return QPixmap::fromImage( image );
947 return QPixmap( path );
957 static QString appPath;
958 if ( appPath.isNull() )
960 if ( QCoreApplication::instance() )
962 appPath = applicationDirPath();
966 qWarning(
"Application path not initialized" );
970 if ( !appPath.isNull() || getenv(
"QGIS_PREFIX_PATH" ) )
972 QString prefix = getenv(
"QGIS_PREFIX_PATH" ) ? getenv(
"QGIS_PREFIX_PATH" ) : appPath;
977 static const QStringList paths { QStringList() << QString() << QStringLiteral(
"/.." ) << QStringLiteral(
"/bin" ) << QStringLiteral(
"/../../.." ) };
978 for (
const QString &path : paths )
980 f.setFileName( prefix + path +
"/qgisbuildpath.txt" );
984 if ( f.exists() && f.open( QIODevice::ReadOnly ) )
986 ABISYM( mRunningFromBuildDir ) =
true;
987 *sBuildSourcePath() = f.readLine().trimmed();
988 *sBuildOutputPath() = f.readLine().trimmed();
990 QgsDebugMsgLevel( QStringLiteral(
"- source directory: %1" ).arg( sBuildSourcePath()->toUtf8().constData() ), 4 );
991 QgsDebugMsgLevel( QStringLiteral(
"- output directory of the build: %1" ).arg( sBuildOutputPath()->toUtf8().constData() ), 4 );
992#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
993 *sCfgIntDir() = prefix.split(
'/', Qt::SkipEmptyParts ).last();
994 qDebug(
"- cfg: %s", sCfgIntDir()->toUtf8().constData() );
1000 if ( getenv(
"QGIS_PREFIX_PATH" ) )
1006 QDir dir( QDir::homePath() );
1011#if defined(Q_OS_MACOS)
1013#elif defined(Q_OS_WIN)
1018 QDir dir( appPath );
1020 if ( appPath.contains( QStringLiteral(
"cgi-bin" ) ) )
1030 if ( ABISYM( mRunningFromBuildDir ) )
1031 return *sBuildOutputPath() + QStringLiteral(
"/data" );
1033 return prefixPath +
'/' + QStringLiteral( QGIS_DATA_SUBDIR );
1038 return *sThemeName();
1048 qApp->setStyleSheet( QString() );
1052 QString path = themes.value(
themeName );
1053 QString stylesheetname = path +
"/style.qss";
1055 QFile file( stylesheetname );
1056 QFile variablesfile( path +
"/variables.qss" );
1058 QFileInfo variableInfo( variablesfile );
1060 if ( !file.open( QIODevice::ReadOnly ) || ( variableInfo.exists() && !variablesfile.open( QIODevice::ReadOnly ) ) )
1065 QString styledata = file.readAll();
1066 styledata.replace( QLatin1String(
"@theme_path" ), path );
1068 if ( variableInfo.exists() )
1070 QTextStream in( &variablesfile );
1071 while ( !in.atEnd() )
1073 QString line = in.readLine();
1075 if ( line.startsWith(
'@' ) )
1077 int index = line.indexOf(
':' );
1078 QString name = line.mid( 0, index );
1079 QString value = line.mid( index + 1, line.length() );
1080 styledata.replace( name, value );
1083 variablesfile.close();
1091 const static QRegularExpression regex( QStringLiteral(
"(?<=[\\s:])([0-9\\.]+)(?=em)" ) );
1092 QRegularExpressionMatch match = regex.match( styledata, index );
1093 while ( match.hasMatch() )
1095 index = match.capturedStart();
1096 styledata.remove( index, match.captured( 0 ).length() );
1098 styledata.insert( index, number );
1099 index += number.length();
1100 match = regex.match( styledata, index );
1104 qApp->setStyleSheet( styledata );
1106 QFile palettefile( path +
"/palette.txt" );
1107 QFileInfo paletteInfo( palettefile );
1108 if ( paletteInfo.exists() && palettefile.open( QIODevice::ReadOnly ) )
1110 QPalette
pal = qApp->palette();
1111 QTextStream in( &palettefile );
1112 while ( !in.atEnd() )
1114 QString line = in.readLine();
1115 QStringList parts = line.split(
':' );
1116 if ( parts.count() == 2 )
1118 int role = parts.at( 0 ).trimmed().toInt();
1120 pal.setColor(
static_cast< QPalette::ColorRole
>( role ), color );
1123 palettefile.close();
1124 qApp->setPalette(
pal );
1133 QHash<QString, QString> mapping;
1134 mapping.insert( QStringLiteral(
"default" ), QString() );
1135 const auto constPaths = paths;
1136 for (
const QString &path : constPaths )
1138 QDir folder( path );
1139 QFileInfoList styleFiles = folder.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
1140 const auto constStyleFiles = styleFiles;
1141 for (
const QFileInfo &info : constStyleFiles )
1143 QFileInfo styleFile( info.absoluteFilePath() +
"/style.qss" );
1144 if ( !styleFile.exists() )
1147 QString name = info.baseName();
1148 QString path = info.absoluteFilePath();
1149 mapping.insert( name, path );
1157 return pkgDataPath() + QStringLiteral(
"/doc/AUTHORS" );
1162 return pkgDataPath() + QStringLiteral(
"/doc/CONTRIBUTORS" );
1166 return pkgDataPath() + QStringLiteral(
"/doc/developersmap.html" );
1171 return pkgDataPath() + QStringLiteral(
"/doc/SPONSORS" );
1176 return pkgDataPath() + QStringLiteral(
"/doc/DONORS" );
1181 return pkgDataPath() + QStringLiteral(
"/doc/TRANSLATORS" );
1186 return pkgDataPath() + QStringLiteral(
"/doc/LICENSE" );
1191 if ( ABISYM( mRunningFromBuildDir ) )
1192 return *sBuildOutputPath() + QStringLiteral(
"/i18n/" );
1194 return pkgDataPath() + QStringLiteral(
"/i18n/" );
1199 return pkgDataPath() + QStringLiteral(
"/resources/metadata-ISO/" );
1204 return pkgDataPath() + QStringLiteral(
"/resources/qgis.db" );
1209 return *sConfigPath();
1219 return *sAuthDbDirPath() + QStringLiteral(
"qgis-auth.db" );
1224 return *sAuthDbUri();
1229 return QStringLiteral(
":/images/splash/" );
1234 return pkgDataPath() + QStringLiteral(
"/images/icons/" );
1239 if ( ABISYM( mRunningFromBuildDir ) )
1241 QString tempCopy = QDir::tempPath() +
"/srs6.db";
1243 if ( !QFile( tempCopy ).exists() )
1246 if ( !f.copy( tempCopy ) )
1248 qFatal(
"Could not create temporary copy" );
1256 return pkgDataPath() + QStringLiteral(
"/resources/srs.db" );
1263 members()->mSvgPathCacheValid =
false;
1268 static QReadWriteLock lock;
1272 if ( members()->mSvgPathCacheValid )
1274 return members()->mSvgPathCache;
1285 for (
const QString &path : pathList )
1287 if ( !paths.contains( path ) )
1288 paths.append( path );
1290 for (
const QString &path : std::as_const( *sDefaultSvgPaths() ) )
1292 if ( !paths.contains( path ) )
1293 paths.append( path );
1295 members()->mSvgPathCache = paths;
1310 return *sSystemEnvVars();
1320 const thread_local QRegularExpression regexp( QRegularExpression::anchoredPattern( QStringLiteral(
"^[A-Za-z][A-Za-z0-9\\._-]*" ) ) );
1326 if ( !sUserName()->isEmpty() )
1327 return *sUserName();
1330 TCHAR name [ UNLEN + 1 ];
1331 DWORD size = UNLEN + 1;
1333 if ( GetUserName( ( TCHAR * )name, &size ) )
1335#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
1336 *sUserName() = QString::fromLocal8Bit( name );
1338 *sUserName() = QString::fromWCharArray( name );
1343#elif QT_CONFIG(process)
1346 process.start( QStringLiteral(
"whoami" ), QStringList() );
1347 process.waitForFinished();
1348 *sUserName() = process.readAllStandardOutput().trimmed();
1351 if ( !sUserName()->isEmpty() )
1352 return *sUserName();
1355 *sUserName() = qgetenv(
"USER" );
1356 if ( !sUserName()->isEmpty() )
1357 return *sUserName();
1360 *sUserName() = qgetenv(
"USERNAME" );
1361 return *sUserName();
1366 if ( !sUserFullName()->isEmpty() )
1367 return *sUserFullName();
1370 TCHAR name [ UNLEN + 1 ];
1371 DWORD size = UNLEN + 1;
1374 if ( GetUserNameEx( NameDisplay, ( TCHAR * )name, &size ) )
1376#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
1377 *sUserFullName() = QString::fromLocal8Bit( name );
1379 *sUserFullName() = QString::fromWCharArray( name );
1384 if ( sUserFullName()->isEmpty() )
1386#elif defined(Q_OS_ANDROID) || defined(__MINGW32__)
1387 *sUserFullName() = QStringLiteral(
"Not available" );
1389 struct passwd *p = getpwuid( getuid() );
1393 QString gecosName = QString( p->pw_gecos );
1394 *sUserFullName() = gecosName.left( gecosName.indexOf(
',', 0 ) );
1399 return *sUserFullName();
1404#if defined(Q_OS_ANDROID)
1405 return QLatin1String(
"android" );
1406#elif defined(Q_OS_MAC)
1407 return QLatin1String(
"osx" );
1408#elif defined(Q_OS_WIN)
1409 return QLatin1String(
"windows" );
1410#elif defined(Q_OS_LINUX)
1411 return QStringLiteral(
"linux" );
1412#elif defined(Q_OS_FREEBSD)
1413 return QStringLiteral(
"freebsd" );
1414#elif defined(Q_OS_OPENBSD)
1415 return QStringLiteral(
"openbsd" );
1416#elif defined(Q_OS_NETBSD)
1417 return QStringLiteral(
"netbsd" );
1418#elif defined(Q_OS_UNIX)
1419 return QLatin1String(
"unix" );
1421 return QLatin1String(
"unknown" );
1427#if defined(Q_OS_ANDROID)
1429#elif defined(Q_OS_MAC)
1431#elif defined(Q_OS_WIN)
1432 MEMORYSTATUSEX memoryStatus;
1433 ZeroMemory( &memoryStatus,
sizeof( MEMORYSTATUSEX ) );
1434 memoryStatus.dwLength =
sizeof( MEMORYSTATUSEX );
1435 if ( GlobalMemoryStatusEx( &memoryStatus ) )
1437 return memoryStatus.ullTotalPhys / ( 1024 * 1024 );
1443#elif defined(Q_OS_LINUX)
1444 constexpr int megabyte = 1024 * 1024;
1447 return si.totalram / megabyte;
1448#elif defined(Q_OS_FREEBSD)
1450#elif defined(Q_OS_OPENBSD)
1452#elif defined(Q_OS_NETBSD)
1454#elif defined(Q_OS_UNIX)
1463 return *sPlatformName();
1468 if ( !sApplicationFullName()->isEmpty() )
1469 return *sApplicationFullName();
1472 *sApplicationFullName() = qgetenv(
"QGIS_APPLICATION_FULL_NAME" );
1473 if ( !sApplicationFullName()->isEmpty() )
1474 return *sApplicationFullName();
1478 *sApplicationFullName() = settings.
value(
1479 QStringLiteral(
"/qgis/application_full_name" ),
1480 QStringLiteral(
"%1 %2" ).arg( applicationName(),
platform() )
1482 return *sApplicationFullName();
1491 if (
locale.startsWith( QLatin1String(
"en" ), Qt::CaseInsensitive ) )
1500 return QLocale().name().left( 2 );
1506 QLocale::setDefault(
locale );
1517 return pkgDataPath() + QStringLiteral(
"/resources/symbology-style.xml" );
1522 return pkgDataPath() + QStringLiteral(
"/resources/themes" );
1527 return pkgDataPath() + QStringLiteral(
"/resources/server/" );
1532 return *sLibraryPath();
1537 return *sLibexecPath();
1542 return *sQmlImportPath();
1547 return ( htonl( 1 ) == 1 ) ?
XDR :
NDR;
1554 init( *sProfilePath() );
1579 if (
auto *lInstance =
instance() )
1581 if ( !lInstance->mAuthManager )
1585 return lInstance->mAuthManager;
1590 if ( !sAuthManager )
1592 return sAuthManager;
1605 QThreadPool::globalInstance()->waitForDone();
1608 if (
auto *lInstance =
instance() )
1609 delete lInstance->mAuthManager;
1611 delete sAuthManager;
1614 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1620 if ( QgsProject::sProject )
1628 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1631 if ( QgsProviderRegistry::exists() )
1640 GDALDestroyDriverManager();
1645 QString myEnvironmentVar( getenv(
"QGIS_PREFIX_PATH" ) );
1646 QString myState = tr(
"QgsApplication state:\n"
1647 " - QGIS_PREFIX_PATH env var: %1\n"
1649 " - Plugin Path: %3\n"
1650 " - Package Data Path: %4\n"
1651 " - Active Theme Name: %5\n"
1652 " - Active Theme Path: %6\n"
1653 " - Default Theme Path: %7\n"
1654 " - SVG Search Paths: %8\n"
1655 " - User DB Path: %9\n"
1656 " - Auth DB Path: %10\n" )
1657 .arg( myEnvironmentVar,
1664 svgPaths().join( tr(
"\n ",
"match indentation of application state" ) ),
1677 QColor myColor1( Qt::lightGray );
1678 QColor myColor2 = myColor1;
1679 myColor2 = myColor2.lighter( 110 );
1681 myStyle = QStringLiteral(
".overview{"
1683 " font-weight: bold;"
1686 " background: white;"
1688 " font-family: 'Lato', 'Open Sans', 'Lucida Grande', 'Segoe UI', 'Arial', sans-serif;"
1691 "h1{ background-color: #F6F6F6;"
1693 " font-size: x-large; "
1694 " font-weight: normal;"
1695 " background: none;"
1696 " padding: 0.75em 0 0;"
1698 " line-height: 3em;"
1700 "h2{ background-color: #F6F6F6;"
1702 " font-size: medium; "
1703 " font-weight: normal;"
1704 " background: none;"
1705 " padding: 0.75em 0 0;"
1707 " line-height: 1.1em;"
1709 "h3{ background-color: #F6F6F6;"
1711 " font-weight: bold;"
1712 " font-size: large;"
1713 " text-align: left;"
1714 " border-bottom: 5px solid #DCEB5C;"
1716 "h4{ background-color: #F6F6F6;"
1718 " font-weight: bold;"
1719 " font-size: medium;"
1720 " text-align: left;"
1722 "h5{ background-color: #F6F6F6;"
1724 " font-weight: bold;"
1725 " font-size: small;"
1726 " text-align: left;"
1728 "a{ color: #729FCF;"
1729 " font-family: arial,sans-serif;"
1731 "label{ background-color: #FFFFCC;"
1732 " border: 1px solid black;"
1734 " padding: 0px 3px; "
1735 " font-size: small;"
1738 " font-weight: bold;"
1743 " border-top: 1px solid black;"
1745 ".list-view .highlight {"
1746 " text-align: left;"
1749 " padding-right: 15px;"
1750 " padding-left: 20px;"
1751 " font-weight: bold;"
1753 ".tabular-view .odd-row {"
1754 " background-color: #f9f9f9;"
1757 " font-weight: bold;"
1758 " padding-top:25px;"
1762 switch ( styleSheetType )
1765 myStyle += QStringLiteral(
1767 " border-collapse: collapse;"
1770 ".tabular-view th, .tabular-view td { "
1771 " border:1px solid black;"
1776 myStyle += QStringLiteral(
1781 "table.tabular-view, table.list-view { "
1782 " border-collapse: collapse;"
1783 " table-layout:fixed;"
1784 " width: 100% !important;"
1789 " line-height: inherit;"
1792 " word-wrap: break-word; "
1793 " vertical-align: top;"
1796 ".list-view th:first-child, .list-view td:first-child {"
1799 ".list-view.highlight { "
1800 " padding-left: inherit; "
1803 ".tabular-view th:first-child, .tabular-view td:first-child { "
1807 ".tabular-view th.strong { "
1808 " background-color: #eee; "
1811 ".tabular-view th, .tabular-view td { "
1812 " border: 1px solid #eee;"
1823 if ( 0 >= OGRGetDriverCount() )
1831 QString aPathUrl = aPath;
1832 QString tPathUrl = targetPath;
1833#if defined( Q_OS_WIN )
1834 const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
1836 aPathUrl.replace(
'\\',
'/' );
1837 if ( aPathUrl.startsWith(
"//" ) )
1840 aPathUrl =
"\\\\" + aPathUrl.mid( 2 );
1843 tPathUrl.replace(
'\\',
'/' );
1844 if ( tPathUrl.startsWith(
"//" ) )
1847 tPathUrl =
"\\\\" + tPathUrl.mid( 2 );
1850 const Qt::CaseSensitivity cs = Qt::CaseSensitive;
1853 QStringList targetElems = tPathUrl.split(
'/', Qt::SkipEmptyParts );
1854 QStringList aPathElems = aPathUrl.split(
'/', Qt::SkipEmptyParts );
1856 targetElems.removeAll( QStringLiteral(
"." ) );
1857 aPathElems.removeAll( QStringLiteral(
"." ) );
1861 while ( !aPathElems.isEmpty() &&
1862 !targetElems.isEmpty() &&
1863 aPathElems[0].compare( targetElems[0], cs ) == 0 )
1865 aPathElems.removeFirst();
1866 targetElems.removeFirst();
1876 if ( !targetElems.isEmpty() )
1879 for (
int i = 0; i < targetElems.size(); i++ )
1881 aPathElems.insert( 0, QStringLiteral(
".." ) );
1888 aPathElems.insert( 0, QStringLiteral(
"." ) );
1891 return aPathElems.join( QLatin1Char(
'/' ) );
1897 if ( !rpath.startsWith( QLatin1String(
"./" ) ) && !rpath.startsWith( QLatin1String(
"../" ) ) )
1902 QString rPathUrl = rpath;
1903 QString targetPathUrl = targetPath;
1905#if defined(Q_OS_WIN)
1906 rPathUrl.replace(
'\\',
'/' );
1907 targetPathUrl.replace(
'\\',
'/' );
1909 bool uncPath = targetPathUrl.startsWith(
"//" );
1912 QStringList srcElems = rPathUrl.split(
'/', Qt::SkipEmptyParts );
1913 QStringList targetElems = targetPathUrl.split(
'/', Qt::SkipEmptyParts );
1915#if defined(Q_OS_WIN)
1918 targetElems.insert( 0,
"" );
1919 targetElems.insert( 0,
"" );
1924 targetElems << srcElems;
1925 targetElems.removeAll( QStringLiteral(
"." ) );
1929 while ( ( pos = targetElems.indexOf( QLatin1String(
".." ) ) ) > 0 )
1932 targetElems.removeAt( pos - 1 );
1933 targetElems.removeAt( pos - 1 );
1936#if !defined(Q_OS_WIN)
1938 targetElems.prepend( QString() );
1941 return targetElems.join( QLatin1Char(
'/' ) );
1946 return *sBuildSourcePath();
1951 return *sBuildOutputPath();
1954#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
1955QString QgsApplication::cfgIntDir()
1957 return *sCfgIntDir();
1963 if ( sGdalSkipList()->contains( driver ) || driver.isEmpty() )
1967 *sGdalSkipList() << driver;
1973 if ( !sGdalSkipList()->contains( driver ) )
1977 int myPos = sGdalSkipList()->indexOf( driver );
1980 sGdalSkipList()->removeAt( myPos );
1987 return *sGdalSkipList();
1991 const QStringList &deferredSkippedGdalDrivers )
2005 QString joinedList, delimiter;
2006 if ( settings.
contains( QStringLiteral(
"gdal/skipDrivers" ) ) )
2008 joinedList = settings.
value( QStringLiteral(
"gdal/skipDrivers" ), QString() ).toString();
2009 delimiter = QStringLiteral(
"," );
2013 joinedList = settings.
value( QStringLiteral(
"gdal/skipList" ), QString() ).toString();
2014 delimiter = QStringLiteral(
" " );
2017 if ( !joinedList.isEmpty() )
2019 myList = joinedList.split( delimiter );
2021 *sGdalSkipList() = myList;
2027 return *sDeferredSkippedGdalDrivers();
2032 sGdalSkipList()->removeDuplicates();
2033 QStringList realDisabledDriverList;
2034 for (
const auto &driverName : *sGdalSkipList() )
2036 if ( !sDeferredSkippedGdalDrivers()->contains( driverName ) )
2037 realDisabledDriverList << driverName;
2039 QString myDriverList = realDisabledDriverList.join(
',' );
2040 QgsDebugMsgLevel( QStringLiteral(
"Gdal Skipped driver list set to:" ), 2 );
2042 CPLSetConfigOption(
"GDAL_SKIP", myDriverList.toUtf8() );
2049 QDir myDir( folder );
2050 if ( !myDir.exists() )
2052 myDir.mkpath( folder );
2058void QgsApplication::copyPath(
const QString &src,
const QString &dst )
2061 if ( ! dir.exists() )
2064 const auto subDirectories = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot );
2065 for (
const QString &d : subDirectories )
2067 QString dst_path = dst + QDir::separator() + d;
2068 dir.mkpath( dst_path );
2069 copyPath( src + QDir::separator() + d, dst_path );
2072 const auto files = dir.entryList( QDir::Files );
2073 for (
const QString &f :
files )
2075 QFile::copy( src + QDir::separator() + f, dst + QDir::separator() + f );
2084 QVariantMap variables;
2088 QStringList childKeys = settings.
childKeys();
2089 for ( QStringList::const_iterator it = childKeys.constBegin(); it != childKeys.constEnd(); ++it )
2092 variables.insert( name, settings.
value( name ) );
2102 QVariantMap::const_iterator it = variables.constBegin();
2105 for ( ; it != variables.constEnd(); ++it )
2107 settings.
setValue( it.key(), it.value() );
2118 settings.
setValue( QStringLiteral(
"variables/" ) + name, value );
2125 QFontMetrics fm( ( QFont() ) );
2126 const double scale = 1.1 * standardSize / 24;
2127 int scaledIconSize =
static_cast< int >( std::floor( std::max(
Qgis::UI_SCALE_FACTOR * fm.height() * scale,
static_cast< double >( standardSize ) ) ) );
2128 if ( applyDevicePixelRatio )
2130 if ( QWidget *activeWindow = QApplication::activeWindow() )
2131 scaledIconSize *= ( activeWindow->screen() ? QApplication::activeWindow()->screen()->devicePixelRatio() : 1 );
2133 return scaledIconSize;
2146 app->installTranslators();
2152 return *sTranslation();
2162 ApplicationMembers *appMembers = members();
2163 if ( appMembers->mNullRepresentation.isNull() )
2165 appMembers->mNullRepresentation =
QgsSettings().
value( QStringLiteral(
"qgis/nullValue" ), QStringLiteral(
"NULL" ) ).toString();
2167 return appMembers->mNullRepresentation;
2172 ApplicationMembers *appMembers = members();
2186 return members()->mActionScopeRegistry;
2195 QDir myDir( myPamPath );
2196 if ( !myDir.exists() )
2198 myDir.mkpath( myPamPath );
2201#if defined(Q_OS_WIN)
2202 CPLSetConfigOption(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() );
2206 int myChangeFlag = 0;
2207 setenv(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag );
2214 if ( !qgisPrivateDbFile.exists() )
2218 QFile masterFile( qgisMasterDbFileName );
2224 bool isDbFileCopied = masterFile.copy( qgisPrivateDbFile.fileName() );
2226 if ( !isDbFileCopied )
2230 *errorMessage = tr(
"[ERROR] Can not make qgis.db private copy" );
2235 QFile::Permissions perms = QFile( qgisPrivateDbFile.fileName() ).permissions();
2236 if ( !( perms & QFile::WriteOwner ) )
2238 if ( !qgisPrivateDbFile.setPermissions( perms | QFile::WriteOwner ) )
2242 *errorMessage = tr(
"Can not make '%1' user writable" ).arg( qgisPrivateDbFile.fileName() );
2256 *errorMessage = tr(
"Could not open qgis.db" );
2261 char *errmsg =
nullptr;
2262 int res = sqlite3_exec( database.get(),
"SELECT srs_id FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2263 if ( res != SQLITE_OK )
2265 sqlite3_free( errmsg );
2268 if ( sqlite3_exec( database.get(),
2269 "DROP INDEX IF EXISTS idx_srsauthid;"
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);",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2286 *errorMessage = tr(
"Creation of missing tbl_srs in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2288 sqlite3_free( errmsg );
2295 res = sqlite3_exec( database.get(),
"SELECT wkt FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2296 if ( res != SQLITE_OK )
2299 sqlite3_free( errmsg );
2300 if ( sqlite3_exec( database.get(),
2301 "DROP INDEX IF EXISTS idx_srsauthid;"
2302 "DROP TABLE IF EXISTS tbl_srs_bak;"
2303 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2304 "CREATE TABLE tbl_srs ("
2305 "srs_id INTEGER PRIMARY KEY,"
2306 "description text NOT NULL,"
2307 "projection_acronym text NOT NULL,"
2308 "ellipsoid_acronym NOT NULL,"
2309 "parameters text NOT NULL,"
2311 "auth_name varchar,"
2313 "is_geo integer NOT NULL,"
2314 "deprecated boolean,"
2316 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2317 "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;"
2318 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2322 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2324 sqlite3_free( errmsg );
2330 res = sqlite3_exec( database.get(),
"SELECT acronym FROM tbl_projection LIMIT 0",
nullptr,
nullptr, &errmsg );
2331 if ( res != SQLITE_OK )
2333 sqlite3_free( errmsg );
2336 if ( sqlite3_exec( database.get(),
2337 "CREATE TABLE tbl_projection ("
2338 "acronym varchar(20) NOT NULL PRIMARY KEY,"
2339 "name varchar(255) NOT NULL default '',"
2340 "notes varchar(255) NOT NULL default '',"
2341 "parameters varchar(255) NOT NULL default ''"
2342 ")",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2346 *errorMessage = tr(
"Creation of missing tbl_projection in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2348 sqlite3_free( errmsg );
2353 res = sqlite3_exec( database.get(),
"SELECT epsg FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2354 if ( res == SQLITE_OK )
2357 if ( sqlite3_exec( database.get(),
2358 "DROP INDEX IF EXISTS idx_srsauthid;"
2359 "DROP TABLE IF EXISTS tbl_srs_bak;"
2360 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2361 "CREATE TABLE tbl_srs ("
2362 "srs_id INTEGER PRIMARY KEY,"
2363 "description text NOT NULL,"
2364 "projection_acronym text NOT NULL,"
2365 "ellipsoid_acronym NOT NULL,"
2366 "parameters text NOT NULL,"
2368 "auth_name varchar,"
2370 "is_geo integer NOT NULL,"
2371 "deprecated boolean,"
2373 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2374 "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;"
2375 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2379 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2381 sqlite3_free( errmsg );
2387 sqlite3_free( errmsg );
2390 if ( sqlite3_exec( database.get(),
"DROP VIEW vw_srs",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2392 QgsDebugError( QStringLiteral(
"vw_srs didn't exists in private qgis.db: %1" ).arg( errmsg ) );
2395 if ( sqlite3_exec( database.get(),
2396 "CREATE VIEW vw_srs AS"
2398 " a.description AS description"
2399 ",a.srs_id AS srs_id"
2400 ",a.is_geo AS is_geo"
2401 ",coalesce(b.name,a.projection_acronym) AS name"
2402 ",a.parameters AS parameters"
2403 ",a.auth_name AS auth_name"
2404 ",a.auth_id AS auth_id"
2405 ",a.deprecated AS deprecated"
2407 " LEFT OUTER JOIN tbl_projection b ON a.projection_acronym=b.acronym"
2408 " ORDER BY coalesce(b.name,a.projection_acronym),a.description",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2412 *errorMessage = tr(
"Update of view in private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2414 sqlite3_free( errmsg );
2426 if ( maxThreads < 1 || maxThreads > QThread::idealThreadCount() )
2441 QThreadPool::globalInstance()->setMaxThreadCount(
maxThreads );
2442 QgsDebugMsgLevel( QStringLiteral(
"set QThreadPool max thread count to %1" ).arg( QThreadPool::globalInstance()->maxThreadCount() ), 2 );
2447 return members()->mTaskManager;
2452 return members()->mSettingsRegistryCore;
2457 return members()->mColorSchemeRegistry;
2462 return members()->mPaintEffectRegistry;
2467 return members()->mRendererRegistry;
2472 return members()->mRasterRendererRegistry;
2477 return members()->mPointCloudRendererRegistry;
2482 return members()->mTiledSceneRendererRegistry;
2487 if (
auto *lInstance =
instance() )
2489 if ( !
instance()->mDataItemProviderRegistry )
2493 return lInstance->mDataItemProviderRegistry;
2499 if ( !sDataItemProviderRegistry )
2501 return sDataItemProviderRegistry;
2507 return members()->mCrsRegistry;
2512 return members()->mSvgCache;
2517 return members()->mImageCache;
2522 return members()->mSourceCache;
2527 return members()->mNetworkContentFetcherRegistry;
2532 return members()->mValidityCheckRegistry;
2537 return members()->mSymbolLayerRegistry;
2542 return members()->mCalloutRegistry;
2547 return members()->mLayoutItemRegistry;
2552 return members()->mAnnotationItemRegistry;
2557 return members()->mSensorRegistry;
2562 return members()->mGpsConnectionRegistry;
2567 return members()->mGpsBabelFormatRegistry;
2572 return members()->mPluginLayerRegistry;
2577 return members()->mClassificationMethodRegistry;
2582 return members()->mBookmarkManager;
2587 return members()->mTileDownloadManager;
2592 return members()->mRecentStyleHandler;
2597 return members()->mQueryLogger;
2602 return members()->mStyleModel;
2607 return members()->mFontManager;
2612 return members()->mMessageLog;
2617 return members()->mProcessingRegistry;
2622 return members()->mConnectionRegistry;
2627 return members()->mLayerMetadataProviderRegistry;
2632 return members()->mPageSizeRegistry;
2637 return members()->mAnnotationRegistry;
2642 return members()->mNumericFormatRegistry;
2647 return members()->mFieldFormatterRegistry;
2652 return members()->m3DRendererRegistry;
2657 return members()->m3DSymbolRegistry;
2662 return members()->mScaleBarRendererRegistry;
2667 return members()->mLabelingEngineRuleRegistry;
2672 return members()->mProjectStorageRegistry;
2677 return members()->mExternalStorageRegistry;
2682 return members()->mProfileSourceRegistry;
2687 return members()->mLocalizedDataPathRegistry;
2690QgsApplication::ApplicationMembers::ApplicationMembers()
2700 profiler->
start( tr(
"Create query logger" ) );
2705 profiler->
start( tr(
"Setup coordinate reference system registry" ) );
2710 profiler->
start( tr(
"Create connection registry" ) );
2715 profiler->
start( tr(
"Create project storage registry" ) );
2720 profiler->
start( tr(
"Create layer metadata provider registry" ) );
2725 profiler->
start( tr(
"Create font manager" ) );
2730 profiler->
start( tr(
"Setup task manager" ) );
2735 profiler->
start( tr(
"Setup action scope registry" ) );
2740 profiler->
start( tr(
"Setup numeric formats" ) );
2745 profiler->
start( tr(
"Setup field formats" ) );
2750 profiler->
start( tr(
"Setup SVG cache" ) );
2755 profiler->
start( tr(
"Setup image cache" ) );
2760 profiler->
start( tr(
"Setup source cache" ) );
2765 profiler->
start( tr(
"Setup color scheme registry" ) );
2770 profiler->
start( tr(
"Setup paint effect" ) );
2775 profiler->
start( tr(
"Setup symbol layer registry" ) );
2780 profiler->
start( tr(
"Recent style handler" ) );
2785 profiler->
start( tr(
"Setup callout registry" ) );
2790 profiler->
start( tr(
"Setup renderer registry" ) );
2795 profiler->
start( tr(
"Setup raster renderer registry" ) );
2800 profiler->
start( tr(
"Setup point cloud renderer registry" ) );
2805 profiler->
start( tr(
"Setup tiled scene renderer registry" ) );
2810 profiler->
start( tr(
"Setup GPS registry" ) );
2815 profiler->
start( tr(
"Setup GPSBabel format registry" ) );
2820 profiler->
start( tr(
"Setup plugin layer registry" ) );
2825 profiler->
start( tr(
"Setup Processing registry" ) );
2831 profiler->
start( tr(
"Setup layout item registry" ) );
2833 mLayoutItemRegistry->populate();
2837 profiler->
start( tr(
"Setup annotation registry" ) );
2838 mAnnotationRegistry =
new QgsAnnotationRegistry();
2842 profiler->
start( tr(
"Setup annotation item registry" ) );
2844 mAnnotationItemRegistry->populate();
2848 profiler->
start( tr(
"Setup labeling engine rule registry" ) );
2853 profiler->
start( tr(
"Setup sensor registry" ) );
2855 mSensorRegistry->populate();
2859 profiler->
start( tr(
"Setup 3D symbol registry" ) );
2864 profiler->
start( tr(
"Setup 3D renderer registry" ) );
2869 profiler->
start( tr(
"Setup external storage registry" ) );
2874 profiler->
start( tr(
"Setup profile source registry" ) );
2879 profiler->
start( tr(
"Setup network content cache" ) );
2884 profiler->
start( tr(
"Setup layout check registry" ) );
2889 profiler->
start( tr(
"Setup classification registry" ) );
2894 profiler->
start( tr(
"Setup bookmark manager" ) );
2899 profiler->
start( tr(
"Setup tile download manager" ) );
2904 profiler->
start( tr(
"Setup scalebar registry" ) );
2910QgsApplication::ApplicationMembers::~ApplicationMembers()
2913 delete mTileDownloadManager;
2914 delete mScaleBarRendererRegistry;
2915 delete mValidityCheckRegistry;
2916 delete mActionScopeRegistry;
2917 delete m3DRendererRegistry;
2918 delete m3DSymbolRegistry;
2919 delete mAnnotationRegistry;
2920 delete mColorSchemeRegistry;
2921 delete mFieldFormatterRegistry;
2922 delete mGpsConnectionRegistry;
2923 delete mGpsBabelFormatRegistry;
2925 delete mPaintEffectRegistry;
2926 delete mPluginLayerRegistry;
2927 delete mProcessingRegistry;
2928 delete mPageSizeRegistry;
2929 delete mAnnotationItemRegistry;
2930 delete mSensorRegistry;
2931 delete mLayoutItemRegistry;
2932 delete mPointCloudRendererRegistry;
2933 delete mTiledSceneRendererRegistry;
2934 delete mRasterRendererRegistry;
2935 delete mRendererRegistry;
2938 delete mSourceCache;
2939 delete mCalloutRegistry;
2940 delete mRecentStyleHandler;
2941 delete mLabelingEngineRuleRegistry;
2942 delete mSymbolLayerRegistry;
2943 delete mExternalStorageRegistry;
2944 delete mProfileSourceRegistry;
2945 delete mTaskManager;
2946 delete mNetworkContentFetcherRegistry;
2947 delete mClassificationMethodRegistry;
2948 delete mNumericFormatRegistry;
2949 delete mBookmarkManager;
2950 delete mConnectionRegistry;
2951 delete mProjectStorageRegistry;
2952 delete mLayerMetadataProviderRegistry;
2953 delete mFontManager;
2954 delete mLocalizedDataPathRegistry;
2955 delete mCrsRegistry;
2956 delete mQueryLogger;
2957 delete mSettingsRegistryCore;
2960QgsApplication::ApplicationMembers *QgsApplication::members()
2962 if (
auto *lInstance =
instance() )
2964 return lInstance->mApplicationMembers;
2968 static QRecursiveMutex sMemberMutex;
2969 QMutexLocker lock( &sMemberMutex );
2970 if ( !sApplicationMembers )
2971 sApplicationMembers =
new ApplicationMembers();
2972 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 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 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 offering an interface to manage the authentication configuration database and to utilize co...
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.
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.
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.
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)