64 #include <QFileOpenEvent> 65 #include <QMessageBox> 68 #include <QProcessEnvironment> 71 #include <QThreadPool> 76 #include <netinet/in.h> 82 #define SECURITY_WIN32 84 #pragma comment( lib, "Secur32.lib" ) 87 #include "qgsconfig.h" 94 #define CONN_POOL_MAX_CONCURRENT_CONNS 4 96 QObject *
ABISYM( QgsApplication::mFileOpenEventReceiver );
97 QStringList
ABISYM( QgsApplication::mFileOpenEventList );
98 QString
ABISYM( QgsApplication::mPrefixPath );
99 QString
ABISYM( QgsApplication::mPluginPath );
100 QString
ABISYM( QgsApplication::mPkgDataPath );
101 QString
ABISYM( QgsApplication::mLibraryPath );
102 QString
ABISYM( QgsApplication::mLibexecPath );
103 QString
ABISYM( QgsApplication::mQmlImportPath );
104 QString
ABISYM( QgsApplication::mThemeName );
105 QString
ABISYM( QgsApplication::mUIThemeName );
106 QString
ABISYM( QgsApplication::mProfilePath );
108 QStringList
ABISYM( QgsApplication::mDefaultSvgPaths );
109 QMap<QString, QString>
ABISYM( QgsApplication::mSystemEnvVars );
110 QString
ABISYM( QgsApplication::mConfigPath );
112 bool ABISYM( QgsApplication::mInitialized ) =
false;
113 bool ABISYM( QgsApplication::mRunningFromBuildDir ) =
false;
114 QString
ABISYM( QgsApplication::mBuildSourcePath );
115 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) 116 QString
ABISYM( QgsApplication::mCfgIntDir );
118 QString
ABISYM( QgsApplication::mBuildOutputPath );
119 QStringList
ABISYM( QgsApplication::mGdalSkipList );
120 int ABISYM( QgsApplication::mMaxThreads );
121 QString
ABISYM( QgsApplication::mAuthDbDirPath );
123 QString QgsApplication::sUserName;
124 QString QgsApplication::sUserFullName;
125 QString QgsApplication::sPlatformName = QStringLiteral(
"desktop" );
126 QString QgsApplication::sTranslation;
132 QgsApplication::ApplicationMembers *QgsApplication::sApplicationMembers =
nullptr;
135 : QApplication( argc, argv, GUIenabled )
137 sPlatformName = platformName;
139 if ( sTranslation != QLatin1String(
"C" ) )
141 mQgisTranslator =
new QTranslator();
142 if ( mQgisTranslator->load( QStringLiteral(
"qgis_" ) + sTranslation,
i18nPath() ) )
144 installTranslator( mQgisTranslator );
148 QgsDebugMsg( QStringLiteral(
"loading of qgis translation failed %1/qgis_%2" ).arg(
i18nPath(), sTranslation ) );
156 mQtTranslator =
new QTranslator();
157 if ( mQtTranslator->load( QStringLiteral(
"qt_" ) + sTranslation, QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ) )
159 installTranslator( mQtTranslator );
163 QgsDebugMsg( QStringLiteral(
"loading of qt translation failed %1/qt_%2" ).arg( QLibraryInfo::location( QLibraryInfo::TranslationsPath ), sTranslation ) );
167 mApplicationMembers =
new ApplicationMembers();
169 ABISYM( mProfilePath ) = profileFolder;
174 if ( profileFolder.isEmpty() )
176 if ( getenv(
"QGIS_CUSTOM_CONFIG_PATH" ) )
178 QString envProfileFolder = getenv(
"QGIS_CUSTOM_CONFIG_PATH" );
179 profileFolder = envProfileFolder + QDir::separator() +
"profiles";
183 profileFolder = QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ).value( 0 );
190 profileFolder = profile->
folder();
194 ABISYM( mProfilePath ) = profileFolder;
196 qRegisterMetaType<QgsGeometry::Error>(
"QgsGeometry::Error" );
197 qRegisterMetaType<QgsProcessingFeatureSourceDefinition>(
"QgsProcessingFeatureSourceDefinition" );
198 qRegisterMetaType<QgsProcessingOutputLayerDefinition>(
"QgsProcessingOutputLayerDefinition" );
199 qRegisterMetaType<QgsUnitTypes::LayoutUnit>(
"QgsUnitTypes::LayoutUnit" );
200 qRegisterMetaType<QgsFeatureId>(
"QgsFeatureId" );
201 qRegisterMetaType<QgsFeatureIds>(
"QgsFeatureIds" );
202 qRegisterMetaType<QgsProperty>(
"QgsProperty" );
203 qRegisterMetaType<Qgis::MessageLevel>(
"Qgis::MessageLevel" );
204 qRegisterMetaType<QgsReferencedRectangle>(
"QgsReferencedRectangle" );
205 qRegisterMetaType<QgsReferencedPointXY>(
"QgsReferencedPointXY" );
206 qRegisterMetaType<QgsLayoutRenderContext::Flags>(
"QgsLayoutRenderContext::Flags" );
207 qRegisterMetaType<QgsStyle::StyleEntity>(
"QgsStyle::StyleEntity" );
208 qRegisterMetaType<QgsCoordinateReferenceSystem>(
"QgsCoordinateReferenceSystem" );
209 qRegisterMetaType<QgsAuthManager::MessageLevel>(
"QgsAuthManager::MessageLevel" );
210 qRegisterMetaType<QgsNetworkRequestParameters>(
"QgsNetworkRequestParameters" );
211 qRegisterMetaType<QgsNetworkReplyContent>(
"QgsNetworkReplyContent" );
215 if ( ABISYM( mRunningFromBuildDir ) )
218 ABISYM( mPrefixPath ) = QString();
219 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) 220 setPluginPath( ABISYM( mBuildOutputPath ) +
'/' + QString( QGIS_PLUGIN_SUBDIR ) +
'/' + ABISYM( mCfgIntDir ) );
222 setPluginPath( ABISYM( mBuildOutputPath ) +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
225 ABISYM( mLibraryPath ) = ABISYM( mBuildOutputPath ) +
'/' + QGIS_LIB_SUBDIR +
'/';
226 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) 227 ABISYM( mLibexecPath ) = ABISYM( mBuildOutputPath ) +
'/' + QGIS_LIBEXEC_SUBDIR +
'/' + ABISYM( mCfgIntDir ) +
'/';
229 ABISYM( mLibexecPath ) = ABISYM( mBuildOutputPath ) +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
231 #if defined( HAVE_QUICK ) 232 ABISYM( mQmlImportPath ) = ABISYM( mBuildOutputPath ) +
'/' + QGIS_QML_SUBDIR +
'/';
237 char *
prefixPath = getenv(
"QGIS_PREFIX_PATH" );
240 if ( ABISYM( mPrefixPath ).isNull() )
242 #if defined(Q_OS_MACX) || defined(Q_OS_WIN) 244 #elif defined(ANDROID) 246 QDir myDir( QDir::homePath() );
248 QString myPrefix = myDir.absolutePath();
251 QDir myDir( applicationDirPath() );
253 if ( applicationDirPath().contains( QStringLiteral(
"cgi-bin" ) ) )
258 QString myPrefix = myDir.absolutePath();
269 ABISYM( mConfigPath ) = profileFolder +
'/';
273 if ( getenv(
"QGIS_AUTH_DB_DIR_PATH" ) )
279 QMap<QString, QString> systemEnvVarMap;
280 QString passfile( QStringLiteral(
"QGIS_AUTH_PASSWORD_FILE" ) );
282 const auto systemEnvironment = QProcessEnvironment::systemEnvironment().toStringList();
283 for (
const QString &varStr : systemEnvironment )
285 int pos = varStr.indexOf( QLatin1Char(
'=' ) );
288 QString varStrName = varStr.left( pos );
289 QString varStrValue = varStr.mid( pos + 1 );
290 if ( varStrName != passfile )
292 systemEnvVarMap.insert( varStrName, varStrValue );
295 ABISYM( mSystemEnvVars ) = systemEnvVarMap;
298 QCoreApplication::addLibraryPath(
pluginPath() );
303 ABISYM( mMaxThreads ) = -1;
308 ABISYM( mInitialized ) =
true;
313 delete mDataItemProviderRegistry;
314 delete mApplicationMembers;
315 delete mQgisTranslator;
316 delete mQtTranslator;
321 return qobject_cast<
QgsApplication *>( QCoreApplication::instance() );
327 if ( event->type() == QEvent::FileOpen )
330 if ( ABISYM( mFileOpenEventReceiver ) )
333 done =
notify( ABISYM( mFileOpenEventReceiver ), event );
340 ABISYM( mFileOpenEventList ).append( static_cast<QFileOpenEvent *>( event )->file() );
347 done = QApplication::event( event );
356 if ( thread() == receiver->thread() )
357 emit
preNotify( receiver, event, &done );
366 done = QApplication::notify( receiver, event );
371 if ( qApp->thread() == QThread::currentThread() )
372 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
374 catch ( std::exception &e )
376 QgsDebugMsg(
"Caught unhandled std::exception: " + QString::fromLatin1( e.what() ) );
377 if ( qApp->thread() == QThread::currentThread() )
378 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.what() );
382 QgsDebugMsg( QStringLiteral(
"Caught unhandled unknown exception" ) );
383 if ( qApp->thread() == QThread::currentThread() )
384 QMessageBox::critical( activeWindow(), tr(
"Exception" ), tr(
"unknown exception" ) );
392 return members()->mProfiler;
398 ABISYM( mFileOpenEventReceiver ) = receiver;
400 if ( ABISYM( mFileOpenEventList ).count() > 0 )
402 QStringListIterator i( ABISYM( mFileOpenEventList ) );
403 while ( i.hasNext() )
405 QFileOpenEvent foe( i.next() );
406 QgsApplication::sendEvent( ABISYM( mFileOpenEventReceiver ), &foe );
408 ABISYM( mFileOpenEventList ).clear();
415 #if defined(_MSC_VER) 416 if ( ABISYM( mPrefixPath ).endsWith(
"/bin" ) )
418 ABISYM( mPrefixPath ).chop( 4 );
421 if ( useDefaultPaths && !ABISYM( mRunningFromBuildDir ) )
423 setPluginPath( ABISYM( mPrefixPath ) +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
424 setPkgDataPath( ABISYM( mPrefixPath ) +
'/' + QStringLiteral( QGIS_DATA_SUBDIR ) );
426 ABISYM( mLibraryPath ) = ABISYM( mPrefixPath ) +
'/' + QGIS_LIB_SUBDIR +
'/';
427 ABISYM( mLibexecPath ) = ABISYM( mPrefixPath ) +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
428 #if defined( HAVE_QUICK ) 429 ABISYM( mQmlImportPath ) = ABISYM( mPrefixPath ) +
'/' + QGIS_QML_SUBDIR +
'/';
441 QString mySvgPath = pkgDataPath + ( ABISYM( mRunningFromBuildDir ) ?
"/images/svg/" :
"/svg/" );
443 if ( !ABISYM( mDefaultSvgPaths ).contains( mySvgPath ) )
444 ABISYM( mDefaultSvgPaths ) << mySvgPath;
449 ABISYM( mDefaultSvgPaths ) = pathList;
454 QFileInfo fi( authDbDirPath );
455 if ( fi.exists() && fi.isDir() && fi.isWritable() )
457 ABISYM( mAuthDbDirPath ) = fi.canonicalFilePath() + QDir::separator();
463 if ( ABISYM( mRunningFromBuildDir ) )
465 static bool sOnce =
true;
469 ( void ) blockNotifications;
470 qWarning(
"!!! prefix path was requested, but it is not valid - we do not run from installed path !!!" );
475 return ABISYM( mPrefixPath );
479 return ABISYM( mPluginPath );
483 if ( ABISYM( mPkgDataPath ).isNull() )
486 return ABISYM( mPkgDataPath );
490 return QStringLiteral(
":/images/themes/default/" );
495 QDir dir( usersThemes );
503 return defaultThemes;
509 return iconsPath() + QStringLiteral(
"qgis-icon-60x60.png" );
516 if ( QFile::exists( path + iconFile ) )
517 return path + iconFile;
526 if ( app && app->mIconCache.contains( name ) )
527 return app->mIconCache.value( name );
531 QString myPreferredPath =
activeThemePath() + QDir::separator() + name;
533 if ( QFile::exists( myPreferredPath ) )
535 icon = QIcon( myPreferredPath );
537 else if ( QFile::exists( myDefaultPath ) )
541 icon = QIcon( myDefaultPath );
549 app->mIconCache.insert( name, icon );
556 if ( app && app->mCursorCache.contains( cursor ) )
557 return app->mCursorCache.value( cursor );
568 name = QStringLiteral(
"mZoomIn.svg" );
573 name = QStringLiteral(
"mZoomOut.svg" );
580 name = QStringLiteral(
"mIdentify.svg" );
583 name = QStringLiteral(
"mCrossHair.svg" );
586 name = QStringLiteral(
"mCapturePoint.svg" );
589 name = QStringLiteral(
"mSelect.svg" );
596 name = QStringLiteral(
"mSampler.svg" );
601 Q_ASSERT( ! name.isEmpty( ) );
603 QIcon icon =
getThemeIcon( QStringLiteral(
"cursors" ) + QDir::separator() + name );
606 if ( ! icon.isNull( ) )
610 cursorIcon = QCursor( icon.pixmap( std::ceil( scale * 32 ), std::ceil( scale * 32 ) ), std::ceil( scale * activeX ), std::ceil( scale * activeY ) );
613 app->mCursorCache.insert( cursor, cursorIcon );
620 QString myPreferredPath =
activeThemePath() + QDir::separator() + name;
622 if ( QFile::exists( myPreferredPath ) )
624 return QPixmap( myPreferredPath );
630 return QPixmap( myDefaultPath );
641 static QString appPath;
642 if ( appPath.isNull() )
644 if ( QCoreApplication::instance() )
646 appPath = applicationDirPath();
650 qWarning(
"Application path not initialized" );
654 if ( !appPath.isNull() || getenv(
"QGIS_PREFIX_PATH" ) )
656 QString prefix = getenv(
"QGIS_PREFIX_PATH" ) ? getenv(
"QGIS_PREFIX_PATH" ) : appPath;
661 Q_FOREACH (
const QString &path, QStringList() <<
"" <<
"/.." <<
"/bin" <<
"/../../.." )
663 f.setFileName( prefix + path +
"/qgisbuildpath.txt" );
667 if ( f.exists() && f.open( QIODevice::ReadOnly ) )
669 ABISYM( mRunningFromBuildDir ) =
true;
670 ABISYM( mBuildSourcePath ) = f.readLine().trimmed();
671 ABISYM( mBuildOutputPath ) = f.readLine().trimmed();
673 QgsDebugMsgLevel( QStringLiteral(
"- source directory: %1" ).arg( ABISYM( mBuildSourcePath ).toUtf8().constData() ), 4 );
674 QgsDebugMsgLevel( QStringLiteral(
"- output directory of the build: %1" ).arg( ABISYM( mBuildOutputPath ).toUtf8().constData() ), 4 );
675 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) 676 ABISYM( mCfgIntDir ) = appPath.split(
'/', QString::SkipEmptyParts ).last();
677 qDebug(
"- cfg: %s", ABISYM( mCfgIntDir ).toUtf8().constData() );
683 if ( getenv(
"QGIS_PREFIX_PATH" ) )
684 prefixPath = getenv(
"QGIS_PREFIX_PATH" );
689 QDir dir( QDir::homePath() );
691 prefixPath = dir.absolutePath();
694 #if defined(Q_OS_MACX) || defined(Q_OS_WIN) 695 prefixPath = appPath;
696 #if defined(_MSC_VER) 697 if ( prefixPath.endsWith(
"/bin" ) )
698 prefixPath.chop( 4 );
703 if ( appPath.contains( QStringLiteral(
"cgi-bin" ) ) )
708 prefixPath = dir.absolutePath();
713 if ( ABISYM( mRunningFromBuildDir ) )
714 return ABISYM( mBuildSourcePath );
716 return prefixPath +
'/' + QStringLiteral( QGIS_DATA_SUBDIR );
721 return ABISYM( mThemeName );
728 if ( themeName == QStringLiteral(
"default" ) || !themes.contains( themeName ) )
731 qApp->setStyleSheet( QString() );
735 QString path = themes.value( themeName );
736 QString stylesheetname = path +
"/style.qss";
738 QFile file( stylesheetname );
739 QFile variablesfile( path +
"/variables.qss" );
741 QFileInfo variableInfo( variablesfile );
743 if ( !file.open( QIODevice::ReadOnly ) || ( variableInfo.exists() && !variablesfile.open( QIODevice::ReadOnly ) ) )
748 QString styledata = file.readAll();
749 styledata.replace( QStringLiteral(
"@theme_path" ), path );
751 if ( variableInfo.exists() )
753 QTextStream in( &variablesfile );
754 while ( !in.atEnd() )
756 QString line = in.readLine();
758 if ( line.startsWith(
'@' ) )
760 int index = line.indexOf(
':' );
761 QString name = line.mid( 0, index );
762 QString value = line.mid( index + 1, line.length() );
763 styledata.replace( name, value );
766 variablesfile.close();
774 QRegularExpression regex( QStringLiteral(
"(?<=[\\s:])([0-9\\.]+)(?=em)" ) );
775 QRegularExpressionMatch match = regex.match( styledata, index );
776 while ( match.hasMatch() )
778 index = match.capturedStart();
779 styledata.remove( index, match.captured( 0 ).length() );
781 styledata.insert( index, number );
782 index += number.length();
783 match = regex.match( styledata, index );
787 qApp->setStyleSheet( styledata );
789 QFile palettefile( path +
"/palette.txt" );
790 QFileInfo paletteInfo( palettefile );
791 if ( paletteInfo.exists() && palettefile.open( QIODevice::ReadOnly ) )
793 QPalette
pal = qApp->palette();
794 QTextStream in( &palettefile );
795 while ( !in.atEnd() )
797 QString line = in.readLine();
798 QStringList parts = line.split(
':' );
799 if ( parts.count() == 2 )
801 int role = parts.at( 0 ).trimmed().toInt();
803 pal.setColor( static_cast< QPalette::ColorRole >( role ), color );
807 qApp->setPalette( pal );
816 QHash<QString, QString> mapping;
817 mapping.insert( QStringLiteral(
"default" ), QString() );
818 Q_FOREACH (
const QString &path, paths )
821 QFileInfoList styleFiles = folder.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
822 Q_FOREACH (
const QFileInfo &info, styleFiles )
824 QFileInfo styleFile( info.absoluteFilePath() +
"/style.qss" );
825 if ( !styleFile.exists() )
828 QString name = info.baseName();
829 QString path = info.absoluteFilePath();
830 mapping.insert( name, path );
838 return pkgDataPath() + QStringLiteral(
"/doc/AUTHORS" );
843 return pkgDataPath() + QStringLiteral(
"/doc/CONTRIBUTORS" );
847 return pkgDataPath() + QStringLiteral(
"/doc/developersmap.html" );
852 return pkgDataPath() + QStringLiteral(
"/doc/SPONSORS" );
857 return pkgDataPath() + QStringLiteral(
"/doc/DONORS" );
862 return pkgDataPath() + QStringLiteral(
"/doc/TRANSLATORS" );
867 return pkgDataPath() + QStringLiteral(
"/doc/LICENSE" );
872 if ( ABISYM( mRunningFromBuildDir ) )
873 return ABISYM( mBuildOutputPath ) + QStringLiteral(
"/i18n/" );
880 return pkgDataPath() + QStringLiteral(
"/resources/metadata-ISO/" );
885 return pkgDataPath() + QStringLiteral(
"/resources/qgis.db" );
890 return ABISYM( mConfigPath );
900 return ABISYM( mAuthDbDirPath ) + QStringLiteral(
"qgis-auth.db" );
905 return QStringLiteral(
":/images/splash/" );
910 return pkgDataPath() + QStringLiteral(
"/images/icons/" );
915 if ( ABISYM( mRunningFromBuildDir ) )
917 QString tempCopy = QDir::tempPath() +
"/srs.db";
919 if ( !QFile( tempCopy ).exists() )
922 if ( !f.copy( tempCopy ) )
924 qFatal(
"Could not create temporary copy" );
932 return pkgDataPath() + QStringLiteral(
"/resources/srs.db" );
941 QStringList pathList = settings.
value( QStringLiteral(
"svg/searchPathsForSVG" ) ).toStringList();
945 Q_FOREACH (
const QString &path, pathList )
947 if ( !paths.contains( path ) )
948 paths.append( path );
950 Q_FOREACH (
const QString &path, ABISYM( mDefaultSvgPaths ) )
952 if ( !paths.contains( path ) )
953 paths.append( path );
964 QStringList pathList = settings.
value( QStringLiteral(
"Layout/searchPathsForTemplates" ), QVariant(),
QgsSettings::Core ).toStringList();
976 return QRegExp(
"^[A-Za-z][A-Za-z0-9\\._-]*" );
981 if ( !sUserName.isEmpty() )
985 TCHAR name [ UNLEN + 1 ];
986 DWORD size = UNLEN + 1;
988 if ( GetUserName( ( TCHAR * )name, &size ) )
990 sUserName = QString( name );
993 #elif QT_CONFIG(process) 996 process.start( QStringLiteral(
"whoami" ) );
997 process.waitForFinished();
998 sUserName = process.readAllStandardOutput().trimmed();
1001 if ( !sUserName.isEmpty() )
1005 sUserName = qgetenv(
"USER" );
1006 if ( !sUserName.isEmpty() )
1010 sUserName = qgetenv(
"USERNAME" );
1016 if ( !sUserFullName.isEmpty() )
1017 return sUserFullName;
1020 TCHAR name [ UNLEN + 1 ];
1021 DWORD size = UNLEN + 1;
1024 if ( GetUserNameEx( NameDisplay, ( TCHAR * )name, &size ) )
1026 sUserFullName = QString( name );
1030 if ( sUserFullName.isEmpty() )
1032 #elif defined(Q_OS_ANDROID) || defined(__MINGW32__) 1033 sUserFullName =
"Not available";
1035 struct passwd *p = getpwuid( getuid() );
1039 QString gecosName = QString( p->pw_gecos );
1040 sUserFullName = gecosName.left( gecosName.indexOf(
',', 0 ) );
1045 return sUserFullName;
1050 #if defined(Q_OS_ANDROID) 1051 return QLatin1String(
"android" );
1052 #elif defined(Q_OS_MAC) 1053 return QLatin1String(
"osx" );
1054 #elif defined(Q_OS_WIN) 1055 return QLatin1String(
"windows" );
1056 #elif defined(Q_OS_LINUX) 1057 return QStringLiteral(
"linux" );
1059 return QLatin1String(
"unknown" );
1065 return sPlatformName;
1071 bool overrideLocale = settings.
value( QStringLiteral(
"locale/overrideFlag" ),
false ).toBool();
1072 if ( overrideLocale )
1074 QString
locale = settings.
value( QStringLiteral(
"locale/userLocale" ), QString() ).toString();
1076 if ( locale.startsWith( QLatin1String(
"en" ), Qt::CaseInsensitive ) )
1078 return locale.left( 2 );
1085 return QLocale().name().left( 2 );
1096 return pkgDataPath() + QStringLiteral(
"/resources/symbology-style.xml" );
1101 return pkgDataPath() + QStringLiteral(
"/resources/themes" );
1106 return pkgDataPath() + QStringLiteral(
"/resources/server/" );
1111 return ABISYM( mLibraryPath );
1116 return ABISYM( mLibexecPath );
1121 return ABISYM( mQmlImportPath );
1126 return ( htonl( 1 ) == 1 ) ?
XDR :
NDR;
1171 if ( !sAuthManager )
1173 return sAuthManager;
1185 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1203 GDALDestroyDriverManager();
1208 QString myEnvironmentVar( getenv(
"QGIS_PREFIX_PATH" ) );
1209 QString myState = tr(
"Application state:\n" 1210 "QGIS_PREFIX_PATH env var:\t\t%1\n" 1212 "Plugin Path:\t\t%3\n" 1213 "Package Data Path:\t%4\n" 1214 "Active Theme Name:\t%5\n" 1215 "Active Theme Path:\t%6\n" 1216 "Default Theme Path:\t%7\n" 1217 "SVG Search Paths:\t%8\n" 1218 "User DB Path:\t%9\n" 1219 "Auth DB Path:\t%10\n" )
1220 .arg( myEnvironmentVar,
1227 svgPaths().join( tr(
"\n\t\t",
"match indentation of application state" ) ),
1240 QColor myColor1( Qt::lightGray );
1241 QColor myColor2 = myColor1;
1242 myColor2 = myColor2.lighter( 110 );
1244 myStyle =
".overview{" 1246 " font-weight: bold;" 1249 " background: white;" 1251 " font-family: 'Lato', 'Ubuntu', 'Lucida Grande', 'Segoe UI', 'Arial', sans-serif;" 1254 "h1{ background-color: #F6F6F6;" 1256 " font-size: x-large; " 1257 " font-weight: normal;" 1258 " background: none;" 1259 " padding: 0.75em 0 0;" 1261 " line-height: 3em;" 1263 "h2{ background-color: #F6F6F6;" 1265 " font-size: medium; " 1266 " font-weight: normal;" 1267 " background: none;" 1268 " padding: 0.75em 0 0;" 1270 " line-height: 1.1em;" 1272 "h3{ background-color: #F6F6F6;" 1274 " font-weight: bold;" 1275 " font-size: large;" 1276 " text-align: right;" 1277 " border-bottom: 5px solid #DCEB5C;" 1279 "h4{ background-color: #F6F6F6;" 1281 " font-weight: bold;" 1282 " font-size: medium;" 1283 " text-align: right;" 1285 "h5{ background-color: #F6F6F6;" 1287 " font-weight: bold;" 1288 " font-size: small;" 1289 " text-align: right;" 1291 "a{ color: #729FCF;" 1292 " font-family: arial,sans-serif;" 1294 "label{ background-color: #FFFFCC;" 1295 " border: 1px solid black;" 1297 " padding: 0px 3px; " 1298 " font-size: small;" 1301 " font-weight: bold;" 1302 " padding-top:25px;" 1304 ".list-view .highlight {" 1305 " text-align: right;" 1308 " padding-right: 15px;" 1309 " padding-left: 20px;" 1310 " font-weight: bold;" 1313 " font-weight: bold;" 1316 " border-collapse: collapse;" 1319 ".tabular-view th, .tabular-view td { " 1320 " border:10px solid black;" 1322 ".tabular-view .odd-row{" 1323 " background-color: #f9f9f9;" 1328 " border-top: 1px solid black;" 1335 if ( 0 >= OGRGetDriverCount() )
1343 QString aPathUrl = aPath;
1344 QString tPathUrl = targetPath;
1345 #if defined( Q_OS_WIN ) 1346 const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
1348 aPathUrl.replace(
'\\',
'/' );
1349 if ( aPathUrl.startsWith(
"//" ) )
1352 aPathUrl =
"\\\\" + aPathUrl.mid( 2 );
1355 tPathUrl.replace(
'\\',
'/' );
1356 if ( tPathUrl.startsWith(
"//" ) )
1359 tPathUrl =
"\\\\" + tPathUrl.mid( 2 );
1362 const Qt::CaseSensitivity cs = Qt::CaseSensitive;
1365 QStringList targetElems = tPathUrl.split(
'/', QString::SkipEmptyParts );
1366 QStringList aPathElems = aPathUrl.split(
'/', QString::SkipEmptyParts );
1368 targetElems.removeAll( QStringLiteral(
"." ) );
1369 aPathElems.removeAll( QStringLiteral(
"." ) );
1373 while ( !aPathElems.isEmpty() &&
1374 !targetElems.isEmpty() &&
1375 aPathElems[0].compare( targetElems[0], cs ) == 0 )
1377 aPathElems.removeFirst();
1378 targetElems.removeFirst();
1388 if ( !targetElems.isEmpty() )
1391 for (
int i = 0; i < targetElems.size(); i++ )
1393 aPathElems.insert( 0, QStringLiteral(
".." ) );
1400 aPathElems.insert( 0, QStringLiteral(
"." ) );
1403 return aPathElems.join( QStringLiteral(
"/" ) );
1409 if ( !rpath.startsWith( QLatin1String(
"./" ) ) && !rpath.startsWith( QLatin1String(
"../" ) ) )
1414 QString rPathUrl = rpath;
1415 QString targetPathUrl = targetPath;
1417 #if defined(Q_OS_WIN) 1418 rPathUrl.replace(
'\\',
'/' );
1419 targetPathUrl.replace(
'\\',
'/' );
1421 bool uncPath = targetPathUrl.startsWith(
"//" );
1424 QStringList srcElems = rPathUrl.split(
'/', QString::SkipEmptyParts );
1425 QStringList targetElems = targetPathUrl.split(
'/', QString::SkipEmptyParts );
1427 #if defined(Q_OS_WIN) 1430 targetElems.insert( 0,
"" );
1431 targetElems.insert( 0,
"" );
1436 targetElems << srcElems;
1437 targetElems.removeAll( QStringLiteral(
"." ) );
1441 while ( ( pos = targetElems.indexOf( QStringLiteral(
".." ) ) ) > 0 )
1444 targetElems.removeAt( pos - 1 );
1445 targetElems.removeAt( pos - 1 );
1448 #if !defined(Q_OS_WIN) 1450 targetElems.prepend( QString() );
1453 return targetElems.join( QStringLiteral(
"/" ) );
1458 if (
ABISYM( mGdalSkipList ).contains( driver ) || driver.isEmpty() )
1462 ABISYM( mGdalSkipList ) << driver;
1468 if ( !
ABISYM( mGdalSkipList ).contains( driver ) )
1472 int myPos =
ABISYM( mGdalSkipList ).indexOf( driver );
1475 ABISYM( mGdalSkipList ).removeAt( myPos );
1482 ABISYM( mGdalSkipList ).removeDuplicates();
1483 QString myDriverList =
ABISYM( mGdalSkipList ).join( QStringLiteral(
" " ) );
1484 QgsDebugMsg( QStringLiteral(
"Gdal Skipped driver list set to:" ) );
1486 CPLSetConfigOption(
"GDAL_SKIP", myDriverList.toUtf8() );
1493 QDir myDir( folder );
1494 if ( !myDir.exists() )
1496 myDir.mkpath( folder );
1502 void QgsApplication::copyPath(
const QString &src,
const QString &dst )
1505 if ( ! dir.exists() )
1508 Q_FOREACH (
const QString &d, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
1510 QString dst_path = dst + QDir::separator() + d;
1511 dir.mkpath( dst_path );
1512 copyPath( src + QDir::separator() + d, dst_path );
1515 Q_FOREACH (
const QString &f, dir.entryList( QDir::Files ) )
1517 QFile::copy( src + QDir::separator() + f, dst + QDir::separator() + f );
1526 QVariantMap variables;
1530 QStringList childKeys = settings.
childKeys();
1531 for ( QStringList::const_iterator it = childKeys.constBegin(); it != childKeys.constEnd(); ++it )
1534 variables.insert( name, settings.
value( name ) );
1544 QVariantMap::const_iterator it = variables.constBegin();
1547 for ( ; it != variables.constEnd(); ++it )
1549 settings.
setValue( it.key(), it.value() );
1560 settings.
setValue( QStringLiteral(
"variables/" ) + name, value );
1577 ApplicationMembers *appMembers = members();
1578 if ( appMembers->mNullRepresentation.isNull() )
1580 appMembers->mNullRepresentation =
QgsSettings().
value( QStringLiteral(
"qgis/nullValue" ), QStringLiteral(
"NULL" ) ).toString();
1582 return appMembers->mNullRepresentation;
1587 ApplicationMembers *appMembers = members();
1588 if ( !appMembers || appMembers->mNullRepresentation == nullRepresentation )
1601 return members()->mActionScopeRegistry;
1610 QDir myDir( myPamPath );
1611 if ( !myDir.exists() )
1613 myDir.mkpath( myPamPath );
1616 #if defined(Q_OS_WIN) 1617 CPLSetConfigOption(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() );
1621 int myChangeFlag = 0;
1622 setenv(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag );
1629 if ( !qgisPrivateDbFile.exists() )
1633 QFile masterFile( qgisMasterDbFileName );
1639 bool isDbFileCopied = masterFile.copy( qgisPrivateDbFile.fileName() );
1641 if ( !isDbFileCopied )
1645 *errorMessage = tr(
"[ERROR] Can not make qgis.db private copy" );
1650 QFile::Permissions perms = QFile( qgisPrivateDbFile.fileName() ).permissions();
1651 if ( !( perms & QFile::WriteOwner ) )
1653 if ( !qgisPrivateDbFile.setPermissions( perms | QFile::WriteOwner ) )
1657 *errorMessage = tr(
"Can not make '%1' user writable" ).arg( qgisPrivateDbFile.fileName() );
1671 *errorMessage = tr(
"Could not open qgis.db" );
1676 char *errmsg =
nullptr;
1677 int res = sqlite3_exec( database.get(),
"SELECT epsg FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
1678 if ( res == SQLITE_OK )
1681 if ( sqlite3_exec( database.get(),
1682 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;" 1683 "CREATE TABLE tbl_srs (" 1684 "srs_id INTEGER PRIMARY KEY," 1685 "description text NOT NULL," 1686 "projection_acronym text NOT NULL," 1687 "ellipsoid_acronym NOT NULL," 1688 "parameters text NOT NULL," 1690 "auth_name varchar," 1692 "is_geo integer NOT NULL," 1693 "deprecated boolean);" 1694 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);" 1695 "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;" 1696 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK
1701 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
1703 sqlite3_free( errmsg );
1709 sqlite3_free( errmsg );
1712 if ( sqlite3_exec( database.get(),
"DROP VIEW vw_srs",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
1714 QgsDebugMsg( QStringLiteral(
"vw_srs didn't exists in private qgis.db: %1" ).arg( errmsg ) );
1717 if ( sqlite3_exec( database.get(),
1718 "CREATE VIEW vw_srs AS" 1720 " a.description AS description" 1721 ",a.srs_id AS srs_id" 1722 ",a.is_geo AS is_geo" 1723 ",coalesce(b.name,a.projection_acronym) AS name" 1724 ",a.parameters AS parameters" 1725 ",a.auth_name AS auth_name" 1726 ",a.auth_id AS auth_id" 1727 ",a.deprecated AS deprecated" 1729 " LEFT OUTER JOIN tbl_projection b ON a.projection_acronym=b.acronym" 1730 " ORDER BY coalesce(b.name,a.projection_acronym),a.description",
nullptr,
nullptr, &errmsg ) != SQLITE_OK
1735 *errorMessage = tr(
"Update of view in private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
1737 sqlite3_free( errmsg );
1746 QgsDebugMsg( QStringLiteral(
"maxThreads: %1" ).arg( maxThreads ) );
1750 if ( maxThreads < 1 || maxThreads > QThread::idealThreadCount() )
1757 if ( maxThreads == -1 )
1758 maxThreads = QThread::idealThreadCount();
1761 QThreadPool::globalInstance()->setMaxThreadCount( maxThreads );
1762 QgsDebugMsg( QStringLiteral(
"set QThreadPool max thread count to %1" ).arg( QThreadPool::globalInstance()->maxThreadCount() ) );
1767 return members()->mTaskManager;
1772 return members()->mColorSchemeRegistry;
1777 return members()->mPaintEffectRegistry;
1782 return members()->mRendererRegistry;
1787 return members()->mRasterRendererRegistry;
1794 if ( !
instance()->mDataItemProviderRegistry )
1798 return instance()->mDataItemProviderRegistry;
1804 if ( !sDataItemProviderRegistry )
1806 return sDataItemProviderRegistry;
1812 return members()->mSvgCache;
1817 return members()->mImageCache;
1822 return members()->mNetworkContentFetcherRegistry;
1827 return members()->mValidityCheckRegistry;
1832 return members()->mSymbolLayerRegistry;
1837 return members()->mLayoutItemRegistry;
1842 return members()->mGpsConnectionRegistry;
1847 return members()->mPluginLayerRegistry;
1852 return members()->mMessageLog;
1857 return members()->mProcessingRegistry;
1862 return members()->mPageSizeRegistry;
1867 return members()->mAnnotationRegistry;
1872 return members()->mFieldFormatterRegistry;
1877 return members()->m3DRendererRegistry;
1882 return members()->mProjectStorageRegistry;
1885 QgsApplication::ApplicationMembers::ApplicationMembers()
1906 mLayoutItemRegistry->populate();
1907 mAnnotationRegistry =
new QgsAnnotationRegistry();
1914 QgsApplication::ApplicationMembers::~ApplicationMembers()
1916 delete mValidityCheckRegistry;
1917 delete mActionScopeRegistry;
1918 delete m3DRendererRegistry;
1919 delete mAnnotationRegistry;
1920 delete mColorSchemeRegistry;
1921 delete mFieldFormatterRegistry;
1922 delete mGpsConnectionRegistry;
1924 delete mPaintEffectRegistry;
1925 delete mPluginLayerRegistry;
1926 delete mProcessingRegistry;
1927 delete mProjectStorageRegistry;
1928 delete mPageSizeRegistry;
1929 delete mLayoutItemRegistry;
1931 delete mRasterRendererRegistry;
1932 delete mRendererRegistry;
1935 delete mSymbolLayerRegistry;
1936 delete mTaskManager;
1937 delete mNetworkContentFetcherRegistry;
1940 QgsApplication::ApplicationMembers *QgsApplication::members()
1944 return instance()->mApplicationMembers;
1948 static QMutex sMemberMutex( QMutex::Recursive );
1949 QMutexLocker lock( &sMemberMutex );
1950 if ( !sApplicationMembers )
1951 sApplicationMembers =
new ApplicationMembers();
1952 return sApplicationMembers;
static QStringList layoutTemplatePaths()
Returns the paths to layout template directories.
Singleton offering an interface to manage the authentication configuration database and to utilize co...
QgsApplication(int &argc, char **argv, bool GUIenabled, const QString &profileFolder=QString(), const QString &platformName="desktop")
static QString locale()
Returns the QGIS locale.
static QgsSymbolLayerRegistry * symbolLayerRegistry()
Returns the application's symbol layer registry, used for managing symbol layers. ...
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
This class keeps a list of data item providers that may add items to the browser tree.
static void setThemeName(const QString &themeName)
Set the active theme to the specified theme.
void addDefaultSchemes()
Adds all default color schemes to this color scheme.
static Qgs3DRendererRegistry * renderer3DRegistry()
Returns registry of available 3D renderers.
static QString resolveProfilesFolder(const QString &basePath=QString())
Resolves the profiles folder for the given path.
static QgsAnnotationRegistry * annotationRegistry()
Returns the application's annotation registry, used for managing annotation types.
Extends QApplication to provide access to QGIS specific resources such as theme paths, database paths etc.
static QgsFieldFormatterRegistry * fieldFormatterRegistry()
Gets the registry of available field formatters.
Cursor
The Cursor enum defines constants for QGIS custom cursors.
static QString userStylePath()
Returns the path to user's style.
Registry of color schemes.
static QgsAuthManager * instance()
Enforce singleton pattern.
static QgsApplication * instance()
Returns the singleton instance of the QgsApplication.
static QString authorsFilePath()
Returns the path to the authors file.
static void setPrefixPath(const QString &prefixPath, bool useDefaultPaths=false)
Alters prefix path - used by 3rd party apps.
A registry of plugin layers types.
static QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
static void setCustomVariables(const QVariantMap &customVariables)
Custom expression variables for this application.
static QString libraryPath()
Returns the path containing qgis_core, qgis_gui, qgispython (and other) libraries.
static QgsRuntimeProfiler * profiler()
Returns the application runtime profiler.
static QString defaultThemePath()
Returns the path to the default theme directory.
static const double UI_SCALE_FACTOR
UI scaling factor.
This class is a composition of two QSettings instances:
static QString qgisMasterDatabaseFilePath()
Returns the path to the master qgis.db file.
void customVariablesChanged()
Emitted whenever a custom global variable changes.
static QString qgisUserDatabaseFilePath()
Returns the path to the user qgis.db file.
bool event(QEvent *event) override
Watch for QFileOpenEvent.
void requestForTranslatableObjects(QgsTranslationContext *translationContext)
Emitted when project strings which require translation are being collected for inclusion in a ...
static QString donorsFilePath()
Returns the path to the donors file.
static QString relativePathToAbsolutePath(const QString &rpath, const QString &targetPath)
Converts path relative to target to an absolute path.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
int maxConcurrentConnectionsPerPool() const
The maximum number of concurrent connections per connections pool.
void nullRepresentationChanged()
This string is used to represent the value NULL throughout QGIS.
static QgsImageCache * imageCache()
Returns the application's image cache, used for caching resampled versions of raster images...
static QgsValidityCheckRegistry * validityCheckRegistry()
Returns the application's validity check registry, used for managing validity checks.
static QString themeName()
Set the active theme to the specified theme.
static QString defaultThemesFolder()
Returns the path to default themes folder from install (works as a starting point).
void initStyleScheme()
Initializes the default random style color scheme for the user.
QStringList childKeys() const
Returns a list of all top-level keys that can be read using the QSettings object. ...
static void restoreGdalDriver(const QString &driver)
Sets the GDAL_SKIP environment variable to exclude the specified driver and then calls GDALDriverMana...
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
A cache for images / pictures derived from svg files.
void remove(const QString &key, QgsSettings::Section section=QgsSettings::NoSection)
Removes the setting key and any sub-settings of key in a section.
static QString resolvePkgPath()
Calculate the application pkg path.
Registry for raster renderers.
static void registerOgrDrivers()
Register OGR drivers ensuring this only happens once.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
User profile contains information about the user profile folders on the machine.
Precisely identify a point on the canvas.
static QgsPluginLayerRegistry * pluginLayerRegistry()
Returns the application's plugin layer registry, used for managing plugin layer types.
static QVariantMap customVariables()
Custom expression variables for this application.
This class keeps a list of QgsAbstractValidityCheck checks which can be used when performing validity...
static void setFileOpenEventReceiver(QObject *receiver)
Sets the FileOpen event receiver.
static QString reportStyleSheet()
Returns a standard css style sheet for reports.
static int maxThreads()
Gets maximum concurrent thread count.
static endian_t endian()
Returns whether this machine uses big or little endian.
static QPixmap getThemePixmap(const QString &name)
Helper to get a theme icon as a pixmap.
static QString userFullName()
Returns the user's operating system login account full display name.
static QgsPaintEffectRegistry * paintEffectRegistry()
Returns the application's paint effect registry, used for managing paint effects. ...
static QString developersMapFilePath()
Returns the path to the developers map file.
static QString absolutePathToRelativePath(const QString &apath, const QString &targetPath)
Converts absolute path to path relative to target.
static QString defaultStylePath()
Returns the path to default style (works as a starting point).
static QgsTaskManager * taskManager()
Returns the application's task manager, used for managing application wide background task handling...
static QgsMessageLog * messageLog()
Returns the application's message log.
static void applyGdalSkippedDrivers()
Apply the skipped drivers list to gdal.
#define CONN_POOL_MAX_CONCURRENT_CONNS
endian_t
Constants for endian-ness.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
static QgsLayoutItemRegistry * layoutItemRegistry()
Returns the application's layout item registry, used for layout item types.
static void setNullRepresentation(const QString &nullRepresentation)
This string is used to represent the value NULL throughout QGIS.
static QString pluginPath()
Returns the path to the application plugin directory.
Keeps track of available 3D renderers.
#define QgsDebugMsgLevel(str, level)
Registry of available symbol layer classes.
Registry for temporary fetched files.
static bool createThemeFolder()
Create the users theme folder.
static bool createDatabase(QString *errorMessage=nullptr)
initialize qgis.db
static void cleanRegisteredFunctions()
Deletes all registered functions whose ownership have been transferred to the expression engine...
static QString i18nPath()
Returns the path to the translation directory.
static void cleanDefaultStyle()
Deletes the default style. Only to be used by QgsApplication::exitQgis()
static QString nullRepresentation()
This string is used to represent the value NULL throughout QGIS.
static QString splashPath()
Returns the path to the splash screen image directory.
static void setCustomVariable(const QString &name, const QVariant &value)
Set a single custom expression variable.
static QgsGpsConnectionRegistry * gpsConnectionRegistry()
Returns the application's GPS connection registry, used for managing GPS connections.
A registry for known page sizes.
static const char * QGIS_ORGANIZATION_NAME
int open(const QString &path)
Opens the database at the specified file path.
static QgsProjectStorageRegistry * projectStorageRegistry()
Returns registry of available project storage implementations.
Task manager for managing a set of long-running QgsTask tasks.
Used for the collecting of strings from projects for translation and creation of ts files...
static QString userLoginName()
Returns the user's operating system login account name.
static QString pkgDataPath()
Returns the common root path of all application data directories.
static QString osName()
Returns a string name of the operating system QGIS is running on.
static void initQgis()
loads providers
static void setDefaultSvgPaths(const QStringList &pathList)
Alters default svg paths - used by 3rd party apps.
Unique pointer for sqlite3 databases, which automatically closes the database when the pointer goes o...
static void skipGdalDriver(const QString &driver)
Sets the GDAL_SKIP environment variable to include the specified driver and then calls GDALDriverMana...
void beginGroup(const QString &prefix, QgsSettings::Section section=QgsSettings::NoSection)
Appends prefix to the current group.
static QgsAuthManager * authManager()
Returns the application's authentication manager instance.
static QRegExp shortNameRegExp()
Returns the short name regular expression for line edit validator.
static QgsNetworkAccessManager * instance(Qt::ConnectionType connectionType=Qt::BlockingQueuedConnection)
Returns a pointer to the active QgsNetworkAccessManager for the current thread.
Identify: obtain information about the object.
Registry for various processing components, including providers, algorithms and various parameters an...
static QString showSettings()
Convenience function to get a summary of the paths used in this application instance useful for debug...
static QString appIconPath()
Gets application icon.
static QgsColorSchemeRegistry * colorSchemeRegistry()
Returns the application's color scheme registry, used for managing color schemes. ...
static const char * QGIS_ORGANIZATION_DOMAIN
bool notify(QObject *receiver, QEvent *event) override
Catch exceptions when sending event to receiver.
Registry of available layout item types.
static void setPkgDataPath(const QString &pkgDataPath)
Alters pkg data path - used by 3rd party apps.
static QgsPageSizeRegistry * pageSizeRegistry()
Returns the application's page size registry, used for managing layout page sizes.
static QString contributorsFilePath()
Returns the path to the contributors file.
static QString activeThemePath()
Returns the path to the currently active theme directory.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
static void init(QString profileFolder=QString())
This method initializes paths etc for QGIS.
static void setPluginPath(const QString &pluginPath)
Alters plugin path - used by 3rd party apps.
QgsUserProfile * getProfile(const QString &defaultProfile="default", bool createNew=true, bool initSettings=true)
Returns the profile from the given root profile location.
static QgsProject * instance()
Returns the QgsProject singleton instance.
A class to register / unregister existing GPS connections such that the information is available to a...
static QgsNetworkContentFetcherRegistry * networkContentFetcherRegistry()
Returns the application's network content registry used for fetching temporary files during QGIS sess...
bool init(const QString &pluginPath=QString(), const QString &authDatabasePath=QString())
init initialize QCA, prioritize qca-ossl plugin and optionally set up the authentication database ...
static QString platform()
Returns the QGIS platform name, e.g., "desktop" or "server".
static QString srsDatabaseFilePath()
Returns the path to the srs.db file.
QObject * ABISYM(QgsApplication::mFileOpenEventReceiver)
static void exitQgis()
deletes provider registry and map layer registry
Temporarily blocks the application QgsMessageLog (see QgsApplication::messageLog()) from emitting the...
A cache for images derived from raster files.
static QStringList svgPaths()
Returns the paths to svg directories.
static QString sponsorsFilePath()
Returns the path to the sponsors file.
Registry of storage backends that QgsProject may use.
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
static QString qgisAuthDatabaseFilePath()
Returns the path to the user authentication database file: qgis-auth.db.
const QString folder() const
The base folder for the user profile.
The action scope registry is an application wide registry that contains a list of available action sc...
static QHash< QString, QString > uiThemes()
All themes found in ~/.qgis3/themes folder.
static QString libexecPath()
Returns the path with utility executables (help viewer, crssync, ...)
static QString prefixPath()
Returns the path to the application prefix directory.
static QString iconsPath()
Returns the path to the icons image directory.
static QString translatorsFilePath()
Returns the path to the sponsors file.
static const char * QGIS_APPLICATION_NAME
void collectTranslatableObjects(QgsTranslationContext *translationContext)
Emits the signal to collect all the strings of .qgs to be included in ts file.
~QgsApplication() override
static QString serverResourcesPath()
Returns the path to the server resources directory.
static QgsActionScopeRegistry * actionScopeRegistry()
Returns the action scope registry.
User profile manager is used to manager list, and manage user profiles on the users machine...
static QString metadataPath()
Returns the path to the metadata directory.
Defines a QGIS exception class.
static QgsRasterRendererRegistry * rasterRendererRegistry()
Returns the application's raster renderer registry, used for managing raster layer renderers...
static QgsDataItemProviderRegistry * dataItemProviderRegistry()
Returns the application's data item provider registry, which keeps a list of data item providers that...
static QgsRendererRegistry * rendererRegistry()
Returns the application's renderer registry, used for managing vector layer renderers.
Interface for logging messages from QGIS in GUI independent way.
static QString qmlImportPath()
Returns the path where QML components are installed for QGIS Quick library.
static void setMaxThreads(int maxThreads)
Set maximum concurrent thread count.
Select and capture a point or a feature.
static void setUITheme(const QString &themeName)
Set the current UI theme used to style the interface.
static QColor decodeColor(const QString &str)
static QString licenceFilePath()
Returns the path to the licence file.
Registry of available paint effects.
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers, algorithms, and various parameters and outputs.
static QString userThemesFolder()
Returns the path to user's themes folder.
void preNotify(QObject *receiver, QEvent *event, bool *done)
static void setAuthDatabaseDirPath(const QString &authDbDirPath)
Alters authentication data base directory path - used by 3rd party apps.