71 #include <QFileOpenEvent> 72 #include <QMessageBox> 75 #include <QProcessEnvironment> 78 #include <QThreadPool> 83 #include <netinet/in.h> 89 #define SECURITY_WIN32 91 #pragma comment( lib, "Secur32.lib" ) 94 #include "qgsconfig.h" 101 #if PROJ_VERSION_MAJOR>=6 106 #define CONN_POOL_MAX_CONCURRENT_CONNS 4 108 QObject *
ABISYM( QgsApplication::mFileOpenEventReceiver ) =
nullptr;
109 bool ABISYM( QgsApplication::mInitialized ) =
false;
110 bool ABISYM( QgsApplication::mRunningFromBuildDir ) =
false;
114 QgsApplication::ApplicationMembers *QgsApplication::sApplicationMembers =
nullptr;
116 int ABISYM( QgsApplication::sMaxThreads ) = -1;
133 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) 147 : QApplication( argc, argv, GUIenabled )
149 *sPlatformName() = platformName;
151 if ( *sTranslation() != QLatin1String(
"C" ) )
153 mQgisTranslator =
new QTranslator();
154 if ( mQgisTranslator->load( QStringLiteral(
"qgis_" ) + *sTranslation(), i18nPath() ) )
156 installTranslator( mQgisTranslator );
160 QgsDebugMsg( QStringLiteral(
"loading of qgis translation failed %1/qgis_%2" ).arg( i18nPath(), *sTranslation() ) );
168 mQtTranslator =
new QTranslator();
169 if ( mQtTranslator->load( QStringLiteral(
"qt_" ) + *sTranslation(), QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ) )
171 installTranslator( mQtTranslator );
175 QgsDebugMsg( QStringLiteral(
"loading of qt translation failed %1/qt_%2" ).arg( QLibraryInfo::location( QLibraryInfo::TranslationsPath ), *sTranslation() ) );
179 mApplicationMembers =
new ApplicationMembers();
181 *sProfilePath() = profileFolder;
186 if ( profileFolder.isEmpty() )
188 if ( getenv(
"QGIS_CUSTOM_CONFIG_PATH" ) )
190 profileFolder = getenv(
"QGIS_CUSTOM_CONFIG_PATH" );
194 profileFolder = QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ).value( 0 );
201 profileFolder = profile->
folder();
205 *sProfilePath() = profileFolder;
207 qRegisterMetaType<QgsGeometry::Error>(
"QgsGeometry::Error" );
208 qRegisterMetaType<QgsProcessingFeatureSourceDefinition>(
"QgsProcessingFeatureSourceDefinition" );
209 qRegisterMetaType<QgsProcessingOutputLayerDefinition>(
"QgsProcessingOutputLayerDefinition" );
210 qRegisterMetaType<QgsUnitTypes::LayoutUnit>(
"QgsUnitTypes::LayoutUnit" );
211 qRegisterMetaType<QgsFeatureId>(
"QgsFeatureId" );
212 qRegisterMetaType<QgsFeatureIds>(
"QgsFeatureIds" );
213 qRegisterMetaType<QgsProperty>(
"QgsProperty" );
214 qRegisterMetaType<Qgis::MessageLevel>(
"Qgis::MessageLevel" );
215 qRegisterMetaType<QgsReferencedRectangle>(
"QgsReferencedRectangle" );
216 qRegisterMetaType<QgsReferencedPointXY>(
"QgsReferencedPointXY" );
217 qRegisterMetaType<QgsLayoutRenderContext::Flags>(
"QgsLayoutRenderContext::Flags" );
218 qRegisterMetaType<QgsStyle::StyleEntity>(
"QgsStyle::StyleEntity" );
219 qRegisterMetaType<QgsCoordinateReferenceSystem>(
"QgsCoordinateReferenceSystem" );
220 qRegisterMetaType<QgsAuthManager::MessageLevel>(
"QgsAuthManager::MessageLevel" );
221 qRegisterMetaType<QgsNetworkRequestParameters>(
"QgsNetworkRequestParameters" );
222 qRegisterMetaType<QgsNetworkReplyContent>(
"QgsNetworkReplyContent" );
223 qRegisterMetaType<QgsGeometry>(
"QgsGeometry" );
224 qRegisterMetaType<QgsDatumTransform::GridDetails>(
"QgsDatumTransform::GridDetails" );
225 qRegisterMetaType<QgsDatumTransform::TransformDetails>(
"QgsDatumTransform::TransformDetails" );
226 qRegisterMetaType<QgsNewsFeedParser::Entry>(
"QgsNewsFeedParser::Entry" );
230 if ( ABISYM( mRunningFromBuildDir ) )
233 *sPrefixPath() = QString();
234 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) 235 setPluginPath( *sBuildOutputPath() +
'/' + QString( QGIS_PLUGIN_SUBDIR ) +
'/' + *sCfgIntDir() );
237 setPluginPath( *sBuildOutputPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
239 setPkgDataPath( *sBuildOutputPath() + QStringLiteral(
"/data" ) );
240 *sLibraryPath() = *sBuildOutputPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
241 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) 242 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/' + *sCfgIntDir() +
'/';
244 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
246 #if defined( HAVE_QUICK ) 247 *sQmlImportPath() = *sBuildOutputPath() +
'/' + QGIS_QML_SUBDIR +
'/';
252 char *
prefixPath = getenv(
"QGIS_PREFIX_PATH" );
255 if ( sPrefixPath()->isNull() )
257 #if defined(Q_OS_MACX) || defined(Q_OS_WIN) 259 #elif defined(ANDROID) 261 QDir myDir( QDir::homePath() );
263 QString myPrefix = myDir.absolutePath();
266 QDir myDir( applicationDirPath() );
268 if ( applicationDirPath().contains( QStringLiteral(
"cgi-bin" ) ) )
273 QString myPrefix = myDir.absolutePath();
284 *sConfigPath() = profileFolder +
'/';
288 if ( getenv(
"QGIS_AUTH_DB_DIR_PATH" ) )
294 QMap<QString, QString> systemEnvVarMap;
295 QString passfile( QStringLiteral(
"QGIS_AUTH_PASSWORD_FILE" ) );
297 const auto systemEnvironment = QProcessEnvironment::systemEnvironment().toStringList();
298 for (
const QString &varStr : systemEnvironment )
300 int pos = varStr.indexOf( QLatin1Char(
'=' ) );
303 QString varStrName = varStr.left( pos );
304 QString varStrValue = varStr.mid( pos + 1 );
305 if ( varStrName != passfile )
307 systemEnvVarMap.insert( varStrName, varStrValue );
310 *sSystemEnvVars() = systemEnvVarMap;
312 #if PROJ_VERSION_MAJOR>=6 316 char **newPaths =
new char *[currentProjSearchPaths.length()];
317 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
319 newPaths[i] = CPLStrdup( currentProjSearchPaths.at( i ).toUtf8().constData() );
321 proj_context_set_search_paths(
nullptr, currentProjSearchPaths.count(), newPaths );
322 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
324 CPLFree( newPaths[i] );
331 QCoreApplication::addLibraryPath(
pluginPath() );
336 ABISYM( sMaxThreads ) = -1;
342 if ( !members()->mStyleModel )
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 sFileOpenEventList()->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 ( sFileOpenEventList()->count() > 0 )
454 const QStringList fileOpenEventList = *sFileOpenEventList();
455 for (
const QString &file : fileOpenEventList )
457 QFileOpenEvent foe( file );
458 QgsApplication::sendEvent( ABISYM( mFileOpenEventReceiver ), &foe );
460 sFileOpenEventList()->clear();
467 #if defined(Q_OS_WIN) 468 if ( sPrefixPath()->endsWith(
"/bin" ) )
470 sPrefixPath()->chop( 4 );
473 if ( useDefaultPaths && !ABISYM( mRunningFromBuildDir ) )
475 setPluginPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
476 setPkgDataPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_DATA_SUBDIR ) );
478 *sLibraryPath() = *sPrefixPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
479 *sLibexecPath() = *sPrefixPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
480 #if defined( HAVE_QUICK ) 481 *sQmlImportPath() = *sPrefixPath() +
'/' + QGIS_QML_SUBDIR +
'/';
494 QString mySvgPath = pkgDataPath + QStringLiteral(
"/svg/" );
497 if ( !sDefaultSvgPaths()->contains( mySvgPath ) )
498 *sDefaultSvgPaths() << mySvgPath;
503 *sDefaultSvgPaths() = pathList;
508 QFileInfo fi( authDbDirPath );
509 if ( fi.exists() && fi.isDir() && fi.isWritable() )
511 *sAuthDbDirPath() = fi.canonicalFilePath() + QDir::separator();
518 if ( ABISYM( mRunningFromBuildDir ) )
520 static bool sOnce =
true;
524 ( void ) blockNotifications;
525 qWarning(
"!!! prefix path was requested, but it is not valid - we do not run from installed path !!!" );
531 return *sPrefixPath();
535 return *sPluginPath();
540 if ( sPkgDataPath()->isNull() )
543 return *sPkgDataPath();
548 return QStringLiteral(
":/images/themes/default/" );
553 QDir dir( usersThemes );
561 return defaultThemes;
567 return iconsPath() + QStringLiteral(
"qgis-icon-60x60.png" );
572 return ABISYM( sMaxThreads );
579 if ( QFile::exists( path + iconFile ) )
580 return path + iconFile;
589 if ( app && app->mIconCache.contains( name ) )
590 return app->mIconCache.value( name );
594 QString myPreferredPath =
activeThemePath() + QDir::separator() + name;
596 if ( QFile::exists( myPreferredPath ) )
598 icon = QIcon( myPreferredPath );
600 else if ( QFile::exists( myDefaultPath ) )
604 icon = QIcon( myDefaultPath );
612 app->mIconCache.insert( name, icon );
619 if ( app && app->mCursorCache.contains( cursor ) )
620 return app->mCursorCache.value( cursor );
631 name = QStringLiteral(
"mZoomIn.svg" );
636 name = QStringLiteral(
"mZoomOut.svg" );
643 name = QStringLiteral(
"mIdentify.svg" );
646 name = QStringLiteral(
"mCrossHair.svg" );
649 name = QStringLiteral(
"mCapturePoint.svg" );
652 name = QStringLiteral(
"mSelect.svg" );
659 name = QStringLiteral(
"mSampler.svg" );
664 Q_ASSERT( ! name.isEmpty( ) );
666 QIcon icon =
getThemeIcon( QStringLiteral(
"cursors" ) + QDir::separator() + name );
669 if ( ! icon.isNull( ) )
673 cursorIcon = QCursor( icon.pixmap( std::ceil( scale * 32 ), std::ceil( scale * 32 ) ), std::ceil( scale * activeX ), std::ceil( scale * activeY ) );
676 app->mCursorCache.insert( cursor, cursorIcon );
683 QString myPreferredPath =
activeThemePath() + QDir::separator() + name;
685 if ( QFile::exists( myPreferredPath ) )
687 return QPixmap( myPreferredPath );
693 return QPixmap( myDefaultPath );
704 static QString appPath;
705 if ( appPath.isNull() )
707 if ( QCoreApplication::instance() )
709 appPath = applicationDirPath();
713 qWarning(
"Application path not initialized" );
717 if ( !appPath.isNull() || getenv(
"QGIS_PREFIX_PATH" ) )
719 QString prefix = getenv(
"QGIS_PREFIX_PATH" ) ? getenv(
"QGIS_PREFIX_PATH" ) : appPath;
724 static const QStringList paths { QStringList() << QString() << QStringLiteral(
"/.." ) << QStringLiteral(
"/bin" ) << QStringLiteral(
"/../../.." ) };
725 for (
const QString &path : paths )
727 f.setFileName( prefix + path +
"/qgisbuildpath.txt" );
731 if ( f.exists() && f.open( QIODevice::ReadOnly ) )
733 ABISYM( mRunningFromBuildDir ) =
true;
734 *sBuildSourcePath() = f.readLine().trimmed();
735 *sBuildOutputPath() = f.readLine().trimmed();
737 QgsDebugMsgLevel( QStringLiteral(
"- source directory: %1" ).arg( sBuildSourcePath()->toUtf8().constData() ), 4 );
738 QgsDebugMsgLevel( QStringLiteral(
"- output directory of the build: %1" ).arg( sBuildOutputPath()->toUtf8().constData() ), 4 );
739 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) 740 *sCfgIntDir() = appPath.split(
'/', QString::SkipEmptyParts ).last();
741 qDebug(
"- cfg: %s", sCfgIntDir()->toUtf8().constData() );
747 if ( getenv(
"QGIS_PREFIX_PATH" ) )
748 prefixPath = getenv(
"QGIS_PREFIX_PATH" );
753 QDir dir( QDir::homePath() );
755 prefixPath = dir.absolutePath();
758 #if defined(Q_OS_MACX) 759 prefixPath = appPath;
760 #elif defined(Q_OS_WIN) 761 prefixPath = appPath;
762 if ( prefixPath.endsWith(
"/bin" ) )
763 prefixPath.chop( 4 );
767 if ( appPath.contains( QStringLiteral(
"cgi-bin" ) ) )
772 prefixPath = dir.absolutePath();
777 if ( ABISYM( mRunningFromBuildDir ) )
778 return *sBuildOutputPath() + QStringLiteral(
"/data" );
780 return prefixPath +
'/' + QStringLiteral( QGIS_DATA_SUBDIR );
785 return *sThemeName();
792 if ( themeName == QStringLiteral(
"default" ) || !themes.contains( themeName ) )
795 qApp->setStyleSheet( QString() );
799 QString path = themes.value( themeName );
800 QString stylesheetname = path +
"/style.qss";
802 QFile file( stylesheetname );
803 QFile variablesfile( path +
"/variables.qss" );
805 QFileInfo variableInfo( variablesfile );
807 if ( !file.open( QIODevice::ReadOnly ) || ( variableInfo.exists() && !variablesfile.open( QIODevice::ReadOnly ) ) )
812 QString styledata = file.readAll();
813 styledata.replace( QStringLiteral(
"@theme_path" ), path );
815 if ( variableInfo.exists() )
817 QTextStream in( &variablesfile );
818 while ( !in.atEnd() )
820 QString line = in.readLine();
822 if ( line.startsWith(
'@' ) )
824 int index = line.indexOf(
':' );
825 QString name = line.mid( 0, index );
826 QString value = line.mid( index + 1, line.length() );
827 styledata.replace( name, value );
830 variablesfile.close();
838 QRegularExpression regex( QStringLiteral(
"(?<=[\\s:])([0-9\\.]+)(?=em)" ) );
839 QRegularExpressionMatch match = regex.match( styledata, index );
840 while ( match.hasMatch() )
842 index = match.capturedStart();
843 styledata.remove( index, match.captured( 0 ).length() );
845 styledata.insert( index, number );
846 index += number.length();
847 match = regex.match( styledata, index );
851 qApp->setStyleSheet( styledata );
853 QFile palettefile( path +
"/palette.txt" );
854 QFileInfo paletteInfo( palettefile );
855 if ( paletteInfo.exists() && palettefile.open( QIODevice::ReadOnly ) )
857 QPalette
pal = qApp->palette();
858 QTextStream in( &palettefile );
859 while ( !in.atEnd() )
861 QString line = in.readLine();
862 QStringList parts = line.split(
':' );
863 if ( parts.count() == 2 )
865 int role = parts.at( 0 ).trimmed().toInt();
867 pal.setColor( static_cast< QPalette::ColorRole >( role ), color );
871 qApp->setPalette( pal );
880 QHash<QString, QString> mapping;
881 mapping.insert( QStringLiteral(
"default" ), QString() );
882 const auto constPaths = paths;
883 for (
const QString &path : constPaths )
886 QFileInfoList styleFiles = folder.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
887 const auto constStyleFiles = styleFiles;
888 for (
const QFileInfo &info : constStyleFiles )
890 QFileInfo styleFile( info.absoluteFilePath() +
"/style.qss" );
891 if ( !styleFile.exists() )
894 QString name = info.baseName();
895 QString path = info.absoluteFilePath();
896 mapping.insert( name, path );
904 return pkgDataPath() + QStringLiteral(
"/doc/AUTHORS" );
909 return pkgDataPath() + QStringLiteral(
"/doc/CONTRIBUTORS" );
913 return pkgDataPath() + QStringLiteral(
"/doc/developersmap.html" );
918 return pkgDataPath() + QStringLiteral(
"/doc/SPONSORS" );
923 return pkgDataPath() + QStringLiteral(
"/doc/DONORS" );
928 return pkgDataPath() + QStringLiteral(
"/doc/TRANSLATORS" );
933 return pkgDataPath() + QStringLiteral(
"/doc/LICENSE" );
938 if ( ABISYM( mRunningFromBuildDir ) )
939 return *sBuildOutputPath() + QStringLiteral(
"/i18n/" );
946 return pkgDataPath() + QStringLiteral(
"/resources/metadata-ISO/" );
951 return pkgDataPath() + QStringLiteral(
"/resources/qgis.db" );
956 return *sConfigPath();
966 return *sAuthDbDirPath() + QStringLiteral(
"qgis-auth.db" );
971 return QStringLiteral(
":/images/splash/" );
976 return pkgDataPath() + QStringLiteral(
"/images/icons/" );
981 if ( ABISYM( mRunningFromBuildDir ) )
983 #if PROJ_VERSION_MAJOR>=6 984 QString tempCopy = QDir::tempPath() +
"/srs6.db";
986 QString tempCopy = QDir::tempPath() +
"/srs.db";
989 if ( !QFile( tempCopy ).exists() )
991 #if PROJ_VERSION_MAJOR>=6 996 if ( !f.copy( tempCopy ) )
998 qFatal(
"Could not create temporary copy" );
1006 return pkgDataPath() + QStringLiteral(
"/resources/srs.db" );
1015 const QStringList pathList = settings.
value( QStringLiteral(
"svg/searchPathsForSVG" ) ).toStringList();
1019 for (
const QString &path : pathList )
1021 if ( !paths.contains( path ) )
1022 paths.append( path );
1024 for (
const QString &path : qgis::as_const( *sDefaultSvgPaths() ) )
1026 if ( !paths.contains( path ) )
1027 paths.append( path );
1038 QStringList pathList = settings.
value( QStringLiteral(
"Layout/searchPathsForTemplates" ), QVariant(),
QgsSettings::Core ).toStringList();
1045 return *sSystemEnvVars();
1055 return QRegExp(
"^[A-Za-z][A-Za-z0-9\\._-]*" );
1060 if ( !sUserName()->isEmpty() )
1061 return *sUserName();
1064 TCHAR name [ UNLEN + 1 ];
1065 DWORD size = UNLEN + 1;
1067 if ( GetUserName( ( TCHAR * )name, &size ) )
1069 *sUserName() = QString::fromLocal8Bit( name );
1072 #elif QT_CONFIG(process) 1075 process.start( QStringLiteral(
"whoami" ) );
1076 process.waitForFinished();
1077 *sUserName() = process.readAllStandardOutput().trimmed();
1080 if ( !sUserName()->isEmpty() )
1081 return *sUserName();
1084 *sUserName() = qgetenv(
"USER" );
1085 if ( !sUserName()->isEmpty() )
1086 return *sUserName();
1089 *sUserName() = qgetenv(
"USERNAME" );
1090 return *sUserName();
1095 if ( !sUserFullName()->isEmpty() )
1096 return *sUserFullName();
1099 TCHAR name [ UNLEN + 1 ];
1100 DWORD size = UNLEN + 1;
1103 if ( GetUserNameEx( NameDisplay, ( TCHAR * )name, &size ) )
1105 *sUserFullName() = QString::fromLocal8Bit( name );
1109 if ( sUserFullName()->isEmpty() )
1111 #elif defined(Q_OS_ANDROID) || defined(__MINGW32__) 1112 *sUserFullName() = QStringLiteral(
"Not available" );
1114 struct passwd *p = getpwuid( getuid() );
1118 QString gecosName = QString( p->pw_gecos );
1119 *sUserFullName() = gecosName.left( gecosName.indexOf(
',', 0 ) );
1124 return *sUserFullName();
1129 #if defined(Q_OS_ANDROID) 1130 return QLatin1String(
"android" );
1131 #elif defined(Q_OS_MAC) 1132 return QLatin1String(
"osx" );
1133 #elif defined(Q_OS_WIN) 1134 return QLatin1String(
"windows" );
1135 #elif defined(Q_OS_LINUX) 1136 return QStringLiteral(
"linux" );
1137 #elif defined(Q_OS_FREEBSD) 1138 return QStringLiteral(
"freebsd" );
1139 #elif defined(Q_OS_OPENBSD) 1140 return QStringLiteral(
"openbsd" );
1141 #elif defined(Q_OS_NETBSD) 1142 return QStringLiteral(
"netbsd" );
1143 #elif defined(Q_OS_UNIX) 1144 return QLatin1String(
"unix" );
1146 return QLatin1String(
"unknown" );
1152 return *sPlatformName();
1158 bool overrideLocale = settings.
value( QStringLiteral(
"locale/overrideFlag" ),
false ).toBool();
1159 if ( overrideLocale )
1161 QString
locale = settings.
value( QStringLiteral(
"locale/userLocale" ), QString() ).toString();
1163 if ( locale.startsWith( QLatin1String(
"en" ), Qt::CaseInsensitive ) )
1165 return locale.left( 2 );
1172 return QLocale().name().left( 2 );
1183 return pkgDataPath() + QStringLiteral(
"/resources/symbology-style.xml" );
1188 return pkgDataPath() + QStringLiteral(
"/resources/themes" );
1193 return pkgDataPath() + QStringLiteral(
"/resources/server/" );
1198 return *sLibraryPath();
1203 return *sLibexecPath();
1208 return *sQmlImportPath();
1213 return ( htonl( 1 ) == 1 ) ?
XDR :
NDR;
1220 init( *sProfilePath() );
1257 if ( !sAuthManager )
1259 return sAuthManager;
1267 QThreadPool::globalInstance()->waitForDone();
1273 delete sAuthManager;
1278 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1286 if ( QgsProviderRegistry::exists() )
1295 GDALDestroyDriverManager();
1300 QString myEnvironmentVar( getenv(
"QGIS_PREFIX_PATH" ) );
1301 QString myState = tr(
"Application state:\n" 1302 "QGIS_PREFIX_PATH env var:\t\t%1\n" 1304 "Plugin Path:\t\t%3\n" 1305 "Package Data Path:\t%4\n" 1306 "Active Theme Name:\t%5\n" 1307 "Active Theme Path:\t%6\n" 1308 "Default Theme Path:\t%7\n" 1309 "SVG Search Paths:\t%8\n" 1310 "User DB Path:\t%9\n" 1311 "Auth DB Path:\t%10\n" )
1312 .arg( myEnvironmentVar,
1319 svgPaths().join( tr(
"\n\t\t",
"match indentation of application state" ) ),
1332 QColor myColor1( Qt::lightGray );
1333 QColor myColor2 = myColor1;
1334 myColor2 = myColor2.lighter( 110 );
1336 myStyle = QStringLiteral(
".overview{" 1338 " font-weight: bold;" 1341 " background: white;" 1343 " font-family: 'Lato', 'Ubuntu', 'Lucida Grande', 'Segoe UI', 'Arial', sans-serif;" 1346 "h1{ background-color: #F6F6F6;" 1348 " font-size: x-large; " 1349 " font-weight: normal;" 1350 " background: none;" 1351 " padding: 0.75em 0 0;" 1353 " line-height: 3em;" 1355 "h2{ background-color: #F6F6F6;" 1357 " font-size: medium; " 1358 " font-weight: normal;" 1359 " background: none;" 1360 " padding: 0.75em 0 0;" 1362 " line-height: 1.1em;" 1364 "h3{ background-color: #F6F6F6;" 1366 " font-weight: bold;" 1367 " font-size: large;" 1368 " text-align: left;" 1369 " border-bottom: 5px solid #DCEB5C;" 1371 "h4{ background-color: #F6F6F6;" 1373 " font-weight: bold;" 1374 " font-size: medium;" 1375 " text-align: left;" 1377 "h5{ background-color: #F6F6F6;" 1379 " font-weight: bold;" 1380 " font-size: small;" 1381 " text-align: left;" 1383 "a{ color: #729FCF;" 1384 " font-family: arial,sans-serif;" 1386 "label{ background-color: #FFFFCC;" 1387 " border: 1px solid black;" 1389 " padding: 0px 3px; " 1390 " font-size: small;" 1393 " font-weight: bold;" 1398 " border-top: 1px solid black;" 1400 ".list-view .highlight {" 1401 " text-align: left;" 1404 " padding-right: 15px;" 1405 " padding-left: 20px;" 1406 " font-weight: bold;" 1408 ".tabular-view .odd-row {" 1409 " background-color: #f9f9f9;" 1412 " font-weight: bold;" 1413 " padding-top:25px;" 1417 switch ( styleSheetType )
1419 case StyleSheetType::Qt:
1420 myStyle += QStringLiteral(
1422 " border-collapse: collapse;" 1425 ".tabular-view th, .tabular-view td { " 1426 " border:10px solid black;" 1430 case StyleSheetType::WebBrowser:
1431 myStyle += QStringLiteral(
1436 "table.tabular-view, table.list-view { " 1437 " border-collapse: collapse;" 1438 " table-layout:fixed;" 1439 " width: 100% !important;" 1444 " line-height: inherit;" 1447 " word-wrap: break-word; " 1448 " vertical-align: top;" 1451 ".list-view th:first-child, .list-view td:first-child {" 1454 ".list-view.highlight { " 1455 " padding-left: inherit; " 1458 ".tabular-view th:first-child, .tabular-view td:first-child { " 1462 ".tabular-view th.strong { " 1463 " background-color: #eee; " 1466 ".tabular-view th, .tabular-view td { " 1467 " border: solid 1px #eee;" 1478 if ( 0 >= OGRGetDriverCount() )
1486 QString aPathUrl = aPath;
1487 QString tPathUrl = targetPath;
1488 #if defined( Q_OS_WIN ) 1489 const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
1491 aPathUrl.replace(
'\\',
'/' );
1492 if ( aPathUrl.startsWith(
"//" ) )
1495 aPathUrl =
"\\\\" + aPathUrl.mid( 2 );
1498 tPathUrl.replace(
'\\',
'/' );
1499 if ( tPathUrl.startsWith(
"//" ) )
1502 tPathUrl =
"\\\\" + tPathUrl.mid( 2 );
1505 const Qt::CaseSensitivity cs = Qt::CaseSensitive;
1508 QStringList targetElems = tPathUrl.split(
'/', QString::SkipEmptyParts );
1509 QStringList aPathElems = aPathUrl.split(
'/', QString::SkipEmptyParts );
1511 targetElems.removeAll( QStringLiteral(
"." ) );
1512 aPathElems.removeAll( QStringLiteral(
"." ) );
1516 while ( !aPathElems.isEmpty() &&
1517 !targetElems.isEmpty() &&
1518 aPathElems[0].compare( targetElems[0], cs ) == 0 )
1520 aPathElems.removeFirst();
1521 targetElems.removeFirst();
1531 if ( !targetElems.isEmpty() )
1534 for (
int i = 0; i < targetElems.size(); i++ )
1536 aPathElems.insert( 0, QStringLiteral(
".." ) );
1543 aPathElems.insert( 0, QStringLiteral(
"." ) );
1546 return aPathElems.join( QStringLiteral(
"/" ) );
1552 if ( !rpath.startsWith( QLatin1String(
"./" ) ) && !rpath.startsWith( QLatin1String(
"../" ) ) )
1557 QString rPathUrl = rpath;
1558 QString targetPathUrl = targetPath;
1560 #if defined(Q_OS_WIN) 1561 rPathUrl.replace(
'\\',
'/' );
1562 targetPathUrl.replace(
'\\',
'/' );
1564 bool uncPath = targetPathUrl.startsWith(
"//" );
1567 QStringList srcElems = rPathUrl.split(
'/', QString::SkipEmptyParts );
1568 QStringList targetElems = targetPathUrl.split(
'/', QString::SkipEmptyParts );
1570 #if defined(Q_OS_WIN) 1573 targetElems.insert( 0,
"" );
1574 targetElems.insert( 0,
"" );
1579 targetElems << srcElems;
1580 targetElems.removeAll( QStringLiteral(
"." ) );
1584 while ( ( pos = targetElems.indexOf( QStringLiteral(
".." ) ) ) > 0 )
1587 targetElems.removeAt( pos - 1 );
1588 targetElems.removeAt( pos - 1 );
1591 #if !defined(Q_OS_WIN) 1593 targetElems.prepend( QString() );
1596 return targetElems.join( QStringLiteral(
"/" ) );
1601 return *sBuildSourcePath();
1606 return *sBuildOutputPath();
1609 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) 1610 QString QgsApplication::cfgIntDir()
1612 return *sCfgIntDir();
1618 if ( sGdalSkipList()->contains( driver ) || driver.isEmpty() )
1622 *sGdalSkipList() << driver;
1628 if ( !sGdalSkipList()->contains( driver ) )
1632 int myPos = sGdalSkipList()->indexOf( driver );
1635 sGdalSkipList()->removeAt( myPos );
1642 return *sGdalSkipList();
1652 settings.
setValue( QStringLiteral(
"gdal/skipList" ), skippedGdalDrivers.join( QStringLiteral(
" " ) ) );
1660 QString joinedList = settings.
value( QStringLiteral(
"gdal/skipList" ), QString() ).toString();
1662 if ( !joinedList.isEmpty() )
1664 myList = joinedList.split(
' ' );
1666 *sGdalSkipList() = myList;
1672 return *sDeferredSkippedGdalDrivers();
1677 sGdalSkipList()->removeDuplicates();
1678 QStringList realDisabledDriverList;
1679 for (
const auto &driverName : *sGdalSkipList() )
1681 if ( !sDeferredSkippedGdalDrivers()->contains( driverName ) )
1682 realDisabledDriverList << driverName;
1684 QString myDriverList = realDisabledDriverList.join(
' ' );
1685 QgsDebugMsgLevel( QStringLiteral(
"Gdal Skipped driver list set to:" ), 1 );
1687 CPLSetConfigOption(
"GDAL_SKIP", myDriverList.toUtf8() );
1694 QDir myDir( folder );
1695 if ( !myDir.exists() )
1697 myDir.mkpath( folder );
1703 void QgsApplication::copyPath(
const QString &src,
const QString &dst )
1706 if ( ! dir.exists() )
1709 const auto subDirectories = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot );
1710 for (
const QString &d : subDirectories )
1712 QString dst_path = dst + QDir::separator() + d;
1713 dir.mkpath( dst_path );
1714 copyPath( src + QDir::separator() + d, dst_path );
1717 const auto files = dir.entryList( QDir::Files );
1718 for (
const QString &f : files )
1720 QFile::copy( src + QDir::separator() + f, dst + QDir::separator() + f );
1729 QVariantMap variables;
1733 QStringList childKeys = settings.
childKeys();
1734 for ( QStringList::const_iterator it = childKeys.constBegin(); it != childKeys.constEnd(); ++it )
1737 variables.insert( name, settings.
value( name ) );
1747 QVariantMap::const_iterator it = variables.constBegin();
1750 for ( ; it != variables.constEnd(); ++it )
1752 settings.
setValue( it.key(), it.value() );
1763 settings.
setValue( QStringLiteral(
"variables/" ) + name, value );
1775 *sTranslation() = translation;
1785 ApplicationMembers *appMembers = members();
1786 if ( appMembers->mNullRepresentation.isNull() )
1788 appMembers->mNullRepresentation =
QgsSettings().
value( QStringLiteral(
"qgis/nullValue" ), QStringLiteral(
"NULL" ) ).toString();
1790 return appMembers->mNullRepresentation;
1795 ApplicationMembers *appMembers = members();
1796 if ( !appMembers || appMembers->mNullRepresentation == nullRepresentation )
1809 return members()->mActionScopeRegistry;
1818 QDir myDir( myPamPath );
1819 if ( !myDir.exists() )
1821 myDir.mkpath( myPamPath );
1824 #if defined(Q_OS_WIN) 1825 CPLSetConfigOption(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() );
1829 int myChangeFlag = 0;
1830 setenv(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag );
1837 if ( !qgisPrivateDbFile.exists() )
1841 QFile masterFile( qgisMasterDbFileName );
1847 bool isDbFileCopied = masterFile.copy( qgisPrivateDbFile.fileName() );
1849 if ( !isDbFileCopied )
1853 *errorMessage = tr(
"[ERROR] Can not make qgis.db private copy" );
1858 QFile::Permissions perms = QFile( qgisPrivateDbFile.fileName() ).permissions();
1859 if ( !( perms & QFile::WriteOwner ) )
1861 if ( !qgisPrivateDbFile.setPermissions( perms | QFile::WriteOwner ) )
1865 *errorMessage = tr(
"Can not make '%1' user writable" ).arg( qgisPrivateDbFile.fileName() );
1879 *errorMessage = tr(
"Could not open qgis.db" );
1884 char *errmsg =
nullptr;
1885 int res = sqlite3_exec( database.get(),
"SELECT srs_id FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
1886 if ( res != SQLITE_OK )
1888 sqlite3_free( errmsg );
1891 if ( sqlite3_exec( database.get(),
1892 "DROP INDEX IF EXISTS idx_srsauthid;" 1893 "CREATE TABLE tbl_srs (" 1894 "srs_id INTEGER PRIMARY KEY," 1895 "description text NOT NULL," 1896 "projection_acronym text NOT NULL," 1897 "ellipsoid_acronym NOT NULL," 1898 "parameters text NOT NULL," 1900 "auth_name varchar," 1902 "is_geo integer NOT NULL," 1903 "deprecated boolean," 1905 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
1909 *errorMessage = tr(
"Creation of missing tbl_srs in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
1911 sqlite3_free( errmsg );
1918 res = sqlite3_exec( database.get(),
"SELECT wkt FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
1919 if ( res != SQLITE_OK )
1922 sqlite3_free( errmsg );
1923 if ( sqlite3_exec( database.get(),
1924 "DROP INDEX IF EXISTS idx_srsauthid;" 1925 "DROP TABLE IF EXISTS tbl_srs_bak;" 1926 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;" 1927 "CREATE TABLE tbl_srs (" 1928 "srs_id INTEGER PRIMARY KEY," 1929 "description text NOT NULL," 1930 "projection_acronym text NOT NULL," 1931 "ellipsoid_acronym NOT NULL," 1932 "parameters text NOT NULL," 1934 "auth_name varchar," 1936 "is_geo integer NOT NULL," 1937 "deprecated boolean," 1939 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);" 1940 "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;" 1941 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
1945 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
1947 sqlite3_free( errmsg );
1953 res = sqlite3_exec( database.get(),
"SELECT acronym FROM tbl_projection LIMIT 0",
nullptr,
nullptr, &errmsg );
1954 if ( res != SQLITE_OK )
1956 sqlite3_free( errmsg );
1959 if ( sqlite3_exec( database.get(),
1960 "CREATE TABLE tbl_projection (" 1961 "acronym varchar(20) NOT NULL PRIMARY KEY," 1962 "name varchar(255) NOT NULL default ''," 1963 "notes varchar(255) NOT NULL default ''," 1964 "parameters varchar(255) NOT NULL default ''" 1965 ")",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
1969 *errorMessage = tr(
"Creation of missing tbl_projection in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
1971 sqlite3_free( errmsg );
1976 res = sqlite3_exec( database.get(),
"SELECT epsg FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
1977 if ( res == SQLITE_OK )
1980 if ( sqlite3_exec( database.get(),
1981 "DROP INDEX IF EXISTS idx_srsauthid;" 1982 "DROP TABLE IF EXISTS tbl_srs_bak;" 1983 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;" 1984 "CREATE TABLE tbl_srs (" 1985 "srs_id INTEGER PRIMARY KEY," 1986 "description text NOT NULL," 1987 "projection_acronym text NOT NULL," 1988 "ellipsoid_acronym NOT NULL," 1989 "parameters text NOT NULL," 1991 "auth_name varchar," 1993 "is_geo integer NOT NULL," 1994 "deprecated boolean," 1996 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);" 1997 "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;" 1998 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2002 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2004 sqlite3_free( errmsg );
2010 sqlite3_free( errmsg );
2013 if ( sqlite3_exec( database.get(),
"DROP VIEW vw_srs",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2015 QgsDebugMsg( QStringLiteral(
"vw_srs didn't exists in private qgis.db: %1" ).arg( errmsg ) );
2018 if ( sqlite3_exec( database.get(),
2019 "CREATE VIEW vw_srs AS" 2021 " a.description AS description" 2022 ",a.srs_id AS srs_id" 2023 ",a.is_geo AS is_geo" 2024 ",coalesce(b.name,a.projection_acronym) AS name" 2025 ",a.parameters AS parameters" 2026 ",a.auth_name AS auth_name" 2027 ",a.auth_id AS auth_id" 2028 ",a.deprecated AS deprecated" 2030 " LEFT OUTER JOIN tbl_projection b ON a.projection_acronym=b.acronym" 2031 " ORDER BY coalesce(b.name,a.projection_acronym),a.description",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2035 *errorMessage = tr(
"Update of view in private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2037 sqlite3_free( errmsg );
2046 QgsDebugMsgLevel( QStringLiteral(
"maxThreads: %1" ).arg( maxThreads ), 1 );
2050 if ( maxThreads < 1 || maxThreads > QThread::idealThreadCount() )
2057 if ( maxThreads == -1 )
2058 maxThreads = QThread::idealThreadCount();
2061 QThreadPool::globalInstance()->setMaxThreadCount( maxThreads );
2062 QgsDebugMsgLevel( QStringLiteral(
"set QThreadPool max thread count to %1" ).arg( QThreadPool::globalInstance()->maxThreadCount() ), 1 );
2067 return members()->mTaskManager;
2072 return members()->mColorSchemeRegistry;
2077 return members()->mPaintEffectRegistry;
2082 return members()->mRendererRegistry;
2087 return members()->mRasterRendererRegistry;
2094 if ( !
instance()->mDataItemProviderRegistry )
2098 return instance()->mDataItemProviderRegistry;
2104 if ( !sDataItemProviderRegistry )
2106 return sDataItemProviderRegistry;
2112 return members()->mSvgCache;
2117 return members()->mImageCache;
2122 return members()->mNetworkContentFetcherRegistry;
2127 return members()->mValidityCheckRegistry;
2132 return members()->mSymbolLayerRegistry;
2137 return members()->mCalloutRegistry;
2142 return members()->mLayoutItemRegistry;
2147 return members()->mGpsConnectionRegistry;
2152 return members()->mPluginLayerRegistry;
2157 return members()->mClassificationMethodRegistry;
2162 return members()->mBookmarkManager;
2167 return members()->mStyleModel;
2172 return members()->mMessageLog;
2177 return members()->mProcessingRegistry;
2182 return members()->mPageSizeRegistry;
2187 return members()->mAnnotationRegistry;
2192 return members()->mNumericFormatRegistry;
2197 return members()->mFieldFormatterRegistry;
2202 return members()->m3DRendererRegistry;
2207 return members()->mProjectStorageRegistry;
2210 QgsApplication::ApplicationMembers::ApplicationMembers()
2233 mLayoutItemRegistry->populate();
2234 mAnnotationRegistry =
new QgsAnnotationRegistry();
2243 QgsApplication::ApplicationMembers::~ApplicationMembers()
2246 delete mValidityCheckRegistry;
2247 delete mActionScopeRegistry;
2248 delete m3DRendererRegistry;
2249 delete mAnnotationRegistry;
2250 delete mColorSchemeRegistry;
2251 delete mFieldFormatterRegistry;
2252 delete mGpsConnectionRegistry;
2254 delete mPaintEffectRegistry;
2255 delete mPluginLayerRegistry;
2256 delete mProcessingRegistry;
2257 delete mProjectStorageRegistry;
2258 delete mPageSizeRegistry;
2259 delete mLayoutItemRegistry;
2261 delete mRasterRendererRegistry;
2262 delete mRendererRegistry;
2265 delete mCalloutRegistry;
2266 delete mSymbolLayerRegistry;
2267 delete mTaskManager;
2268 delete mNetworkContentFetcherRegistry;
2269 delete mClassificationMethodRegistry;
2270 delete mNumericFormatRegistry;
2271 delete mBookmarkManager;
2274 QgsApplication::ApplicationMembers *QgsApplication::members()
2278 return instance()->mApplicationMembers;
2282 static QMutex sMemberMutex( QMutex::Recursive );
2283 QMutexLocker lock( &sMemberMutex );
2284 if ( !sApplicationMembers )
2285 sApplicationMembers =
new ApplicationMembers();
2286 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...
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 QString buildSourcePath()
Returns path to the source directory. Valid only when running from build directory.
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.
Q_GLOBAL_STATIC_WITH_ARGS(PalPropertyList, palHiddenProperties,({ QgsPalLayerSettings::PositionX, QgsPalLayerSettings::PositionY, QgsPalLayerSettings::Show, QgsPalLayerSettings::LabelRotation, QgsPalLayerSettings::Family, QgsPalLayerSettings::FontStyle, QgsPalLayerSettings::Size, QgsPalLayerSettings::Bold, QgsPalLayerSettings::Italic, QgsPalLayerSettings::Underline, QgsPalLayerSettings::Color, QgsPalLayerSettings::Strikeout, QgsPalLayerSettings::MultiLineAlignment, QgsPalLayerSettings::BufferSize, QgsPalLayerSettings::BufferDraw, QgsPalLayerSettings::BufferColor, QgsPalLayerSettings::LabelDistance, QgsPalLayerSettings::Hali, QgsPalLayerSettings::Vali, QgsPalLayerSettings::ScaleVisibility, QgsPalLayerSettings::MinScale, QgsPalLayerSettings::MaxScale, QgsPalLayerSettings::AlwaysShow, QgsPalLayerSettings::CalloutDraw, QgsPalLayerSettings::LabelAllParts })) QgsAuxiliaryLayer
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.
static void invalidateCache(bool disableCache=false)
Clears the internal cache used.
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 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 reportStyleSheet(QgsApplication::StyleSheetType styleSheetType=QgsApplication::StyleSheetType::Qt)
Returns a css style sheet for reports, the styleSheetType argument determines what type of stylesheet...
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 QgsNumericFormatRegistry * numericFormatRegistry()
Gets the registry of available numeric formats.
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 endian_t endian()
Returns whether this machine uses big or little endian.
QMap< QString, QString > QgsStringMap
static QStringList deferredSkippedGdalDrivers()
Returns the list of gdal drivers that have been disabled in the current session, and thus...
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.
Q_GLOBAL_STATIC(QReadWriteLock, sDefinitionCacheLock)
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 setTranslation(const QString &translation)
Set translation.
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 int maxThreads()
Gets maximum concurrent thread count.
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.
StyleSheetType
The StyleSheetType enum represents the stylesheet type that a widget supports.
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 QStringList skippedGdalDrivers()
Returns the list of gdal drivers that should be skipped (based on GDAL_SKIP environment variable) ...
static QString contributorsFilePath()
Returns the path to the contributors file.
static QString activeThemePath()
Returns the path to the currently active theme directory.
static QString buildOutputPath()
Returns path to the build output directory. Valid only when running from build 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.
static QMap< QString, QString > systemEnvVars()
Returns the system environment variables passed to application.
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.