91 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
92 #include <QDesktopWidget>
97 #include <QFileOpenEvent>
98 #include <QMessageBox>
101 #include <QProcessEnvironment>
104 #include <QThreadPool>
107 #include <QLibraryInfo>
108 #include <QStandardPaths>
109 #include <QRegularExpression>
110 #include <QTextStream>
112 #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
113 #include <QRecursiveMutex>
117 #include <netinet/in.h>
123 #define SECURITY_WIN32
124 #include <security.h>
126 #pragma comment( lib, "Secur32.lib" )
130 #include "qgsconfig.h"
134 #include <cpl_conv.h>
140 #if defined(Q_OS_LINUX)
141 #include <sys/sysinfo.h>
144 #define CONN_POOL_MAX_CONCURRENT_CONNS 4
146 QObject *
ABISYM( QgsApplication::mFileOpenEventReceiver ) =
nullptr;
147 bool ABISYM( QgsApplication::mInitialized ) =
false;
148 bool ABISYM( QgsApplication::mRunningFromBuildDir ) =
false;
152 QgsApplication::ApplicationMembers *QgsApplication::sApplicationMembers =
nullptr;
154 int ABISYM( QgsApplication::sMaxThreads ) = -1;
171 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
187 : QApplication( argc, argv, GUIenabled )
189 *sPlatformName() = platformName;
191 if ( *sTranslation() != QLatin1String(
"C" ) )
193 mQgisTranslator =
new QTranslator();
194 if ( mQgisTranslator->load( QStringLiteral(
"qgis_" ) + *sTranslation(), i18nPath() ) )
196 installTranslator( mQgisTranslator );
200 QgsDebugMsgLevel( QStringLiteral(
"loading of qgis translation failed %1/qgis_%2" ).arg( i18nPath(), *sTranslation() ), 2 );
208 QString qtTranslationsPath = QLibraryInfo::location( QLibraryInfo::TranslationsPath );
210 QString prefix = QDir( QString(
"%1/../" ).arg( QApplication::applicationDirPath() ) ).absolutePath();
211 qtTranslationsPath = prefix + qtTranslationsPath.mid( QLibraryInfo::location( QLibraryInfo::PrefixPath ).length() );
214 mQtTranslator =
new QTranslator();
215 if ( mQtTranslator->load( QStringLiteral(
"qt_" ) + *sTranslation(), qtTranslationsPath ) )
217 installTranslator( mQtTranslator );
221 QgsDebugMsgLevel( QStringLiteral(
"loading of qt translation failed %1/qt_%2" ).arg( qtTranslationsPath, *sTranslation() ), 2 );
224 mQtBaseTranslator =
new QTranslator();
225 if ( mQtBaseTranslator->load( QStringLiteral(
"qtbase_" ) + *sTranslation(), qtTranslationsPath ) )
227 installTranslator( mQtBaseTranslator );
231 QgsDebugMsgLevel( QStringLiteral(
"loading of qtbase translation failed %1/qt_%2" ).arg( qtTranslationsPath, *sTranslation() ), 2 );
235 mApplicationMembers =
new ApplicationMembers();
237 *sProfilePath() = profileFolder;
244 if ( profileFolder.isEmpty() )
246 if ( getenv(
"QGIS_CUSTOM_CONFIG_PATH" ) )
248 profileFolder = getenv(
"QGIS_CUSTOM_CONFIG_PATH" );
252 profileFolder = QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ).value( 0 );
259 profileFolder = profile->
folder();
263 *sProfilePath() = profileFolder;
265 static std::once_flag sMetaTypesRegistered;
266 std::call_once( sMetaTypesRegistered, []
268 qRegisterMetaType<QgsGeometry::Error>(
"QgsGeometry::Error" );
269 qRegisterMetaType<QgsDatabaseQueryLogEntry>(
"QgsDatabaseQueryLogEntry" );
270 qRegisterMetaType<QgsProcessingFeatureSourceDefinition>(
"QgsProcessingFeatureSourceDefinition" );
271 qRegisterMetaType<QgsProcessingOutputLayerDefinition>(
"QgsProcessingOutputLayerDefinition" );
272 qRegisterMetaType<QgsUnitTypes::LayoutUnit>(
"QgsUnitTypes::LayoutUnit" );
273 qRegisterMetaType<QgsFeatureId>(
"QgsFeatureId" );
274 qRegisterMetaType<QgsFields>(
"QgsFields" );
275 qRegisterMetaType<QgsFeatureIds>(
"QgsFeatureIds" );
276 qRegisterMetaType<QgsProperty>(
"QgsProperty" );
277 qRegisterMetaType<QgsFeatureStoreList>(
"QgsFeatureStoreList" );
278 qRegisterMetaType<Qgis::MessageLevel>(
"Qgis::MessageLevel" );
279 qRegisterMetaType<Qgis::BrowserItemState>(
"Qgis::BrowserItemState" );
280 qRegisterMetaType<QgsReferencedRectangle>(
"QgsReferencedRectangle" );
281 qRegisterMetaType<QgsReferencedPointXY>(
"QgsReferencedPointXY" );
282 qRegisterMetaType<QgsReferencedGeometry>(
"QgsReferencedGeometry" );
283 qRegisterMetaType<QgsLayoutRenderContext::Flags>(
"QgsLayoutRenderContext::Flags" );
284 qRegisterMetaType<QgsStyle::StyleEntity>(
"QgsStyle::StyleEntity" );
285 qRegisterMetaType<QgsCoordinateReferenceSystem>(
"QgsCoordinateReferenceSystem" );
286 qRegisterMetaType<QgsAuthManager::MessageLevel>(
"QgsAuthManager::MessageLevel" );
287 qRegisterMetaType<QgsNetworkRequestParameters>(
"QgsNetworkRequestParameters" );
288 qRegisterMetaType<QgsNetworkReplyContent>(
"QgsNetworkReplyContent" );
289 qRegisterMetaType<QgsGeometry>(
"QgsGeometry" );
290 qRegisterMetaType<QgsDatumTransform::GridDetails>(
"QgsDatumTransform::GridDetails" );
291 qRegisterMetaType<QgsDatumTransform::TransformDetails>(
"QgsDatumTransform::TransformDetails" );
292 qRegisterMetaType<QgsNewsFeedParser::Entry>(
"QgsNewsFeedParser::Entry" );
293 qRegisterMetaType<QgsRectangle>(
"QgsRectangle" );
294 qRegisterMetaType<QgsLocatorResult>(
"QgsLocatorResult" );
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>();
311 qRegisterMetaType<QPainter::CompositionMode>(
"QPainter::CompositionMode" );
312 qRegisterMetaType<QgsDateTimeRange>(
"QgsDateTimeRange" );
313 qRegisterMetaType<QList<QgsMapLayer *>>(
"QList<QgsMapLayer*>" );
314 qRegisterMetaType<QMap<QNetworkRequest::Attribute, QVariant>>(
"QMap<QNetworkRequest::Attribute,QVariant>" );
315 qRegisterMetaType<QMap<QNetworkRequest::KnownHeaders, QVariant>>(
"QMap<QNetworkRequest::KnownHeaders,QVariant>" );
316 qRegisterMetaType<QList<QNetworkReply::RawHeaderPair>>(
"QList<QNetworkReply::RawHeaderPair>" );
321 if ( ABISYM( mRunningFromBuildDir ) )
324 *sPrefixPath() = QString();
325 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
326 setPluginPath( *sBuildOutputPath() +
'/' + QString( QGIS_PLUGIN_SUBDIR ) +
'/' + *sCfgIntDir() );
328 setPluginPath( *sBuildOutputPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
330 setPkgDataPath( *sBuildOutputPath() + QStringLiteral(
"/data" ) );
331 *sLibraryPath() = *sBuildOutputPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
332 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
333 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/' + *sCfgIntDir() +
'/';
335 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
337 #if defined( HAVE_QUICK )
338 *sQmlImportPath() = *sBuildOutputPath() +
'/' + QGIS_QML_SUBDIR +
'/';
343 char *
prefixPath = getenv(
"QGIS_PREFIX_PATH" );
346 if ( sPrefixPath()->isNull() )
348 #if defined(Q_OS_MACX) || defined(Q_OS_WIN)
350 #elif defined(ANDROID)
352 QDir myDir( QDir::homePath() );
354 QString myPrefix = myDir.absolutePath();
357 QDir myDir( applicationDirPath() );
359 if ( applicationDirPath().contains( QStringLiteral(
"cgi-bin" ) ) )
364 QString myPrefix = myDir.absolutePath();
375 *sConfigPath() = profileFolder +
'/';
379 if ( getenv(
"QGIS_AUTH_DB_DIR_PATH" ) )
385 QMap<QString, QString> systemEnvVarMap;
386 QString passfile( QStringLiteral(
"QGIS_AUTH_PASSWORD_FILE" ) );
388 const auto systemEnvironment = QProcessEnvironment::systemEnvironment().toStringList();
389 for (
const QString &varStr : systemEnvironment )
391 int pos = varStr.indexOf( QLatin1Char(
'=' ) );
394 QString varStrName = varStr.left( pos );
395 QString varStrValue = varStr.mid( pos + 1 );
396 if ( varStrName != passfile )
398 systemEnvVarMap.insert( varStrName, varStrValue );
401 *sSystemEnvVars() = systemEnvVarMap;
408 QString projLib( QDir::cleanPath(
pkgDataPath().append(
"/proj" ) ) );
409 if ( QFile::exists( projLib ) )
411 currentProjSearchPaths.append( projLib );
415 char **newPaths =
new char *[currentProjSearchPaths.length()];
416 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
418 newPaths[i] = CPLStrdup( currentProjSearchPaths.at( i ).toUtf8().constData() );
420 proj_context_set_search_paths(
nullptr, currentProjSearchPaths.count(), newPaths );
421 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
423 CPLFree( newPaths[i] );
428 QCoreApplication::addLibraryPath(
pluginPath() );
433 ABISYM( sMaxThreads ) = -1;
448 if ( !members()->mStyleModel )
451 ABISYM( mInitialized ) =
true;
456 delete mDataItemProviderRegistry;
457 delete mApplicationMembers;
458 delete mQgisTranslator;
459 delete mQtTranslator;
460 delete mQtBaseTranslator;
468 void QgsApplication::invalidateCaches()
480 return qobject_cast<QgsApplication *>( QCoreApplication::instance() );
486 if (
event->type() == QEvent::FileOpen )
489 if ( ABISYM( mFileOpenEventReceiver ) )
492 done =
notify( ABISYM( mFileOpenEventReceiver ),
event );
499 sFileOpenEventList()->append(
static_cast<QFileOpenEvent *
>(
event )->file() );
506 done = QApplication::event(
event );
515 if ( thread() == receiver->thread() )
525 done = QApplication::notify( receiver,
event );
529 qCritical() <<
"Caught unhandled QgsException: " << e.
what();
530 if ( qApp->thread() == QThread::currentThread() )
531 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
533 catch ( std::exception &e )
535 qCritical() <<
"Caught unhandled std::exception: " << e.what();
536 if ( qApp->thread() == QThread::currentThread() )
537 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.what() );
541 qCritical() <<
"Caught unhandled unknown exception";
542 if ( qApp->thread() == QThread::currentThread() )
543 QMessageBox::critical( activeWindow(), tr(
"Exception" ), tr(
"unknown exception" ) );
551 return QgsRuntimeProfiler::threadLocalInstance();
557 ABISYM( mFileOpenEventReceiver ) = receiver;
559 if ( sFileOpenEventList()->count() > 0 )
561 const QStringList fileOpenEventList = *sFileOpenEventList();
562 for (
const QString &file : fileOpenEventList )
564 QFileOpenEvent foe( file );
565 QgsApplication::sendEvent( ABISYM( mFileOpenEventReceiver ), &foe );
567 sFileOpenEventList()->clear();
574 #if defined(Q_OS_WIN)
575 if ( sPrefixPath()->endsWith(
"/bin" ) )
577 sPrefixPath()->chop( 4 );
580 if ( useDefaultPaths && !ABISYM( mRunningFromBuildDir ) )
582 setPluginPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
583 setPkgDataPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_DATA_SUBDIR ) );
585 *sLibraryPath() = *sPrefixPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
586 *sLibexecPath() = *sPrefixPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
587 #if defined( HAVE_QUICK )
588 *sQmlImportPath() = *sPrefixPath() +
'/' + QGIS_QML_SUBDIR +
'/';
601 QString mySvgPath =
pkgDataPath + QStringLiteral(
"/svg/" );
604 if ( !sDefaultSvgPaths()->contains( mySvgPath ) )
605 *sDefaultSvgPaths() << mySvgPath;
610 *sDefaultSvgPaths() = pathList;
615 QFileInfo fi( authDbDirPath );
616 if ( fi.exists() && fi.isDir() && fi.isWritable() )
618 *sAuthDbDirPath() = fi.canonicalFilePath() + QDir::separator();
625 if ( ABISYM( mRunningFromBuildDir ) )
627 static bool sOnce =
true;
631 ( void ) blockNotifications;
632 qWarning(
"!!! prefix path was requested, but it is not valid - we do not run from installed path !!!" );
638 return *sPrefixPath();
642 return *sPluginPath();
647 if ( sPkgDataPath()->isNull() )
650 return *sPkgDataPath();
655 return QStringLiteral(
":/images/themes/default/" );
660 QDir dir( usersThemes );
668 return defaultThemes;
674 return iconsPath() + QStringLiteral(
"qgis-icon-60x60.png" );
679 return ABISYM( sMaxThreads );
686 if ( QFile::exists( path + iconFile ) )
687 return path + iconFile;
695 const QString cacheKey = ( name.startsWith(
'/' ) ? name.mid( 1 ) : name )
696 + ( fillColor.isValid() ? QStringLiteral(
"_%1" ).arg( fillColor.name( QColor::HexArgb ).mid( 1 ) ) : QString() )
697 + ( strokeColor.isValid() ? QStringLiteral(
"_%1" ).arg( strokeColor.name( QColor::HexArgb ).mid( 1 ) ) : QString() );
699 if ( app && app->mIconCache.contains( cacheKey ) )
700 return app->mIconCache.value( cacheKey );
703 const bool colorBased = fillColor.isValid() || strokeColor.isValid();
705 auto iconFromColoredSvg = [ = ](
const QString & path ) -> QIcon
710 const QString
iconPath = sIconCacheDir()->filePath( cacheKey + QStringLiteral(
".svg" ) );
712 if ( f.open( QFile::WriteOnly | QFile::Truncate ) )
714 f.write( svgContent );
719 QgsDebugMsg( QStringLiteral(
"Could not create colorized icon svg at %1" ).arg(
iconPath ) );
723 return QIcon( f.fileName() );
728 if ( QFile::exists( preferredPath ) )
732 icon = iconFromColoredSvg( preferredPath );
736 icon = QIcon( preferredPath );
739 else if ( QFile::exists( defaultPath ) )
745 icon = iconFromColoredSvg( defaultPath );
749 icon = QIcon( defaultPath );
758 app->mIconCache.insert( cacheKey, icon );
765 if ( app && app->mCursorCache.contains( cursor ) )
766 return app->mCursorCache.value( cursor );
777 name = QStringLiteral(
"mZoomIn.svg" );
782 name = QStringLiteral(
"mZoomOut.svg" );
789 name = QStringLiteral(
"mIdentify.svg" );
792 name = QStringLiteral(
"mCrossHair.svg" );
795 name = QStringLiteral(
"mCapturePoint.svg" );
798 name = QStringLiteral(
"mSelect.svg" );
805 name = QStringLiteral(
"mSampler.svg" );
810 Q_ASSERT( ! name.isEmpty( ) );
812 QIcon icon =
getThemeIcon( QStringLiteral(
"cursors" ) + QDir::separator() + name );
815 if ( ! icon.isNull( ) )
819 cursorIcon = QCursor( icon.pixmap( std::ceil( scale * 32 ), std::ceil( scale * 32 ) ), std::ceil( scale * activeX ), std::ceil( scale * activeY ) );
822 app->mCursorCache.insert( cursor, cursorIcon );
829 const QString preferredPath =
activeThemePath() + QDir::separator() + name;
831 const QString path = QFile::exists( preferredPath ) ? preferredPath : defaultPath;
832 if ( foreColor.isValid() || backColor.isValid() )
834 bool fitsInCache =
false;
835 const QImage image =
svgCache()->
svgAsImage( path, size, backColor, foreColor, 1, 1, fitsInCache );
836 return QPixmap::fromImage( image );
839 return QPixmap( path );
849 static QString appPath;
850 if ( appPath.isNull() )
852 if ( QCoreApplication::instance() )
854 appPath = applicationDirPath();
858 qWarning(
"Application path not initialized" );
862 if ( !appPath.isNull() || getenv(
"QGIS_PREFIX_PATH" ) )
864 QString prefix = getenv(
"QGIS_PREFIX_PATH" ) ? getenv(
"QGIS_PREFIX_PATH" ) : appPath;
869 static const QStringList paths { QStringList() << QString() << QStringLiteral(
"/.." ) << QStringLiteral(
"/bin" ) << QStringLiteral(
"/../../.." ) };
870 for (
const QString &path : paths )
872 f.setFileName( prefix + path +
"/qgisbuildpath.txt" );
876 if ( f.exists() && f.open( QIODevice::ReadOnly ) )
878 ABISYM( mRunningFromBuildDir ) =
true;
879 *sBuildSourcePath() = f.readLine().trimmed();
880 *sBuildOutputPath() = f.readLine().trimmed();
882 QgsDebugMsgLevel( QStringLiteral(
"- source directory: %1" ).arg( sBuildSourcePath()->toUtf8().constData() ), 4 );
883 QgsDebugMsgLevel( QStringLiteral(
"- output directory of the build: %1" ).arg( sBuildOutputPath()->toUtf8().constData() ), 4 );
884 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
885 *sCfgIntDir() = prefix.split(
'/', QString::SkipEmptyParts ).last();
886 qDebug(
"- cfg: %s", sCfgIntDir()->toUtf8().constData() );
892 if ( getenv(
"QGIS_PREFIX_PATH" ) )
898 QDir dir( QDir::homePath() );
903 #if defined(Q_OS_MACX)
905 #elif defined(Q_OS_WIN)
912 if ( appPath.contains( QStringLiteral(
"cgi-bin" ) ) )
922 if ( ABISYM( mRunningFromBuildDir ) )
923 return *sBuildOutputPath() + QStringLiteral(
"/data" );
925 return prefixPath +
'/' + QStringLiteral( QGIS_DATA_SUBDIR );
930 return *sThemeName();
940 qApp->setStyleSheet( QString() );
944 QString path = themes.value(
themeName );
945 QString stylesheetname = path +
"/style.qss";
947 QFile file( stylesheetname );
948 QFile variablesfile( path +
"/variables.qss" );
950 QFileInfo variableInfo( variablesfile );
952 if ( !file.open( QIODevice::ReadOnly ) || ( variableInfo.exists() && !variablesfile.open( QIODevice::ReadOnly ) ) )
957 QString styledata = file.readAll();
958 styledata.replace( QLatin1String(
"@theme_path" ), path );
960 if ( variableInfo.exists() )
962 QTextStream in( &variablesfile );
963 while ( !in.atEnd() )
965 QString line = in.readLine();
967 if ( line.startsWith(
'@' ) )
969 int index = line.indexOf(
':' );
970 QString name = line.mid( 0, index );
971 QString value = line.mid( index + 1, line.length() );
972 styledata.replace( name, value );
975 variablesfile.close();
983 const static QRegularExpression regex( QStringLiteral(
"(?<=[\\s:])([0-9\\.]+)(?=em)" ) );
984 QRegularExpressionMatch match = regex.match( styledata, index );
985 while ( match.hasMatch() )
987 index = match.capturedStart();
988 styledata.remove( index, match.captured( 0 ).length() );
990 styledata.insert( index, number );
991 index += number.length();
992 match = regex.match( styledata, index );
996 qApp->setStyleSheet( styledata );
998 QFile palettefile( path +
"/palette.txt" );
999 QFileInfo paletteInfo( palettefile );
1000 if ( paletteInfo.exists() && palettefile.open( QIODevice::ReadOnly ) )
1002 QPalette
pal = qApp->palette();
1003 QTextStream in( &palettefile );
1004 while ( !in.atEnd() )
1006 QString line = in.readLine();
1007 QStringList parts = line.split(
':' );
1008 if ( parts.count() == 2 )
1010 int role = parts.at( 0 ).trimmed().toInt();
1012 pal.setColor(
static_cast< QPalette::ColorRole
>( role ), color );
1015 palettefile.close();
1016 qApp->setPalette(
pal );
1025 QHash<QString, QString> mapping;
1026 mapping.insert( QStringLiteral(
"default" ), QString() );
1027 const auto constPaths = paths;
1028 for (
const QString &path : constPaths )
1030 QDir folder( path );
1031 QFileInfoList styleFiles = folder.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
1032 const auto constStyleFiles = styleFiles;
1033 for (
const QFileInfo &info : constStyleFiles )
1035 QFileInfo styleFile( info.absoluteFilePath() +
"/style.qss" );
1036 if ( !styleFile.exists() )
1039 QString name = info.baseName();
1040 QString path = info.absoluteFilePath();
1041 mapping.insert( name, path );
1049 return pkgDataPath() + QStringLiteral(
"/doc/AUTHORS" );
1054 return pkgDataPath() + QStringLiteral(
"/doc/CONTRIBUTORS" );
1058 return pkgDataPath() + QStringLiteral(
"/doc/developersmap.html" );
1063 return pkgDataPath() + QStringLiteral(
"/doc/SPONSORS" );
1068 return pkgDataPath() + QStringLiteral(
"/doc/DONORS" );
1073 return pkgDataPath() + QStringLiteral(
"/doc/TRANSLATORS" );
1078 return pkgDataPath() + QStringLiteral(
"/doc/LICENSE" );
1083 if ( ABISYM( mRunningFromBuildDir ) )
1084 return *sBuildOutputPath() + QStringLiteral(
"/i18n/" );
1086 return pkgDataPath() + QStringLiteral(
"/i18n/" );
1091 return pkgDataPath() + QStringLiteral(
"/resources/metadata-ISO/" );
1096 return pkgDataPath() + QStringLiteral(
"/resources/qgis.db" );
1101 return *sConfigPath();
1111 return *sAuthDbDirPath() + QStringLiteral(
"qgis-auth.db" );
1116 return QStringLiteral(
":/images/splash/" );
1121 return pkgDataPath() + QStringLiteral(
"/images/icons/" );
1126 if ( ABISYM( mRunningFromBuildDir ) )
1128 QString tempCopy = QDir::tempPath() +
"/srs6.db";
1130 if ( !QFile( tempCopy ).exists() )
1133 if ( !f.copy( tempCopy ) )
1135 qFatal(
"Could not create temporary copy" );
1143 return pkgDataPath() + QStringLiteral(
"/resources/srs.db" );
1150 members()->mSvgPathCacheValid =
false;
1155 static QReadWriteLock lock;
1159 if ( members()->mSvgPathCacheValid )
1161 return members()->mSvgPathCache;
1172 for (
const QString &path : pathList )
1174 if ( !paths.contains( path ) )
1175 paths.append( path );
1177 for (
const QString &path : std::as_const( *sDefaultSvgPaths() ) )
1179 if ( !paths.contains( path ) )
1180 paths.append( path );
1182 members()->mSvgPathCache = paths;
1197 return *sSystemEnvVars();
1207 const thread_local QRegularExpression regexp( QRegularExpression::anchoredPattern( QStringLiteral(
"^[A-Za-z][A-Za-z0-9\\._-]*" ) ) );
1213 if ( !sUserName()->isEmpty() )
1214 return *sUserName();
1217 TCHAR name [ UNLEN + 1 ];
1218 DWORD size = UNLEN + 1;
1220 if ( GetUserName( ( TCHAR * )name, &size ) )
1222 *sUserName() = QString::fromLocal8Bit( name );
1225 #elif QT_CONFIG(process)
1228 process.start( QStringLiteral(
"whoami" ), QStringList() );
1229 process.waitForFinished();
1230 *sUserName() = process.readAllStandardOutput().trimmed();
1233 if ( !sUserName()->isEmpty() )
1234 return *sUserName();
1237 *sUserName() = qgetenv(
"USER" );
1238 if ( !sUserName()->isEmpty() )
1239 return *sUserName();
1242 *sUserName() = qgetenv(
"USERNAME" );
1243 return *sUserName();
1248 if ( !sUserFullName()->isEmpty() )
1249 return *sUserFullName();
1252 TCHAR name [ UNLEN + 1 ];
1253 DWORD size = UNLEN + 1;
1256 if ( GetUserNameEx( NameDisplay, ( TCHAR * )name, &size ) )
1258 *sUserFullName() = QString::fromLocal8Bit( name );
1262 if ( sUserFullName()->isEmpty() )
1264 #elif defined(Q_OS_ANDROID) || defined(__MINGW32__)
1265 *sUserFullName() = QStringLiteral(
"Not available" );
1267 struct passwd *p = getpwuid( getuid() );
1271 QString gecosName = QString( p->pw_gecos );
1272 *sUserFullName() = gecosName.left( gecosName.indexOf(
',', 0 ) );
1277 return *sUserFullName();
1282 #if defined(Q_OS_ANDROID)
1283 return QLatin1String(
"android" );
1284 #elif defined(Q_OS_MAC)
1285 return QLatin1String(
"osx" );
1286 #elif defined(Q_OS_WIN)
1287 return QLatin1String(
"windows" );
1288 #elif defined(Q_OS_LINUX)
1289 return QStringLiteral(
"linux" );
1290 #elif defined(Q_OS_FREEBSD)
1291 return QStringLiteral(
"freebsd" );
1292 #elif defined(Q_OS_OPENBSD)
1293 return QStringLiteral(
"openbsd" );
1294 #elif defined(Q_OS_NETBSD)
1295 return QStringLiteral(
"netbsd" );
1296 #elif defined(Q_OS_UNIX)
1297 return QLatin1String(
"unix" );
1299 return QLatin1String(
"unknown" );
1305 #if defined(Q_OS_ANDROID)
1307 #elif defined(Q_OS_MAC)
1309 #elif defined(Q_OS_WIN)
1310 MEMORYSTATUSEX memoryStatus;
1311 ZeroMemory( &memoryStatus,
sizeof( MEMORYSTATUSEX ) );
1312 memoryStatus.dwLength =
sizeof( MEMORYSTATUSEX );
1313 if ( GlobalMemoryStatusEx( &memoryStatus ) )
1315 return memoryStatus.ullTotalPhys / ( 1024 * 1024 );
1321 #elif defined(Q_OS_LINUX)
1322 constexpr
int megabyte = 1024 * 1024;
1325 return si.totalram / megabyte;
1326 #elif defined(Q_OS_FREEBSD)
1328 #elif defined(Q_OS_OPENBSD)
1330 #elif defined(Q_OS_NETBSD)
1332 #elif defined(Q_OS_UNIX)
1341 return *sPlatformName();
1350 if (
locale.startsWith( QLatin1String(
"en" ), Qt::CaseInsensitive ) )
1359 return QLocale().name().left( 2 );
1365 QLocale::setDefault(
locale );
1376 return pkgDataPath() + QStringLiteral(
"/resources/symbology-style.xml" );
1381 return pkgDataPath() + QStringLiteral(
"/resources/themes" );
1386 return pkgDataPath() + QStringLiteral(
"/resources/server/" );
1391 return *sLibraryPath();
1396 return *sLibexecPath();
1401 return *sQmlImportPath();
1406 return ( htonl( 1 ) == 1 ) ?
XDR :
NDR;
1413 init( *sProfilePath() );
1438 if (
auto *lInstance =
instance() )
1440 if ( !lInstance->mAuthManager )
1444 return lInstance->mAuthManager;
1449 if ( !sAuthManager )
1451 return sAuthManager;
1459 QThreadPool::globalInstance()->waitForDone();
1462 if (
auto *lInstance =
instance() )
1463 delete lInstance->mAuthManager;
1465 delete sAuthManager;
1470 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1478 if ( QgsProviderRegistry::exists() )
1487 GDALDestroyDriverManager();
1492 QString myEnvironmentVar( getenv(
"QGIS_PREFIX_PATH" ) );
1493 QString myState = tr(
"Application state:\n"
1494 "QGIS_PREFIX_PATH env var:\t\t%1\n"
1496 "Plugin Path:\t\t%3\n"
1497 "Package Data Path:\t%4\n"
1498 "Active Theme Name:\t%5\n"
1499 "Active Theme Path:\t%6\n"
1500 "Default Theme Path:\t%7\n"
1501 "SVG Search Paths:\t%8\n"
1502 "User DB Path:\t%9\n"
1503 "Auth DB Path:\t%10\n" )
1504 .arg( myEnvironmentVar,
1511 svgPaths().join( tr(
"\n\t\t",
"match indentation of application state" ) ),
1524 QColor myColor1( Qt::lightGray );
1525 QColor myColor2 = myColor1;
1526 myColor2 = myColor2.lighter( 110 );
1528 myStyle = QStringLiteral(
".overview{"
1530 " font-weight: bold;"
1533 " background: white;"
1535 " font-family: 'Lato', 'Open Sans', 'Lucida Grande', 'Segoe UI', 'Arial', sans-serif;"
1538 "h1{ background-color: #F6F6F6;"
1540 " font-size: x-large; "
1541 " font-weight: normal;"
1542 " background: none;"
1543 " padding: 0.75em 0 0;"
1545 " line-height: 3em;"
1547 "h2{ background-color: #F6F6F6;"
1549 " font-size: medium; "
1550 " font-weight: normal;"
1551 " background: none;"
1552 " padding: 0.75em 0 0;"
1554 " line-height: 1.1em;"
1556 "h3{ background-color: #F6F6F6;"
1558 " font-weight: bold;"
1559 " font-size: large;"
1560 " text-align: left;"
1561 " border-bottom: 5px solid #DCEB5C;"
1563 "h4{ background-color: #F6F6F6;"
1565 " font-weight: bold;"
1566 " font-size: medium;"
1567 " text-align: left;"
1569 "h5{ background-color: #F6F6F6;"
1571 " font-weight: bold;"
1572 " font-size: small;"
1573 " text-align: left;"
1575 "a{ color: #729FCF;"
1576 " font-family: arial,sans-serif;"
1578 "label{ background-color: #FFFFCC;"
1579 " border: 1px solid black;"
1581 " padding: 0px 3px; "
1582 " font-size: small;"
1585 " font-weight: bold;"
1590 " border-top: 1px solid black;"
1592 ".list-view .highlight {"
1593 " text-align: left;"
1596 " padding-right: 15px;"
1597 " padding-left: 20px;"
1598 " font-weight: bold;"
1600 ".tabular-view .odd-row {"
1601 " background-color: #f9f9f9;"
1604 " font-weight: bold;"
1605 " padding-top:25px;"
1609 switch ( styleSheetType )
1611 case StyleSheetType::Qt:
1612 myStyle += QStringLiteral(
1614 " border-collapse: collapse;"
1617 ".tabular-view th, .tabular-view td { "
1618 " border:1px solid black;"
1622 case StyleSheetType::WebBrowser:
1623 myStyle += QStringLiteral(
1628 "table.tabular-view, table.list-view { "
1629 " border-collapse: collapse;"
1630 " table-layout:fixed;"
1631 " width: 100% !important;"
1636 " line-height: inherit;"
1639 " word-wrap: break-word; "
1640 " vertical-align: top;"
1643 ".list-view th:first-child, .list-view td:first-child {"
1646 ".list-view.highlight { "
1647 " padding-left: inherit; "
1650 ".tabular-view th:first-child, .tabular-view td:first-child { "
1654 ".tabular-view th.strong { "
1655 " background-color: #eee; "
1658 ".tabular-view th, .tabular-view td { "
1659 " border: 1px solid #eee;"
1670 if ( 0 >= OGRGetDriverCount() )
1678 QString aPathUrl = aPath;
1679 QString tPathUrl = targetPath;
1680 #if defined( Q_OS_WIN )
1681 const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
1683 aPathUrl.replace(
'\\',
'/' );
1684 if ( aPathUrl.startsWith(
"//" ) )
1687 aPathUrl =
"\\\\" + aPathUrl.mid( 2 );
1690 tPathUrl.replace(
'\\',
'/' );
1691 if ( tPathUrl.startsWith(
"//" ) )
1694 tPathUrl =
"\\\\" + tPathUrl.mid( 2 );
1697 const Qt::CaseSensitivity cs = Qt::CaseSensitive;
1700 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
1701 QStringList targetElems = tPathUrl.split(
'/', QString::SkipEmptyParts );
1702 QStringList aPathElems = aPathUrl.split(
'/', QString::SkipEmptyParts );
1704 QStringList targetElems = tPathUrl.split(
'/', Qt::SkipEmptyParts );
1705 QStringList aPathElems = aPathUrl.split(
'/', Qt::SkipEmptyParts );
1708 targetElems.removeAll( QStringLiteral(
"." ) );
1709 aPathElems.removeAll( QStringLiteral(
"." ) );
1713 while ( !aPathElems.isEmpty() &&
1714 !targetElems.isEmpty() &&
1715 aPathElems[0].compare( targetElems[0], cs ) == 0 )
1717 aPathElems.removeFirst();
1718 targetElems.removeFirst();
1728 if ( !targetElems.isEmpty() )
1731 for (
int i = 0; i < targetElems.size(); i++ )
1733 aPathElems.insert( 0, QStringLiteral(
".." ) );
1740 aPathElems.insert( 0, QStringLiteral(
"." ) );
1743 return aPathElems.join( QLatin1Char(
'/' ) );
1749 if ( !rpath.startsWith( QLatin1String(
"./" ) ) && !rpath.startsWith( QLatin1String(
"../" ) ) )
1754 QString rPathUrl = rpath;
1755 QString targetPathUrl = targetPath;
1757 #if defined(Q_OS_WIN)
1758 rPathUrl.replace(
'\\',
'/' );
1759 targetPathUrl.replace(
'\\',
'/' );
1761 bool uncPath = targetPathUrl.startsWith(
"//" );
1764 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
1765 QStringList srcElems = rPathUrl.split(
'/', QString::SkipEmptyParts );
1766 QStringList targetElems = targetPathUrl.split(
'/', QString::SkipEmptyParts );
1768 QStringList srcElems = rPathUrl.split(
'/', Qt::SkipEmptyParts );
1769 QStringList targetElems = targetPathUrl.split(
'/', Qt::SkipEmptyParts );
1772 #if defined(Q_OS_WIN)
1775 targetElems.insert( 0,
"" );
1776 targetElems.insert( 0,
"" );
1781 targetElems << srcElems;
1782 targetElems.removeAll( QStringLiteral(
"." ) );
1786 while ( ( pos = targetElems.indexOf( QLatin1String(
".." ) ) ) > 0 )
1789 targetElems.removeAt( pos - 1 );
1790 targetElems.removeAt( pos - 1 );
1793 #if !defined(Q_OS_WIN)
1795 targetElems.prepend( QString() );
1798 return targetElems.join( QLatin1Char(
'/' ) );
1803 return *sBuildSourcePath();
1808 return *sBuildOutputPath();
1811 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
1812 QString QgsApplication::cfgIntDir()
1814 return *sCfgIntDir();
1820 if ( sGdalSkipList()->contains( driver ) || driver.isEmpty() )
1824 *sGdalSkipList() << driver;
1830 if ( !sGdalSkipList()->contains( driver ) )
1834 int myPos = sGdalSkipList()->indexOf( driver );
1837 sGdalSkipList()->removeAt( myPos );
1844 return *sGdalSkipList();
1848 const QStringList &deferredSkippedGdalDrivers )
1862 QString joinedList, delimiter;
1863 if ( settings.
contains( QStringLiteral(
"gdal/skipDrivers" ) ) )
1865 joinedList = settings.
value( QStringLiteral(
"gdal/skipDrivers" ), QString() ).toString();
1866 delimiter = QStringLiteral(
"," );
1870 joinedList = settings.
value( QStringLiteral(
"gdal/skipList" ), QString() ).toString();
1871 delimiter = QStringLiteral(
" " );
1874 if ( !joinedList.isEmpty() )
1876 myList = joinedList.split( delimiter );
1878 *sGdalSkipList() = myList;
1884 return *sDeferredSkippedGdalDrivers();
1889 sGdalSkipList()->removeDuplicates();
1890 QStringList realDisabledDriverList;
1891 for (
const auto &driverName : *sGdalSkipList() )
1893 if ( !sDeferredSkippedGdalDrivers()->contains( driverName ) )
1894 realDisabledDriverList << driverName;
1896 QString myDriverList = realDisabledDriverList.join(
',' );
1897 QgsDebugMsgLevel( QStringLiteral(
"Gdal Skipped driver list set to:" ), 2 );
1899 CPLSetConfigOption(
"GDAL_SKIP", myDriverList.toUtf8() );
1906 QDir myDir( folder );
1907 if ( !myDir.exists() )
1909 myDir.mkpath( folder );
1915 void QgsApplication::copyPath(
const QString &src,
const QString &dst )
1918 if ( ! dir.exists() )
1921 const auto subDirectories = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot );
1922 for (
const QString &d : subDirectories )
1924 QString dst_path = dst + QDir::separator() + d;
1925 dir.mkpath( dst_path );
1926 copyPath( src + QDir::separator() + d, dst_path );
1929 const auto files = dir.entryList( QDir::Files );
1930 for (
const QString &f : files )
1932 QFile::copy( src + QDir::separator() + f, dst + QDir::separator() + f );
1941 QVariantMap variables;
1945 QStringList childKeys = settings.
childKeys();
1946 for ( QStringList::const_iterator it = childKeys.constBegin(); it != childKeys.constEnd(); ++it )
1949 variables.insert( name, settings.
value( name ) );
1959 QVariantMap::const_iterator it = variables.constBegin();
1962 for ( ; it != variables.constEnd(); ++it )
1964 settings.
setValue( it.key(), it.value() );
1975 settings.
setValue( QStringLiteral(
"variables/" ) + name, value );
1982 QFontMetrics fm( ( QFont() ) );
1983 const double scale = 1.1 * standardSize / 24;
1984 int scaledIconSize =
static_cast< int >( std::floor( std::max(
Qgis::UI_SCALE_FACTOR * fm.height() * scale,
static_cast< double >( standardSize ) ) ) );
1985 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
1986 if ( applyDevicePixelRatio && QApplication::desktop() )
1987 scaledIconSize *= QApplication::desktop()->devicePixelRatio();
1989 if ( applyDevicePixelRatio )
1991 if ( QWidget *activeWindow = QApplication::activeWindow() )
1992 scaledIconSize *= ( activeWindow->screen() ? QApplication::activeWindow()->screen()->devicePixelRatio() : 1 );
1995 return scaledIconSize;
2010 return *sTranslation();
2020 ApplicationMembers *appMembers = members();
2021 if ( appMembers->mNullRepresentation.isNull() )
2023 appMembers->mNullRepresentation =
QgsSettings().
value( QStringLiteral(
"qgis/nullValue" ), QStringLiteral(
"NULL" ) ).toString();
2025 return appMembers->mNullRepresentation;
2030 ApplicationMembers *appMembers = members();
2044 return members()->mActionScopeRegistry;
2053 QDir myDir( myPamPath );
2054 if ( !myDir.exists() )
2056 myDir.mkpath( myPamPath );
2059 #if defined(Q_OS_WIN)
2060 CPLSetConfigOption(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() );
2064 int myChangeFlag = 0;
2065 setenv(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag );
2072 if ( !qgisPrivateDbFile.exists() )
2076 QFile masterFile( qgisMasterDbFileName );
2082 bool isDbFileCopied = masterFile.copy( qgisPrivateDbFile.fileName() );
2084 if ( !isDbFileCopied )
2088 *errorMessage = tr(
"[ERROR] Can not make qgis.db private copy" );
2093 QFile::Permissions perms = QFile( qgisPrivateDbFile.fileName() ).permissions();
2094 if ( !( perms & QFile::WriteOwner ) )
2096 if ( !qgisPrivateDbFile.setPermissions( perms | QFile::WriteOwner ) )
2100 *errorMessage = tr(
"Can not make '%1' user writable" ).arg( qgisPrivateDbFile.fileName() );
2114 *errorMessage = tr(
"Could not open qgis.db" );
2119 char *errmsg =
nullptr;
2120 int res = sqlite3_exec( database.get(),
"SELECT srs_id FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2121 if ( res != SQLITE_OK )
2123 sqlite3_free( errmsg );
2126 if ( sqlite3_exec( database.get(),
2127 "DROP INDEX IF EXISTS idx_srsauthid;"
2128 "CREATE TABLE tbl_srs ("
2129 "srs_id INTEGER PRIMARY KEY,"
2130 "description text NOT NULL,"
2131 "projection_acronym text NOT NULL,"
2132 "ellipsoid_acronym NOT NULL,"
2133 "parameters text NOT NULL,"
2135 "auth_name varchar,"
2137 "is_geo integer NOT NULL,"
2138 "deprecated boolean,"
2140 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2144 *errorMessage = tr(
"Creation of missing tbl_srs in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2146 sqlite3_free( errmsg );
2153 res = sqlite3_exec( database.get(),
"SELECT wkt FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2154 if ( res != SQLITE_OK )
2157 sqlite3_free( errmsg );
2158 if ( sqlite3_exec( database.get(),
2159 "DROP INDEX IF EXISTS idx_srsauthid;"
2160 "DROP TABLE IF EXISTS tbl_srs_bak;"
2161 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2162 "CREATE TABLE tbl_srs ("
2163 "srs_id INTEGER PRIMARY KEY,"
2164 "description text NOT NULL,"
2165 "projection_acronym text NOT NULL,"
2166 "ellipsoid_acronym NOT NULL,"
2167 "parameters text NOT NULL,"
2169 "auth_name varchar,"
2171 "is_geo integer NOT NULL,"
2172 "deprecated boolean,"
2174 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2175 "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;"
2176 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2180 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2182 sqlite3_free( errmsg );
2188 res = sqlite3_exec( database.get(),
"SELECT acronym FROM tbl_projection LIMIT 0",
nullptr,
nullptr, &errmsg );
2189 if ( res != SQLITE_OK )
2191 sqlite3_free( errmsg );
2194 if ( sqlite3_exec( database.get(),
2195 "CREATE TABLE tbl_projection ("
2196 "acronym varchar(20) NOT NULL PRIMARY KEY,"
2197 "name varchar(255) NOT NULL default '',"
2198 "notes varchar(255) NOT NULL default '',"
2199 "parameters varchar(255) NOT NULL default ''"
2200 ")",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2204 *errorMessage = tr(
"Creation of missing tbl_projection in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2206 sqlite3_free( errmsg );
2211 res = sqlite3_exec( database.get(),
"SELECT epsg FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2212 if ( res == SQLITE_OK )
2215 if ( sqlite3_exec( database.get(),
2216 "DROP INDEX IF EXISTS idx_srsauthid;"
2217 "DROP TABLE IF EXISTS tbl_srs_bak;"
2218 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2219 "CREATE TABLE tbl_srs ("
2220 "srs_id INTEGER PRIMARY KEY,"
2221 "description text NOT NULL,"
2222 "projection_acronym text NOT NULL,"
2223 "ellipsoid_acronym NOT NULL,"
2224 "parameters text NOT NULL,"
2226 "auth_name varchar,"
2228 "is_geo integer NOT NULL,"
2229 "deprecated boolean,"
2231 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2232 "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;"
2233 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2237 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2239 sqlite3_free( errmsg );
2245 sqlite3_free( errmsg );
2248 if ( sqlite3_exec( database.get(),
"DROP VIEW vw_srs",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2250 QgsDebugMsg( QStringLiteral(
"vw_srs didn't exists in private qgis.db: %1" ).arg( errmsg ) );
2253 if ( sqlite3_exec( database.get(),
2254 "CREATE VIEW vw_srs AS"
2256 " a.description AS description"
2257 ",a.srs_id AS srs_id"
2258 ",a.is_geo AS is_geo"
2259 ",coalesce(b.name,a.projection_acronym) AS name"
2260 ",a.parameters AS parameters"
2261 ",a.auth_name AS auth_name"
2262 ",a.auth_id AS auth_id"
2263 ",a.deprecated AS deprecated"
2265 " LEFT OUTER JOIN tbl_projection b ON a.projection_acronym=b.acronym"
2266 " ORDER BY coalesce(b.name,a.projection_acronym),a.description",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2270 *errorMessage = tr(
"Update of view in private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2272 sqlite3_free( errmsg );
2285 if ( maxThreads < 1 || maxThreads > QThread::idealThreadCount() )
2296 QThreadPool::globalInstance()->setMaxThreadCount(
maxThreads );
2297 QgsDebugMsgLevel( QStringLiteral(
"set QThreadPool max thread count to %1" ).arg( QThreadPool::globalInstance()->maxThreadCount() ), 2 );
2302 return members()->mTaskManager;
2307 return members()->mSettingsRegistryCore;
2312 return members()->mColorSchemeRegistry;
2317 return members()->mPaintEffectRegistry;
2322 return members()->mRendererRegistry;
2327 return members()->mRasterRendererRegistry;
2332 return members()->mPointCloudRendererRegistry;
2337 if (
auto *lInstance =
instance() )
2339 if ( !
instance()->mDataItemProviderRegistry )
2343 return lInstance->mDataItemProviderRegistry;
2349 if ( !sDataItemProviderRegistry )
2351 return sDataItemProviderRegistry;
2357 return members()->mCrsRegistry;
2362 return members()->mSvgCache;
2367 return members()->mImageCache;
2372 return members()->mSourceCache;
2377 return members()->mNetworkContentFetcherRegistry;
2382 return members()->mValidityCheckRegistry;
2387 return members()->mSymbolLayerRegistry;
2392 return members()->mCalloutRegistry;
2397 return members()->mLayoutItemRegistry;
2402 return members()->mAnnotationItemRegistry;
2407 return members()->mGpsConnectionRegistry;
2412 return members()->mGpsBabelFormatRegistry;
2417 return members()->mPluginLayerRegistry;
2422 return members()->mClassificationMethodRegistry;
2427 return members()->mBookmarkManager;
2432 return members()->mTileDownloadManager;
2437 return members()->mRecentStyleHandler;
2442 return members()->mQueryLogger;
2447 return members()->mStyleModel;
2452 return members()->mMessageLog;
2457 return members()->mProcessingRegistry;
2462 return members()->mConnectionRegistry;
2467 return members()->mPageSizeRegistry;
2472 return members()->mAnnotationRegistry;
2477 return members()->mNumericFormatRegistry;
2482 return members()->mFieldFormatterRegistry;
2487 return members()->m3DRendererRegistry;
2492 return members()->m3DSymbolRegistry;
2497 return members()->mScaleBarRendererRegistry;
2502 return members()->mProjectStorageRegistry.get();
2507 return members()->mExternalStorageRegistry;
2512 return members()->mLocalizedDataPathRegistry;
2515 QgsApplication::ApplicationMembers::ApplicationMembers()
2525 profiler->
start( tr(
"Create query logger" ) );
2530 profiler->
start( tr(
"Setup coordinate reference system registry" ) );
2535 profiler->
start( tr(
"Create connection registry" ) );
2540 profiler->
start( tr(
"Setup task manager" ) );
2545 profiler->
start( tr(
"Setup action scope registry" ) );
2550 profiler->
start( tr(
"Setup numeric formats" ) );
2555 profiler->
start( tr(
"Setup field formats" ) );
2560 profiler->
start( tr(
"Setup SVG cache" ) );
2565 profiler->
start( tr(
"Setup image cache" ) );
2570 profiler->
start( tr(
"Setup source cache" ) );
2575 profiler->
start( tr(
"Setup color scheme registry" ) );
2580 profiler->
start( tr(
"Setup paint effect" ) );
2585 profiler->
start( tr(
"Setup symbol layer registry" ) );
2590 profiler->
start( tr(
"Recent style handler" ) );
2595 profiler->
start( tr(
"Setup callout registry" ) );
2600 profiler->
start( tr(
"Setup renderer registry" ) );
2605 profiler->
start( tr(
"Setup raster renderer registry" ) );
2610 profiler->
start( tr(
"Setup point cloud renderer registry" ) );
2615 profiler->
start( tr(
"Setup GPS registry" ) );
2620 profiler->
start( tr(
"Setup GPSBabel format registry" ) );
2625 profiler->
start( tr(
"Setup plugin layer registry" ) );
2630 profiler->
start( tr(
"Setup Processing registry" ) );
2636 profiler->
start( tr(
"Setup layout item registry" ) );
2638 mLayoutItemRegistry->populate();
2642 profiler->
start( tr(
"Setup annotation registry" ) );
2643 mAnnotationRegistry =
new QgsAnnotationRegistry();
2647 profiler->
start( tr(
"Setup annotation item registry" ) );
2649 mAnnotationItemRegistry->populate();
2653 profiler->
start( tr(
"Setup 3D symbol registry" ) );
2658 profiler->
start( tr(
"Setup 3D renderer registry" ) );
2663 profiler->
start( tr(
"Setup project storage registry" ) );
2668 profiler->
start( tr(
"Setup external storage registry" ) );
2673 profiler->
start( tr(
"Setup network content cache" ) );
2678 profiler->
start( tr(
"Setup layout check registry" ) );
2683 profiler->
start( tr(
"Setup classification registry" ) );
2688 profiler->
start( tr(
"Setup bookmark manager" ) );
2693 profiler->
start( tr(
"Setup tile download manager" ) );
2698 profiler->
start( tr(
"Setup scalebar registry" ) );
2704 QgsApplication::ApplicationMembers::~ApplicationMembers()
2707 delete mTileDownloadManager;
2708 delete mScaleBarRendererRegistry;
2709 delete mValidityCheckRegistry;
2710 delete mActionScopeRegistry;
2711 delete m3DRendererRegistry;
2712 delete m3DSymbolRegistry;
2713 delete mAnnotationRegistry;
2714 delete mColorSchemeRegistry;
2715 delete mFieldFormatterRegistry;
2716 delete mGpsConnectionRegistry;
2717 delete mGpsBabelFormatRegistry;
2719 delete mPaintEffectRegistry;
2720 delete mPluginLayerRegistry;
2721 delete mProcessingRegistry;
2722 delete mPageSizeRegistry;
2723 delete mAnnotationItemRegistry;
2724 delete mLayoutItemRegistry;
2725 delete mPointCloudRendererRegistry;
2726 delete mRasterRendererRegistry;
2727 delete mRendererRegistry;
2730 delete mSourceCache;
2731 delete mCalloutRegistry;
2732 delete mRecentStyleHandler;
2733 delete mSymbolLayerRegistry;
2734 delete mExternalStorageRegistry;
2735 delete mTaskManager;
2736 delete mNetworkContentFetcherRegistry;
2737 delete mClassificationMethodRegistry;
2738 delete mNumericFormatRegistry;
2739 delete mBookmarkManager;
2740 delete mConnectionRegistry;
2741 delete mLocalizedDataPathRegistry;
2742 delete mCrsRegistry;
2743 delete mQueryLogger;
2744 delete mSettingsRegistryCore;
2747 QgsApplication::ApplicationMembers *QgsApplication::members()
2749 if (
auto *lInstance =
instance() )
2751 return lInstance->mApplicationMembers;
2755 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
2756 static QMutex sMemberMutex( QMutex::Recursive );
2758 static QRecursiveMutex sMemberMutex;
2760 QMutexLocker lock( &sMemberMutex );
2761 if ( !sApplicationMembers )
2762 sApplicationMembers =
new ApplicationMembers();
2763 return sApplicationMembers;