70 #include <QFileOpenEvent> 71 #include <QMessageBox> 74 #include <QProcessEnvironment> 77 #include <QThreadPool> 82 #include <netinet/in.h> 88 #define SECURITY_WIN32 90 #pragma comment( lib, "Secur32.lib" ) 93 #include "qgsconfig.h" 100 #if PROJ_VERSION_MAJOR>=6 105 #define CONN_POOL_MAX_CONCURRENT_CONNS 4 107 QObject *
ABISYM( QgsApplication::mFileOpenEventReceiver );
108 QStringList
ABISYM( QgsApplication::mFileOpenEventList );
109 QString
ABISYM( QgsApplication::mPrefixPath );
110 QString
ABISYM( QgsApplication::mPluginPath );
111 QString
ABISYM( QgsApplication::mPkgDataPath );
112 QString
ABISYM( QgsApplication::mLibraryPath );
113 QString
ABISYM( QgsApplication::mLibexecPath );
114 QString
ABISYM( QgsApplication::mQmlImportPath );
115 QString
ABISYM( QgsApplication::mThemeName );
116 QString
ABISYM( QgsApplication::mUIThemeName );
117 QString
ABISYM( QgsApplication::mProfilePath );
119 QStringList
ABISYM( QgsApplication::mDefaultSvgPaths );
120 QMap<QString, QString>
ABISYM( QgsApplication::mSystemEnvVars );
121 QString
ABISYM( QgsApplication::mConfigPath );
123 bool ABISYM( QgsApplication::mInitialized ) =
false;
124 bool ABISYM( QgsApplication::mRunningFromBuildDir ) =
false;
125 QString
ABISYM( QgsApplication::mBuildSourcePath );
126 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) 127 QString
ABISYM( QgsApplication::mCfgIntDir );
129 QString
ABISYM( QgsApplication::mBuildOutputPath );
130 QStringList
ABISYM( QgsApplication::mGdalSkipList );
131 QStringList QgsApplication::sDeferredSkippedGdalDrivers;
132 int ABISYM( QgsApplication::mMaxThreads );
133 QString
ABISYM( QgsApplication::mAuthDbDirPath );
135 QString QgsApplication::sUserName;
136 QString QgsApplication::sUserFullName;
137 QString QgsApplication::sPlatformName = QStringLiteral(
"desktop" );
138 QString QgsApplication::sTranslation;
144 QgsApplication::ApplicationMembers *QgsApplication::sApplicationMembers =
nullptr;
148 : QApplication( argc, argv, GUIenabled )
150 sPlatformName = platformName;
152 if ( sTranslation != QLatin1String(
"C" ) )
154 mQgisTranslator =
new QTranslator();
155 if ( mQgisTranslator->load( QStringLiteral(
"qgis_" ) + sTranslation,
i18nPath() ) )
157 installTranslator( mQgisTranslator );
161 QgsDebugMsg( QStringLiteral(
"loading of qgis translation failed %1/qgis_%2" ).arg(
i18nPath(), sTranslation ) );
169 mQtTranslator =
new QTranslator();
170 if ( mQtTranslator->load( QStringLiteral(
"qt_" ) + sTranslation, QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ) )
172 installTranslator( mQtTranslator );
176 QgsDebugMsg( QStringLiteral(
"loading of qt translation failed %1/qt_%2" ).arg( QLibraryInfo::location( QLibraryInfo::TranslationsPath ), sTranslation ) );
180 mApplicationMembers =
new ApplicationMembers();
182 ABISYM( mProfilePath ) = profileFolder;
187 if ( profileFolder.isEmpty() )
189 if ( getenv(
"QGIS_CUSTOM_CONFIG_PATH" ) )
191 profileFolder = getenv(
"QGIS_CUSTOM_CONFIG_PATH" );
195 profileFolder = QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ).value( 0 );
202 profileFolder = profile->
folder();
206 ABISYM( mProfilePath ) = profileFolder;
208 qRegisterMetaType<QgsGeometry::Error>(
"QgsGeometry::Error" );
209 qRegisterMetaType<QgsProcessingFeatureSourceDefinition>(
"QgsProcessingFeatureSourceDefinition" );
210 qRegisterMetaType<QgsProcessingOutputLayerDefinition>(
"QgsProcessingOutputLayerDefinition" );
211 qRegisterMetaType<QgsUnitTypes::LayoutUnit>(
"QgsUnitTypes::LayoutUnit" );
212 qRegisterMetaType<QgsFeatureId>(
"QgsFeatureId" );
213 qRegisterMetaType<QgsFeatureIds>(
"QgsFeatureIds" );
214 qRegisterMetaType<QgsProperty>(
"QgsProperty" );
215 qRegisterMetaType<Qgis::MessageLevel>(
"Qgis::MessageLevel" );
216 qRegisterMetaType<QgsReferencedRectangle>(
"QgsReferencedRectangle" );
217 qRegisterMetaType<QgsReferencedPointXY>(
"QgsReferencedPointXY" );
218 qRegisterMetaType<QgsLayoutRenderContext::Flags>(
"QgsLayoutRenderContext::Flags" );
219 qRegisterMetaType<QgsStyle::StyleEntity>(
"QgsStyle::StyleEntity" );
220 qRegisterMetaType<QgsCoordinateReferenceSystem>(
"QgsCoordinateReferenceSystem" );
221 qRegisterMetaType<QgsAuthManager::MessageLevel>(
"QgsAuthManager::MessageLevel" );
222 qRegisterMetaType<QgsNetworkRequestParameters>(
"QgsNetworkRequestParameters" );
223 qRegisterMetaType<QgsNetworkReplyContent>(
"QgsNetworkReplyContent" );
224 qRegisterMetaType<QgsGeometry>(
"QgsGeometry" );
225 qRegisterMetaType<QgsDatumTransform::GridDetails>(
"QgsDatumTransform::GridDetails" );
226 qRegisterMetaType<QgsDatumTransform::TransformDetails>(
"QgsDatumTransform::TransformDetails" );
227 qRegisterMetaType<QgsNewsFeedParser::Entry>(
"QgsNewsFeedParser::Entry" );
231 if ( ABISYM( mRunningFromBuildDir ) )
234 ABISYM( mPrefixPath ) = QString();
235 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) 236 setPluginPath( ABISYM( mBuildOutputPath ) +
'/' + QString( QGIS_PLUGIN_SUBDIR ) +
'/' + ABISYM( mCfgIntDir ) );
238 setPluginPath( ABISYM( mBuildOutputPath ) +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
241 ABISYM( mLibraryPath ) = ABISYM( mBuildOutputPath ) +
'/' + QGIS_LIB_SUBDIR +
'/';
242 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) 243 ABISYM( mLibexecPath ) = ABISYM( mBuildOutputPath ) +
'/' + QGIS_LIBEXEC_SUBDIR +
'/' + ABISYM( mCfgIntDir ) +
'/';
245 ABISYM( mLibexecPath ) = ABISYM( mBuildOutputPath ) +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
247 #if defined( HAVE_QUICK ) 248 ABISYM( mQmlImportPath ) = ABISYM( mBuildOutputPath ) +
'/' + QGIS_QML_SUBDIR +
'/';
253 char *
prefixPath = getenv(
"QGIS_PREFIX_PATH" );
256 if ( ABISYM( mPrefixPath ).isNull() )
258 #if defined(Q_OS_MACX) || defined(Q_OS_WIN) 260 #elif defined(ANDROID) 262 QDir myDir( QDir::homePath() );
264 QString myPrefix = myDir.absolutePath();
267 QDir myDir( applicationDirPath() );
269 if ( applicationDirPath().contains( QStringLiteral(
"cgi-bin" ) ) )
274 QString myPrefix = myDir.absolutePath();
285 ABISYM( mConfigPath ) = profileFolder +
'/';
289 if ( getenv(
"QGIS_AUTH_DB_DIR_PATH" ) )
295 QMap<QString, QString> systemEnvVarMap;
296 QString passfile( QStringLiteral(
"QGIS_AUTH_PASSWORD_FILE" ) );
298 const auto systemEnvironment = QProcessEnvironment::systemEnvironment().toStringList();
299 for (
const QString &varStr : systemEnvironment )
301 int pos = varStr.indexOf( QLatin1Char(
'=' ) );
304 QString varStrName = varStr.left( pos );
305 QString varStrValue = varStr.mid( pos + 1 );
306 if ( varStrName != passfile )
308 systemEnvVarMap.insert( varStrName, varStrValue );
311 ABISYM( mSystemEnvVars ) = systemEnvVarMap;
313 #if PROJ_VERSION_MAJOR>=6 317 char **newPaths =
new char *[currentProjSearchPaths.length()];
318 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
320 newPaths[i] = CPLStrdup( currentProjSearchPaths.at( i ).toUtf8().constData() );
322 proj_context_set_search_paths(
nullptr, currentProjSearchPaths.count(), newPaths );
323 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
325 CPLFree( newPaths[i] );
332 QCoreApplication::addLibraryPath(
pluginPath() );
337 ABISYM( mMaxThreads ) = -1;
345 ABISYM( mInitialized ) =
true;
350 delete mDataItemProviderRegistry;
351 delete mApplicationMembers;
352 delete mQgisTranslator;
353 delete mQtTranslator;
361 void QgsApplication::invalidateCaches()
373 return qobject_cast<
QgsApplication *>( QCoreApplication::instance() );
379 if ( event->type() == QEvent::FileOpen )
382 if ( ABISYM( mFileOpenEventReceiver ) )
385 done =
notify( ABISYM( mFileOpenEventReceiver ), event );
392 ABISYM( mFileOpenEventList ).append( static_cast<QFileOpenEvent *>( event )->file() );
399 done = QApplication::event( event );
408 if ( thread() == receiver->thread() )
409 emit
preNotify( receiver, event, &done );
418 done = QApplication::notify( receiver, event );
423 if ( qApp->thread() == QThread::currentThread() )
424 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
426 catch ( std::exception &e )
428 QgsDebugMsg(
"Caught unhandled std::exception: " + QString::fromLatin1( e.what() ) );
429 if ( qApp->thread() == QThread::currentThread() )
430 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.what() );
434 QgsDebugMsg( QStringLiteral(
"Caught unhandled unknown exception" ) );
435 if ( qApp->thread() == QThread::currentThread() )
436 QMessageBox::critical( activeWindow(), tr(
"Exception" ), tr(
"unknown exception" ) );
444 return members()->mProfiler;
450 ABISYM( mFileOpenEventReceiver ) = receiver;
452 if ( ABISYM( mFileOpenEventList ).count() > 0 )
454 QStringListIterator i( ABISYM( mFileOpenEventList ) );
455 while ( i.hasNext() )
457 QFileOpenEvent foe( i.next() );
458 QgsApplication::sendEvent( ABISYM( mFileOpenEventReceiver ), &foe );
460 ABISYM( mFileOpenEventList ).clear();
467 #if defined(Q_OS_WIN) 468 if ( ABISYM( mPrefixPath ).endsWith(
"/bin" ) )
470 ABISYM( mPrefixPath ).chop( 4 );
473 if ( useDefaultPaths && !ABISYM( mRunningFromBuildDir ) )
475 setPluginPath( ABISYM( mPrefixPath ) +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
476 setPkgDataPath( ABISYM( mPrefixPath ) +
'/' + QStringLiteral( QGIS_DATA_SUBDIR ) );
478 ABISYM( mLibraryPath ) = ABISYM( mPrefixPath ) +
'/' + QGIS_LIB_SUBDIR +
'/';
479 ABISYM( mLibexecPath ) = ABISYM( mPrefixPath ) +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
480 #if defined( HAVE_QUICK ) 481 ABISYM( mQmlImportPath ) = ABISYM( mPrefixPath ) +
'/' + QGIS_QML_SUBDIR +
'/';
493 QString mySvgPath = pkgDataPath + ( ABISYM( mRunningFromBuildDir ) ?
"/images/svg/" :
"/svg/" );
495 if ( !ABISYM( mDefaultSvgPaths ).contains( mySvgPath ) )
496 ABISYM( mDefaultSvgPaths ) << mySvgPath;
501 ABISYM( mDefaultSvgPaths ) = pathList;
506 QFileInfo fi( authDbDirPath );
507 if ( fi.exists() && fi.isDir() && fi.isWritable() )
509 ABISYM( mAuthDbDirPath ) = fi.canonicalFilePath() + QDir::separator();
516 if ( ABISYM( mRunningFromBuildDir ) )
518 static bool sOnce =
true;
522 ( void ) blockNotifications;
523 qWarning(
"!!! prefix path was requested, but it is not valid - we do not run from installed path !!!" );
529 return ABISYM( mPrefixPath );
533 return ABISYM( mPluginPath );
537 if ( ABISYM( mPkgDataPath ).isNull() )
540 return ABISYM( mPkgDataPath );
544 return QStringLiteral(
":/images/themes/default/" );
549 QDir dir( usersThemes );
557 return defaultThemes;
563 return iconsPath() + QStringLiteral(
"qgis-icon-60x60.png" );
570 if ( QFile::exists( path + iconFile ) )
571 return path + iconFile;
580 if ( app && app->mIconCache.contains( name ) )
581 return app->mIconCache.value( name );
585 QString myPreferredPath =
activeThemePath() + QDir::separator() + name;
587 if ( QFile::exists( myPreferredPath ) )
589 icon = QIcon( myPreferredPath );
591 else if ( QFile::exists( myDefaultPath ) )
595 icon = QIcon( myDefaultPath );
603 app->mIconCache.insert( name, icon );
610 if ( app && app->mCursorCache.contains( cursor ) )
611 return app->mCursorCache.value( cursor );
622 name = QStringLiteral(
"mZoomIn.svg" );
627 name = QStringLiteral(
"mZoomOut.svg" );
634 name = QStringLiteral(
"mIdentify.svg" );
637 name = QStringLiteral(
"mCrossHair.svg" );
640 name = QStringLiteral(
"mCapturePoint.svg" );
643 name = QStringLiteral(
"mSelect.svg" );
650 name = QStringLiteral(
"mSampler.svg" );
655 Q_ASSERT( ! name.isEmpty( ) );
657 QIcon icon =
getThemeIcon( QStringLiteral(
"cursors" ) + QDir::separator() + name );
660 if ( ! icon.isNull( ) )
664 cursorIcon = QCursor( icon.pixmap( std::ceil( scale * 32 ), std::ceil( scale * 32 ) ), std::ceil( scale * activeX ), std::ceil( scale * activeY ) );
667 app->mCursorCache.insert( cursor, cursorIcon );
674 QString myPreferredPath =
activeThemePath() + QDir::separator() + name;
676 if ( QFile::exists( myPreferredPath ) )
678 return QPixmap( myPreferredPath );
684 return QPixmap( myDefaultPath );
695 static QString appPath;
696 if ( appPath.isNull() )
698 if ( QCoreApplication::instance() )
700 appPath = applicationDirPath();
704 qWarning(
"Application path not initialized" );
708 if ( !appPath.isNull() || getenv(
"QGIS_PREFIX_PATH" ) )
710 QString prefix = getenv(
"QGIS_PREFIX_PATH" ) ? getenv(
"QGIS_PREFIX_PATH" ) : appPath;
715 static const QStringList paths { QStringList() << QString() << QStringLiteral(
"/.." ) << QStringLiteral(
"/bin" ) << QStringLiteral(
"/../../.." ) };
716 for (
const QString &path : paths )
718 f.setFileName( prefix + path +
"/qgisbuildpath.txt" );
722 if ( f.exists() && f.open( QIODevice::ReadOnly ) )
724 ABISYM( mRunningFromBuildDir ) =
true;
725 ABISYM( mBuildSourcePath ) = f.readLine().trimmed();
726 ABISYM( mBuildOutputPath ) = f.readLine().trimmed();
728 QgsDebugMsgLevel( QStringLiteral(
"- source directory: %1" ).arg( ABISYM( mBuildSourcePath ).toUtf8().constData() ), 4 );
729 QgsDebugMsgLevel( QStringLiteral(
"- output directory of the build: %1" ).arg( ABISYM( mBuildOutputPath ).toUtf8().constData() ), 4 );
730 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) 731 ABISYM( mCfgIntDir ) = appPath.split(
'/', QString::SkipEmptyParts ).last();
732 qDebug(
"- cfg: %s", ABISYM( mCfgIntDir ).toUtf8().constData() );
738 if ( getenv(
"QGIS_PREFIX_PATH" ) )
739 prefixPath = getenv(
"QGIS_PREFIX_PATH" );
744 QDir dir( QDir::homePath() );
746 prefixPath = dir.absolutePath();
749 #if defined(Q_OS_MACX) 750 prefixPath = appPath;
751 #elif defined(Q_OS_WIN) 752 prefixPath = appPath;
753 if ( prefixPath.endsWith(
"/bin" ) )
754 prefixPath.chop( 4 );
758 if ( appPath.contains( QStringLiteral(
"cgi-bin" ) ) )
763 prefixPath = dir.absolutePath();
768 if ( ABISYM( mRunningFromBuildDir ) )
769 return ABISYM( mBuildSourcePath );
771 return prefixPath +
'/' + QStringLiteral( QGIS_DATA_SUBDIR );
776 return ABISYM( mThemeName );
783 if ( themeName == QStringLiteral(
"default" ) || !themes.contains( themeName ) )
786 qApp->setStyleSheet( QString() );
790 QString path = themes.value( themeName );
791 QString stylesheetname = path +
"/style.qss";
793 QFile file( stylesheetname );
794 QFile variablesfile( path +
"/variables.qss" );
796 QFileInfo variableInfo( variablesfile );
798 if ( !file.open( QIODevice::ReadOnly ) || ( variableInfo.exists() && !variablesfile.open( QIODevice::ReadOnly ) ) )
803 QString styledata = file.readAll();
804 styledata.replace( QStringLiteral(
"@theme_path" ), path );
806 if ( variableInfo.exists() )
808 QTextStream in( &variablesfile );
809 while ( !in.atEnd() )
811 QString line = in.readLine();
813 if ( line.startsWith(
'@' ) )
815 int index = line.indexOf(
':' );
816 QString name = line.mid( 0, index );
817 QString value = line.mid( index + 1, line.length() );
818 styledata.replace( name, value );
821 variablesfile.close();
829 QRegularExpression regex( QStringLiteral(
"(?<=[\\s:])([0-9\\.]+)(?=em)" ) );
830 QRegularExpressionMatch match = regex.match( styledata, index );
831 while ( match.hasMatch() )
833 index = match.capturedStart();
834 styledata.remove( index, match.captured( 0 ).length() );
836 styledata.insert( index, number );
837 index += number.length();
838 match = regex.match( styledata, index );
842 qApp->setStyleSheet( styledata );
844 QFile palettefile( path +
"/palette.txt" );
845 QFileInfo paletteInfo( palettefile );
846 if ( paletteInfo.exists() && palettefile.open( QIODevice::ReadOnly ) )
848 QPalette
pal = qApp->palette();
849 QTextStream in( &palettefile );
850 while ( !in.atEnd() )
852 QString line = in.readLine();
853 QStringList parts = line.split(
':' );
854 if ( parts.count() == 2 )
856 int role = parts.at( 0 ).trimmed().toInt();
858 pal.setColor( static_cast< QPalette::ColorRole >( role ), color );
862 qApp->setPalette( pal );
871 QHash<QString, QString> mapping;
872 mapping.insert( QStringLiteral(
"default" ), QString() );
873 const auto constPaths = paths;
874 for (
const QString &path : constPaths )
877 QFileInfoList styleFiles = folder.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
878 const auto constStyleFiles = styleFiles;
879 for (
const QFileInfo &info : constStyleFiles )
881 QFileInfo styleFile( info.absoluteFilePath() +
"/style.qss" );
882 if ( !styleFile.exists() )
885 QString name = info.baseName();
886 QString path = info.absoluteFilePath();
887 mapping.insert( name, path );
895 return pkgDataPath() + QStringLiteral(
"/doc/AUTHORS" );
900 return pkgDataPath() + QStringLiteral(
"/doc/CONTRIBUTORS" );
904 return pkgDataPath() + QStringLiteral(
"/doc/developersmap.html" );
909 return pkgDataPath() + QStringLiteral(
"/doc/SPONSORS" );
914 return pkgDataPath() + QStringLiteral(
"/doc/DONORS" );
919 return pkgDataPath() + QStringLiteral(
"/doc/TRANSLATORS" );
924 return pkgDataPath() + QStringLiteral(
"/doc/LICENSE" );
929 if ( ABISYM( mRunningFromBuildDir ) )
930 return ABISYM( mBuildOutputPath ) + QStringLiteral(
"/i18n/" );
937 return pkgDataPath() + QStringLiteral(
"/resources/metadata-ISO/" );
942 return pkgDataPath() + QStringLiteral(
"/resources/qgis.db" );
947 return ABISYM( mConfigPath );
957 return ABISYM( mAuthDbDirPath ) + QStringLiteral(
"qgis-auth.db" );
962 return QStringLiteral(
":/images/splash/" );
967 return pkgDataPath() + QStringLiteral(
"/images/icons/" );
972 if ( ABISYM( mRunningFromBuildDir ) )
974 #if PROJ_VERSION_MAJOR>=6 975 QString tempCopy = QDir::tempPath() +
"/srs6.db";
977 QString tempCopy = QDir::tempPath() +
"/srs.db";
980 if ( !QFile( tempCopy ).exists() )
982 #if PROJ_VERSION_MAJOR>=6 987 if ( !f.copy( tempCopy ) )
989 qFatal(
"Could not create temporary copy" );
997 return pkgDataPath() + QStringLiteral(
"/resources/srs.db" );
1006 QStringList pathList = settings.
value( QStringLiteral(
"svg/searchPathsForSVG" ) ).toStringList();
1010 const auto constPathList = pathList;
1011 for (
const QString &path : constPathList )
1013 if ( !paths.contains( path ) )
1014 paths.append( path );
1016 for (
const QString &path : qgis::as_const( ABISYM( mDefaultSvgPaths ) ) )
1018 if ( !paths.contains( path ) )
1019 paths.append( path );
1030 QStringList pathList = settings.
value( QStringLiteral(
"Layout/searchPathsForTemplates" ), QVariant(),
QgsSettings::Core ).toStringList();
1042 return QRegExp(
"^[A-Za-z][A-Za-z0-9\\._-]*" );
1047 if ( !sUserName.isEmpty() )
1051 TCHAR name [ UNLEN + 1 ];
1052 DWORD size = UNLEN + 1;
1054 if ( GetUserName( ( TCHAR * )name, &size ) )
1056 sUserName = QString::fromLocal8Bit( name );
1059 #elif QT_CONFIG(process) 1062 process.start( QStringLiteral(
"whoami" ) );
1063 process.waitForFinished();
1064 sUserName = process.readAllStandardOutput().trimmed();
1067 if ( !sUserName.isEmpty() )
1071 sUserName = qgetenv(
"USER" );
1072 if ( !sUserName.isEmpty() )
1076 sUserName = qgetenv(
"USERNAME" );
1082 if ( !sUserFullName.isEmpty() )
1083 return sUserFullName;
1086 TCHAR name [ UNLEN + 1 ];
1087 DWORD size = UNLEN + 1;
1090 if ( GetUserNameEx( NameDisplay, ( TCHAR * )name, &size ) )
1092 sUserFullName = QString::fromLocal8Bit( name );
1096 if ( sUserFullName.isEmpty() )
1098 #elif defined(Q_OS_ANDROID) || defined(__MINGW32__) 1099 sUserFullName =
"Not available";
1101 struct passwd *p = getpwuid( getuid() );
1105 QString gecosName = QString( p->pw_gecos );
1106 sUserFullName = gecosName.left( gecosName.indexOf(
',', 0 ) );
1111 return sUserFullName;
1116 #if defined(Q_OS_ANDROID) 1117 return QLatin1String(
"android" );
1118 #elif defined(Q_OS_MAC) 1119 return QLatin1String(
"osx" );
1120 #elif defined(Q_OS_WIN) 1121 return QLatin1String(
"windows" );
1122 #elif defined(Q_OS_LINUX) 1123 return QStringLiteral(
"linux" );
1124 #elif defined(Q_OS_FREEBSD) 1125 return QStringLiteral(
"freebsd" );
1126 #elif defined(Q_OS_OPENBSD) 1127 return QStringLiteral(
"openbsd" );
1128 #elif defined(Q_OS_NETBSD) 1129 return QStringLiteral(
"netbsd" );
1130 #elif defined(Q_OS_UNIX) 1131 return QLatin1String(
"unix" );
1133 return QLatin1String(
"unknown" );
1139 return sPlatformName;
1145 bool overrideLocale = settings.
value( QStringLiteral(
"locale/overrideFlag" ),
false ).toBool();
1146 if ( overrideLocale )
1148 QString
locale = settings.
value( QStringLiteral(
"locale/userLocale" ), QString() ).toString();
1150 if ( locale.startsWith( QLatin1String(
"en" ), Qt::CaseInsensitive ) )
1152 return locale.left( 2 );
1159 return QLocale().name().left( 2 );
1170 return pkgDataPath() + QStringLiteral(
"/resources/symbology-style.xml" );
1175 return pkgDataPath() + QStringLiteral(
"/resources/themes" );
1180 return pkgDataPath() + QStringLiteral(
"/resources/server/" );
1185 return ABISYM( mLibraryPath );
1190 return ABISYM( mLibexecPath );
1195 return ABISYM( mQmlImportPath );
1200 return ( htonl( 1 ) == 1 ) ?
XDR :
NDR;
1244 if ( !sAuthManager )
1246 return sAuthManager;
1254 QThreadPool::globalInstance()->waitForDone();
1260 delete sAuthManager;
1265 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1273 if ( QgsProviderRegistry::exists() )
1282 GDALDestroyDriverManager();
1287 QString myEnvironmentVar( getenv(
"QGIS_PREFIX_PATH" ) );
1288 QString myState = tr(
"Application state:\n" 1289 "QGIS_PREFIX_PATH env var:\t\t%1\n" 1291 "Plugin Path:\t\t%3\n" 1292 "Package Data Path:\t%4\n" 1293 "Active Theme Name:\t%5\n" 1294 "Active Theme Path:\t%6\n" 1295 "Default Theme Path:\t%7\n" 1296 "SVG Search Paths:\t%8\n" 1297 "User DB Path:\t%9\n" 1298 "Auth DB Path:\t%10\n" )
1299 .arg( myEnvironmentVar,
1306 svgPaths().join( tr(
"\n\t\t",
"match indentation of application state" ) ),
1319 QColor myColor1( Qt::lightGray );
1320 QColor myColor2 = myColor1;
1321 myColor2 = myColor2.lighter( 110 );
1323 myStyle =
".overview{" 1325 " font-weight: bold;" 1328 " background: white;" 1330 " font-family: 'Lato', 'Ubuntu', 'Lucida Grande', 'Segoe UI', 'Arial', sans-serif;" 1333 "h1{ background-color: #F6F6F6;" 1335 " font-size: x-large; " 1336 " font-weight: normal;" 1337 " background: none;" 1338 " padding: 0.75em 0 0;" 1340 " line-height: 3em;" 1342 "h2{ background-color: #F6F6F6;" 1344 " font-size: medium; " 1345 " font-weight: normal;" 1346 " background: none;" 1347 " padding: 0.75em 0 0;" 1349 " line-height: 1.1em;" 1351 "h3{ background-color: #F6F6F6;" 1353 " font-weight: bold;" 1354 " font-size: large;" 1355 " text-align: right;" 1356 " border-bottom: 5px solid #DCEB5C;" 1358 "h4{ background-color: #F6F6F6;" 1360 " font-weight: bold;" 1361 " font-size: medium;" 1362 " text-align: right;" 1364 "h5{ background-color: #F6F6F6;" 1366 " font-weight: bold;" 1367 " font-size: small;" 1368 " text-align: right;" 1370 "a{ color: #729FCF;" 1371 " font-family: arial,sans-serif;" 1373 "label{ background-color: #FFFFCC;" 1374 " border: 1px solid black;" 1376 " padding: 0px 3px; " 1377 " font-size: small;" 1380 " font-weight: bold;" 1381 " padding-top:25px;" 1383 ".list-view .highlight {" 1384 " text-align: right;" 1387 " padding-right: 15px;" 1388 " padding-left: 20px;" 1389 " font-weight: bold;" 1392 " font-weight: bold;" 1395 " border-collapse: collapse;" 1398 ".tabular-view th, .tabular-view td { " 1399 " border:10px solid black;" 1401 ".tabular-view .odd-row{" 1402 " background-color: #f9f9f9;" 1407 " border-top: 1px solid black;" 1414 if ( 0 >= OGRGetDriverCount() )
1422 QString aPathUrl = aPath;
1423 QString tPathUrl = targetPath;
1424 #if defined( Q_OS_WIN ) 1425 const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
1427 aPathUrl.replace(
'\\',
'/' );
1428 if ( aPathUrl.startsWith(
"//" ) )
1431 aPathUrl =
"\\\\" + aPathUrl.mid( 2 );
1434 tPathUrl.replace(
'\\',
'/' );
1435 if ( tPathUrl.startsWith(
"//" ) )
1438 tPathUrl =
"\\\\" + tPathUrl.mid( 2 );
1441 const Qt::CaseSensitivity cs = Qt::CaseSensitive;
1444 QStringList targetElems = tPathUrl.split(
'/', QString::SkipEmptyParts );
1445 QStringList aPathElems = aPathUrl.split(
'/', QString::SkipEmptyParts );
1447 targetElems.removeAll( QStringLiteral(
"." ) );
1448 aPathElems.removeAll( QStringLiteral(
"." ) );
1452 while ( !aPathElems.isEmpty() &&
1453 !targetElems.isEmpty() &&
1454 aPathElems[0].compare( targetElems[0], cs ) == 0 )
1456 aPathElems.removeFirst();
1457 targetElems.removeFirst();
1467 if ( !targetElems.isEmpty() )
1470 for (
int i = 0; i < targetElems.size(); i++ )
1472 aPathElems.insert( 0, QStringLiteral(
".." ) );
1479 aPathElems.insert( 0, QStringLiteral(
"." ) );
1482 return aPathElems.join( QStringLiteral(
"/" ) );
1488 if ( !rpath.startsWith( QLatin1String(
"./" ) ) && !rpath.startsWith( QLatin1String(
"../" ) ) )
1493 QString rPathUrl = rpath;
1494 QString targetPathUrl = targetPath;
1496 #if defined(Q_OS_WIN) 1497 rPathUrl.replace(
'\\',
'/' );
1498 targetPathUrl.replace(
'\\',
'/' );
1500 bool uncPath = targetPathUrl.startsWith(
"//" );
1503 QStringList srcElems = rPathUrl.split(
'/', QString::SkipEmptyParts );
1504 QStringList targetElems = targetPathUrl.split(
'/', QString::SkipEmptyParts );
1506 #if defined(Q_OS_WIN) 1509 targetElems.insert( 0,
"" );
1510 targetElems.insert( 0,
"" );
1515 targetElems << srcElems;
1516 targetElems.removeAll( QStringLiteral(
"." ) );
1520 while ( ( pos = targetElems.indexOf( QStringLiteral(
".." ) ) ) > 0 )
1523 targetElems.removeAt( pos - 1 );
1524 targetElems.removeAt( pos - 1 );
1527 #if !defined(Q_OS_WIN) 1529 targetElems.prepend( QString() );
1532 return targetElems.join( QStringLiteral(
"/" ) );
1537 if (
ABISYM( mGdalSkipList ).contains( driver ) || driver.isEmpty() )
1541 ABISYM( mGdalSkipList ) << driver;
1547 if ( !
ABISYM( mGdalSkipList ).contains( driver ) )
1551 int myPos =
ABISYM( mGdalSkipList ).indexOf( driver );
1554 ABISYM( mGdalSkipList ).removeAt( myPos );
1566 settings.
setValue( QStringLiteral(
"gdal/skipList" ), skippedGdalDrivers.join( QStringLiteral(
" " ) ) );
1574 QString joinedList = settings.
value( QStringLiteral(
"gdal/skipList" ), QString() ).toString();
1576 if ( !joinedList.isEmpty() )
1578 myList = joinedList.split(
' ' );
1580 ABISYM( mGdalSkipList ) = myList;
1586 ABISYM( mGdalSkipList ).removeDuplicates();
1587 QStringList realDisabledDriverList;
1588 for (
const auto &driverName :
ABISYM( mGdalSkipList ) )
1590 if ( !sDeferredSkippedGdalDrivers.contains( driverName ) )
1591 realDisabledDriverList << driverName;
1593 QString myDriverList = realDisabledDriverList.join(
' ' );
1594 QgsDebugMsg( QStringLiteral(
"Gdal Skipped driver list set to:" ) );
1596 CPLSetConfigOption(
"GDAL_SKIP", myDriverList.toUtf8() );
1603 QDir myDir( folder );
1604 if ( !myDir.exists() )
1606 myDir.mkpath( folder );
1612 void QgsApplication::copyPath(
const QString &src,
const QString &dst )
1615 if ( ! dir.exists() )
1618 const auto subDirectories = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot );
1619 for (
const QString &d : subDirectories )
1621 QString dst_path = dst + QDir::separator() + d;
1622 dir.mkpath( dst_path );
1623 copyPath( src + QDir::separator() + d, dst_path );
1626 const auto files = dir.entryList( QDir::Files );
1627 for (
const QString &f : files )
1629 QFile::copy( src + QDir::separator() + f, dst + QDir::separator() + f );
1638 QVariantMap variables;
1642 QStringList childKeys = settings.
childKeys();
1643 for ( QStringList::const_iterator it = childKeys.constBegin(); it != childKeys.constEnd(); ++it )
1646 variables.insert( name, settings.
value( name ) );
1656 QVariantMap::const_iterator it = variables.constBegin();
1659 for ( ; it != variables.constEnd(); ++it )
1661 settings.
setValue( it.key(), it.value() );
1672 settings.
setValue( QStringLiteral(
"variables/" ) + name, value );
1689 ApplicationMembers *appMembers = members();
1690 if ( appMembers->mNullRepresentation.isNull() )
1692 appMembers->mNullRepresentation =
QgsSettings().
value( QStringLiteral(
"qgis/nullValue" ), QStringLiteral(
"NULL" ) ).toString();
1694 return appMembers->mNullRepresentation;
1699 ApplicationMembers *appMembers = members();
1700 if ( !appMembers || appMembers->mNullRepresentation == nullRepresentation )
1713 return members()->mActionScopeRegistry;
1722 QDir myDir( myPamPath );
1723 if ( !myDir.exists() )
1725 myDir.mkpath( myPamPath );
1728 #if defined(Q_OS_WIN) 1729 CPLSetConfigOption(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() );
1733 int myChangeFlag = 0;
1734 setenv(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag );
1741 if ( !qgisPrivateDbFile.exists() )
1745 QFile masterFile( qgisMasterDbFileName );
1751 bool isDbFileCopied = masterFile.copy( qgisPrivateDbFile.fileName() );
1753 if ( !isDbFileCopied )
1757 *errorMessage = tr(
"[ERROR] Can not make qgis.db private copy" );
1762 QFile::Permissions perms = QFile( qgisPrivateDbFile.fileName() ).permissions();
1763 if ( !( perms & QFile::WriteOwner ) )
1765 if ( !qgisPrivateDbFile.setPermissions( perms | QFile::WriteOwner ) )
1769 *errorMessage = tr(
"Can not make '%1' user writable" ).arg( qgisPrivateDbFile.fileName() );
1783 *errorMessage = tr(
"Could not open qgis.db" );
1788 char *errmsg =
nullptr;
1789 int res = sqlite3_exec( database.get(),
"SELECT epsg FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
1790 if ( res == SQLITE_OK )
1793 if ( sqlite3_exec( database.get(),
1794 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;" 1795 "CREATE TABLE tbl_srs (" 1796 "srs_id INTEGER PRIMARY KEY," 1797 "description text NOT NULL," 1798 "projection_acronym text NOT NULL," 1799 "ellipsoid_acronym NOT NULL," 1800 "parameters text NOT NULL," 1802 "auth_name varchar," 1804 "is_geo integer NOT NULL," 1805 "deprecated boolean);" 1806 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);" 1807 "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;" 1808 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK
1813 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
1815 sqlite3_free( errmsg );
1821 sqlite3_free( errmsg );
1824 if ( sqlite3_exec( database.get(),
"DROP VIEW vw_srs",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
1826 QgsDebugMsg( QStringLiteral(
"vw_srs didn't exists in private qgis.db: %1" ).arg( errmsg ) );
1829 if ( sqlite3_exec( database.get(),
1830 "CREATE VIEW vw_srs AS" 1832 " a.description AS description" 1833 ",a.srs_id AS srs_id" 1834 ",a.is_geo AS is_geo" 1835 ",coalesce(b.name,a.projection_acronym) AS name" 1836 ",a.parameters AS parameters" 1837 ",a.auth_name AS auth_name" 1838 ",a.auth_id AS auth_id" 1839 ",a.deprecated AS deprecated" 1841 " LEFT OUTER JOIN tbl_projection b ON a.projection_acronym=b.acronym" 1842 " ORDER BY coalesce(b.name,a.projection_acronym),a.description",
nullptr,
nullptr, &errmsg ) != SQLITE_OK
1847 *errorMessage = tr(
"Update of view in private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
1849 sqlite3_free( errmsg );
1858 QgsDebugMsg( QStringLiteral(
"maxThreads: %1" ).arg( maxThreads ) );
1862 if ( maxThreads < 1 || maxThreads > QThread::idealThreadCount() )
1869 if ( maxThreads == -1 )
1870 maxThreads = QThread::idealThreadCount();
1873 QThreadPool::globalInstance()->setMaxThreadCount( maxThreads );
1874 QgsDebugMsg( QStringLiteral(
"set QThreadPool max thread count to %1" ).arg( QThreadPool::globalInstance()->maxThreadCount() ) );
1879 return members()->mTaskManager;
1884 return members()->mColorSchemeRegistry;
1889 return members()->mPaintEffectRegistry;
1894 return members()->mRendererRegistry;
1899 return members()->mRasterRendererRegistry;
1906 if ( !
instance()->mDataItemProviderRegistry )
1910 return instance()->mDataItemProviderRegistry;
1916 if ( !sDataItemProviderRegistry )
1918 return sDataItemProviderRegistry;
1924 return members()->mSvgCache;
1929 return members()->mImageCache;
1934 return members()->mNetworkContentFetcherRegistry;
1939 return members()->mValidityCheckRegistry;
1944 return members()->mSymbolLayerRegistry;
1949 return members()->mCalloutRegistry;
1954 return members()->mLayoutItemRegistry;
1959 return members()->mGpsConnectionRegistry;
1964 return members()->mPluginLayerRegistry;
1969 return members()->mClassificationMethodRegistry;
1974 return members()->mBookmarkManager;
1979 return members()->mStyleModel;
1984 return members()->mMessageLog;
1989 return members()->mProcessingRegistry;
1994 return members()->mPageSizeRegistry;
1999 return members()->mAnnotationRegistry;
2004 return members()->mFieldFormatterRegistry;
2009 return members()->m3DRendererRegistry;
2014 return members()->mProjectStorageRegistry;
2017 QgsApplication::ApplicationMembers::ApplicationMembers()
2039 mLayoutItemRegistry->populate();
2040 mAnnotationRegistry =
new QgsAnnotationRegistry();
2049 QgsApplication::ApplicationMembers::~ApplicationMembers()
2052 delete mValidityCheckRegistry;
2053 delete mActionScopeRegistry;
2054 delete m3DRendererRegistry;
2055 delete mAnnotationRegistry;
2056 delete mColorSchemeRegistry;
2057 delete mFieldFormatterRegistry;
2058 delete mGpsConnectionRegistry;
2060 delete mPaintEffectRegistry;
2061 delete mPluginLayerRegistry;
2062 delete mProcessingRegistry;
2063 delete mProjectStorageRegistry;
2064 delete mPageSizeRegistry;
2065 delete mLayoutItemRegistry;
2067 delete mRasterRendererRegistry;
2068 delete mRendererRegistry;
2071 delete mCalloutRegistry;
2072 delete mSymbolLayerRegistry;
2073 delete mTaskManager;
2074 delete mNetworkContentFetcherRegistry;
2075 delete mClassificationMethodRegistry;
2076 delete mBookmarkManager;
2079 QgsApplication::ApplicationMembers *QgsApplication::members()
2083 return instance()->mApplicationMembers;
2087 static QMutex sMemberMutex( QMutex::Recursive );
2088 QMutexLocker lock( &sMemberMutex );
2089 if ( !sApplicationMembers )
2090 sApplicationMembers =
new ApplicationMembers();
2091 return sApplicationMembers;
static QStringList layoutTemplatePaths()
Returns the paths to layout template directories.
A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle ...
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 QgsCalloutRegistry * calloutRegistry()
Returns the application's callout registry, used for managing callout types.
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 void invalidateCache(bool disableCache=false)
Clears the internal cache used.
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 invalidateCache(bool disableCache=false)
Clears the internal cache used to initialize QgsCoordinateReferenceSystem objects.
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 QStringList skippedGdalDrivers()
Returns the list of gdal drivers that should be skipped (based on GDAL_SKIP environment variable) ...
static QVariantMap customVariables()
Custom expression variables for this application.
Manages storage of a set of bookmarks.
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 QgsStyle * defaultStyle()
Returns default application-wide style.
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 QStringList deferredSkippedGdalDrivers()
Returns the list of gdal drivers that have been disabled in the current session, and thus...
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
This class manages all known classification methods.
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 void setSkippedGdalDrivers(const QStringList &skippedGdalDrivers, const QStringList &deferredSkippedGdalDrivers)
Sets the list of gdal drivers that should be disabled (skippedGdalDrivers), but excludes for now the ...
static 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...
static QgsStyleModel * defaultStyleModel()
Returns a shared QgsStyleModel containing the default style library (see QgsStyle::defaultStyle()).
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 QgsClassificationMethodRegistry * classificationMethodRegistry()
Returns the application's classification methods registry, used in graduated renderer.
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...
Registry of available callout classes.
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 QgsBookmarkManager * bookmarkManager()
Returns the application's bookmark manager, used for storing installation-wide bookmarks.
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.
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 void registerGdalDriversFromSettings()
Register gdal drivers, excluding the ones mentioned in "gdal/skipList" setting.
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.
void initialize(const QString &filePath)
initialize
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.