65 #include <QFileOpenEvent> 66 #include <QMessageBox> 69 #include <QProcessEnvironment> 72 #include <QThreadPool> 77 #include <netinet/in.h> 83 #define SECURITY_WIN32 85 #pragma comment( lib, "Secur32.lib" ) 88 #include "qgsconfig.h" 95 #if PROJ_VERSION_MAJOR>=6 100 #define CONN_POOL_MAX_CONCURRENT_CONNS 4 102 QObject *
ABISYM( QgsApplication::mFileOpenEventReceiver );
103 QStringList
ABISYM( QgsApplication::mFileOpenEventList );
104 QString
ABISYM( QgsApplication::mPrefixPath );
105 QString
ABISYM( QgsApplication::mPluginPath );
106 QString
ABISYM( QgsApplication::mPkgDataPath );
107 QString
ABISYM( QgsApplication::mLibraryPath );
108 QString
ABISYM( QgsApplication::mLibexecPath );
109 QString
ABISYM( QgsApplication::mQmlImportPath );
110 QString
ABISYM( QgsApplication::mThemeName );
111 QString
ABISYM( QgsApplication::mUIThemeName );
112 QString
ABISYM( QgsApplication::mProfilePath );
114 QStringList
ABISYM( QgsApplication::mDefaultSvgPaths );
115 QMap<QString, QString>
ABISYM( QgsApplication::mSystemEnvVars );
116 QString
ABISYM( QgsApplication::mConfigPath );
118 bool ABISYM( QgsApplication::mInitialized ) =
false;
119 bool ABISYM( QgsApplication::mRunningFromBuildDir ) =
false;
120 QString
ABISYM( QgsApplication::mBuildSourcePath );
121 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) 122 QString
ABISYM( QgsApplication::mCfgIntDir );
124 QString
ABISYM( QgsApplication::mBuildOutputPath );
125 QStringList
ABISYM( QgsApplication::mGdalSkipList );
126 int ABISYM( QgsApplication::mMaxThreads );
127 QString
ABISYM( QgsApplication::mAuthDbDirPath );
129 QString QgsApplication::sUserName;
130 QString QgsApplication::sUserFullName;
131 QString QgsApplication::sPlatformName = QStringLiteral(
"desktop" );
132 QString QgsApplication::sTranslation;
138 QgsApplication::ApplicationMembers *QgsApplication::sApplicationMembers =
nullptr;
142 : QApplication( argc, argv, GUIenabled )
144 sPlatformName = platformName;
146 if ( sTranslation != QLatin1String(
"C" ) )
148 mQgisTranslator =
new QTranslator();
149 if ( mQgisTranslator->load( QStringLiteral(
"qgis_" ) + sTranslation,
i18nPath() ) )
151 installTranslator( mQgisTranslator );
155 QgsDebugMsg( QStringLiteral(
"loading of qgis translation failed %1/qgis_%2" ).arg(
i18nPath(), sTranslation ) );
163 mQtTranslator =
new QTranslator();
164 if ( mQtTranslator->load( QStringLiteral(
"qt_" ) + sTranslation, QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ) )
166 installTranslator( mQtTranslator );
170 QgsDebugMsg( QStringLiteral(
"loading of qt translation failed %1/qt_%2" ).arg( QLibraryInfo::location( QLibraryInfo::TranslationsPath ), sTranslation ) );
174 mApplicationMembers =
new ApplicationMembers();
176 ABISYM( mProfilePath ) = profileFolder;
181 if ( profileFolder.isEmpty() )
183 if ( getenv(
"QGIS_CUSTOM_CONFIG_PATH" ) )
185 profileFolder = getenv(
"QGIS_CUSTOM_CONFIG_PATH" );
189 profileFolder = QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ).value( 0 );
196 profileFolder = profile->
folder();
200 ABISYM( mProfilePath ) = profileFolder;
202 qRegisterMetaType<QgsGeometry::Error>(
"QgsGeometry::Error" );
203 qRegisterMetaType<QgsProcessingFeatureSourceDefinition>(
"QgsProcessingFeatureSourceDefinition" );
204 qRegisterMetaType<QgsProcessingOutputLayerDefinition>(
"QgsProcessingOutputLayerDefinition" );
205 qRegisterMetaType<QgsUnitTypes::LayoutUnit>(
"QgsUnitTypes::LayoutUnit" );
206 qRegisterMetaType<QgsFeatureId>(
"QgsFeatureId" );
207 qRegisterMetaType<QgsFeatureIds>(
"QgsFeatureIds" );
208 qRegisterMetaType<QgsProperty>(
"QgsProperty" );
209 qRegisterMetaType<Qgis::MessageLevel>(
"Qgis::MessageLevel" );
210 qRegisterMetaType<QgsReferencedRectangle>(
"QgsReferencedRectangle" );
211 qRegisterMetaType<QgsReferencedPointXY>(
"QgsReferencedPointXY" );
212 qRegisterMetaType<QgsLayoutRenderContext::Flags>(
"QgsLayoutRenderContext::Flags" );
213 qRegisterMetaType<QgsStyle::StyleEntity>(
"QgsStyle::StyleEntity" );
214 qRegisterMetaType<QgsCoordinateReferenceSystem>(
"QgsCoordinateReferenceSystem" );
215 qRegisterMetaType<QgsAuthManager::MessageLevel>(
"QgsAuthManager::MessageLevel" );
216 qRegisterMetaType<QgsNetworkRequestParameters>(
"QgsNetworkRequestParameters" );
217 qRegisterMetaType<QgsNetworkReplyContent>(
"QgsNetworkReplyContent" );
218 qRegisterMetaType<QgsGeometry>(
"QgsGeometry" );
219 qRegisterMetaType<QgsDatumTransform::GridDetails>(
"QgsDatumTransform::GridDetails" );
220 qRegisterMetaType<QgsDatumTransform::TransformDetails>(
"QgsDatumTransform::TransformDetails" );
224 if ( ABISYM( mRunningFromBuildDir ) )
227 ABISYM( mPrefixPath ) = QString();
228 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) 229 setPluginPath( ABISYM( mBuildOutputPath ) +
'/' + QString( QGIS_PLUGIN_SUBDIR ) +
'/' + ABISYM( mCfgIntDir ) );
231 setPluginPath( ABISYM( mBuildOutputPath ) +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
234 ABISYM( mLibraryPath ) = ABISYM( mBuildOutputPath ) +
'/' + QGIS_LIB_SUBDIR +
'/';
235 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) 236 ABISYM( mLibexecPath ) = ABISYM( mBuildOutputPath ) +
'/' + QGIS_LIBEXEC_SUBDIR +
'/' + ABISYM( mCfgIntDir ) +
'/';
238 ABISYM( mLibexecPath ) = ABISYM( mBuildOutputPath ) +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
240 #if defined( HAVE_QUICK ) 241 ABISYM( mQmlImportPath ) = ABISYM( mBuildOutputPath ) +
'/' + QGIS_QML_SUBDIR +
'/';
246 char *
prefixPath = getenv(
"QGIS_PREFIX_PATH" );
249 if ( ABISYM( mPrefixPath ).isNull() )
251 #if defined(Q_OS_MACX) || defined(Q_OS_WIN) 253 #elif defined(ANDROID) 255 QDir myDir( QDir::homePath() );
257 QString myPrefix = myDir.absolutePath();
260 QDir myDir( applicationDirPath() );
262 if ( applicationDirPath().contains( QStringLiteral(
"cgi-bin" ) ) )
267 QString myPrefix = myDir.absolutePath();
278 ABISYM( mConfigPath ) = profileFolder +
'/';
282 if ( getenv(
"QGIS_AUTH_DB_DIR_PATH" ) )
288 QMap<QString, QString> systemEnvVarMap;
289 QString passfile( QStringLiteral(
"QGIS_AUTH_PASSWORD_FILE" ) );
291 const auto systemEnvironment = QProcessEnvironment::systemEnvironment().toStringList();
292 for (
const QString &varStr : systemEnvironment )
294 int pos = varStr.indexOf( QLatin1Char(
'=' ) );
297 QString varStrName = varStr.left( pos );
298 QString varStrValue = varStr.mid( pos + 1 );
299 if ( varStrName != passfile )
301 systemEnvVarMap.insert( varStrName, varStrValue );
304 ABISYM( mSystemEnvVars ) = systemEnvVarMap;
306 #if PROJ_VERSION_MAJOR>=6 310 const char **newPaths =
new const char *[currentProjSearchPaths.length()];
311 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
313 newPaths[i] = currentProjSearchPaths.at( i ).toUtf8().constData();
315 proj_context_set_search_paths(
nullptr, currentProjSearchPaths.count(), newPaths );
321 QCoreApplication::addLibraryPath(
pluginPath() );
326 ABISYM( mMaxThreads ) = -1;
331 ABISYM( mInitialized ) =
true;
336 delete mDataItemProviderRegistry;
337 delete mApplicationMembers;
338 delete mQgisTranslator;
339 delete mQtTranslator;
354 return qobject_cast<
QgsApplication *>( QCoreApplication::instance() );
360 if ( event->type() == QEvent::FileOpen )
363 if ( ABISYM( mFileOpenEventReceiver ) )
366 done =
notify( ABISYM( mFileOpenEventReceiver ), event );
373 ABISYM( mFileOpenEventList ).append( static_cast<QFileOpenEvent *>( event )->file() );
380 done = QApplication::event( event );
389 if ( thread() == receiver->thread() )
390 emit
preNotify( receiver, event, &done );
399 done = QApplication::notify( receiver, event );
404 if ( qApp->thread() == QThread::currentThread() )
405 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
407 catch ( std::exception &e )
409 QgsDebugMsg(
"Caught unhandled std::exception: " + QString::fromLatin1( e.what() ) );
410 if ( qApp->thread() == QThread::currentThread() )
411 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.what() );
415 QgsDebugMsg( QStringLiteral(
"Caught unhandled unknown exception" ) );
416 if ( qApp->thread() == QThread::currentThread() )
417 QMessageBox::critical( activeWindow(), tr(
"Exception" ), tr(
"unknown exception" ) );
425 return members()->mProfiler;
431 ABISYM( mFileOpenEventReceiver ) = receiver;
433 if ( ABISYM( mFileOpenEventList ).count() > 0 )
435 QStringListIterator i( ABISYM( mFileOpenEventList ) );
436 while ( i.hasNext() )
438 QFileOpenEvent foe( i.next() );
439 QgsApplication::sendEvent( ABISYM( mFileOpenEventReceiver ), &foe );
441 ABISYM( mFileOpenEventList ).clear();
448 #if defined(_MSC_VER) 449 if ( ABISYM( mPrefixPath ).endsWith(
"/bin" ) )
451 ABISYM( mPrefixPath ).chop( 4 );
454 if ( useDefaultPaths && !ABISYM( mRunningFromBuildDir ) )
456 setPluginPath( ABISYM( mPrefixPath ) +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
457 setPkgDataPath( ABISYM( mPrefixPath ) +
'/' + QStringLiteral( QGIS_DATA_SUBDIR ) );
459 ABISYM( mLibraryPath ) = ABISYM( mPrefixPath ) +
'/' + QGIS_LIB_SUBDIR +
'/';
460 ABISYM( mLibexecPath ) = ABISYM( mPrefixPath ) +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
461 #if defined( HAVE_QUICK ) 462 ABISYM( mQmlImportPath ) = ABISYM( mPrefixPath ) +
'/' + QGIS_QML_SUBDIR +
'/';
474 QString mySvgPath = pkgDataPath + ( ABISYM( mRunningFromBuildDir ) ?
"/images/svg/" :
"/svg/" );
476 if ( !ABISYM( mDefaultSvgPaths ).contains( mySvgPath ) )
477 ABISYM( mDefaultSvgPaths ) << mySvgPath;
482 ABISYM( mDefaultSvgPaths ) = pathList;
487 QFileInfo fi( authDbDirPath );
488 if ( fi.exists() && fi.isDir() && fi.isWritable() )
490 ABISYM( mAuthDbDirPath ) = fi.canonicalFilePath() + QDir::separator();
496 if ( ABISYM( mRunningFromBuildDir ) )
498 static bool sOnce =
true;
502 ( void ) blockNotifications;
503 qWarning(
"!!! prefix path was requested, but it is not valid - we do not run from installed path !!!" );
508 return ABISYM( mPrefixPath );
512 return ABISYM( mPluginPath );
516 if ( ABISYM( mPkgDataPath ).isNull() )
519 return ABISYM( mPkgDataPath );
523 return QStringLiteral(
":/images/themes/default/" );
528 QDir dir( usersThemes );
536 return defaultThemes;
542 return iconsPath() + QStringLiteral(
"qgis-icon-60x60.png" );
549 if ( QFile::exists( path + iconFile ) )
550 return path + iconFile;
559 if ( app && app->mIconCache.contains( name ) )
560 return app->mIconCache.value( name );
564 QString myPreferredPath =
activeThemePath() + QDir::separator() + name;
566 if ( QFile::exists( myPreferredPath ) )
568 icon = QIcon( myPreferredPath );
570 else if ( QFile::exists( myDefaultPath ) )
574 icon = QIcon( myDefaultPath );
582 app->mIconCache.insert( name, icon );
589 if ( app && app->mCursorCache.contains( cursor ) )
590 return app->mCursorCache.value( cursor );
601 name = QStringLiteral(
"mZoomIn.svg" );
606 name = QStringLiteral(
"mZoomOut.svg" );
613 name = QStringLiteral(
"mIdentify.svg" );
616 name = QStringLiteral(
"mCrossHair.svg" );
619 name = QStringLiteral(
"mCapturePoint.svg" );
622 name = QStringLiteral(
"mSelect.svg" );
629 name = QStringLiteral(
"mSampler.svg" );
634 Q_ASSERT( ! name.isEmpty( ) );
636 QIcon icon =
getThemeIcon( QStringLiteral(
"cursors" ) + QDir::separator() + name );
639 if ( ! icon.isNull( ) )
643 cursorIcon = QCursor( icon.pixmap( std::ceil( scale * 32 ), std::ceil( scale * 32 ) ), std::ceil( scale * activeX ), std::ceil( scale * activeY ) );
646 app->mCursorCache.insert( cursor, cursorIcon );
653 QString myPreferredPath =
activeThemePath() + QDir::separator() + name;
655 if ( QFile::exists( myPreferredPath ) )
657 return QPixmap( myPreferredPath );
663 return QPixmap( myDefaultPath );
674 static QString appPath;
675 if ( appPath.isNull() )
677 if ( QCoreApplication::instance() )
679 appPath = applicationDirPath();
683 qWarning(
"Application path not initialized" );
687 if ( !appPath.isNull() || getenv(
"QGIS_PREFIX_PATH" ) )
689 QString prefix = getenv(
"QGIS_PREFIX_PATH" ) ? getenv(
"QGIS_PREFIX_PATH" ) : appPath;
694 static const QStringList paths { QStringList() << QString() << QStringLiteral(
"/.." ) << QStringLiteral(
"/bin" ) << QStringLiteral(
"/../../.." ) };
695 for (
const QString &path : paths )
697 f.setFileName( prefix + path +
"/qgisbuildpath.txt" );
701 if ( f.exists() && f.open( QIODevice::ReadOnly ) )
703 ABISYM( mRunningFromBuildDir ) =
true;
704 ABISYM( mBuildSourcePath ) = f.readLine().trimmed();
705 ABISYM( mBuildOutputPath ) = f.readLine().trimmed();
707 QgsDebugMsgLevel( QStringLiteral(
"- source directory: %1" ).arg( ABISYM( mBuildSourcePath ).toUtf8().constData() ), 4 );
708 QgsDebugMsgLevel( QStringLiteral(
"- output directory of the build: %1" ).arg( ABISYM( mBuildOutputPath ).toUtf8().constData() ), 4 );
709 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) 710 ABISYM( mCfgIntDir ) = appPath.split(
'/', QString::SkipEmptyParts ).last();
711 qDebug(
"- cfg: %s", ABISYM( mCfgIntDir ).toUtf8().constData() );
717 if ( getenv(
"QGIS_PREFIX_PATH" ) )
718 prefixPath = getenv(
"QGIS_PREFIX_PATH" );
723 QDir dir( QDir::homePath() );
725 prefixPath = dir.absolutePath();
728 #if defined(Q_OS_MACX) || defined(Q_OS_WIN) 729 prefixPath = appPath;
730 #if defined(_MSC_VER) 731 if ( prefixPath.endsWith(
"/bin" ) )
732 prefixPath.chop( 4 );
737 if ( appPath.contains( QStringLiteral(
"cgi-bin" ) ) )
742 prefixPath = dir.absolutePath();
747 if ( ABISYM( mRunningFromBuildDir ) )
748 return ABISYM( mBuildSourcePath );
750 return prefixPath +
'/' + QStringLiteral( QGIS_DATA_SUBDIR );
755 return ABISYM( mThemeName );
762 if ( themeName == QStringLiteral(
"default" ) || !themes.contains( themeName ) )
765 qApp->setStyleSheet( QString() );
769 QString path = themes.value( themeName );
770 QString stylesheetname = path +
"/style.qss";
772 QFile file( stylesheetname );
773 QFile variablesfile( path +
"/variables.qss" );
775 QFileInfo variableInfo( variablesfile );
777 if ( !file.open( QIODevice::ReadOnly ) || ( variableInfo.exists() && !variablesfile.open( QIODevice::ReadOnly ) ) )
782 QString styledata = file.readAll();
783 styledata.replace( QStringLiteral(
"@theme_path" ), path );
785 if ( variableInfo.exists() )
787 QTextStream in( &variablesfile );
788 while ( !in.atEnd() )
790 QString line = in.readLine();
792 if ( line.startsWith(
'@' ) )
794 int index = line.indexOf(
':' );
795 QString name = line.mid( 0, index );
796 QString value = line.mid( index + 1, line.length() );
797 styledata.replace( name, value );
800 variablesfile.close();
808 QRegularExpression regex( QStringLiteral(
"(?<=[\\s:])([0-9\\.]+)(?=em)" ) );
809 QRegularExpressionMatch match = regex.match( styledata, index );
810 while ( match.hasMatch() )
812 index = match.capturedStart();
813 styledata.remove( index, match.captured( 0 ).length() );
815 styledata.insert( index, number );
816 index += number.length();
817 match = regex.match( styledata, index );
821 qApp->setStyleSheet( styledata );
823 QFile palettefile( path +
"/palette.txt" );
824 QFileInfo paletteInfo( palettefile );
825 if ( paletteInfo.exists() && palettefile.open( QIODevice::ReadOnly ) )
827 QPalette
pal = qApp->palette();
828 QTextStream in( &palettefile );
829 while ( !in.atEnd() )
831 QString line = in.readLine();
832 QStringList parts = line.split(
':' );
833 if ( parts.count() == 2 )
835 int role = parts.at( 0 ).trimmed().toInt();
837 pal.setColor( static_cast< QPalette::ColorRole >( role ), color );
841 qApp->setPalette( pal );
850 QHash<QString, QString> mapping;
851 mapping.insert( QStringLiteral(
"default" ), QString() );
852 const auto constPaths = paths;
853 for (
const QString &path : constPaths )
856 QFileInfoList styleFiles = folder.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
857 const auto constStyleFiles = styleFiles;
858 for (
const QFileInfo &info : constStyleFiles )
860 QFileInfo styleFile( info.absoluteFilePath() +
"/style.qss" );
861 if ( !styleFile.exists() )
864 QString name = info.baseName();
865 QString path = info.absoluteFilePath();
866 mapping.insert( name, path );
874 return pkgDataPath() + QStringLiteral(
"/doc/AUTHORS" );
879 return pkgDataPath() + QStringLiteral(
"/doc/CONTRIBUTORS" );
883 return pkgDataPath() + QStringLiteral(
"/doc/developersmap.html" );
888 return pkgDataPath() + QStringLiteral(
"/doc/SPONSORS" );
893 return pkgDataPath() + QStringLiteral(
"/doc/DONORS" );
898 return pkgDataPath() + QStringLiteral(
"/doc/TRANSLATORS" );
903 return pkgDataPath() + QStringLiteral(
"/doc/LICENSE" );
908 if ( ABISYM( mRunningFromBuildDir ) )
909 return ABISYM( mBuildOutputPath ) + QStringLiteral(
"/i18n/" );
916 return pkgDataPath() + QStringLiteral(
"/resources/metadata-ISO/" );
921 return pkgDataPath() + QStringLiteral(
"/resources/qgis.db" );
926 return ABISYM( mConfigPath );
936 return ABISYM( mAuthDbDirPath ) + QStringLiteral(
"qgis-auth.db" );
941 return QStringLiteral(
":/images/splash/" );
946 return pkgDataPath() + QStringLiteral(
"/images/icons/" );
951 if ( ABISYM( mRunningFromBuildDir ) )
953 QString tempCopy = QDir::tempPath() +
"/srs.db";
955 if ( !QFile( tempCopy ).exists() )
958 if ( !f.copy( tempCopy ) )
960 qFatal(
"Could not create temporary copy" );
968 return pkgDataPath() + QStringLiteral(
"/resources/srs.db" );
977 QStringList pathList = settings.
value( QStringLiteral(
"svg/searchPathsForSVG" ) ).toStringList();
981 const auto constPathList = pathList;
982 for (
const QString &path : constPathList )
984 if ( !paths.contains( path ) )
985 paths.append( path );
987 for (
const QString &path : qgis::as_const( ABISYM( mDefaultSvgPaths ) ) )
989 if ( !paths.contains( path ) )
990 paths.append( path );
1001 QStringList pathList = settings.
value( QStringLiteral(
"Layout/searchPathsForTemplates" ), QVariant(),
QgsSettings::Core ).toStringList();
1013 return QRegExp(
"^[A-Za-z][A-Za-z0-9\\._-]*" );
1018 if ( !sUserName.isEmpty() )
1022 TCHAR name [ UNLEN + 1 ];
1023 DWORD size = UNLEN + 1;
1025 if ( GetUserName( ( TCHAR * )name, &size ) )
1027 sUserName = QString::fromLocal8Bit( name );
1030 #elif QT_CONFIG(process) 1033 process.start( QStringLiteral(
"whoami" ) );
1034 process.waitForFinished();
1035 sUserName = process.readAllStandardOutput().trimmed();
1038 if ( !sUserName.isEmpty() )
1042 sUserName = qgetenv(
"USER" );
1043 if ( !sUserName.isEmpty() )
1047 sUserName = qgetenv(
"USERNAME" );
1053 if ( !sUserFullName.isEmpty() )
1054 return sUserFullName;
1057 TCHAR name [ UNLEN + 1 ];
1058 DWORD size = UNLEN + 1;
1061 if ( GetUserNameEx( NameDisplay, ( TCHAR * )name, &size ) )
1063 sUserFullName = QString::fromLocal8Bit( name );
1067 if ( sUserFullName.isEmpty() )
1069 #elif defined(Q_OS_ANDROID) || defined(__MINGW32__) 1070 sUserFullName =
"Not available";
1072 struct passwd *p = getpwuid( getuid() );
1076 QString gecosName = QString( p->pw_gecos );
1077 sUserFullName = gecosName.left( gecosName.indexOf(
',', 0 ) );
1082 return sUserFullName;
1087 #if defined(Q_OS_ANDROID) 1088 return QLatin1String(
"android" );
1089 #elif defined(Q_OS_MAC) 1090 return QLatin1String(
"osx" );
1091 #elif defined(Q_OS_WIN) 1092 return QLatin1String(
"windows" );
1093 #elif defined(Q_OS_LINUX) 1094 return QStringLiteral(
"linux" );
1096 return QLatin1String(
"unknown" );
1102 return sPlatformName;
1108 bool overrideLocale = settings.
value( QStringLiteral(
"locale/overrideFlag" ),
false ).toBool();
1109 if ( overrideLocale )
1111 QString
locale = settings.
value( QStringLiteral(
"locale/userLocale" ), QString() ).toString();
1113 if ( locale.startsWith( QLatin1String(
"en" ), Qt::CaseInsensitive ) )
1115 return locale.left( 2 );
1122 return QLocale().name().left( 2 );
1133 return pkgDataPath() + QStringLiteral(
"/resources/symbology-style.xml" );
1138 return pkgDataPath() + QStringLiteral(
"/resources/themes" );
1143 return pkgDataPath() + QStringLiteral(
"/resources/server/" );
1148 return ABISYM( mLibraryPath );
1153 return ABISYM( mLibexecPath );
1158 return ABISYM( mQmlImportPath );
1163 return ( htonl( 1 ) == 1 ) ?
XDR :
NDR;
1207 if ( !sAuthManager )
1209 return sAuthManager;
1220 delete sAuthManager;
1225 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1233 if ( QgsProviderRegistry::exists() )
1246 GDALDestroyDriverManager();
1251 QString myEnvironmentVar( getenv(
"QGIS_PREFIX_PATH" ) );
1252 QString myState = tr(
"Application state:\n" 1253 "QGIS_PREFIX_PATH env var:\t\t%1\n" 1255 "Plugin Path:\t\t%3\n" 1256 "Package Data Path:\t%4\n" 1257 "Active Theme Name:\t%5\n" 1258 "Active Theme Path:\t%6\n" 1259 "Default Theme Path:\t%7\n" 1260 "SVG Search Paths:\t%8\n" 1261 "User DB Path:\t%9\n" 1262 "Auth DB Path:\t%10\n" )
1263 .arg( myEnvironmentVar,
1270 svgPaths().join( tr(
"\n\t\t",
"match indentation of application state" ) ),
1283 QColor myColor1( Qt::lightGray );
1284 QColor myColor2 = myColor1;
1285 myColor2 = myColor2.lighter( 110 );
1287 myStyle =
".overview{" 1289 " font-weight: bold;" 1292 " background: white;" 1294 " font-family: 'Lato', 'Ubuntu', 'Lucida Grande', 'Segoe UI', 'Arial', sans-serif;" 1297 "h1{ background-color: #F6F6F6;" 1299 " font-size: x-large; " 1300 " font-weight: normal;" 1301 " background: none;" 1302 " padding: 0.75em 0 0;" 1304 " line-height: 3em;" 1306 "h2{ background-color: #F6F6F6;" 1308 " font-size: medium; " 1309 " font-weight: normal;" 1310 " background: none;" 1311 " padding: 0.75em 0 0;" 1313 " line-height: 1.1em;" 1315 "h3{ background-color: #F6F6F6;" 1317 " font-weight: bold;" 1318 " font-size: large;" 1319 " text-align: right;" 1320 " border-bottom: 5px solid #DCEB5C;" 1322 "h4{ background-color: #F6F6F6;" 1324 " font-weight: bold;" 1325 " font-size: medium;" 1326 " text-align: right;" 1328 "h5{ background-color: #F6F6F6;" 1330 " font-weight: bold;" 1331 " font-size: small;" 1332 " text-align: right;" 1334 "a{ color: #729FCF;" 1335 " font-family: arial,sans-serif;" 1337 "label{ background-color: #FFFFCC;" 1338 " border: 1px solid black;" 1340 " padding: 0px 3px; " 1341 " font-size: small;" 1344 " font-weight: bold;" 1345 " padding-top:25px;" 1347 ".list-view .highlight {" 1348 " text-align: right;" 1351 " padding-right: 15px;" 1352 " padding-left: 20px;" 1353 " font-weight: bold;" 1356 " font-weight: bold;" 1359 " border-collapse: collapse;" 1362 ".tabular-view th, .tabular-view td { " 1363 " border:10px solid black;" 1365 ".tabular-view .odd-row{" 1366 " background-color: #f9f9f9;" 1371 " border-top: 1px solid black;" 1378 if ( 0 >= OGRGetDriverCount() )
1386 QString aPathUrl = aPath;
1387 QString tPathUrl = targetPath;
1388 #if defined( Q_OS_WIN ) 1389 const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
1391 aPathUrl.replace(
'\\',
'/' );
1392 if ( aPathUrl.startsWith(
"//" ) )
1395 aPathUrl =
"\\\\" + aPathUrl.mid( 2 );
1398 tPathUrl.replace(
'\\',
'/' );
1399 if ( tPathUrl.startsWith(
"//" ) )
1402 tPathUrl =
"\\\\" + tPathUrl.mid( 2 );
1405 const Qt::CaseSensitivity cs = Qt::CaseSensitive;
1408 QStringList targetElems = tPathUrl.split(
'/', QString::SkipEmptyParts );
1409 QStringList aPathElems = aPathUrl.split(
'/', QString::SkipEmptyParts );
1411 targetElems.removeAll( QStringLiteral(
"." ) );
1412 aPathElems.removeAll( QStringLiteral(
"." ) );
1416 while ( !aPathElems.isEmpty() &&
1417 !targetElems.isEmpty() &&
1418 aPathElems[0].compare( targetElems[0], cs ) == 0 )
1420 aPathElems.removeFirst();
1421 targetElems.removeFirst();
1431 if ( !targetElems.isEmpty() )
1434 for (
int i = 0; i < targetElems.size(); i++ )
1436 aPathElems.insert( 0, QStringLiteral(
".." ) );
1443 aPathElems.insert( 0, QStringLiteral(
"." ) );
1446 return aPathElems.join( QStringLiteral(
"/" ) );
1452 if ( !rpath.startsWith( QLatin1String(
"./" ) ) && !rpath.startsWith( QLatin1String(
"../" ) ) )
1457 QString rPathUrl = rpath;
1458 QString targetPathUrl = targetPath;
1460 #if defined(Q_OS_WIN) 1461 rPathUrl.replace(
'\\',
'/' );
1462 targetPathUrl.replace(
'\\',
'/' );
1464 bool uncPath = targetPathUrl.startsWith(
"//" );
1467 QStringList srcElems = rPathUrl.split(
'/', QString::SkipEmptyParts );
1468 QStringList targetElems = targetPathUrl.split(
'/', QString::SkipEmptyParts );
1470 #if defined(Q_OS_WIN) 1473 targetElems.insert( 0,
"" );
1474 targetElems.insert( 0,
"" );
1479 targetElems << srcElems;
1480 targetElems.removeAll( QStringLiteral(
"." ) );
1484 while ( ( pos = targetElems.indexOf( QStringLiteral(
".." ) ) ) > 0 )
1487 targetElems.removeAt( pos - 1 );
1488 targetElems.removeAt( pos - 1 );
1491 #if !defined(Q_OS_WIN) 1493 targetElems.prepend( QString() );
1496 return targetElems.join( QStringLiteral(
"/" ) );
1501 if (
ABISYM( mGdalSkipList ).contains( driver ) || driver.isEmpty() )
1505 ABISYM( mGdalSkipList ) << driver;
1511 if ( !
ABISYM( mGdalSkipList ).contains( driver ) )
1515 int myPos =
ABISYM( mGdalSkipList ).indexOf( driver );
1518 ABISYM( mGdalSkipList ).removeAt( myPos );
1525 ABISYM( mGdalSkipList ).removeDuplicates();
1526 QString myDriverList =
ABISYM( mGdalSkipList ).join( QStringLiteral(
" " ) );
1527 QgsDebugMsg( QStringLiteral(
"Gdal Skipped driver list set to:" ) );
1529 CPLSetConfigOption(
"GDAL_SKIP", myDriverList.toUtf8() );
1536 QDir myDir( folder );
1537 if ( !myDir.exists() )
1539 myDir.mkpath( folder );
1545 void QgsApplication::copyPath(
const QString &src,
const QString &dst )
1548 if ( ! dir.exists() )
1551 const auto subDirectories = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot );
1552 for (
const QString &d : subDirectories )
1554 QString dst_path = dst + QDir::separator() + d;
1555 dir.mkpath( dst_path );
1556 copyPath( src + QDir::separator() + d, dst_path );
1559 const auto files = dir.entryList( QDir::Files );
1560 for (
const QString &f : files )
1562 QFile::copy( src + QDir::separator() + f, dst + QDir::separator() + f );
1571 QVariantMap variables;
1575 QStringList childKeys = settings.
childKeys();
1576 for ( QStringList::const_iterator it = childKeys.constBegin(); it != childKeys.constEnd(); ++it )
1579 variables.insert( name, settings.
value( name ) );
1589 QVariantMap::const_iterator it = variables.constBegin();
1592 for ( ; it != variables.constEnd(); ++it )
1594 settings.
setValue( it.key(), it.value() );
1605 settings.
setValue( QStringLiteral(
"variables/" ) + name, value );
1622 ApplicationMembers *appMembers = members();
1623 if ( appMembers->mNullRepresentation.isNull() )
1625 appMembers->mNullRepresentation =
QgsSettings().
value( QStringLiteral(
"qgis/nullValue" ), QStringLiteral(
"NULL" ) ).toString();
1627 return appMembers->mNullRepresentation;
1632 ApplicationMembers *appMembers = members();
1633 if ( !appMembers || appMembers->mNullRepresentation == nullRepresentation )
1646 return members()->mActionScopeRegistry;
1655 QDir myDir( myPamPath );
1656 if ( !myDir.exists() )
1658 myDir.mkpath( myPamPath );
1661 #if defined(Q_OS_WIN) 1662 CPLSetConfigOption(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() );
1666 int myChangeFlag = 0;
1667 setenv(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag );
1674 if ( !qgisPrivateDbFile.exists() )
1678 QFile masterFile( qgisMasterDbFileName );
1684 bool isDbFileCopied = masterFile.copy( qgisPrivateDbFile.fileName() );
1686 if ( !isDbFileCopied )
1690 *errorMessage = tr(
"[ERROR] Can not make qgis.db private copy" );
1695 QFile::Permissions perms = QFile( qgisPrivateDbFile.fileName() ).permissions();
1696 if ( !( perms & QFile::WriteOwner ) )
1698 if ( !qgisPrivateDbFile.setPermissions( perms | QFile::WriteOwner ) )
1702 *errorMessage = tr(
"Can not make '%1' user writable" ).arg( qgisPrivateDbFile.fileName() );
1716 *errorMessage = tr(
"Could not open qgis.db" );
1721 char *errmsg =
nullptr;
1722 int res = sqlite3_exec( database.get(),
"SELECT epsg FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
1723 if ( res == SQLITE_OK )
1726 if ( sqlite3_exec( database.get(),
1727 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;" 1728 "CREATE TABLE tbl_srs (" 1729 "srs_id INTEGER PRIMARY KEY," 1730 "description text NOT NULL," 1731 "projection_acronym text NOT NULL," 1732 "ellipsoid_acronym NOT NULL," 1733 "parameters text NOT NULL," 1735 "auth_name varchar," 1737 "is_geo integer NOT NULL," 1738 "deprecated boolean);" 1739 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);" 1740 "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;" 1741 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK
1746 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
1748 sqlite3_free( errmsg );
1754 sqlite3_free( errmsg );
1757 if ( sqlite3_exec( database.get(),
"DROP VIEW vw_srs",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
1759 QgsDebugMsg( QStringLiteral(
"vw_srs didn't exists in private qgis.db: %1" ).arg( errmsg ) );
1762 if ( sqlite3_exec( database.get(),
1763 "CREATE VIEW vw_srs AS" 1765 " a.description AS description" 1766 ",a.srs_id AS srs_id" 1767 ",a.is_geo AS is_geo" 1768 ",coalesce(b.name,a.projection_acronym) AS name" 1769 ",a.parameters AS parameters" 1770 ",a.auth_name AS auth_name" 1771 ",a.auth_id AS auth_id" 1772 ",a.deprecated AS deprecated" 1774 " LEFT OUTER JOIN tbl_projection b ON a.projection_acronym=b.acronym" 1775 " ORDER BY coalesce(b.name,a.projection_acronym),a.description",
nullptr,
nullptr, &errmsg ) != SQLITE_OK
1780 *errorMessage = tr(
"Update of view in private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
1782 sqlite3_free( errmsg );
1791 QgsDebugMsg( QStringLiteral(
"maxThreads: %1" ).arg( maxThreads ) );
1795 if ( maxThreads < 1 || maxThreads > QThread::idealThreadCount() )
1802 if ( maxThreads == -1 )
1803 maxThreads = QThread::idealThreadCount();
1806 QThreadPool::globalInstance()->setMaxThreadCount( maxThreads );
1807 QgsDebugMsg( QStringLiteral(
"set QThreadPool max thread count to %1" ).arg( QThreadPool::globalInstance()->maxThreadCount() ) );
1812 return members()->mTaskManager;
1817 return members()->mColorSchemeRegistry;
1822 return members()->mPaintEffectRegistry;
1827 return members()->mRendererRegistry;
1832 return members()->mRasterRendererRegistry;
1839 if ( !
instance()->mDataItemProviderRegistry )
1843 return instance()->mDataItemProviderRegistry;
1849 if ( !sDataItemProviderRegistry )
1851 return sDataItemProviderRegistry;
1857 return members()->mSvgCache;
1862 return members()->mImageCache;
1867 return members()->mNetworkContentFetcherRegistry;
1872 return members()->mValidityCheckRegistry;
1877 return members()->mSymbolLayerRegistry;
1882 return members()->mLayoutItemRegistry;
1887 return members()->mGpsConnectionRegistry;
1892 return members()->mPluginLayerRegistry;
1897 return members()->mMessageLog;
1902 return members()->mProcessingRegistry;
1907 return members()->mPageSizeRegistry;
1912 return members()->mAnnotationRegistry;
1917 return members()->mFieldFormatterRegistry;
1922 return members()->m3DRendererRegistry;
1927 return members()->mProjectStorageRegistry;
1930 QgsApplication::ApplicationMembers::ApplicationMembers()
1951 mLayoutItemRegistry->populate();
1952 mAnnotationRegistry =
new QgsAnnotationRegistry();
1959 QgsApplication::ApplicationMembers::~ApplicationMembers()
1961 delete mValidityCheckRegistry;
1962 delete mActionScopeRegistry;
1963 delete m3DRendererRegistry;
1964 delete mAnnotationRegistry;
1965 delete mColorSchemeRegistry;
1966 delete mFieldFormatterRegistry;
1967 delete mGpsConnectionRegistry;
1969 delete mPaintEffectRegistry;
1970 delete mPluginLayerRegistry;
1971 delete mProcessingRegistry;
1972 delete mProjectStorageRegistry;
1973 delete mPageSizeRegistry;
1974 delete mLayoutItemRegistry;
1976 delete mRasterRendererRegistry;
1977 delete mRendererRegistry;
1980 delete mSymbolLayerRegistry;
1981 delete mTaskManager;
1982 delete mNetworkContentFetcherRegistry;
1985 QgsApplication::ApplicationMembers *QgsApplication::members()
1989 return instance()->mApplicationMembers;
1993 static QMutex sMemberMutex( QMutex::Recursive );
1994 QMutexLocker lock( &sMemberMutex );
1995 if ( !sApplicationMembers )
1996 sApplicationMembers =
new ApplicationMembers();
1997 return sApplicationMembers;
static QStringList layoutTemplatePaths()
Returns the paths to layout template directories.
Singleton offering an interface to manage the authentication configuration database and to utilize co...
QgsApplication(int &argc, char **argv, bool GUIenabled, const QString &profileFolder=QString(), const QString &platformName="desktop")
static QString locale()
Returns the QGIS locale.
static QgsSymbolLayerRegistry * symbolLayerRegistry()
Returns the application's symbol layer registry, used for managing symbol layers. ...
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
This class keeps a list of data item providers that may add items to the browser tree.
static void setThemeName(const QString &themeName)
Set the active theme to the specified theme.
void addDefaultSchemes()
Adds all default color schemes to this color scheme.
static Qgs3DRendererRegistry * renderer3DRegistry()
Returns registry of available 3D renderers.
static QString resolveProfilesFolder(const QString &basePath=QString())
Resolves the profiles folder for the given path.
static QgsAnnotationRegistry * annotationRegistry()
Returns the application's annotation registry, used for managing annotation types.
Extends QApplication to provide access to QGIS specific resources such as theme paths, database paths etc.
static QgsFieldFormatterRegistry * fieldFormatterRegistry()
Gets the registry of available field formatters.
Cursor
The Cursor enum defines constants for QGIS custom cursors.
static QString userStylePath()
Returns the path to user's style.
Registry of color schemes.
static QgsAuthManager * instance()
Enforce singleton pattern.
static QgsApplication * instance()
Returns the singleton instance of the QgsApplication.
static QString authorsFilePath()
Returns the path to the authors file.
static void setPrefixPath(const QString &prefixPath, bool useDefaultPaths=false)
Alters prefix path - used by 3rd party apps.
A registry of plugin layers types.
static QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
static void setCustomVariables(const QVariantMap &customVariables)
Custom expression variables for this application.
static QString libraryPath()
Returns the path containing qgis_core, qgis_gui, qgispython (and other) libraries.
static QgsRuntimeProfiler * profiler()
Returns the application runtime profiler.
static QString defaultThemePath()
Returns the path to the default theme directory.
static const double UI_SCALE_FACTOR
UI scaling factor.
This class is a composition of two QSettings instances:
static QString qgisMasterDatabaseFilePath()
Returns the path to the master qgis.db file.
void customVariablesChanged()
Emitted whenever a custom global variable changes.
static QString qgisUserDatabaseFilePath()
Returns the path to the user qgis.db file.
bool event(QEvent *event) override
Watch for QFileOpenEvent.
void requestForTranslatableObjects(QgsTranslationContext *translationContext)
Emitted when project strings which require translation are being collected for inclusion in a ...
static QString donorsFilePath()
Returns the path to the donors file.
static QString relativePathToAbsolutePath(const QString &rpath, const QString &targetPath)
Converts path relative to target to an absolute path.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
int maxConcurrentConnectionsPerPool() const
The maximum number of concurrent connections per connections pool.
void nullRepresentationChanged()
This string is used to represent the value NULL throughout QGIS.
static QgsImageCache * imageCache()
Returns the application's image cache, used for caching resampled versions of raster images...
static QgsValidityCheckRegistry * validityCheckRegistry()
Returns the application's validity check registry, used for managing validity checks.
static QString themeName()
Set the active theme to the specified theme.
static QString defaultThemesFolder()
Returns the path to default themes folder from install (works as a starting point).
void initStyleScheme()
Initializes the default random style color scheme for the user.
QStringList childKeys() const
Returns a list of all top-level keys that can be read using the QSettings object. ...
static void restoreGdalDriver(const QString &driver)
Sets the GDAL_SKIP environment variable to exclude the specified driver and then calls GDALDriverMana...
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
A cache for images / pictures derived from svg files.
void remove(const QString &key, QgsSettings::Section section=QgsSettings::NoSection)
Removes the setting key and any sub-settings of key in a section.
static QString resolvePkgPath()
Calculate the application pkg path.
Registry for raster renderers.
static void registerOgrDrivers()
Register OGR drivers ensuring this only happens once.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
User profile contains information about the user profile folders on the machine.
Precisely identify a point on the canvas.
static QgsPluginLayerRegistry * pluginLayerRegistry()
Returns the application's plugin layer registry, used for managing plugin layer types.
static QVariantMap customVariables()
Custom expression variables for this application.
This class keeps a list of QgsAbstractValidityCheck checks which can be used when performing validity...
static void setFileOpenEventReceiver(QObject *receiver)
Sets the FileOpen event receiver.
static QString reportStyleSheet()
Returns a standard css style sheet for reports.
static int maxThreads()
Gets maximum concurrent thread count.
static endian_t endian()
Returns whether this machine uses big or little endian.
static QPixmap getThemePixmap(const QString &name)
Helper to get a theme icon as a pixmap.
static QString userFullName()
Returns the user's operating system login account full display name.
static QgsPaintEffectRegistry * paintEffectRegistry()
Returns the application's paint effect registry, used for managing paint effects. ...
static QString developersMapFilePath()
Returns the path to the developers map file.
static QString absolutePathToRelativePath(const QString &apath, const QString &targetPath)
Converts absolute path to path relative to target.
static QString defaultStylePath()
Returns the path to default style (works as a starting point).
static QgsTaskManager * taskManager()
Returns the application's task manager, used for managing application wide background task handling...
static QgsMessageLog * messageLog()
Returns the application's message log.
static void applyGdalSkippedDrivers()
Apply the skipped drivers list to gdal.
#define CONN_POOL_MAX_CONCURRENT_CONNS
endian_t
Constants for endian-ness.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
static QgsLayoutItemRegistry * layoutItemRegistry()
Returns the application's layout item registry, used for layout item types.
static void setNullRepresentation(const QString &nullRepresentation)
This string is used to represent the value NULL throughout QGIS.
static QString pluginPath()
Returns the path to the application plugin directory.
Keeps track of available 3D renderers.
#define QgsDebugMsgLevel(str, level)
Registry of available symbol layer classes.
Registry for temporary fetched files.
static bool createThemeFolder()
Create the users theme folder.
static bool createDatabase(QString *errorMessage=nullptr)
initialize qgis.db
static void cleanRegisteredFunctions()
Deletes all registered functions whose ownership have been transferred to the expression engine...
static QString i18nPath()
Returns the path to the translation directory.
static void cleanDefaultStyle()
Deletes the default style. Only to be used by QgsApplication::exitQgis()
static QString nullRepresentation()
This string is used to represent the value NULL throughout QGIS.
static QString splashPath()
Returns the path to the splash screen image directory.
static void setCustomVariable(const QString &name, const QVariant &value)
Set a single custom expression variable.
static QgsGpsConnectionRegistry * gpsConnectionRegistry()
Returns the application's GPS connection registry, used for managing GPS connections.
A registry for known page sizes.
static const char * QGIS_ORGANIZATION_NAME
int open(const QString &path)
Opens the database at the specified file path.
static QgsProjectStorageRegistry * projectStorageRegistry()
Returns registry of available project storage implementations.
Task manager for managing a set of long-running QgsTask tasks.
Used for the collecting of strings from projects for translation and creation of ts files...
static QString userLoginName()
Returns the user's operating system login account name.
static QString pkgDataPath()
Returns the common root path of all application data directories.
static QString osName()
Returns a string name of the operating system QGIS is running on.
static void initQgis()
loads providers
static void setDefaultSvgPaths(const QStringList &pathList)
Alters default svg paths - used by 3rd party apps.
static QStringList searchPaths()
Returns the current list of Proj file search paths.
Unique pointer for sqlite3 databases, which automatically closes the database when the pointer goes o...
static void skipGdalDriver(const QString &driver)
Sets the GDAL_SKIP environment variable to include the specified driver and then calls GDALDriverMana...
void beginGroup(const QString &prefix, QgsSettings::Section section=QgsSettings::NoSection)
Appends prefix to the current group.
static QgsAuthManager * authManager()
Returns the application's authentication manager instance.
static QRegExp shortNameRegExp()
Returns the short name regular expression for line edit validator.
static QgsNetworkAccessManager * instance(Qt::ConnectionType connectionType=Qt::BlockingQueuedConnection)
Returns a pointer to the active QgsNetworkAccessManager for the current thread.
Identify: obtain information about the object.
Registry for various processing components, including providers, algorithms and various parameters an...
static QString showSettings()
Convenience function to get a summary of the paths used in this application instance useful for debug...
static QString appIconPath()
Gets application icon.
static QgsColorSchemeRegistry * colorSchemeRegistry()
Returns the application's color scheme registry, used for managing color schemes. ...
static const char * QGIS_ORGANIZATION_DOMAIN
bool notify(QObject *receiver, QEvent *event) override
Catch exceptions when sending event to receiver.
Registry of available layout item types.
static void setPkgDataPath(const QString &pkgDataPath)
Alters pkg data path - used by 3rd party apps.
static QgsPageSizeRegistry * pageSizeRegistry()
Returns the application's page size registry, used for managing layout page sizes.
static QString contributorsFilePath()
Returns the path to the contributors file.
static QString activeThemePath()
Returns the path to the currently active theme directory.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
static void init(QString profileFolder=QString())
This method initializes paths etc for QGIS.
static void setPluginPath(const QString &pluginPath)
Alters plugin path - used by 3rd party apps.
QgsUserProfile * getProfile(const QString &defaultProfile="default", bool createNew=true, bool initSettings=true)
Returns the profile from the given root profile location.
static QgsProject * instance()
Returns the QgsProject singleton instance.
A class to register / unregister existing GPS connections such that the information is available to a...
static QgsNetworkContentFetcherRegistry * networkContentFetcherRegistry()
Returns the application's network content registry used for fetching temporary files during QGIS sess...
bool init(const QString &pluginPath=QString(), const QString &authDatabasePath=QString())
init initialize QCA, prioritize qca-ossl plugin and optionally set up the authentication database ...
static QString platform()
Returns the QGIS platform name, e.g., "desktop" or "server".
static QString srsDatabaseFilePath()
Returns the path to the srs.db file.
QObject * ABISYM(QgsApplication::mFileOpenEventReceiver)
static void exitQgis()
deletes provider registry and map layer registry
Temporarily blocks the application QgsMessageLog (see QgsApplication::messageLog()) from emitting the...
A cache for images derived from raster files.
static QStringList svgPaths()
Returns the paths to svg directories.
static QString sponsorsFilePath()
Returns the path to the sponsors file.
Registry of storage backends that QgsProject may use.
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
static QString qgisAuthDatabaseFilePath()
Returns the path to the user authentication database file: qgis-auth.db.
static void invalidateCache()
Clears the internal cache used to initialize QgsCoordinateReferenceSystem objects.
const QString folder() const
The base folder for the user profile.
The action scope registry is an application wide registry that contains a list of available action sc...
static QHash< QString, QString > uiThemes()
All themes found in ~/.qgis3/themes folder.
static QString libexecPath()
Returns the path with utility executables (help viewer, crssync, ...)
static QString prefixPath()
Returns the path to the application prefix directory.
static QString iconsPath()
Returns the path to the icons image directory.
static QString translatorsFilePath()
Returns the path to the sponsors file.
static const char * QGIS_APPLICATION_NAME
void collectTranslatableObjects(QgsTranslationContext *translationContext)
Emits the signal to collect all the strings of .qgs to be included in ts file.
~QgsApplication() override
static QString serverResourcesPath()
Returns the path to the server resources directory.
static QgsActionScopeRegistry * actionScopeRegistry()
Returns the action scope registry.
User profile manager is used to manager list, and manage user profiles on the users machine...
static QString metadataPath()
Returns the path to the metadata directory.
Defines a QGIS exception class.
static QgsRasterRendererRegistry * rasterRendererRegistry()
Returns the application's raster renderer registry, used for managing raster layer renderers...
static QgsDataItemProviderRegistry * dataItemProviderRegistry()
Returns the application's data item provider registry, which keeps a list of data item providers that...
static QgsRendererRegistry * rendererRegistry()
Returns the application's renderer registry, used for managing vector layer renderers.
Interface for logging messages from QGIS in GUI independent way.
static QString qmlImportPath()
Returns the path where QML components are installed for QGIS Quick library.
static void setMaxThreads(int maxThreads)
Set maximum concurrent thread count.
Select and capture a point or a feature.
static void setUITheme(const QString &themeName)
Set the current UI theme used to style the interface.
static QColor decodeColor(const QString &str)
static QString licenceFilePath()
Returns the path to the licence file.
Registry of available paint effects.
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers, algorithms, and various parameters and outputs.
static QString userThemesFolder()
Returns the path to user's themes folder.
void preNotify(QObject *receiver, QEvent *event, bool *done)
static void setAuthDatabaseDirPath(const QString &authDbDirPath)
Alters authentication data base directory path - used by 3rd party apps.