103#include <QAuthenticator>
107#include <QFileOpenEvent>
109#include <QLibraryInfo>
111#include <QMessageBox>
115#include <QProcessEnvironment>
116#include <QRecursiveMutex>
117#include <QRegularExpression>
119#include <QStandardPaths>
121#include <QTextStream>
122#include <QThreadPool>
124#include "moc_qgsapplication.cpp"
126#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
127#include <QImageReader>
143#include <netinet/in.h>
149#define SECURITY_WIN32
152#pragma comment( lib, "Secur32.lib" )
156#include "qgsconfig.h"
166#if defined(Q_OS_LINUX)
167#include <sys/sysinfo.h>
170#define CONN_POOL_MAX_CONCURRENT_CONNS 4
230QObject *
ABISYM( QgsApplication::mFileOpenEventReceiver ) =
nullptr;
231bool ABISYM( QgsApplication::mInitialized ) =
false;
232bool ABISYM( QgsApplication::mRunningFromBuildDir ) =
false;
238int ABISYM( QgsApplication::sMaxThreads ) = -1;
255#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
273 : QApplication( argc, argv, GUIenabled )
275 *sPlatformName() = platformName;
280 if ( platformName != QLatin1String(
"desktop" ) )
282 mApplicationMembers = std::make_unique<ApplicationMembers>();
285 mApplicationMembers->mSettingsRegistryCore->migrateOldSettings();
289 QgsDebugError( QStringLiteral(
"Error migrating old settings: %1" ).arg( e.
what() ) );
294 *sProfilePath() = profileFolder;
301 qRegisterMetaType<QgsGeometry::Error>(
"QgsGeometry::Error" );
302 qRegisterMetaType<QgsDatabaseQueryLogEntry>(
"QgsDatabaseQueryLogEntry" );
303 qRegisterMetaType<QgsProcessingFeatureSourceDefinition>(
"QgsProcessingFeatureSourceDefinition" );
304 qRegisterMetaType<QgsProcessingOutputLayerDefinition>(
"QgsProcessingOutputLayerDefinition" );
305 qRegisterMetaType<Qgis::LayoutUnit>(
"Qgis::LayoutUnit" );
306 qRegisterMetaType<QgsUnsetAttributeValue>(
"QgsUnsetAttributeValue" );
307 qRegisterMetaType<QgsFeatureId>(
"QgsFeatureId" );
308 qRegisterMetaType<QgsFields>(
"QgsFields" );
309 qRegisterMetaType<QgsFeatureIds>(
"QgsFeatureIds" );
310 qRegisterMetaType<QgsProperty>(
"QgsProperty" );
311 qRegisterMetaType<QgsFeatureStoreList>(
"QgsFeatureStoreList" );
312 qRegisterMetaType<Qgis::MessageLevel>(
"Qgis::MessageLevel" );
313 qRegisterMetaType<Qgis::BrowserItemState>(
"Qgis::BrowserItemState" );
314 qRegisterMetaType<Qgis::GpsFixStatus>(
"Qgis::GpsFixStatus" );
315 qRegisterMetaType<QgsReferencedRectangle>(
"QgsReferencedRectangle" );
316 qRegisterMetaType<QgsReferencedPointXY>(
"QgsReferencedPointXY" );
317 qRegisterMetaType<QgsReferencedGeometry>(
"QgsReferencedGeometry" );
318 qRegisterMetaType<Qgis::LayoutRenderFlags>(
"Qgis::LayoutRenderFlags" );
319 qRegisterMetaType<QgsStyle::StyleEntity>(
"QgsStyle::StyleEntity" );
320 qRegisterMetaType<QgsCoordinateReferenceSystem>(
"QgsCoordinateReferenceSystem" );
321 qRegisterMetaType<QgsAuthManager::MessageLevel>(
"QgsAuthManager::MessageLevel" );
322 qRegisterMetaType<QgsNetworkRequestParameters>(
"QgsNetworkRequestParameters" );
323 qRegisterMetaType<QgsNetworkReplyContent>(
"QgsNetworkReplyContent" );
324 qRegisterMetaType<QgsFeature>(
"QgsFeature" );
325 qRegisterMetaType<QgsGeometry>(
"QgsGeometry" );
326 qRegisterMetaType<QgsInterval>(
"QgsInterval" );
327 qRegisterMetaType<QgsRectangle>(
"QgsRectangle" );
328 qRegisterMetaType<QgsPointXY>(
"QgsPointXY" );
329 qRegisterMetaType<QgsPoint>(
"QgsPoint" );
330 qRegisterMetaType<QgsDatumTransform::GridDetails>(
"QgsDatumTransform::GridDetails" );
331 qRegisterMetaType<QgsDatumTransform::TransformDetails>(
"QgsDatumTransform::TransformDetails" );
332 qRegisterMetaType<QgsNewsFeedParser::Entry>(
"QgsNewsFeedParser::Entry" );
333 qRegisterMetaType<QgsRectangle>(
"QgsRectangle" );
334 qRegisterMetaType<QgsLocatorResult>(
"QgsLocatorResult" );
335 qRegisterMetaType<QgsGradientColorRamp>(
"QgsGradientColorRamp" );
336 qRegisterMetaType<QgsProcessingModelChildParameterSource>(
"QgsProcessingModelChildParameterSource" );
337#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
340 qRegisterMetaTypeStreamOperators<QgsProcessingModelChildParameterSource>(
"QgsProcessingModelChildParameterSource" );
342 qRegisterMetaType<QgsRemappingSinkDefinition>(
"QgsRemappingSinkDefinition" );
343 qRegisterMetaType<QgsProcessingModelChildDependency>(
"QgsProcessingModelChildDependency" );
344 qRegisterMetaType<QgsTextFormat>(
"QgsTextFormat" );
345#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
346 QMetaType::registerComparators<QgsProcessingModelChildDependency>();
347 QMetaType::registerEqualsComparator<QgsProcessingFeatureSourceDefinition>();
348 QMetaType::registerEqualsComparator<QgsProperty>();
349 QMetaType::registerEqualsComparator<QgsDateTimeRange>();
350 QMetaType::registerEqualsComparator<QgsDateRange>();
351 QMetaType::registerEqualsComparator<QgsUnsetAttributeValue>();
353 qRegisterMetaType<QPainter::CompositionMode>(
"QPainter::CompositionMode" );
354 qRegisterMetaType<QgsDateTimeRange>(
"QgsDateTimeRange" );
355 qRegisterMetaType<QgsDoubleRange>(
"QgsDoubleRange" );
356 qRegisterMetaType<QgsIntRange>(
"QgsIntRange" );
357 qRegisterMetaType<QList<QgsMapLayer *>>(
"QList<QgsMapLayer*>" );
358 qRegisterMetaType<QMap<QNetworkRequest::Attribute, QVariant>>(
"QMap<QNetworkRequest::Attribute,QVariant>" );
359 qRegisterMetaType<QMap<QNetworkRequest::KnownHeaders, QVariant>>(
"QMap<QNetworkRequest::KnownHeaders,QVariant>" );
360 qRegisterMetaType<QList<QNetworkReply::RawHeaderPair>>(
"QList<QNetworkReply::RawHeaderPair>" );
361 qRegisterMetaType<QNetworkReply::NetworkError>(
"QNetworkReply::NetworkError" );
362 qRegisterMetaType< QAuthenticator * >(
"QAuthenticator*" );
363 qRegisterMetaType< QgsGpsInformation >(
"QgsGpsInformation" );
364 qRegisterMetaType< QgsSensorThingsExpansionDefinition >(
"QgsSensorThingsExpansionDefinition" );
365 qRegisterMetaType< QTimeZone >(
"QTimeZone" );
371 if (
platform() == QLatin1String(
"desktop" ) )
373 instance()->mApplicationMembers = std::make_unique<ApplicationMembers>();
376 instance()->mApplicationMembers->mSettingsRegistryCore->migrateOldSettings();
380 QgsDebugError( QStringLiteral(
"Error migrating old settings: %1" ).arg( e.
what() ) );
384 if ( profileFolder.isEmpty() )
386 if ( getenv(
"QGIS_CUSTOM_CONFIG_PATH" ) )
388 profileFolder = getenv(
"QGIS_CUSTOM_CONFIG_PATH" );
392 profileFolder = QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ).value( 0 );
398 std::unique_ptr< QgsUserProfile > profile = manager.
getProfile();
399 profileFolder = profile->folder();
402 *sProfilePath() = profileFolder;
404 static std::once_flag sMetaTypesRegistered;
409 if ( ABISYM( mRunningFromBuildDir ) )
412 *sPrefixPath() = QString();
413#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
414 setPluginPath( *sBuildOutputPath() +
'/' + QString( QGIS_PLUGIN_SUBDIR ) +
'/' + *sCfgIntDir() );
416 setPluginPath( *sBuildOutputPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
418 setPkgDataPath( *sBuildOutputPath() + QStringLiteral(
"/data" ) );
419 *sLibraryPath() = *sBuildOutputPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
420#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
421 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/' + *sCfgIntDir() +
'/';
423 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
425#if defined( HAVE_QUICK )
426 *sQmlImportPath() = *sBuildOutputPath() +
'/' + QGIS_QML_SUBDIR +
'/';
431 char *
prefixPath = getenv(
"QGIS_PREFIX_PATH" );
434 if ( sPrefixPath()->isNull() )
436#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) && !defined(QGIS_MAC_BUNDLE)
438#elif defined(QGIS_MAC_BUNDLE)
439 QDir myDir( applicationDirPath() + QLatin1String(
"/../.." ) );
441#elif defined(ANDROID)
443 QDir myDir( QDir::homePath() );
445 QString myPrefix = myDir.absolutePath();
448 QDir myDir( applicationDirPath() );
450 if ( applicationDirPath().contains( QStringLiteral(
"cgi-bin" ) ) )
455 QString myPrefix = myDir.absolutePath();
466 *sConfigPath() = profileFolder +
'/';
475 if ( getenv(
"QGIS_AUTH_DB_DIR_PATH" ) )
478 sAuthDbUri()->clear();
481 if ( getenv(
"QGIS_AUTH_DB_URI" ) )
483 *sAuthDbUri() = getenv(
"QGIS_AUTH_DB_URI" );
487 if ( sAuthDbUri->isEmpty() )
489 *sAuthDbUri() = QStringLiteral(
"QSQLITE://" ) + *sAuthDbDirPath() + QStringLiteral(
"qgis-auth.db" );
493 qputenv(
"QT3D_RENDERER",
"opengl" );
496 QMap<QString, QString> systemEnvVarMap;
497 QString passfile( QStringLiteral(
"QGIS_AUTH_PASSWORD_FILE" ) );
499 const auto systemEnvironment = QProcessEnvironment::systemEnvironment().toStringList();
500 for (
const QString &varStr : systemEnvironment )
502 int pos = varStr.indexOf( QLatin1Char(
'=' ) );
505 QString varStrName = varStr.left( pos );
506 QString varStrValue = varStr.mid( pos + 1 );
507 if ( varStrName != passfile )
509 systemEnvVarMap.insert( varStrName, varStrValue );
512 *sSystemEnvVars() = systemEnvVarMap;
519 QString projLib( QDir::cleanPath(
pkgDataPath().append(
"/proj" ) ) );
520 if ( QFile::exists( projLib ) )
522 currentProjSearchPaths.append( projLib );
526 char **newPaths =
new char *[currentProjSearchPaths.length()];
527 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
529 newPaths[i] = CPLStrdup( currentProjSearchPaths.at( i ).toUtf8().constData() );
531 proj_context_set_search_paths(
nullptr, currentProjSearchPaths.count(), newPaths );
532 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
534 CPLFree( newPaths[i] );
539 QCoreApplication::addLibraryPath(
pluginPath() );
541#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
543 QImageReader::setAllocationLimit( 512 );
554 ABISYM( sMaxThreads ) = -1;
570 if ( !members()->mStyleModel )
571 members()->mStyleModel = std::make_unique<QgsStyleModel>( defaultStyle );
573 ABISYM( mInitialized ) =
true;
577void QgsApplication::installTranslators()
580 if ( mQgisTranslator )
582 removeTranslator( mQgisTranslator.get() );
583 mQgisTranslator.reset( );
588 removeTranslator( mQtTranslator.get() );
589 mQtTranslator.reset( );
592 if ( mQtBaseTranslator )
594 removeTranslator( mQtBaseTranslator.get() );
595 mQtBaseTranslator.reset( );
599 if ( *sTranslation() != QLatin1String(
"C" ) )
601 mQgisTranslator = std::make_unique<QTranslator>(
this );
602 if ( mQgisTranslator->load( QStringLiteral(
"qgis_" ) + *sTranslation(),
i18nPath() ) )
604 installTranslator( mQgisTranslator.get() );
608 QgsDebugMsgLevel( QStringLiteral(
"loading of qgis translation failed %1/qgis_%2" ).arg(
i18nPath(), *sTranslation() ), 2 );
616 QString qtTranslationsPath = QLibraryInfo::location( QLibraryInfo::TranslationsPath );
618 QString prefix = QDir( QString(
"%1/../" ).arg( QApplication::applicationDirPath() ) ).absolutePath();
619 qtTranslationsPath = prefix + qtTranslationsPath.mid( QLibraryInfo::location( QLibraryInfo::PrefixPath ).length() );
622 mQtTranslator = std::make_unique<QTranslator>(
this );
623 if ( mQtTranslator->load( QStringLiteral(
"qt_" ) + *sTranslation(), qtTranslationsPath ) )
625 installTranslator( mQtTranslator.get() );
629 QgsDebugMsgLevel( QStringLiteral(
"loading of qt translation failed %1/qt_%2" ).arg( qtTranslationsPath, *sTranslation() ), 2 );
632 mQtBaseTranslator = std::make_unique<QTranslator>(
this );
633 if ( mQtBaseTranslator->load( QStringLiteral(
"qtbase_" ) + *sTranslation(), qtTranslationsPath ) )
635 installTranslator( mQtBaseTranslator.get() );
639 QgsDebugMsgLevel( QStringLiteral(
"loading of qtbase translation failed %1/qt_%2" ).arg( qtTranslationsPath, *sTranslation() ), 2 );
646 if ( mApplicationMembers )
650 mApplicationMembers->mSettingsRegistryCore->backwardCompatibility();
654 QgsDebugError( QStringLiteral(
"An error occurred while performing backwards compatibility for settings: %1" ).arg( e.
what() ) );
664void QgsApplication::invalidateCaches()
676 return qobject_cast<QgsApplication *>( QCoreApplication::instance() );
682 if (
event->type() == QEvent::FileOpen )
685 if ( ABISYM( mFileOpenEventReceiver ) )
688 done =
notify( ABISYM( mFileOpenEventReceiver ),
event );
695 sFileOpenEventList()->append(
static_cast<QFileOpenEvent *
>(
event )->file() );
702 done = QApplication::event(
event );
711 if ( thread() == receiver->thread() )
721 done = QApplication::notify( receiver,
event );
725 qCritical() <<
"Caught unhandled QgsException: " << e.
what();
726 if ( qApp->thread() == QThread::currentThread() )
727 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
729 catch ( std::exception &e )
731 qCritical() <<
"Caught unhandled std::exception: " << e.
what();
732 if ( qApp->thread() == QThread::currentThread() )
733 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
737 qCritical() <<
"Caught unhandled unknown exception";
738 if ( qApp->thread() == QThread::currentThread() )
739 QMessageBox::critical( activeWindow(), tr(
"Exception" ), tr(
"unknown exception" ) );
747 return QgsRuntimeProfiler::threadLocalInstance();
753 ABISYM( mFileOpenEventReceiver ) = receiver;
755 if ( sFileOpenEventList()->count() > 0 )
757 const QStringList fileOpenEventList = *sFileOpenEventList();
758 for (
const QString &file : fileOpenEventList )
760 QFileOpenEvent foe( file );
761 QgsApplication::sendEvent( ABISYM( mFileOpenEventReceiver ), &foe );
763 sFileOpenEventList()->clear();
771 if ( sPrefixPath()->endsWith(
"/bin" ) )
773 sPrefixPath()->chop( 4 );
776 if ( useDefaultPaths && !ABISYM( mRunningFromBuildDir ) )
778 setPluginPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
779 setPkgDataPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_DATA_SUBDIR ) );
781 *sLibraryPath() = *sPrefixPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
782 *sLibexecPath() = *sPrefixPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
783#if defined( HAVE_QUICK )
784 *sQmlImportPath() = *sPrefixPath() +
'/' + QGIS_QML_SUBDIR +
'/';
797 QString mySvgPath =
pkgDataPath + QStringLiteral(
"/svg/" );
800 if ( !sDefaultSvgPaths()->contains( mySvgPath ) )
801 *sDefaultSvgPaths() << mySvgPath;
806 *sDefaultSvgPaths() = pathList;
811 QFileInfo fi( authDbDirPath );
812 if ( fi.exists() && fi.isDir() && fi.isWritable() )
814 *sAuthDbDirPath() = fi.canonicalFilePath() + QDir::separator();
821 if ( ABISYM( mRunningFromBuildDir ) )
823 static bool sOnce =
true;
827 ( void ) blockNotifications;
828 qWarning(
"!!! prefix path was requested, but it is not valid - we do not run from installed path !!!" );
834 return *sPrefixPath();
838 return *sPluginPath();
843 if ( sPkgDataPath()->isNull() )
846 return *sPkgDataPath();
851 return QStringLiteral(
":/images/themes/default/" );
856 QDir dir( usersThemes );
864 return defaultThemes;
870 return iconsPath() + QStringLiteral(
"qgis-icon-60x60.png" );
875 return ABISYM( sMaxThreads );
882 if ( QFile::exists( path + iconFile ) )
883 return path + iconFile;
891 const QString cacheKey = ( name.startsWith(
'/' ) ? name.mid( 1 ) : name )
892 + ( fillColor.isValid() ? QStringLiteral(
"_%1" ).arg( fillColor.name( QColor::HexArgb ).mid( 1 ) ) : QString() )
893 + ( strokeColor.isValid() ? QStringLiteral(
"_%1" ).arg( strokeColor.name( QColor::HexArgb ).mid( 1 ) ) : QString() );
895 if ( app && app->mIconCache.contains( cacheKey ) )
896 return app->mIconCache.value( cacheKey );
899 const bool colorBased = fillColor.isValid() || strokeColor.isValid();
901 auto iconFromColoredSvg = [fillColor, strokeColor, cacheKey](
const QString & path ) -> QIcon
906 const QString
iconPath = sIconCacheDir()->filePath( cacheKey + QStringLiteral(
".svg" ) );
907 if (
const QDir dir = QFileInfo(
iconPath ).dir(); !dir.exists() )
913 if ( f.open( QFile::WriteOnly | QFile::Truncate ) )
915 f.write( svgContent );
924 return QIcon( f.fileName() );
929 if ( QFile::exists( preferredPath ) )
933 icon = iconFromColoredSvg( preferredPath );
937 icon = QIcon( preferredPath );
940 else if ( QFile::exists( defaultPath ) )
946 icon = iconFromColoredSvg( defaultPath );
950 icon = QIcon( defaultPath );
959 app->mIconCache.insert( cacheKey, icon );
966 if ( app && app->mCursorCache.contains( cursor ) )
967 return app->mCursorCache.value( cursor );
978 name = QStringLiteral(
"mZoomIn.svg" );
983 name = QStringLiteral(
"mZoomOut.svg" );
990 name = QStringLiteral(
"mIdentify.svg" );
993 name = QStringLiteral(
"mCrossHair.svg" );
996 name = QStringLiteral(
"mCapturePoint.svg" );
999 name = QStringLiteral(
"mSelect.svg" );
1006 name = QStringLiteral(
"mSampler.svg" );
1011 Q_ASSERT( ! name.isEmpty( ) );
1013 QIcon icon =
getThemeIcon( QStringLiteral(
"cursors" ) + QDir::separator() + name );
1016 if ( ! icon.isNull( ) )
1020 cursorIcon = QCursor( icon.pixmap( std::ceil( scale * 32 ), std::ceil( scale * 32 ) ), std::ceil( scale * activeX ), std::ceil( scale * activeY ) );
1023 app->mCursorCache.insert( cursor, cursorIcon );
1030 const QString preferredPath =
activeThemePath() + QDir::separator() + name;
1032 const QString path = QFile::exists( preferredPath ) ? preferredPath : defaultPath;
1033 if ( foreColor.isValid() || backColor.isValid() )
1035 bool fitsInCache =
false;
1036 const QImage image =
svgCache()->
svgAsImage( path, size, backColor, foreColor, 1, 1, fitsInCache );
1037 return QPixmap::fromImage( image );
1040 return QPixmap( path );
1050 static QString appPath;
1051 if ( appPath.isNull() )
1053 if ( QCoreApplication::instance() )
1055 appPath = applicationDirPath();
1059 qWarning(
"Application path not initialized" );
1063 if ( !appPath.isNull() || getenv(
"QGIS_PREFIX_PATH" ) )
1065 QString prefix = getenv(
"QGIS_PREFIX_PATH" ) ? getenv(
"QGIS_PREFIX_PATH" ) : appPath;
1070 static const QStringList paths { QStringList() << QString() << QStringLiteral(
"/.." ) << QStringLiteral(
"/bin" ) << QStringLiteral(
"/../../.." ) };
1071 for (
const QString &path : paths )
1073 f.setFileName( prefix + path +
"/qgisbuildpath.txt" );
1077 if ( f.exists() && f.open( QIODevice::ReadOnly ) )
1079 ABISYM( mRunningFromBuildDir ) =
true;
1080 *sBuildSourcePath() = f.readLine().trimmed();
1081 *sBuildOutputPath() = f.readLine().trimmed();
1083 QgsDebugMsgLevel( QStringLiteral(
"- source directory: %1" ).arg( sBuildSourcePath()->toUtf8().constData() ), 4 );
1084 QgsDebugMsgLevel( QStringLiteral(
"- output directory of the build: %1" ).arg( sBuildOutputPath()->toUtf8().constData() ), 4 );
1085#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
1086 *sCfgIntDir() = prefix.split(
'/', Qt::SkipEmptyParts ).last();
1087 qDebug(
"- cfg: %s", sCfgIntDir()->toUtf8().constData() );
1093 if ( getenv(
"QGIS_PREFIX_PATH" ) )
1099 QDir dir( QDir::homePath() );
1104#if defined(Q_OS_MACOS)
1106#elif defined(Q_OS_WIN)
1111 QDir dir( appPath );
1113 if ( appPath.contains( QStringLiteral(
"cgi-bin" ) ) )
1123 if ( ABISYM( mRunningFromBuildDir ) )
1124 return *sBuildOutputPath() + QStringLiteral(
"/data" );
1126 return prefixPath +
'/' + QStringLiteral( QGIS_DATA_SUBDIR );
1131 return *sThemeName();
1141 qApp->setStyleSheet( QString() );
1145 QString path = themes.value(
themeName );
1146 QString stylesheetname = path +
"/style.qss";
1148 QFile file( stylesheetname );
1149 QFile variablesfile( path +
"/variables.qss" );
1151 QFileInfo variableInfo( variablesfile );
1153 if ( !file.open( QIODevice::ReadOnly ) || ( variableInfo.exists() && !variablesfile.open( QIODevice::ReadOnly ) ) )
1158 QString styledata = file.readAll();
1159 styledata.replace( QLatin1String(
"@theme_path" ), path );
1161 if ( variableInfo.exists() )
1163 QTextStream in( &variablesfile );
1164 while ( !in.atEnd() )
1166 QString line = in.readLine();
1168 if ( line.startsWith(
'@' ) )
1170 int index = line.indexOf(
':' );
1171 QString name = line.mid( 0, index );
1172 QString value = line.mid( index + 1, line.length() );
1173 styledata.replace( name, value );
1176 variablesfile.close();
1184 const static QRegularExpression regex( QStringLiteral(
"(?<=[\\s:])([0-9\\.]+)(?=em)" ) );
1185 QRegularExpressionMatch match = regex.match( styledata, index );
1186 while ( match.hasMatch() )
1188 index = match.capturedStart();
1189 styledata.remove( index, match.captured( 0 ).length() );
1191 styledata.insert( index, number );
1192 index += number.length();
1193 match = regex.match( styledata, index );
1197 qApp->setStyleSheet( styledata );
1199 QFile palettefile( path +
"/palette.txt" );
1200 QFileInfo paletteInfo( palettefile );
1201 if ( paletteInfo.exists() && palettefile.open( QIODevice::ReadOnly ) )
1203 QPalette
pal = qApp->palette();
1204 QTextStream in( &palettefile );
1205 while ( !in.atEnd() )
1207 QString line = in.readLine();
1208 QStringList parts = line.split(
':' );
1209 if ( parts.count() == 2 )
1211 int role = parts.at( 0 ).trimmed().toInt();
1213 pal.setColor(
static_cast< QPalette::ColorRole
>( role ), color );
1216 palettefile.close();
1217 qApp->setPalette(
pal );
1226 QHash<QString, QString> mapping;
1227 mapping.insert( QStringLiteral(
"default" ), QString() );
1228 const auto constPaths = paths;
1229 for (
const QString &path : constPaths )
1231 QDir folder( path );
1232 QFileInfoList styleFiles = folder.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
1233 const auto constStyleFiles = styleFiles;
1234 for (
const QFileInfo &info : constStyleFiles )
1236 QFileInfo styleFile( info.absoluteFilePath() +
"/style.qss" );
1237 if ( !styleFile.exists() )
1240 QString name = info.baseName();
1241 QString path = info.absoluteFilePath();
1242 mapping.insert( name, path );
1250 return pkgDataPath() + QStringLiteral(
"/doc/AUTHORS" );
1255 return pkgDataPath() + QStringLiteral(
"/doc/CONTRIBUTORS" );
1260 return pkgDataPath() + QStringLiteral(
"/doc/SPONSORS" );
1265 return pkgDataPath() + QStringLiteral(
"/doc/DONORS" );
1270 return pkgDataPath() + QStringLiteral(
"/doc/TRANSLATORS" );
1275 return pkgDataPath() + QStringLiteral(
"/doc/LICENSE" );
1280 if ( ABISYM( mRunningFromBuildDir ) )
1281 return *sBuildOutputPath() + QStringLiteral(
"/i18n/" );
1283 return pkgDataPath() + QStringLiteral(
"/i18n/" );
1288 return pkgDataPath() + QStringLiteral(
"/resources/metadata-ISO/" );
1293 return pkgDataPath() + QStringLiteral(
"/resources/qgis.db" );
1298 return *sConfigPath();
1308 return *sAuthDbDirPath() + QStringLiteral(
"qgis-auth.db" );
1313 return *sAuthDbUri();
1318 return QStringLiteral(
":/images/splash/" );
1323 return pkgDataPath() + QStringLiteral(
"/images/icons/" );
1328 if ( ABISYM( mRunningFromBuildDir ) )
1330 QString tempCopy = QDir::tempPath() +
"/srs6.db";
1332 if ( !QFile( tempCopy ).exists() )
1335 if ( !f.copy( tempCopy ) )
1337 qFatal(
"Could not create temporary copy" );
1345 return pkgDataPath() + QStringLiteral(
"/resources/srs.db" );
1352 members()->mSvgPathCacheValid =
false;
1357 static QReadWriteLock lock;
1361 if ( members()->mSvgPathCacheValid )
1363 return members()->mSvgPathCache;
1374 for (
const QString &path : pathList )
1376 if ( !paths.contains( path ) )
1377 paths.append( path );
1379 for (
const QString &path : std::as_const( *sDefaultSvgPaths() ) )
1381 if ( !paths.contains( path ) )
1382 paths.append( path );
1384 members()->mSvgPathCache = paths;
1399 return *sSystemEnvVars();
1409 const thread_local QRegularExpression regexp( QRegularExpression::anchoredPattern( QStringLiteral(
"^[A-Za-z][A-Za-z0-9\\._-]*" ) ) );
1415 if ( !sUserName()->isEmpty() )
1416 return *sUserName();
1419 TCHAR name [ UNLEN + 1 ];
1420 DWORD size = UNLEN + 1;
1422 if ( GetUserName( ( TCHAR * )name, &size ) )
1424#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
1425 *sUserName() = QString::fromLocal8Bit( name );
1427 *sUserName() = QString::fromWCharArray( name );
1432#elif QT_CONFIG(process)
1435 process.start( QStringLiteral(
"whoami" ), QStringList() );
1436 process.waitForFinished();
1437 *sUserName() = process.readAllStandardOutput().trimmed();
1440 if ( !sUserName()->isEmpty() )
1441 return *sUserName();
1444 *sUserName() = qgetenv(
"USER" );
1445 if ( !sUserName()->isEmpty() )
1446 return *sUserName();
1449 *sUserName() = qgetenv(
"USERNAME" );
1450 return *sUserName();
1455 if ( !sUserFullName()->isEmpty() )
1456 return *sUserFullName();
1459 TCHAR name [ UNLEN + 1 ];
1460 DWORD size = UNLEN + 1;
1463 if ( GetUserNameEx( NameDisplay, ( TCHAR * )name, &size ) )
1465#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
1466 *sUserFullName() = QString::fromLocal8Bit( name );
1468 *sUserFullName() = QString::fromWCharArray( name );
1473 if ( sUserFullName()->isEmpty() )
1475#elif defined(Q_OS_ANDROID) || defined(__MINGW32__)
1476 *sUserFullName() = QStringLiteral(
"Not available" );
1478 struct passwd *p = getpwuid( getuid() );
1482 QString gecosName = QString( p->pw_gecos );
1483 *sUserFullName() = gecosName.left( gecosName.indexOf(
',', 0 ) );
1488 return *sUserFullName();
1493#if defined(Q_OS_ANDROID)
1494 return QLatin1String(
"android" );
1495#elif defined(Q_OS_MAC)
1496 return QLatin1String(
"osx" );
1497#elif defined(Q_OS_WIN)
1498 return QLatin1String(
"windows" );
1499#elif defined(Q_OS_LINUX)
1500 return QStringLiteral(
"linux" );
1501#elif defined(Q_OS_FREEBSD)
1502 return QStringLiteral(
"freebsd" );
1503#elif defined(Q_OS_OPENBSD)
1504 return QStringLiteral(
"openbsd" );
1505#elif defined(Q_OS_NETBSD)
1506 return QStringLiteral(
"netbsd" );
1507#elif defined(Q_OS_UNIX)
1508 return QLatin1String(
"unix" );
1510 return QLatin1String(
"unknown" );
1517 return static_cast<int>( CPLGetUsablePhysicalRAM() / 1048576 );
1522 return *sPlatformName();
1527 if ( !sApplicationFullName()->isEmpty() )
1528 return *sApplicationFullName();
1531 *sApplicationFullName() = qgetenv(
"QGIS_APPLICATION_FULL_NAME" );
1532 if ( !sApplicationFullName()->isEmpty() )
1533 return *sApplicationFullName();
1537 *sApplicationFullName() = settings.
value(
1538 QStringLiteral(
"/qgis/application_full_name" ),
1539 QStringLiteral(
"%1 %2" ).arg( applicationName(),
platform() )
1541 return *sApplicationFullName();
1550 if (
locale.startsWith( QLatin1String(
"en" ), Qt::CaseInsensitive ) )
1559 return QLocale().name().left( 2 );
1565 QLocale::setDefault(
locale );
1576 return pkgDataPath() + QStringLiteral(
"/resources/symbology-style.xml" );
1581 return pkgDataPath() + QStringLiteral(
"/resources/themes" );
1586 return pkgDataPath() + QStringLiteral(
"/resources/server/" );
1591 return *sLibraryPath();
1596 return *sLibexecPath();
1601 return *sQmlImportPath();
1606 return ( htonl( 1 ) == 1 ) ?
XDR :
NDR;
1613 init( *sProfilePath() );
1638 if (
auto *lInstance =
instance() )
1640 if ( !lInstance->mAuthManager )
1644 return lInstance->mAuthManager;
1649 if ( !sAuthManager )
1651 return sAuthManager;
1664 QThreadPool::globalInstance()->waitForDone();
1667 if (
auto *lInstance =
instance() )
1668 delete lInstance->mAuthManager;
1670 delete sAuthManager;
1673 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1679 if ( QgsProject::sProject )
1687 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1690 if ( QgsProviderRegistry::exists() )
1699 GDALDestroyDriverManager();
1704 QString myEnvironmentVar( getenv(
"QGIS_PREFIX_PATH" ) );
1705 QString myState = tr(
"QgsApplication state:\n"
1706 " - QGIS_PREFIX_PATH env var: %1\n"
1708 " - Plugin Path: %3\n"
1709 " - Package Data Path: %4\n"
1710 " - Active Theme Name: %5\n"
1711 " - Active Theme Path: %6\n"
1712 " - Default Theme Path: %7\n"
1713 " - SVG Search Paths: %8\n"
1714 " - User DB Path: %9\n"
1715 " - Auth DB Path: %10\n" )
1716 .arg( myEnvironmentVar,
1723 svgPaths().join( tr(
"\n ",
"match indentation of application state" ) ),
1736 QColor myColor1( Qt::lightGray );
1737 QColor myColor2 = myColor1;
1738 myColor2 = myColor2.lighter( 110 );
1740 myStyle = QStringLiteral(
".overview{"
1742 " font-weight: bold;"
1745 " background: white;"
1747 " font-family: 'Lato', 'Open Sans', 'Lucida Grande', 'Segoe UI', 'Arial', sans-serif;"
1750 "h1{ background-color: #F6F6F6;"
1752 " font-size: x-large; "
1753 " font-weight: normal;"
1754 " background: none;"
1755 " padding: 0.75em 0 0;"
1757 " line-height: 3em;"
1759 "h2{ background-color: #F6F6F6;"
1761 " font-size: medium; "
1762 " font-weight: normal;"
1763 " background: none;"
1764 " padding: 0.75em 0 0;"
1766 " line-height: 1.1em;"
1768 "h3{ background-color: #F6F6F6;"
1770 " font-weight: bold;"
1771 " font-size: large;"
1772 " text-align: left;"
1773 " border-bottom: 5px solid #DCEB5C;"
1775 "h4{ background-color: #F6F6F6;"
1777 " font-weight: bold;"
1778 " font-size: medium;"
1779 " text-align: left;"
1781 "h5{ background-color: #F6F6F6;"
1783 " font-weight: bold;"
1784 " font-size: small;"
1785 " text-align: left;"
1787 "a{ color: #729FCF;"
1788 " font-family: arial,sans-serif;"
1790 "label{ background-color: #FFFFCC;"
1791 " border: 1px solid black;"
1793 " padding: 0px 3px; "
1794 " font-size: small;"
1797 " font-weight: bold;"
1802 " border-top: 1px solid black;"
1804 ".list-view .highlight {"
1805 " text-align: left;"
1808 " padding-right: 15px;"
1809 " padding-left: 20px;"
1810 " font-weight: bold;"
1812 ".tabular-view .odd-row {"
1813 " background-color: #f9f9f9;"
1816 " font-weight: bold;"
1817 " padding-top:25px;"
1821 switch ( styleSheetType )
1824 myStyle += QStringLiteral(
1826 " border-collapse: collapse;"
1829 ".tabular-view th, .tabular-view td { "
1830 " border:1px solid black;"
1835 myStyle += QStringLiteral(
1840 "table.tabular-view, table.list-view { "
1841 " border-collapse: collapse;"
1842 " table-layout:fixed;"
1843 " width: 100% !important;"
1848 " line-height: inherit;"
1851 " word-wrap: break-word; "
1852 " vertical-align: top;"
1855 ".list-view th:first-child, .list-view td:first-child {"
1858 ".list-view.highlight { "
1859 " padding-left: inherit; "
1862 ".tabular-view th:first-child, .tabular-view td:first-child { "
1866 ".tabular-view th.strong { "
1867 " background-color: #eee; "
1870 ".tabular-view th, .tabular-view td { "
1871 " border: 1px solid #eee;"
1882 if ( 0 >= OGRGetDriverCount() )
1890 QString aPathUrl = aPath;
1891 QString tPathUrl = targetPath;
1892#if defined( Q_OS_WIN )
1893 const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
1895 aPathUrl.replace(
'\\',
'/' );
1896 if ( aPathUrl.startsWith(
"//" ) )
1899 aPathUrl =
"\\\\" + aPathUrl.mid( 2 );
1902 tPathUrl.replace(
'\\',
'/' );
1903 if ( tPathUrl.startsWith(
"//" ) )
1906 tPathUrl =
"\\\\" + tPathUrl.mid( 2 );
1909 const Qt::CaseSensitivity cs = Qt::CaseSensitive;
1912 QStringList targetElems = tPathUrl.split(
'/', Qt::SkipEmptyParts );
1913 QStringList aPathElems = aPathUrl.split(
'/', Qt::SkipEmptyParts );
1915 targetElems.removeAll( QStringLiteral(
"." ) );
1916 aPathElems.removeAll( QStringLiteral(
"." ) );
1920 while ( !aPathElems.isEmpty() &&
1921 !targetElems.isEmpty() &&
1922 aPathElems[0].compare( targetElems[0], cs ) == 0 )
1924 aPathElems.removeFirst();
1925 targetElems.removeFirst();
1935 if ( !targetElems.isEmpty() )
1938 for (
int i = 0; i < targetElems.size(); i++ )
1940 aPathElems.insert( 0, QStringLiteral(
".." ) );
1947 aPathElems.insert( 0, QStringLiteral(
"." ) );
1950 return aPathElems.join( QLatin1Char(
'/' ) );
1956 if ( !rpath.startsWith( QLatin1String(
"./" ) ) && !rpath.startsWith( QLatin1String(
"../" ) ) )
1961 QString rPathUrl = rpath;
1962 QString targetPathUrl = targetPath;
1964#if defined(Q_OS_WIN)
1965 rPathUrl.replace(
'\\',
'/' );
1966 targetPathUrl.replace(
'\\',
'/' );
1968 bool uncPath = targetPathUrl.startsWith(
"//" );
1971 QStringList srcElems = rPathUrl.split(
'/', Qt::SkipEmptyParts );
1972 QStringList targetElems = targetPathUrl.split(
'/', Qt::SkipEmptyParts );
1974#if defined(Q_OS_WIN)
1977 targetElems.insert( 0,
"" );
1978 targetElems.insert( 0,
"" );
1983 targetElems << srcElems;
1984 targetElems.removeAll( QStringLiteral(
"." ) );
1988 while ( ( pos = targetElems.indexOf( QLatin1String(
".." ) ) ) > 0 )
1991 targetElems.removeAt( pos - 1 );
1992 targetElems.removeAt( pos - 1 );
1995#if !defined(Q_OS_WIN)
1997 targetElems.prepend( QString() );
2000 return targetElems.join( QLatin1Char(
'/' ) );
2005 return *sBuildSourcePath();
2010 return *sBuildOutputPath();
2013#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
2014QString QgsApplication::cfgIntDir()
2016 return *sCfgIntDir();
2022 if ( sGdalSkipList()->contains( driver ) || driver.isEmpty() )
2026 *sGdalSkipList() << driver;
2032 if ( !sGdalSkipList()->contains( driver ) )
2036 int myPos = sGdalSkipList()->indexOf( driver );
2039 sGdalSkipList()->removeAt( myPos );
2046 return *sGdalSkipList();
2064 QString joinedList, delimiter;
2065 if ( settings.
contains( QStringLiteral(
"gdal/skipDrivers" ) ) )
2067 joinedList = settings.
value( QStringLiteral(
"gdal/skipDrivers" ), QString() ).toString();
2068 delimiter = QStringLiteral(
"," );
2072 joinedList = settings.
value( QStringLiteral(
"gdal/skipList" ), QString() ).toString();
2073 delimiter = QStringLiteral(
" " );
2076 if ( !joinedList.isEmpty() )
2078 myList = joinedList.split( delimiter );
2080 *sGdalSkipList() = myList;
2086 return *sDeferredSkippedGdalDrivers();
2091 sGdalSkipList()->removeDuplicates();
2092 QStringList realDisabledDriverList;
2093 for (
const auto &driverName : *sGdalSkipList() )
2095 if ( !sDeferredSkippedGdalDrivers()->contains( driverName ) )
2096 realDisabledDriverList << driverName;
2098 QString myDriverList = realDisabledDriverList.join(
',' );
2099 QgsDebugMsgLevel( QStringLiteral(
"Gdal Skipped driver list set to:" ), 2 );
2101 CPLSetConfigOption(
"GDAL_SKIP", myDriverList.toUtf8() );
2108 QDir myDir( folder );
2109 if ( !myDir.exists() )
2111 myDir.mkpath( folder );
2117void QgsApplication::copyPath(
const QString &src,
const QString &dst )
2120 if ( ! dir.exists() )
2123 const auto subDirectories = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot );
2124 for (
const QString &d : subDirectories )
2126 QString dst_path = dst + QDir::separator() + d;
2127 dir.mkpath( dst_path );
2128 copyPath( src + QDir::separator() + d, dst_path );
2131 const auto files = dir.entryList( QDir::Files );
2132 for (
const QString &f : files )
2134 QFile::copy( src + QDir::separator() + f, dst + QDir::separator() + f );
2143 QVariantMap variables;
2147 QStringList childKeys = settings.
childKeys();
2148 for ( QStringList::const_iterator it = childKeys.constBegin(); it != childKeys.constEnd(); ++it )
2151 variables.insert( name, settings.
value( name ) );
2161 QVariantMap::const_iterator it = variables.constBegin();
2164 for ( ; it != variables.constEnd(); ++it )
2166 settings.
setValue( it.key(), it.value() );
2177 settings.
setValue( QStringLiteral(
"variables/" ) + name, value );
2184 return instance()->mTemporarilyTrustedProjectFolders;
2189 instance()->mTemporarilyTrustedProjectFolders = trustedProjectsFolders;
2194 return instance()->mTemporarilyUntrustedProjectFolders;
2199 instance()->mTemporarilyUntrustedProjectFolders = untrustedProjectsFolders;
2204 QFontMetrics fm( ( QFont() ) );
2205 const double scale = 1.1 * standardSize / 24;
2206 int scaledIconSize =
static_cast< int >( std::floor( std::max(
Qgis::UI_SCALE_FACTOR * fm.height() * scale,
static_cast< double >( standardSize ) ) ) );
2207 if ( applyDevicePixelRatio )
2209 if ( QWidget *activeWindow = QApplication::activeWindow() )
2210 scaledIconSize *= ( activeWindow->screen() ? QApplication::activeWindow()->screen()->devicePixelRatio() : 1 );
2212 return scaledIconSize;
2225 app->installTranslators();
2231 return *sTranslation();
2265 return members()->mActionScopeRegistry.get();
2274 QDir myDir( myPamPath );
2275 if ( !myDir.exists() )
2277 myDir.mkpath( myPamPath );
2280#if defined(Q_OS_WIN)
2281 CPLSetConfigOption(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() );
2285 int myChangeFlag = 0;
2286 setenv(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag );
2293 if ( !qgisPrivateDbFile.exists() )
2297 QFile masterFile( qgisMasterDbFileName );
2303 bool isDbFileCopied = masterFile.copy( qgisPrivateDbFile.fileName() );
2305 if ( !isDbFileCopied )
2309 *errorMessage = tr(
"[ERROR] Can not make qgis.db private copy" );
2314 QFile::Permissions perms = QFile( qgisPrivateDbFile.fileName() ).permissions();
2315 if ( !( perms & QFile::WriteOwner ) )
2317 if ( !qgisPrivateDbFile.setPermissions( perms | QFile::WriteOwner ) )
2321 *errorMessage = tr(
"Can not make '%1' user writable" ).arg( qgisPrivateDbFile.fileName() );
2335 *errorMessage = tr(
"Could not open qgis.db" );
2340 char *errmsg =
nullptr;
2341 int res = sqlite3_exec( database.get(),
"SELECT srs_id FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2342 if ( res != SQLITE_OK )
2344 sqlite3_free( errmsg );
2347 if ( sqlite3_exec( database.get(),
2348 "DROP INDEX IF EXISTS idx_srsauthid;"
2349 "CREATE TABLE tbl_srs ("
2350 "srs_id INTEGER PRIMARY KEY,"
2351 "description text NOT NULL,"
2352 "projection_acronym text NOT NULL,"
2353 "ellipsoid_acronym NOT NULL,"
2354 "parameters text NOT NULL,"
2356 "auth_name varchar,"
2358 "is_geo integer NOT NULL,"
2359 "deprecated boolean,"
2361 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2365 *errorMessage = tr(
"Creation of missing tbl_srs in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2367 sqlite3_free( errmsg );
2374 res = sqlite3_exec( database.get(),
"SELECT wkt FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2375 if ( res != SQLITE_OK )
2378 sqlite3_free( errmsg );
2379 if ( sqlite3_exec( database.get(),
2380 "DROP INDEX IF EXISTS idx_srsauthid;"
2381 "DROP TABLE IF EXISTS tbl_srs_bak;"
2382 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2383 "CREATE TABLE tbl_srs ("
2384 "srs_id INTEGER PRIMARY KEY,"
2385 "description text NOT NULL,"
2386 "projection_acronym text NOT NULL,"
2387 "ellipsoid_acronym NOT NULL,"
2388 "parameters text NOT NULL,"
2390 "auth_name varchar,"
2392 "is_geo integer NOT NULL,"
2393 "deprecated boolean,"
2395 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2396 "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;"
2397 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2401 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2403 sqlite3_free( errmsg );
2409 res = sqlite3_exec( database.get(),
"SELECT acronym FROM tbl_projection LIMIT 0",
nullptr,
nullptr, &errmsg );
2410 if ( res != SQLITE_OK )
2412 sqlite3_free( errmsg );
2415 if ( sqlite3_exec( database.get(),
2416 "CREATE TABLE tbl_projection ("
2417 "acronym varchar(20) NOT NULL PRIMARY KEY,"
2418 "name varchar(255) NOT NULL default '',"
2419 "notes varchar(255) NOT NULL default '',"
2420 "parameters varchar(255) NOT NULL default ''"
2421 ")",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2425 *errorMessage = tr(
"Creation of missing tbl_projection in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2427 sqlite3_free( errmsg );
2432 res = sqlite3_exec( database.get(),
"SELECT epsg FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2433 if ( res == SQLITE_OK )
2436 if ( sqlite3_exec( database.get(),
2437 "DROP INDEX IF EXISTS idx_srsauthid;"
2438 "DROP TABLE IF EXISTS tbl_srs_bak;"
2439 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2440 "CREATE TABLE tbl_srs ("
2441 "srs_id INTEGER PRIMARY KEY,"
2442 "description text NOT NULL,"
2443 "projection_acronym text NOT NULL,"
2444 "ellipsoid_acronym NOT NULL,"
2445 "parameters text NOT NULL,"
2447 "auth_name varchar,"
2449 "is_geo integer NOT NULL,"
2450 "deprecated boolean,"
2452 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2453 "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;"
2454 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2458 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2460 sqlite3_free( errmsg );
2466 sqlite3_free( errmsg );
2469 if ( sqlite3_exec( database.get(),
"DROP VIEW vw_srs",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2471 QgsDebugError( QStringLiteral(
"vw_srs didn't exists in private qgis.db: %1" ).arg( errmsg ) );
2474 if ( sqlite3_exec( database.get(),
2475 "CREATE VIEW vw_srs AS"
2477 " a.description AS description"
2478 ",a.srs_id AS srs_id"
2479 ",a.is_geo AS is_geo"
2480 ",coalesce(b.name,a.projection_acronym) AS name"
2481 ",a.parameters AS parameters"
2482 ",a.auth_name AS auth_name"
2483 ",a.auth_id AS auth_id"
2484 ",a.deprecated AS deprecated"
2486 " LEFT OUTER JOIN tbl_projection b ON a.projection_acronym=b.acronym"
2487 " ORDER BY coalesce(b.name,a.projection_acronym),a.description",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2491 *errorMessage = tr(
"Update of view in private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2493 sqlite3_free( errmsg );
2520 QThreadPool::globalInstance()->setMaxThreadCount(
maxThreads );
2521 QgsDebugMsgLevel( QStringLiteral(
"set QThreadPool max thread count to %1" ).arg( QThreadPool::globalInstance()->maxThreadCount() ), 2 );
2526 return members()->mTaskManager.get();
2531 return members()->mSettingsRegistryCore.get();
2536 return members()->mColorSchemeRegistry.get();
2541 return members()->mPaintEffectRegistry.get();
2546 return members()->mRendererRegistry.get();
2551 return members()->mRasterRendererRegistry.get();
2556 return members()->mPointCloudRendererRegistry.get();
2561 return members()->mTiledSceneRendererRegistry.get();
2566 if (
auto *lInstance =
instance() )
2568 if ( !
instance()->mDataItemProviderRegistry )
2570 lInstance->mDataItemProviderRegistry = std::make_unique<QgsDataItemProviderRegistry>();
2572 return lInstance->mDataItemProviderRegistry.get();
2578 if ( !sDataItemProviderRegistry )
2580 return sDataItemProviderRegistry;
2586 return members()->mCrsRegistry.get();
2591 return members()->mSvgCache.get();
2596 return members()->mImageCache.get();
2601 return members()->mSourceCache.get();
2606 return members()->mNetworkContentFetcherRegistry.get();
2611 return members()->mValidityCheckRegistry.get();
2616 return members()->mSymbolLayerRegistry.get();
2621 return members()->mCalloutRegistry.get();
2626 return members()->mLayoutItemRegistry.get();
2631 return members()->mAnnotationItemRegistry.get();
2636 return members()->mSensorRegistry.get();
2641 return members()->mPlotRegistry.get();
2646 return members()->mGpsConnectionRegistry.get();
2651 return members()->mGpsBabelFormatRegistry.get();
2656 return members()->mPluginLayerRegistry.get();
2661 return members()->mClassificationMethodRegistry.get();
2666 return members()->mBookmarkManager.get();
2671 return members()->mTileDownloadManager.
get();
2676 return members()->mRecentStyleHandler.get();
2681 return members()->mQueryLogger.get();
2686 return members()->mStyleModel.get();
2691 return members()->mFontManager.get();
2696 return members()->mMessageLog.get();
2701 return members()->mProcessingRegistry.get();
2706 return members()->mConnectionRegistry.get();
2711 return members()->mLayerMetadataProviderRegistry.get();
2716 return members()->mPageSizeRegistry.get();
2721 return members()->mAnnotationRegistry.get();
2726 return members()->mNumericFormatRegistry.get();
2731 return members()->mFieldFormatterRegistry.get();
2736 return members()->m3DRendererRegistry.get();
2741 return members()->m3DSymbolRegistry.get();
2746 return members()->mScaleBarRendererRegistry.get();
2751 return members()->mLabelingEngineRuleRegistry.get();
2756 return members()->mProjectStorageRegistry.get();
2761 return members()->mExternalStorageRegistry.get();
2766 return members()->mProfileSourceRegistry.get();
2771 return members()->mLocalizedDataPathRegistry.get();
2784 profiler->start( tr(
"Create query logger" ) );
2785 mQueryLogger = std::make_unique<QgsDatabaseQueryLog>();
2789 profiler->start( tr(
"Setup coordinate reference system registry" ) );
2790 mCrsRegistry = std::make_unique<QgsCoordinateReferenceSystemRegistry>();
2794 profiler->start( tr(
"Create connection registry" ) );
2799 profiler->start( tr(
"Create project storage registry" ) );
2804 profiler->start( tr(
"Create layer metadata provider registry" ) );
2809 profiler->start( tr(
"Create font manager" ) );
2814 profiler->start( tr(
"Setup task manager" ) );
2819 profiler->start( tr(
"Setup action scope registry" ) );
2824 profiler->start( tr(
"Setup numeric formats" ) );
2829 profiler->start( tr(
"Setup field formats" ) );
2834 profiler->start( tr(
"Setup SVG cache" ) );
2835 mSvgCache = std::make_unique<QgsSvgCache>();
2839 profiler->start( tr(
"Setup image cache" ) );
2844 profiler->start( tr(
"Setup source cache" ) );
2849 profiler->start( tr(
"Setup color scheme registry" ) );
2854 profiler->start( tr(
"Setup paint effect" ) );
2859 profiler->start( tr(
"Setup symbol layer registry" ) );
2864 profiler->start( tr(
"Recent style handler" ) );
2869 profiler->start( tr(
"Setup callout registry" ) );
2874 profiler->start( tr(
"Setup renderer registry" ) );
2879 profiler->start( tr(
"Setup raster renderer registry" ) );
2884 profiler->start( tr(
"Setup point cloud renderer registry" ) );
2889 profiler->start( tr(
"Setup tiled scene renderer registry" ) );
2894 profiler->start( tr(
"Setup GPS registry" ) );
2899 profiler->start( tr(
"Setup GPSBabel format registry" ) );
2904 profiler->start( tr(
"Setup plugin layer registry" ) );
2909 profiler->start( tr(
"Setup Processing registry" ) );
2915 profiler->start( tr(
"Setup layout item registry" ) );
2921 profiler->start( tr(
"Setup annotation registry" ) );
2926 profiler->start( tr(
"Setup annotation item registry" ) );
2932 profiler->start( tr(
"Setup labeling engine rule registry" ) );
2937 profiler->start( tr(
"Setup sensor registry" ) );
2943 profiler->start( tr(
"Setup plot registry" ) );
2949 profiler->start( tr(
"Setup 3D symbol registry" ) );
2954 profiler->start( tr(
"Setup 3D renderer registry" ) );
2959 profiler->start( tr(
"Setup external storage registry" ) );
2964 profiler->start( tr(
"Setup profile source registry" ) );
2969 profiler->start( tr(
"Setup network content cache" ) );
2974 profiler->start( tr(
"Setup layout check registry" ) );
2979 profiler->start( tr(
"Setup classification registry" ) );
2984 profiler->start( tr(
"Setup bookmark manager" ) );
2989 profiler->start( tr(
"Setup tile download manager" ) );
2994 profiler->start( tr(
"Setup scalebar registry" ) );
3053 if (
auto *lInstance =
instance() )
3055 return lInstance->mApplicationMembers.get();
3059 static QRecursiveMutex sMemberMutex;
3060 QMutexLocker lock( &sMemberMutex );
3061 if ( !sApplicationMembers )
3062 sApplicationMembers =
new ApplicationMembers();
3063 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.
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 void setTemporarilyUntrustedProjectsFolders(const QStringList &untrustedProjectsFolders)
Sets the list of projects and folders that have been temporarily determined as untrusted by the user.
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 QStringList temporarilyTrustedProjectsFolders()
Returns the list of projects and folders that have been temporarily determined as trusted by the user...
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 QStringList temporarilyUntrustedProjectsFolders()
Returns the list of projects and folders that have been temporarily determined as untrusted by the us...
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.
QgsApplication(int &argc, char **argv, bool GUIenabled, const QString &profileFolder=QString(), const QString &platformName="external")
Constructor for QgsApplication.
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 setTemporarilyTrustedProjectsFolders(const QStringList &trustedProjectsFolders)
Sets the list of projects and folders that have been temporarily determined as trusted by the user.
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 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 QgsPlotRegistry * plotRegistry()
Returns the application's plot registry, used for plot types.
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.
Registry of available plot types.
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...
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.
A boolean settings entry.
An integer settings entry.
A string list settings entry.
Custom exception class for settings related exceptions.
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.
QgsTileDownloadManagerReply * get(const QNetworkRequest &request)
Starts a request.
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.
std::unique_ptr< 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.
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)
std::unique_ptr< QgsBookmarkManager > mBookmarkManager
std::unique_ptr< QgsRasterRendererRegistry > mRasterRendererRegistry
std::unique_ptr< QgsProcessingRegistry > mProcessingRegistry
std::unique_ptr< QgsTaskManager > mTaskManager
std::unique_ptr< QgsAnnotationRegistry > mAnnotationRegistry
std::unique_ptr< QgsCoordinateReferenceSystemRegistry > mCrsRegistry
std::unique_ptr< QgsGpsConnectionRegistry > mGpsConnectionRegistry
std::unique_ptr< QgsLabelingEngineRuleRegistry > mLabelingEngineRuleRegistry
std::unique_ptr< QgsPointCloudRendererRegistry > mPointCloudRendererRegistry
std::unique_ptr< QgsRendererRegistry > mRendererRegistry
std::unique_ptr< Qgs3DSymbolRegistry > m3DSymbolRegistry
std::unique_ptr< QgsPlotRegistry > mPlotRegistry
QString mNullRepresentation
std::unique_ptr< QgsRecentStyleHandler > mRecentStyleHandler
std::unique_ptr< QgsClassificationMethodRegistry > mClassificationMethodRegistry
std::unique_ptr< QgsSensorRegistry > mSensorRegistry
std::unique_ptr< QgsPluginLayerRegistry > mPluginLayerRegistry
std::unique_ptr< QgsDatabaseQueryLog > mQueryLogger
std::unique_ptr< QgsScaleBarRendererRegistry > mScaleBarRendererRegistry
std::unique_ptr< QgsNumericFormatRegistry > mNumericFormatRegistry
std::unique_ptr< QgsLayoutItemRegistry > mLayoutItemRegistry
std::unique_ptr< QgsTiledSceneRendererRegistry > mTiledSceneRendererRegistry
std::unique_ptr< QgsStyleModel > mStyleModel
std::unique_ptr< QgsAnnotationItemRegistry > mAnnotationItemRegistry
std::unique_ptr< QgsImageCache > mImageCache
std::unique_ptr< Qgs3DRendererRegistry > m3DRendererRegistry
std::unique_ptr< QgsCalloutRegistry > mCalloutRegistry
std::unique_ptr< QgsSourceCache > mSourceCache
std::unique_ptr< QgsFontManager > mFontManager
std::unique_ptr< QgsSettingsRegistryCore > mSettingsRegistryCore
std::unique_ptr< QgsPageSizeRegistry > mPageSizeRegistry
std::unique_ptr< QgsExternalStorageRegistry > mExternalStorageRegistry
std::unique_ptr< QgsProfileSourceRegistry > mProfileSourceRegistry
std::unique_ptr< QgsSvgCache > mSvgCache
std::unique_ptr< QgsPaintEffectRegistry > mPaintEffectRegistry
std::unique_ptr< QgsColorSchemeRegistry > mColorSchemeRegistry
std::unique_ptr< QgsActionScopeRegistry > mActionScopeRegistry
std::unique_ptr< QgsBabelFormatRegistry > mGpsBabelFormatRegistry
std::unique_ptr< QgsTileDownloadManager > mTileDownloadManager
std::unique_ptr< QgsValidityCheckRegistry > mValidityCheckRegistry
std::unique_ptr< QgsNetworkContentFetcherRegistry > mNetworkContentFetcherRegistry
std::unique_ptr< QgsConnectionRegistry > mConnectionRegistry
std::unique_ptr< QgsFieldFormatterRegistry > mFieldFormatterRegistry
std::unique_ptr< QgsProjectStorageRegistry > mProjectStorageRegistry
std::unique_ptr< QgsMessageLog > mMessageLog
QStringList mSvgPathCache
std::unique_ptr< QgsLocalizedDataPathRegistry > mLocalizedDataPathRegistry
std::unique_ptr< QgsLayerMetadataProviderRegistry > mLayerMetadataProviderRegistry
std::unique_ptr< QgsSymbolLayerRegistry > mSymbolLayerRegistry