QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsapplication.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsapplication.cpp - Accessors for application-wide data
3  --------------------------------------
4  Date : 02-Jan-2006
5  Copyright : (C) 2006 by Tom Elwertowski
6  Email : telwertowski at users dot sourceforge dot net
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgsapplication.h"
17 #include "qgsauthmanager.h"
20 #include "qgsexception.h"
21 #include "qgsgeometry.h"
23 #include "qgslayoutitemregistry.h"
24 #include "qgslogger.h"
25 #include "qgsproject.h"
28 #include "qgsnetworkreply.h"
29 #include "qgsproviderregistry.h"
30 #include "qgsexpression.h"
31 #include "qgsactionscoperegistry.h"
32 #include "qgsruntimeprofiler.h"
33 #include "qgstaskmanager.h"
37 #include "qgssvgcache.h"
38 #include "qgsimagecache.h"
39 #include "qgssourcecache.h"
40 #include "qgscolorschemeregistry.h"
41 #include "qgspainteffectregistry.h"
44 #include "qgsrendererregistry.h"
45 #include "qgssymbollayerregistry.h"
46 #include "qgssymbollayerutils.h"
47 #include "qgscalloutsregistry.h"
48 #include "qgspluginlayerregistry.h"
50 #include "qgsmessagelog.h"
51 #include "qgsannotationregistry.h"
52 #include "qgssettings.h"
53 #include "qgsunittypes.h"
54 #include "qgsuserprofile.h"
55 #include "qgsuserprofilemanager.h"
56 #include "qgsreferencedgeometry.h"
57 #include "qgs3drendererregistry.h"
58 #include "qgs3dsymbolregistry.h"
59 #include "qgslayoutrendercontext.h"
60 #include "qgssqliteutils.h"
61 #include "qgsstyle.h"
62 #include "qgsprojutils.h"
64 #include "qgsnewsfeedparser.h"
65 #include "qgsbookmarkmanager.h"
66 #include "qgsstylemodel.h"
67 #include "qgsconnectionregistry.h"
69 #include "qgsmeshlayer.h"
70 #include "qgsfeaturestore.h"
71 
74 #include "processing/models/qgsprocessingmodelchildparametersource.h"
75 #include "processing/models/qgsprocessingmodelchilddependency.h"
76 
78 
79 #include <QDesktopWidget>
80 #include <QDir>
81 #include <QFile>
82 #include <QFileInfo>
83 #include <QFileOpenEvent>
84 #include <QMessageBox>
85 #include <QPalette>
86 #include <QProcess>
87 #include <QProcessEnvironment>
88 #include <QIcon>
89 #include <QPixmap>
90 #include <QThreadPool>
91 #include <QLocale>
92 #include <QStyle>
93 
94 #ifndef Q_OS_WIN
95 #include <netinet/in.h>
96 #include <pwd.h>
97 #else
98 #include <winsock.h>
99 #include <windows.h>
100 #include <lmcons.h>
101 #define SECURITY_WIN32
102 #include <security.h>
103 #ifdef _MSC_VER
104 #pragma comment( lib, "Secur32.lib" )
105 #endif
106 #endif
107 
108 #include "qgsconfig.h"
109 
110 #include <gdal.h>
111 #include <ogr_api.h>
112 #include <cpl_conv.h> // for setting gdal options
113 #include <sqlite3.h>
114 
115 #if PROJ_VERSION_MAJOR>=6
116 #include <proj.h>
117 #endif
118 
119 
120 #define CONN_POOL_MAX_CONCURRENT_CONNS 4
121 
122 QObject *ABISYM( QgsApplication::mFileOpenEventReceiver ) = nullptr;
123 bool ABISYM( QgsApplication::mInitialized ) = false;
124 bool ABISYM( QgsApplication::mRunningFromBuildDir ) = false;
125 const char *QgsApplication::QGIS_ORGANIZATION_NAME = "QGIS";
126 const char *QgsApplication::QGIS_ORGANIZATION_DOMAIN = "qgis.org";
127 const char *QgsApplication::QGIS_APPLICATION_NAME = "QGIS3";
128 QgsApplication::ApplicationMembers *QgsApplication::sApplicationMembers = nullptr;
129 QgsAuthManager *QgsApplication::sAuthManager = nullptr;
130 int ABISYM( QgsApplication::sMaxThreads ) = -1;
131 
132 Q_GLOBAL_STATIC( QStringList, sFileOpenEventList )
133 Q_GLOBAL_STATIC( QString, sPrefixPath )
134 Q_GLOBAL_STATIC( QString, sPluginPath )
135 Q_GLOBAL_STATIC( QString, sPkgDataPath )
136 Q_GLOBAL_STATIC( QString, sLibraryPath )
137 Q_GLOBAL_STATIC( QString, sLibexecPath )
138 Q_GLOBAL_STATIC( QString, sQmlImportPath )
139 Q_GLOBAL_STATIC( QString, sThemeName )
140 Q_GLOBAL_STATIC( QString, sProfilePath )
141 
142 Q_GLOBAL_STATIC( QStringList, sDefaultSvgPaths )
143 Q_GLOBAL_STATIC( QgsStringMap, sSystemEnvVars )
144 Q_GLOBAL_STATIC( QString, sConfigPath )
145 
146 Q_GLOBAL_STATIC( QString, sBuildSourcePath )
147 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
148 Q_GLOBAL_STATIC( QString, sCfgIntDir )
149 #endif
150 Q_GLOBAL_STATIC( QString, sBuildOutputPath )
151 Q_GLOBAL_STATIC( QStringList, sGdalSkipList )
152 Q_GLOBAL_STATIC( QStringList, sDeferredSkippedGdalDrivers )
153 Q_GLOBAL_STATIC( QString, sAuthDbDirPath )
154 
155 Q_GLOBAL_STATIC( QString, sUserName )
156 Q_GLOBAL_STATIC( QString, sUserFullName )
157 Q_GLOBAL_STATIC_WITH_ARGS( QString, sPlatformName, ( "desktop" ) )
158 Q_GLOBAL_STATIC( QString, sTranslation )
159 
160 QgsApplication::QgsApplication( int &argc, char **argv, bool GUIenabled, const QString &profileFolder, const QString &platformName )
161  : QApplication( argc, argv, GUIenabled )
162 {
163  *sPlatformName() = platformName;
164 
165  if ( *sTranslation() != QLatin1String( "C" ) )
166  {
167  mQgisTranslator = new QTranslator();
168  if ( mQgisTranslator->load( QStringLiteral( "qgis_" ) + *sTranslation(), i18nPath() ) )
169  {
170  installTranslator( mQgisTranslator );
171  }
172  else
173  {
174  QgsDebugMsgLevel( QStringLiteral( "loading of qgis translation failed %1/qgis_%2" ).arg( i18nPath(), *sTranslation() ), 2 );
175  }
176 
177  /* Translation file for Qt.
178  * The strings from the QMenuBar context section are used by Qt/Mac to shift
179  * the About, Preferences and Quit items to the Mac Application menu.
180  * These items must be translated identically in both qt_ and qgis_ files.
181  */
182  mQtTranslator = new QTranslator();
183  if ( mQtTranslator->load( QStringLiteral( "qt_" ) + *sTranslation(), QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ) )
184  {
185  installTranslator( mQtTranslator );
186  }
187  else
188  {
189  QgsDebugMsgLevel( QStringLiteral( "loading of qt translation failed %1/qt_%2" ).arg( QLibraryInfo::location( QLibraryInfo::TranslationsPath ), *sTranslation() ), 2 );
190  }
191  }
192 
193  mApplicationMembers = new ApplicationMembers();
194 
195  *sProfilePath() = profileFolder;
196 }
197 
198 void QgsApplication::init( QString profileFolder )
199 {
200  if ( profileFolder.isEmpty() )
201  {
202  if ( getenv( "QGIS_CUSTOM_CONFIG_PATH" ) )
203  {
204  profileFolder = getenv( "QGIS_CUSTOM_CONFIG_PATH" );
205  }
206  else
207  {
208  profileFolder = QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ).value( 0 );
209  }
210  // This will normally get here for custom scripts that use QgsApplication.
211  // This doesn't get this hit for QGIS Desktop because we setup the profile via main
212  QString rootProfileFolder = QgsUserProfileManager::resolveProfilesFolder( profileFolder );
213  QgsUserProfileManager manager( rootProfileFolder );
214  QgsUserProfile *profile = manager.getProfile();
215  profileFolder = profile->folder();
216  delete profile;
217  }
218 
219  *sProfilePath() = profileFolder;
220 
221  qRegisterMetaType<QgsGeometry::Error>( "QgsGeometry::Error" );
222  qRegisterMetaType<QgsProcessingFeatureSourceDefinition>( "QgsProcessingFeatureSourceDefinition" );
223  qRegisterMetaType<QgsProcessingOutputLayerDefinition>( "QgsProcessingOutputLayerDefinition" );
224  qRegisterMetaType<QgsUnitTypes::LayoutUnit>( "QgsUnitTypes::LayoutUnit" );
225  qRegisterMetaType<QgsFeatureId>( "QgsFeatureId" );
226  qRegisterMetaType<QgsFeatureIds>( "QgsFeatureIds" );
227  qRegisterMetaType<QgsProperty>( "QgsProperty" );
228  qRegisterMetaType<QgsFeatureStoreList>( "QgsFeatureStoreList" );
229  qRegisterMetaType<Qgis::MessageLevel>( "Qgis::MessageLevel" );
230  qRegisterMetaType<QgsReferencedRectangle>( "QgsReferencedRectangle" );
231  qRegisterMetaType<QgsReferencedPointXY>( "QgsReferencedPointXY" );
232  qRegisterMetaType<QgsReferencedGeometry>( "QgsReferencedGeometry" );
233  qRegisterMetaType<QgsLayoutRenderContext::Flags>( "QgsLayoutRenderContext::Flags" );
234  qRegisterMetaType<QgsStyle::StyleEntity>( "QgsStyle::StyleEntity" );
235  qRegisterMetaType<QgsCoordinateReferenceSystem>( "QgsCoordinateReferenceSystem" );
236  qRegisterMetaType<QgsAuthManager::MessageLevel>( "QgsAuthManager::MessageLevel" );
237  qRegisterMetaType<QgsNetworkRequestParameters>( "QgsNetworkRequestParameters" );
238  qRegisterMetaType<QgsNetworkReplyContent>( "QgsNetworkReplyContent" );
239  qRegisterMetaType<QgsGeometry>( "QgsGeometry" );
240  qRegisterMetaType<QgsDatumTransform::GridDetails>( "QgsDatumTransform::GridDetails" );
241  qRegisterMetaType<QgsDatumTransform::TransformDetails>( "QgsDatumTransform::TransformDetails" );
242  qRegisterMetaType<QgsNewsFeedParser::Entry>( "QgsNewsFeedParser::Entry" );
243  qRegisterMetaType<QgsRectangle>( "QgsRectangle" );
244  qRegisterMetaType<QgsProcessingModelChildParameterSource>( "QgsProcessingModelChildParameterSource" );
245  qRegisterMetaTypeStreamOperators<QgsProcessingModelChildParameterSource>( "QgsProcessingModelChildParameterSource" );
246  qRegisterMetaType<QgsRemappingSinkDefinition>( "QgsRemappingSinkDefinition" );
247  qRegisterMetaType<QgsProcessingModelChildDependency>( "QgsProcessingModelChildDependency" );
248  qRegisterMetaType<QgsTextFormat>( "QgsTextFormat" );
249  QMetaType::registerComparators<QgsProcessingModelChildDependency>();
250  QMetaType::registerEqualsComparator<QgsProcessingFeatureSourceDefinition>();
251  QMetaType::registerEqualsComparator<QgsProperty>();
252 
253  ( void ) resolvePkgPath();
254 
255  if ( ABISYM( mRunningFromBuildDir ) )
256  {
257  // we run from source directory - not installed to destination (specified prefix)
258  *sPrefixPath() = QString(); // set invalid path
259 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
260  setPluginPath( *sBuildOutputPath() + '/' + QString( QGIS_PLUGIN_SUBDIR ) + '/' + *sCfgIntDir() );
261 #else
262  setPluginPath( *sBuildOutputPath() + '/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
263 #endif
264  setPkgDataPath( *sBuildOutputPath() + QStringLiteral( "/data" ) ); // in buildDir/data - used for: doc, resources, svg
265  *sLibraryPath() = *sBuildOutputPath() + '/' + QGIS_LIB_SUBDIR + '/';
266 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
267  *sLibexecPath() = *sBuildOutputPath() + '/' + QGIS_LIBEXEC_SUBDIR + '/' + *sCfgIntDir() + '/';
268 #else
269  *sLibexecPath() = *sBuildOutputPath() + '/' + QGIS_LIBEXEC_SUBDIR + '/';
270 #endif
271 #if defined( HAVE_QUICK )
272  *sQmlImportPath() = *sBuildOutputPath() + '/' + QGIS_QML_SUBDIR + '/';
273 #endif
274  }
275  else
276  {
277  char *prefixPath = getenv( "QGIS_PREFIX_PATH" );
278  if ( !prefixPath )
279  {
280  if ( sPrefixPath()->isNull() )
281  {
282 #if defined(Q_OS_MACX) || defined(Q_OS_WIN)
283  setPrefixPath( applicationDirPath(), true );
284 #elif defined(ANDROID)
285  // this is "/data/data/org.qgis.qgis" in android
286  QDir myDir( QDir::homePath() );
287  myDir.cdUp();
288  QString myPrefix = myDir.absolutePath();
289  setPrefixPath( myPrefix, true );
290 #else
291  QDir myDir( applicationDirPath() );
292  // Fix for server which is one level deeper in /usr/lib/cgi-bin
293  if ( applicationDirPath().contains( QStringLiteral( "cgi-bin" ) ) )
294  {
295  myDir.cdUp();
296  }
297  myDir.cdUp(); // Go from /usr/bin or /usr/lib (for server) to /usr
298  QString myPrefix = myDir.absolutePath();
299  setPrefixPath( myPrefix, true );
300 #endif
301  }
302  }
303  else
304  {
305  setPrefixPath( prefixPath, true );
306  }
307  }
308 
309  *sConfigPath() = profileFolder + '/'; // make sure trailing slash is included
310  *sDefaultSvgPaths() << qgisSettingsDirPath() + QStringLiteral( "svg/" );
311 
312  *sAuthDbDirPath() = qgisSettingsDirPath();
313  if ( getenv( "QGIS_AUTH_DB_DIR_PATH" ) )
314  {
315  setAuthDatabaseDirPath( getenv( "QGIS_AUTH_DB_DIR_PATH" ) );
316  }
317 
318  // store system environment variables passed to application, before they are adjusted
319  QMap<QString, QString> systemEnvVarMap;
320  QString passfile( QStringLiteral( "QGIS_AUTH_PASSWORD_FILE" ) ); // QString, for comparison
321 
322  const auto systemEnvironment = QProcessEnvironment::systemEnvironment().toStringList();
323  for ( const QString &varStr : systemEnvironment )
324  {
325  int pos = varStr.indexOf( QLatin1Char( '=' ) );
326  if ( pos == -1 )
327  continue;
328  QString varStrName = varStr.left( pos );
329  QString varStrValue = varStr.mid( pos + 1 );
330  if ( varStrName != passfile )
331  {
332  systemEnvVarMap.insert( varStrName, varStrValue );
333  }
334  }
335  *sSystemEnvVars() = systemEnvVarMap;
336 
337 #if PROJ_VERSION_MAJOR>=6
338  // append local user-writable folder as a proj search path
339  QStringList currentProjSearchPaths = QgsProjUtils::searchPaths();
340  currentProjSearchPaths.append( qgisSettingsDirPath() + QStringLiteral( "proj" ) );
341 #ifdef Q_OS_MACX
342  // append bundled proj lib for MacOS
343  QString projLib( QDir::cleanPath( pkgDataPath().append( "/proj" ) ) );
344  if ( QFile::exists( projLib ) )
345  {
346  currentProjSearchPaths.append( projLib );
347  }
348 #endif // Q_OS_MACX
349 
350  char **newPaths = new char *[currentProjSearchPaths.length()];
351  for ( int i = 0; i < currentProjSearchPaths.count(); ++i )
352  {
353  newPaths[i] = CPLStrdup( currentProjSearchPaths.at( i ).toUtf8().constData() );
354  }
355  proj_context_set_search_paths( nullptr, currentProjSearchPaths.count(), newPaths );
356  for ( int i = 0; i < currentProjSearchPaths.count(); ++i )
357  {
358  CPLFree( newPaths[i] );
359  }
360  delete [] newPaths;
361 #endif // PROJ_VERSION_MAJOR>=6
362 
363  // allow Qt to search for Qt plugins (e.g. sqldrivers) in our plugin directory
364  QCoreApplication::addLibraryPath( pluginPath() );
365 
366  // set max. thread count to -1
367  // this should be read from QgsSettings but we don't know where they are at this point
368  // so we read actual value in main.cpp
369  ABISYM( sMaxThreads ) = -1;
370 
371  {
372  QgsScopedRuntimeProfile profile( tr( "Load color schemes" ) );
375  }
376 
377  {
378  QgsScopedRuntimeProfile profile( tr( "Load bookmarks" ) );
380  }
381 
382  if ( !members()->mStyleModel )
383  members()->mStyleModel = new QgsStyleModel( QgsStyle::defaultStyle() );
384 
385  ABISYM( mInitialized ) = true;
386 }
387 
389 {
390  delete mDataItemProviderRegistry;
391  delete mApplicationMembers;
392  delete mQgisTranslator;
393  delete mQtTranslator;
394 
395  // we do this here as well as in exitQgis() -- it's safe to call as often as we want,
396  // and there's just a *chance* that someone hasn't properly called exitQgis prior to
397  // this destructor...
398  invalidateCaches();
399 }
400 
401 void QgsApplication::invalidateCaches()
402 {
403  // invalidate coordinate cache while the PROJ context held by the thread-locale
404  // QgsProjContextStore object is still alive. Otherwise if this later object
405  // is destroyed before the static variables of the cache, we might use freed memory.
409 }
410 
412 {
413  return qobject_cast<QgsApplication *>( QCoreApplication::instance() );
414 }
415 
416 bool QgsApplication::event( QEvent *event )
417 {
418  bool done = false;
419  if ( event->type() == QEvent::FileOpen )
420  {
421  // handle FileOpen event (double clicking a file icon in Mac OS X Finder)
422  if ( ABISYM( mFileOpenEventReceiver ) )
423  {
424  // Forward event to main window.
425  done = notify( ABISYM( mFileOpenEventReceiver ), event );
426  }
427  else
428  {
429  // Store filename because receiver has not registered yet.
430  // If QGIS has been launched by double clicking a file icon, FileOpen will be
431  // the first event; the main window is not yet ready to handle the event.
432  sFileOpenEventList()->append( static_cast<QFileOpenEvent *>( event )->file() );
433  done = true;
434  }
435  }
436  else
437  {
438  // pass other events to base class
439  done = QApplication::event( event );
440  }
441  return done;
442 }
443 
444 bool QgsApplication::notify( QObject *receiver, QEvent *event )
445 {
446  bool done = false;
447  // Crashes in customization (especially on Mac), if we're not in the main/UI thread, see #5597
448  if ( thread() == receiver->thread() )
449  emit preNotify( receiver, event, &done );
450 
451  if ( done )
452  return true;
453 
454  // Send event to receiver and catch unhandled exceptions
455  done = true;
456  try
457  {
458  done = QApplication::notify( receiver, event );
459  }
460  catch ( QgsException &e )
461  {
462  qCritical() << "Caught unhandled QgsException: " << e.what();
463  if ( qApp->thread() == QThread::currentThread() )
464  QMessageBox::critical( activeWindow(), tr( "Exception" ), e.what() );
465  }
466  catch ( std::exception &e )
467  {
468  qCritical() << "Caught unhandled std::exception: " << e.what();
469  if ( qApp->thread() == QThread::currentThread() )
470  QMessageBox::critical( activeWindow(), tr( "Exception" ), e.what() );
471  }
472  catch ( ... )
473  {
474  qCritical() << "Caught unhandled unknown exception";
475  if ( qApp->thread() == QThread::currentThread() )
476  QMessageBox::critical( activeWindow(), tr( "Exception" ), tr( "unknown exception" ) );
477  }
478 
479  return done;
480 }
481 
483 {
484  return QgsRuntimeProfiler::threadLocalInstance();
485 }
486 
488 {
489  // Set receiver for FileOpen events
490  ABISYM( mFileOpenEventReceiver ) = receiver;
491  // Propagate any events collected before the receiver has registered.
492  if ( sFileOpenEventList()->count() > 0 )
493  {
494  const QStringList fileOpenEventList = *sFileOpenEventList();
495  for ( const QString &file : fileOpenEventList )
496  {
497  QFileOpenEvent foe( file );
498  QgsApplication::sendEvent( ABISYM( mFileOpenEventReceiver ), &foe );
499  }
500  sFileOpenEventList()->clear();
501  }
502 }
503 
504 void QgsApplication::setPrefixPath( const QString &prefixPath, bool useDefaultPaths )
505 {
506  *sPrefixPath() = prefixPath;
507 #if defined(Q_OS_WIN)
508  if ( sPrefixPath()->endsWith( "/bin" ) )
509  {
510  sPrefixPath()->chop( 4 );
511  }
512 #endif
513  if ( useDefaultPaths && !ABISYM( mRunningFromBuildDir ) )
514  {
515  setPluginPath( *sPrefixPath() + '/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
516  setPkgDataPath( *sPrefixPath() + '/' + QStringLiteral( QGIS_DATA_SUBDIR ) );
517  }
518  *sLibraryPath() = *sPrefixPath() + '/' + QGIS_LIB_SUBDIR + '/';
519  *sLibexecPath() = *sPrefixPath() + '/' + QGIS_LIBEXEC_SUBDIR + '/';
520 #if defined( HAVE_QUICK )
521  *sQmlImportPath() = *sPrefixPath() + '/' + QGIS_QML_SUBDIR + '/';
522 #endif
523 }
524 
525 void QgsApplication::setPluginPath( const QString &pluginPath )
526 {
527  *sPluginPath() = pluginPath;
528 }
529 
530 void QgsApplication::setPkgDataPath( const QString &pkgDataPath )
531 {
532  *sPkgDataPath() = pkgDataPath;
533 
534  QString mySvgPath = pkgDataPath + QStringLiteral( "/svg/" );
535 
536  // avoid duplicate entries
537  if ( !sDefaultSvgPaths()->contains( mySvgPath ) )
538  *sDefaultSvgPaths() << mySvgPath;
539 }
540 
541 void QgsApplication::setDefaultSvgPaths( const QStringList &pathList )
542 {
543  *sDefaultSvgPaths() = pathList;
544 }
545 
546 void QgsApplication::setAuthDatabaseDirPath( const QString &authDbDirPath )
547 {
548  QFileInfo fi( authDbDirPath );
549  if ( fi.exists() && fi.isDir() && fi.isWritable() )
550  {
551  *sAuthDbDirPath() = fi.canonicalFilePath() + QDir::separator();
552  }
553 }
554 
556 {
557 #if 0
558  if ( ABISYM( mRunningFromBuildDir ) )
559  {
560  static bool sOnce = true;
561  if ( sOnce )
562  {
563  QgsMessageLogNotifyBlocker blockNotifications;
564  ( void ) blockNotifications;
565  qWarning( "!!! prefix path was requested, but it is not valid - we do not run from installed path !!!" );
566  }
567  sOnce = false;
568  }
569 #endif
570 
571  return *sPrefixPath();
572 }
574 {
575  return *sPluginPath();
576 }
577 
579 {
580  if ( sPkgDataPath()->isNull() )
581  return resolvePkgPath();
582  else
583  return *sPkgDataPath();
584 }
585 
587 {
588  return QStringLiteral( ":/images/themes/default/" );
589 }
591 {
592  QString usersThemes = userThemesFolder() + QDir::separator() + themeName() + QDir::separator() + "icons/";
593  QDir dir( usersThemes );
594  if ( dir.exists() )
595  {
596  return usersThemes;
597  }
598  else
599  {
600  QString defaultThemes = defaultThemesFolder() + QDir::separator() + themeName() + QDir::separator() + "icons/";
601  return defaultThemes;
602  }
603 }
604 
606 {
607  return iconsPath() + QStringLiteral( "qgis-icon-60x60.png" );
608 }
609 
611 {
612  return ABISYM( sMaxThreads );
613 }
614 
615 QString QgsApplication::iconPath( const QString &iconFile )
616 {
617  // try active theme
618  QString path = activeThemePath();
619  if ( QFile::exists( path + iconFile ) )
620  return path + iconFile;
621 
622  // use default theme
623  return defaultThemePath() + iconFile;
624 }
625 
626 QIcon QgsApplication::getThemeIcon( const QString &name )
627 {
628  QgsApplication *app = instance();
629  if ( app && app->mIconCache.contains( name ) )
630  return app->mIconCache.value( name );
631 
632  QIcon icon;
633 
634  QString myPreferredPath = activeThemePath() + QDir::separator() + name;
635  QString myDefaultPath = defaultThemePath() + QDir::separator() + name;
636  if ( QFile::exists( myPreferredPath ) )
637  {
638  icon = QIcon( myPreferredPath );
639  }
640  else if ( QFile::exists( myDefaultPath ) )
641  {
642  //could still return an empty icon if it
643  //doesn't exist in the default theme either!
644  icon = QIcon( myDefaultPath );
645  }
646  else
647  {
648  icon = QIcon();
649  }
650 
651  if ( app )
652  app->mIconCache.insert( name, icon );
653  return icon;
654 }
655 
657 {
658  QgsApplication *app = instance();
659  if ( app && app->mCursorCache.contains( cursor ) )
660  return app->mCursorCache.value( cursor );
661 
662  // All calculations are done on 32x32 icons
663  // Defaults to center, individual cursors may override
664  int activeX = 16;
665  int activeY = 16;
666 
667  QString name;
668  switch ( cursor )
669  {
670  case ZoomIn:
671  name = QStringLiteral( "mZoomIn.svg" );
672  activeX = 13;
673  activeY = 13;
674  break;
675  case ZoomOut:
676  name = QStringLiteral( "mZoomOut.svg" );
677  activeX = 13;
678  activeY = 13;
679  break;
680  case Identify:
681  activeX = 3;
682  activeY = 6;
683  name = QStringLiteral( "mIdentify.svg" );
684  break;
685  case CrossHair:
686  name = QStringLiteral( "mCrossHair.svg" );
687  break;
688  case CapturePoint:
689  name = QStringLiteral( "mCapturePoint.svg" );
690  break;
691  case Select:
692  name = QStringLiteral( "mSelect.svg" );
693  activeX = 6;
694  activeY = 6;
695  break;
696  case Sampler:
697  activeX = 5;
698  activeY = 5;
699  name = QStringLiteral( "mSampler.svg" );
700  break;
701  // No default
702  }
703  // It should never get here!
704  Q_ASSERT( ! name.isEmpty( ) );
705 
706  QIcon icon = getThemeIcon( QStringLiteral( "cursors" ) + QDir::separator() + name );
707  QCursor cursorIcon;
708  // Check if an icon exists for this cursor (the O.S. default cursor will be used if it does not)
709  if ( ! icon.isNull( ) )
710  {
711  // Apply scaling
712  float scale = Qgis::UI_SCALE_FACTOR * app->fontMetrics().height() / 32.0;
713  cursorIcon = QCursor( icon.pixmap( std::ceil( scale * 32 ), std::ceil( scale * 32 ) ), std::ceil( scale * activeX ), std::ceil( scale * activeY ) );
714  }
715  if ( app )
716  app->mCursorCache.insert( cursor, cursorIcon );
717  return cursorIcon;
718 }
719 
720 // TODO: add some caching mechanism ?
721 QPixmap QgsApplication::getThemePixmap( const QString &name, const QColor &foreColor, const QColor &backColor, const int size )
722 {
723  const QString preferredPath = activeThemePath() + QDir::separator() + name;
724  const QString defaultPath = defaultThemePath() + QDir::separator() + name;
725  const QString path = QFile::exists( preferredPath ) ? preferredPath : defaultPath;
726  if ( foreColor.isValid() || backColor.isValid() )
727  {
728  bool fitsInCache = false;
729  const QImage image = svgCache()->svgAsImage( path, size, backColor, foreColor, 1, 1, fitsInCache );
730  return QPixmap::fromImage( image );
731  }
732 
733  return QPixmap( path );
734 }
735 
736 void QgsApplication::setThemeName( const QString &themeName )
737 {
738  *sThemeName() = themeName;
739 }
740 
742 {
743  static QString appPath;
744  if ( appPath.isNull() )
745  {
746  if ( QCoreApplication::instance() )
747  {
748  appPath = applicationDirPath();
749  }
750  else
751  {
752  qWarning( "Application path not initialized" );
753  }
754  }
755 
756  if ( !appPath.isNull() || getenv( "QGIS_PREFIX_PATH" ) )
757  {
758  QString prefix = getenv( "QGIS_PREFIX_PATH" ) ? getenv( "QGIS_PREFIX_PATH" ) : appPath;
759 
760  // check if QGIS is run from build directory (not the install directory)
761  QFile f;
762  // "/../../.." is for Mac bundled app in build directory
763  static const QStringList paths { QStringList() << QString() << QStringLiteral( "/.." ) << QStringLiteral( "/bin" ) << QStringLiteral( "/../../.." ) };
764  for ( const QString &path : paths )
765  {
766  f.setFileName( prefix + path + "/qgisbuildpath.txt" );
767  if ( f.exists() )
768  break;
769  }
770  if ( f.exists() && f.open( QIODevice::ReadOnly ) )
771  {
772  ABISYM( mRunningFromBuildDir ) = true;
773  *sBuildSourcePath() = f.readLine().trimmed();
774  *sBuildOutputPath() = f.readLine().trimmed();
775  QgsDebugMsgLevel( QStringLiteral( "Running from build directory!" ), 4 );
776  QgsDebugMsgLevel( QStringLiteral( "- source directory: %1" ).arg( sBuildSourcePath()->toUtf8().constData() ), 4 );
777  QgsDebugMsgLevel( QStringLiteral( "- output directory of the build: %1" ).arg( sBuildOutputPath()->toUtf8().constData() ), 4 );
778 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
779  *sCfgIntDir() = prefix.split( '/', QString::SkipEmptyParts ).last();
780  qDebug( "- cfg: %s", sCfgIntDir()->toUtf8().constData() );
781 #endif
782  }
783  }
784 
785  QString prefixPath;
786  if ( getenv( "QGIS_PREFIX_PATH" ) )
787  prefixPath = getenv( "QGIS_PREFIX_PATH" );
788  else
789  {
790 #if defined(ANDROID)
791  // this is "/data/data/org.qgis.qgis" in android
792  QDir dir( QDir::homePath() );
793  dir.cdUp();
794  prefixPath = dir.absolutePath();
795 #else
796 
797 #if defined(Q_OS_MACX)
798  prefixPath = appPath;
799 #elif defined(Q_OS_WIN)
800  prefixPath = appPath;
801  if ( prefixPath.endsWith( "/bin" ) )
802  prefixPath.chop( 4 );
803 #else
804  QDir dir( appPath );
805  // Fix for server which is one level deeper in /usr/lib/cgi-bin
806  if ( appPath.contains( QStringLiteral( "cgi-bin" ) ) )
807  {
808  dir.cdUp();
809  }
810  dir.cdUp(); // Go from /usr/bin or /usr/lib (for server) to /usr
811  prefixPath = dir.absolutePath();
812 #endif
813 #endif
814  }
815 
816  if ( ABISYM( mRunningFromBuildDir ) )
817  return *sBuildOutputPath() + QStringLiteral( "/data" );
818  else
819  return prefixPath + '/' + QStringLiteral( QGIS_DATA_SUBDIR );
820 }
821 
823 {
824  return *sThemeName();
825 }
826 
827 void QgsApplication::setUITheme( const QString &themeName )
828 {
829  // Loop all style sheets, find matching name, load it.
830  QHash<QString, QString> themes = QgsApplication::uiThemes();
831  if ( themeName == QLatin1String( "default" ) || !themes.contains( themeName ) )
832  {
833  setThemeName( QStringLiteral( "default" ) );
834  qApp->setStyleSheet( QString() );
835  return;
836  }
837 
838  QString path = themes.value( themeName );
839  QString stylesheetname = path + "/style.qss";
840 
841  QFile file( stylesheetname );
842  QFile variablesfile( path + "/variables.qss" );
843 
844  QFileInfo variableInfo( variablesfile );
845 
846  if ( !file.open( QIODevice::ReadOnly ) || ( variableInfo.exists() && !variablesfile.open( QIODevice::ReadOnly ) ) )
847  {
848  return;
849  }
850 
851  QString styledata = file.readAll();
852  styledata.replace( QLatin1String( "@theme_path" ), path );
853 
854  if ( variableInfo.exists() )
855  {
856  QTextStream in( &variablesfile );
857  while ( !in.atEnd() )
858  {
859  QString line = in.readLine();
860  // This is a variable
861  if ( line.startsWith( '@' ) )
862  {
863  int index = line.indexOf( ':' );
864  QString name = line.mid( 0, index );
865  QString value = line.mid( index + 1, line.length() );
866  styledata.replace( name, value );
867  }
868  }
869  variablesfile.close();
870  }
871  file.close();
872 
873  if ( Qgis::UI_SCALE_FACTOR != 1.0 )
874  {
875  // apply OS-specific UI scale factor to stylesheet's em values
876  int index = 0;
877  QRegularExpression regex( QStringLiteral( "(?<=[\\s:])([0-9\\.]+)(?=em)" ) );
878  QRegularExpressionMatch match = regex.match( styledata, index );
879  while ( match.hasMatch() )
880  {
881  index = match.capturedStart();
882  styledata.remove( index, match.captured( 0 ).length() );
883  QString number = QString::number( match.captured( 0 ).toDouble() * Qgis::UI_SCALE_FACTOR );
884  styledata.insert( index, number );
885  index += number.length();
886  match = regex.match( styledata, index );
887  }
888  }
889 
890  qApp->setStyleSheet( styledata );
891 
892  QFile palettefile( path + "/palette.txt" );
893  QFileInfo paletteInfo( palettefile );
894  if ( paletteInfo.exists() && palettefile.open( QIODevice::ReadOnly ) )
895  {
896  QPalette pal = qApp->palette();
897  QTextStream in( &palettefile );
898  while ( !in.atEnd() )
899  {
900  QString line = in.readLine();
901  QStringList parts = line.split( ':' );
902  if ( parts.count() == 2 )
903  {
904  int role = parts.at( 0 ).trimmed().toInt();
905  QColor color = QgsSymbolLayerUtils::decodeColor( parts.at( 1 ).trimmed() );
906  pal.setColor( static_cast< QPalette::ColorRole >( role ), color );
907  }
908  }
909  palettefile.close();
910  qApp->setPalette( pal );
911  }
912 
914 }
915 
916 QHash<QString, QString> QgsApplication::uiThemes()
917 {
918  QStringList paths = QStringList() << userThemesFolder() << defaultThemesFolder();
919  QHash<QString, QString> mapping;
920  mapping.insert( QStringLiteral( "default" ), QString() );
921  const auto constPaths = paths;
922  for ( const QString &path : constPaths )
923  {
924  QDir folder( path );
925  QFileInfoList styleFiles = folder.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
926  const auto constStyleFiles = styleFiles;
927  for ( const QFileInfo &info : constStyleFiles )
928  {
929  QFileInfo styleFile( info.absoluteFilePath() + "/style.qss" );
930  if ( !styleFile.exists() )
931  continue;
932 
933  QString name = info.baseName();
934  QString path = info.absoluteFilePath();
935  mapping.insert( name, path );
936  }
937  }
938  return mapping;
939 }
940 
942 {
943  return pkgDataPath() + QStringLiteral( "/doc/AUTHORS" );
944 }
945 
947 {
948  return pkgDataPath() + QStringLiteral( "/doc/CONTRIBUTORS" );
949 }
951 {
952  return pkgDataPath() + QStringLiteral( "/doc/developersmap.html" );
953 }
954 
956 {
957  return pkgDataPath() + QStringLiteral( "/doc/SPONSORS" );
958 }
959 
961 {
962  return pkgDataPath() + QStringLiteral( "/doc/DONORS" );
963 }
964 
966 {
967  return pkgDataPath() + QStringLiteral( "/doc/TRANSLATORS" );
968 }
969 
971 {
972  return pkgDataPath() + QStringLiteral( "/doc/LICENSE" );
973 }
974 
976 {
977  if ( ABISYM( mRunningFromBuildDir ) )
978  return *sBuildOutputPath() + QStringLiteral( "/i18n/" );
979  else
980  return pkgDataPath() + QStringLiteral( "/i18n/" );
981 }
982 
984 {
985  return pkgDataPath() + QStringLiteral( "/resources/metadata-ISO/" );
986 }
987 
989 {
990  return pkgDataPath() + QStringLiteral( "/resources/qgis.db" );
991 }
992 
994 {
995  return *sConfigPath();
996 }
997 
999 {
1000  return qgisSettingsDirPath() + QStringLiteral( "qgis.db" );
1001 }
1002 
1004 {
1005  return *sAuthDbDirPath() + QStringLiteral( "qgis-auth.db" );
1006 }
1007 
1009 {
1010  return QStringLiteral( ":/images/splash/" );
1011 }
1012 
1014 {
1015  return pkgDataPath() + QStringLiteral( "/images/icons/" );
1016 }
1017 
1019 {
1020  if ( ABISYM( mRunningFromBuildDir ) )
1021  {
1022 #if PROJ_VERSION_MAJOR>=6
1023  QString tempCopy = QDir::tempPath() + "/srs6.db";
1024 #else
1025  QString tempCopy = QDir::tempPath() + "/srs.db";
1026 #endif
1027 
1028  if ( !QFile( tempCopy ).exists() )
1029  {
1030 #if PROJ_VERSION_MAJOR>=6
1031  QFile f( buildSourcePath() + "/resources/srs6.db" );
1032 #else
1033  QFile f( buildSourcePath() + "/resources/srs.db" );
1034 #endif
1035  if ( !f.copy( tempCopy ) )
1036  {
1037  qFatal( "Could not create temporary copy" );
1038  }
1039  }
1040 
1041  return tempCopy;
1042  }
1043  else
1044  {
1045  return pkgDataPath() + QStringLiteral( "/resources/srs.db" );
1046  }
1047 }
1048 
1050 {
1051  //local directories to search when looking for an SVG with a given basename
1052  //defined by user in options dialog
1053  QgsSettings settings;
1054  const QStringList pathList = settings.value( QStringLiteral( "svg/searchPathsForSVG" ) ).toStringList();
1055 
1056  // maintain user set order while stripping duplicates
1057  QStringList paths;
1058  for ( const QString &path : pathList )
1059  {
1060  if ( !paths.contains( path ) )
1061  paths.append( path );
1062  }
1063  for ( const QString &path : qgis::as_const( *sDefaultSvgPaths() ) )
1064  {
1065  if ( !paths.contains( path ) )
1066  paths.append( path );
1067  }
1068 
1069  return paths;
1070 }
1071 
1073 {
1074  //local directories to search when looking for an template with a given basename
1075  //defined by user in options dialog
1076  QgsSettings settings;
1077  QStringList pathList = settings.value( QStringLiteral( "Layout/searchPathsForTemplates" ), QVariant(), QgsSettings::Core ).toStringList();
1078 
1079  return pathList;
1080 }
1081 
1082 QMap<QString, QString> QgsApplication::systemEnvVars()
1083 {
1084  return *sSystemEnvVars();
1085 }
1086 
1088 {
1089  return qgisSettingsDirPath() + QStringLiteral( "symbology-style.db" );
1090 }
1091 
1093 {
1094  return QRegExp( "^[A-Za-z][A-Za-z0-9\\._-]*" );
1095 }
1096 
1098 {
1099  if ( !sUserName()->isEmpty() )
1100  return *sUserName();
1101 
1102 #ifdef _MSC_VER
1103  TCHAR name [ UNLEN + 1 ];
1104  DWORD size = UNLEN + 1;
1105 
1106  if ( GetUserName( ( TCHAR * )name, &size ) )
1107  {
1108  *sUserName() = QString::fromLocal8Bit( name );
1109  }
1110 
1111 #elif QT_CONFIG(process)
1112  QProcess process;
1113 
1114  process.start( QStringLiteral( "whoami" ), QStringList() );
1115  process.waitForFinished();
1116  *sUserName() = process.readAllStandardOutput().trimmed();
1117 #endif
1118 
1119  if ( !sUserName()->isEmpty() )
1120  return *sUserName();
1121 
1122  //backup plan - use environment variables
1123  *sUserName() = qgetenv( "USER" );
1124  if ( !sUserName()->isEmpty() )
1125  return *sUserName();
1126 
1127  //last resort
1128  *sUserName() = qgetenv( "USERNAME" );
1129  return *sUserName();
1130 }
1131 
1133 {
1134  if ( !sUserFullName()->isEmpty() )
1135  return *sUserFullName();
1136 
1137 #ifdef _MSC_VER
1138  TCHAR name [ UNLEN + 1 ];
1139  DWORD size = UNLEN + 1;
1140 
1141  //note - this only works for accounts connected to domain
1142  if ( GetUserNameEx( NameDisplay, ( TCHAR * )name, &size ) )
1143  {
1144  *sUserFullName() = QString::fromLocal8Bit( name );
1145  }
1146 
1147  //fall back to login name
1148  if ( sUserFullName()->isEmpty() )
1149  *sUserFullName() = userLoginName();
1150 #elif defined(Q_OS_ANDROID) || defined(__MINGW32__)
1151  *sUserFullName() = QStringLiteral( "Not available" );
1152 #else
1153  struct passwd *p = getpwuid( getuid() );
1154 
1155  if ( p )
1156  {
1157  QString gecosName = QString( p->pw_gecos );
1158  *sUserFullName() = gecosName.left( gecosName.indexOf( ',', 0 ) );
1159  }
1160 
1161 #endif
1162 
1163  return *sUserFullName();
1164 }
1165 
1167 {
1168 #if defined(Q_OS_ANDROID)
1169  return QLatin1String( "android" );
1170 #elif defined(Q_OS_MAC)
1171  return QLatin1String( "osx" );
1172 #elif defined(Q_OS_WIN)
1173  return QLatin1String( "windows" );
1174 #elif defined(Q_OS_LINUX)
1175  return QStringLiteral( "linux" );
1176 #elif defined(Q_OS_FREEBSD)
1177  return QStringLiteral( "freebsd" );
1178 #elif defined(Q_OS_OPENBSD)
1179  return QStringLiteral( "openbsd" );
1180 #elif defined(Q_OS_NETBSD)
1181  return QStringLiteral( "netbsd" );
1182 #elif defined(Q_OS_UNIX)
1183  return QLatin1String( "unix" );
1184 #else
1185  return QLatin1String( "unknown" );
1186 #endif
1187 }
1188 
1190 {
1191  return *sPlatformName();
1192 }
1193 
1195 {
1196  QgsSettings settings;
1197  bool overrideLocale = settings.value( QStringLiteral( "locale/overrideFlag" ), false ).toBool();
1198  if ( overrideLocale )
1199  {
1200  QString locale = settings.value( QStringLiteral( "locale/userLocale" ), QString() ).toString();
1201  // don't differentiate en_US and en_GB
1202  if ( locale.startsWith( QLatin1String( "en" ), Qt::CaseInsensitive ) )
1203  {
1204  return locale.left( 2 );
1205  }
1206 
1207  return locale;
1208  }
1209  else
1210  {
1211  return QLocale().name().left( 2 );
1212  }
1213 }
1214 
1216 {
1217  return qgisSettingsDirPath() + QStringLiteral( "/themes" );
1218 }
1219 
1221 {
1222  return pkgDataPath() + QStringLiteral( "/resources/symbology-style.xml" );
1223 }
1224 
1226 {
1227  return pkgDataPath() + QStringLiteral( "/resources/themes" );
1228 }
1229 
1231 {
1232  return pkgDataPath() + QStringLiteral( "/resources/server/" );
1233 }
1234 
1236 {
1237  return *sLibraryPath();
1238 }
1239 
1241 {
1242  return *sLibexecPath();
1243 }
1244 
1246 {
1247  return *sQmlImportPath();
1248 }
1249 
1251 {
1252  return ( htonl( 1 ) == 1 ) ? XDR : NDR;
1253 }
1254 
1256 {
1257  if ( !ABISYM( mInitialized ) && QgsApplication::instance() )
1258  {
1259  init( *sProfilePath() );
1260  }
1261 
1262  // set the provider plugin path (this creates provider registry)
1264 
1265  // create data item provider registry
1267 
1268  // create project instance if doesn't exist
1270 
1271  // Initialize authentication manager and connect to database
1273 
1274  // Make sure we have a NAM created on the main thread.
1275  // Note that this might call QgsApplication::authManager to
1276  // setup the proxy configuration that's why it needs to be
1277  // called after the QgsAuthManager instance has been created
1279 
1280 }
1281 
1283 {
1284  if ( auto *lInstance = instance() )
1285  {
1286  if ( !lInstance->mAuthManager )
1287  {
1288  lInstance->mAuthManager = QgsAuthManager::instance();
1289  }
1290  return lInstance->mAuthManager;
1291  }
1292  else
1293  {
1294  // no QgsApplication instance
1295  if ( !sAuthManager )
1296  sAuthManager = QgsAuthManager::instance();
1297  return sAuthManager;
1298  }
1299 }
1300 
1301 
1303 {
1304  // make sure all threads are done before exiting
1305  QThreadPool::globalInstance()->waitForDone();
1306 
1307  // don't create to delete
1308  if ( auto *lInstance = instance() )
1309  delete lInstance->mAuthManager;
1310  else
1311  delete sAuthManager;
1312 
1313  //Ensure that all remaining deleteLater QObjects are actually deleted before we exit.
1314  //This isn't strictly necessary (since we're exiting anyway) but doing so prevents a lot of
1315  //LeakSanitiser noise which hides real issues
1316  QgsApplication::sendPostedEvents( nullptr, QEvent::DeferredDelete );
1317 
1318  //delete all registered functions from expression engine (see above comment)
1320 
1321  delete QgsProject::instance();
1322 
1323  // avoid creating instance just to delete it!
1324  if ( QgsProviderRegistry::exists() )
1326 
1327  invalidateCaches();
1328 
1330 
1331  // tear-down GDAL/OGR
1332  OGRCleanupAll();
1333  GDALDestroyDriverManager();
1334 }
1335 
1337 {
1338  QString myEnvironmentVar( getenv( "QGIS_PREFIX_PATH" ) );
1339  QString myState = tr( "Application state:\n"
1340  "QGIS_PREFIX_PATH env var:\t\t%1\n"
1341  "Prefix:\t\t%2\n"
1342  "Plugin Path:\t\t%3\n"
1343  "Package Data Path:\t%4\n"
1344  "Active Theme Name:\t%5\n"
1345  "Active Theme Path:\t%6\n"
1346  "Default Theme Path:\t%7\n"
1347  "SVG Search Paths:\t%8\n"
1348  "User DB Path:\t%9\n"
1349  "Auth DB Path:\t%10\n" )
1350  .arg( myEnvironmentVar,
1351  prefixPath(),
1352  pluginPath(),
1353  pkgDataPath(),
1354  themeName(),
1355  activeThemePath(),
1356  defaultThemePath(),
1357  svgPaths().join( tr( "\n\t\t", "match indentation of application state" ) ),
1359  .arg( qgisAuthDatabaseFilePath() );
1360  return myState;
1361 }
1362 
1364 {
1365  //
1366  // Make the style sheet desktop preferences aware by using qapplication
1367  // palette as a basis for colors where appropriate
1368  //
1369  // QColor myColor1 = palette().highlight().color();
1370  QColor myColor1( Qt::lightGray );
1371  QColor myColor2 = myColor1;
1372  myColor2 = myColor2.lighter( 110 ); //10% lighter
1373  QString myStyle;
1374  myStyle = QStringLiteral( ".overview{"
1375  " font: 1.82em;"
1376  " font-weight: bold;"
1377  "}"
1378  "body{"
1379  " background: white;"
1380  " color: black;"
1381  " font-family: 'Lato', 'Ubuntu', 'Lucida Grande', 'Segoe UI', 'Arial', sans-serif;"
1382  " width: 100%;"
1383  "}"
1384  "h1{ background-color: #F6F6F6;"
1385  " color: #589632; " // from http://qgis.org/en/site/getinvolved/styleguide.html
1386  " font-size: x-large; "
1387  " font-weight: normal;"
1388  " background: none;"
1389  " padding: 0.75em 0 0;"
1390  " margin: 0;"
1391  " line-height: 3em;"
1392  "}"
1393  "h2{ background-color: #F6F6F6;"
1394  " color: #589632; " // from http://qgis.org/en/site/getinvolved/styleguide.html
1395  " font-size: medium; "
1396  " font-weight: normal;"
1397  " background: none;"
1398  " padding: 0.75em 0 0;"
1399  " margin: 0;"
1400  " line-height: 1.1em;"
1401  "}"
1402  "h3{ background-color: #F6F6F6;"
1403  " color: #93b023;" // from http://qgis.org/en/site/getinvolved/styleguide.html
1404  " font-weight: bold;"
1405  " font-size: large;"
1406  " text-align: left;"
1407  " border-bottom: 5px solid #DCEB5C;"
1408  "}"
1409  "h4{ background-color: #F6F6F6;"
1410  " color: #93b023;" // from http://qgis.org/en/site/getinvolved/styleguide.html
1411  " font-weight: bold;"
1412  " font-size: medium;"
1413  " text-align: left;"
1414  "}"
1415  "h5{ background-color: #F6F6F6;"
1416  " color: #93b023;" // from http://qgis.org/en/site/getinvolved/styleguide.html
1417  " font-weight: bold;"
1418  " font-size: small;"
1419  " text-align: left;"
1420  "}"
1421  "a{ color: #729FCF;"
1422  " font-family: arial,sans-serif;"
1423  "}"
1424  "label{ background-color: #FFFFCC;"
1425  " border: 1px solid black;"
1426  " margin: 1px;"
1427  " padding: 0px 3px; "
1428  " font-size: small;"
1429  "}"
1430  "th .strong {"
1431  " font-weight: bold;"
1432  "}"
1433  "hr {"
1434  " border: 0;"
1435  " height: 0;"
1436  " border-top: 1px solid black;"
1437  "}"
1438  ".list-view .highlight {"
1439  " text-align: left;"
1440  " border: 0px;"
1441  " width: 20%;"
1442  " padding-right: 15px;"
1443  " padding-left: 20px;"
1444  " font-weight: bold;"
1445  "}"
1446  ".tabular-view .odd-row {"
1447  " background-color: #f9f9f9;"
1448  "}"
1449  ".section {"
1450  " font-weight: bold;"
1451  " padding-top:25px;"
1452  "}" );
1453 
1454  // We have some subtle differences between Qt based style and QWebKit style
1455  switch ( styleSheetType )
1456  {
1457  case StyleSheetType::Qt:
1458  myStyle += QStringLiteral(
1459  ".tabular-view{ "
1460  " border-collapse: collapse;"
1461  " width: 95%;"
1462  "}"
1463  ".tabular-view th, .tabular-view td { "
1464  " border:1px solid black;"
1465  "}" );
1466  break;
1467 
1468  case StyleSheetType::WebBrowser:
1469  myStyle += QStringLiteral(
1470  "body { "
1471  " margin: auto;"
1472  " width: 97%;"
1473  "}"
1474  "table.tabular-view, table.list-view { "
1475  " border-collapse: collapse;"
1476  " table-layout:fixed;"
1477  " width: 100% !important;"
1478  " font-size: 90%;"
1479  "}"
1480  // Override
1481  "h1 { "
1482  " line-height: inherit;"
1483  "}"
1484  "td, th {"
1485  " word-wrap: break-word; "
1486  " vertical-align: top;"
1487  "}"
1488  // Set first column width
1489  ".list-view th:first-child, .list-view td:first-child {"
1490  " width: 20%;"
1491  "}"
1492  ".list-view.highlight { "
1493  " padding-left: inherit; "
1494  "}"
1495  // Set first column width for inner tables
1496  ".tabular-view th:first-child, .tabular-view td:first-child { "
1497  " width: 20%; "
1498  "}"
1499  // Makes titles bg stand up
1500  ".tabular-view th.strong { "
1501  " background-color: #eee; "
1502  "}"
1503  // Give some visual appearance to those ugly nested tables
1504  ".tabular-view th, .tabular-view td { "
1505  " border: 1px solid #eee;"
1506  "}"
1507  );
1508  break;
1509  }
1510 
1511  return myStyle;
1512 }
1513 
1515 {
1516  if ( 0 >= OGRGetDriverCount() )
1517  {
1518  OGRRegisterAll();
1519  }
1520 }
1521 
1522 QString QgsApplication::absolutePathToRelativePath( const QString &aPath, const QString &targetPath )
1523 {
1524  QString aPathUrl = aPath;
1525  QString tPathUrl = targetPath;
1526 #if defined( Q_OS_WIN )
1527  const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
1528 
1529  aPathUrl.replace( '\\', '/' );
1530  if ( aPathUrl.startsWith( "//" ) )
1531  {
1532  // keep UNC prefix
1533  aPathUrl = "\\\\" + aPathUrl.mid( 2 );
1534  }
1535 
1536  tPathUrl.replace( '\\', '/' );
1537  if ( tPathUrl.startsWith( "//" ) )
1538  {
1539  // keep UNC prefix
1540  tPathUrl = "\\\\" + tPathUrl.mid( 2 );
1541  }
1542 #else
1543  const Qt::CaseSensitivity cs = Qt::CaseSensitive;
1544 #endif
1545 
1546 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
1547  QStringList targetElems = tPathUrl.split( '/', QString::SkipEmptyParts );
1548  QStringList aPathElems = aPathUrl.split( '/', QString::SkipEmptyParts );
1549 #else
1550  QStringList targetElems = tPathUrl.split( '/', Qt::SkipEmptyParts );
1551  QStringList aPathElems = aPathUrl.split( '/', Qt::SkipEmptyParts );
1552 #endif
1553 
1554  targetElems.removeAll( QStringLiteral( "." ) );
1555  aPathElems.removeAll( QStringLiteral( "." ) );
1556 
1557  // remove common part
1558  int n = 0;
1559  while ( !aPathElems.isEmpty() &&
1560  !targetElems.isEmpty() &&
1561  aPathElems[0].compare( targetElems[0], cs ) == 0 )
1562  {
1563  aPathElems.removeFirst();
1564  targetElems.removeFirst();
1565  n++;
1566  }
1567 
1568  if ( n == 0 )
1569  {
1570  // no common parts; might not even be a file
1571  return aPathUrl;
1572  }
1573 
1574  if ( !targetElems.isEmpty() )
1575  {
1576  // go up to the common directory
1577  for ( int i = 0; i < targetElems.size(); i++ )
1578  {
1579  aPathElems.insert( 0, QStringLiteral( ".." ) );
1580  }
1581  }
1582  else
1583  {
1584  // let it start with . nevertheless,
1585  // so relative path always start with either ./ or ../
1586  aPathElems.insert( 0, QStringLiteral( "." ) );
1587  }
1588 
1589  return aPathElems.join( QLatin1Char( '/' ) );
1590 }
1591 
1592 QString QgsApplication::relativePathToAbsolutePath( const QString &rpath, const QString &targetPath )
1593 {
1594  // relative path should always start with ./ or ../
1595  if ( !rpath.startsWith( QLatin1String( "./" ) ) && !rpath.startsWith( QLatin1String( "../" ) ) )
1596  {
1597  return rpath;
1598  }
1599 
1600  QString rPathUrl = rpath;
1601  QString targetPathUrl = targetPath;
1602 
1603 #if defined(Q_OS_WIN)
1604  rPathUrl.replace( '\\', '/' );
1605  targetPathUrl.replace( '\\', '/' );
1606 
1607  bool uncPath = targetPathUrl.startsWith( "//" );
1608 #endif
1609 
1610 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
1611  QStringList srcElems = rPathUrl.split( '/', QString::SkipEmptyParts );
1612  QStringList targetElems = targetPathUrl.split( '/', QString::SkipEmptyParts );
1613 #else
1614  QStringList srcElems = rPathUrl.split( '/', Qt::SkipEmptyParts );
1615  QStringList targetElems = targetPathUrl.split( '/', Qt::SkipEmptyParts );
1616 #endif
1617 
1618 #if defined(Q_OS_WIN)
1619  if ( uncPath )
1620  {
1621  targetElems.insert( 0, "" );
1622  targetElems.insert( 0, "" );
1623  }
1624 #endif
1625 
1626  // append source path elements
1627  targetElems << srcElems;
1628  targetElems.removeAll( QStringLiteral( "." ) );
1629 
1630  // resolve ..
1631  int pos;
1632  while ( ( pos = targetElems.indexOf( QLatin1String( ".." ) ) ) > 0 )
1633  {
1634  // remove preceding element and ..
1635  targetElems.removeAt( pos - 1 );
1636  targetElems.removeAt( pos - 1 );
1637  }
1638 
1639 #if !defined(Q_OS_WIN)
1640  // make path absolute
1641  targetElems.prepend( QString() );
1642 #endif
1643 
1644  return targetElems.join( QLatin1Char( '/' ) );
1645 }
1646 
1648 {
1649  return *sBuildSourcePath();
1650 }
1651 
1653 {
1654  return *sBuildOutputPath();
1655 }
1656 
1657 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
1658 QString QgsApplication::cfgIntDir()
1659 {
1660  return *sCfgIntDir();
1661 }
1662 #endif
1663 
1664 void QgsApplication::skipGdalDriver( const QString &driver )
1665 {
1666  if ( sGdalSkipList()->contains( driver ) || driver.isEmpty() )
1667  {
1668  return;
1669  }
1670  *sGdalSkipList() << driver;
1672 }
1673 
1674 void QgsApplication::restoreGdalDriver( const QString &driver )
1675 {
1676  if ( !sGdalSkipList()->contains( driver ) )
1677  {
1678  return;
1679  }
1680  int myPos = sGdalSkipList()->indexOf( driver );
1681  if ( myPos >= 0 )
1682  {
1683  sGdalSkipList()->removeAt( myPos );
1684  }
1686 }
1687 
1689 {
1690  return *sGdalSkipList();
1691 }
1692 
1693 void QgsApplication::setSkippedGdalDrivers( const QStringList &skippedGdalDrivers,
1694  const QStringList &deferredSkippedGdalDrivers )
1695 {
1696  *sGdalSkipList() = skippedGdalDrivers;
1697  *sDeferredSkippedGdalDrivers() = deferredSkippedGdalDrivers;
1698 
1699  QgsSettings settings;
1700  settings.setValue( QStringLiteral( "gdal/skipDrivers" ), skippedGdalDrivers.join( QLatin1Char( ',' ) ) );
1701 
1703 }
1704 
1706 {
1707  QgsSettings settings;
1708  QString joinedList, delimiter;
1709  if ( settings.contains( QStringLiteral( "gdal/skipDrivers" ) ) )
1710  {
1711  joinedList = settings.value( QStringLiteral( "gdal/skipDrivers" ), QString() ).toString();
1712  delimiter = QStringLiteral( "," );
1713  }
1714  else
1715  {
1716  joinedList = settings.value( QStringLiteral( "gdal/skipList" ), QString() ).toString();
1717  delimiter = QStringLiteral( " " );
1718  }
1719  QStringList myList;
1720  if ( !joinedList.isEmpty() )
1721  {
1722  myList = joinedList.split( delimiter );
1723  }
1724  *sGdalSkipList() = myList;
1726 }
1727 
1729 {
1730  return *sDeferredSkippedGdalDrivers();
1731 }
1732 
1734 {
1735  sGdalSkipList()->removeDuplicates();
1736  QStringList realDisabledDriverList;
1737  for ( const auto &driverName : *sGdalSkipList() )
1738  {
1739  if ( !sDeferredSkippedGdalDrivers()->contains( driverName ) )
1740  realDisabledDriverList << driverName;
1741  }
1742  QString myDriverList = realDisabledDriverList.join( ',' );
1743  QgsDebugMsgLevel( QStringLiteral( "Gdal Skipped driver list set to:" ), 2 );
1744  QgsDebugMsgLevel( myDriverList, 2 );
1745  CPLSetConfigOption( "GDAL_SKIP", myDriverList.toUtf8() );
1746  GDALAllRegister(); //to update driver list and skip missing ones
1747 }
1748 
1750 {
1751  QString folder = userThemesFolder();
1752  QDir myDir( folder );
1753  if ( !myDir.exists() )
1754  {
1755  myDir.mkpath( folder );
1756  }
1757 
1758  return true;
1759 }
1760 
1761 void QgsApplication::copyPath( const QString &src, const QString &dst )
1762 {
1763  QDir dir( src );
1764  if ( ! dir.exists() )
1765  return;
1766 
1767  const auto subDirectories = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot );
1768  for ( const QString &d : subDirectories )
1769  {
1770  QString dst_path = dst + QDir::separator() + d;
1771  dir.mkpath( dst_path );
1772  copyPath( src + QDir::separator() + d, dst_path );
1773  }
1774 
1775  const auto files = dir.entryList( QDir::Files );
1776  for ( const QString &f : files )
1777  {
1778  QFile::copy( src + QDir::separator() + f, dst + QDir::separator() + f );
1779  }
1780 }
1781 
1783 {
1784  //read values from QgsSettings
1785  QgsSettings settings;
1786 
1787  QVariantMap variables;
1788 
1789  //check if settings contains any variables
1790  settings.beginGroup( "variables" );
1791  QStringList childKeys = settings.childKeys();
1792  for ( QStringList::const_iterator it = childKeys.constBegin(); it != childKeys.constEnd(); ++it )
1793  {
1794  QString name = *it;
1795  variables.insert( name, settings.value( name ) );
1796  }
1797 
1798  return variables;
1799 }
1800 
1801 void QgsApplication::setCustomVariables( const QVariantMap &variables )
1802 {
1803  QgsSettings settings;
1804 
1805  QVariantMap::const_iterator it = variables.constBegin();
1806  settings.beginGroup( "variables" );
1807  settings.remove( "" );
1808  for ( ; it != variables.constEnd(); ++it )
1809  {
1810  settings.setValue( it.key(), it.value() );
1811  }
1812 
1813  emit instance()->customVariablesChanged();
1814 }
1815 
1816 void QgsApplication::setCustomVariable( const QString &name, const QVariant &value )
1817 {
1818  // save variable to settings
1819  QgsSettings settings;
1820 
1821  settings.setValue( QStringLiteral( "variables/" ) + name, value );
1822 
1823  emit instance()->customVariablesChanged();
1824 }
1825 
1826 int QgsApplication::scaleIconSize( int standardSize, bool applyDevicePixelRatio )
1827 {
1828  QFontMetrics fm( ( QFont() ) );
1829  const double scale = 1.1 * standardSize / 24;
1830  int scaledIconSize = static_cast< int >( std::floor( std::max( Qgis::UI_SCALE_FACTOR * fm.height() * scale, static_cast< double >( standardSize ) ) ) );
1831  if ( applyDevicePixelRatio && QApplication::desktop() )
1832  scaledIconSize *= QApplication::desktop()->devicePixelRatio();
1833  return scaledIconSize;
1834 }
1835 
1837 {
1839 }
1840 
1841 void QgsApplication::setTranslation( const QString &translation )
1842 {
1843  *sTranslation() = translation;
1844 }
1845 
1847 {
1848  emit requestForTranslatableObjects( translationContext );
1849 }
1850 
1852 {
1853  ApplicationMembers *appMembers = members();
1854  if ( appMembers->mNullRepresentation.isNull() )
1855  {
1856  appMembers->mNullRepresentation = QgsSettings().value( QStringLiteral( "qgis/nullValue" ), QStringLiteral( "NULL" ) ).toString();
1857  }
1858  return appMembers->mNullRepresentation;
1859 }
1860 
1861 void QgsApplication::setNullRepresentation( const QString &nullRepresentation )
1862 {
1863  ApplicationMembers *appMembers = members();
1864  if ( !appMembers || appMembers->mNullRepresentation == nullRepresentation )
1865  return;
1866 
1867  appMembers->mNullRepresentation = nullRepresentation;
1868  QgsSettings().setValue( QStringLiteral( "qgis/nullValue" ), nullRepresentation );
1869 
1870  QgsApplication *app = instance();
1871  if ( app )
1872  emit app->nullRepresentationChanged();
1873 }
1874 
1876 {
1877  return members()->mActionScopeRegistry;
1878 }
1879 
1880 bool QgsApplication::createDatabase( QString *errorMessage )
1881 {
1882  // set a working directory up for gdal to write .aux.xml files into
1883  // for cases where the raster dir is read only to the user
1884  // if the env var is already set it will be used preferentially
1885  QString myPamPath = qgisSettingsDirPath() + QStringLiteral( "gdal_pam/" );
1886  QDir myDir( myPamPath );
1887  if ( !myDir.exists() )
1888  {
1889  myDir.mkpath( myPamPath ); //fail silently
1890  }
1891 
1892 #if defined(Q_OS_WIN)
1893  CPLSetConfigOption( "GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() );
1894 #else
1895  //under other OS's we use an environment var so the user can
1896  //override the path if he likes
1897  int myChangeFlag = 0; //whether we want to force the env var to change
1898  setenv( "GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag );
1899 #endif
1900 
1901  // Check qgis.db and make private copy if necessary
1902  QFile qgisPrivateDbFile( QgsApplication::qgisUserDatabaseFilePath() );
1903 
1904  // first we look for ~/.qgis/qgis.db
1905  if ( !qgisPrivateDbFile.exists() )
1906  {
1907  // if it doesn't exist we copy it in from the global resources dir
1908  QString qgisMasterDbFileName = QgsApplication::qgisMasterDatabaseFilePath();
1909  QFile masterFile( qgisMasterDbFileName );
1910 
1911  // Must be sure there is destination directory ~/.qgis
1912  QDir().mkpath( QgsApplication::qgisSettingsDirPath() );
1913 
1914  //now copy the master file into the users .qgis dir
1915  bool isDbFileCopied = masterFile.copy( qgisPrivateDbFile.fileName() );
1916 
1917  if ( !isDbFileCopied )
1918  {
1919  if ( errorMessage )
1920  {
1921  *errorMessage = tr( "[ERROR] Can not make qgis.db private copy" );
1922  }
1923  return false;
1924  }
1925 
1926  QFile::Permissions perms = QFile( qgisPrivateDbFile.fileName() ).permissions();
1927  if ( !( perms & QFile::WriteOwner ) )
1928  {
1929  if ( !qgisPrivateDbFile.setPermissions( perms | QFile::WriteOwner ) )
1930  {
1931  if ( errorMessage )
1932  {
1933  *errorMessage = tr( "Can not make '%1' user writable" ).arg( qgisPrivateDbFile.fileName() );
1934  }
1935  return false;
1936  }
1937  }
1938  }
1939  else
1940  {
1941  // migrate if necessary
1942  sqlite3_database_unique_ptr database;
1943  if ( database.open( QgsApplication::qgisUserDatabaseFilePath() ) != SQLITE_OK )
1944  {
1945  if ( errorMessage )
1946  {
1947  *errorMessage = tr( "Could not open qgis.db" );
1948  }
1949  return false;
1950  }
1951 
1952  char *errmsg = nullptr;
1953  int res = sqlite3_exec( database.get(), "SELECT srs_id FROM tbl_srs LIMIT 0", nullptr, nullptr, &errmsg );
1954  if ( res != SQLITE_OK )
1955  {
1956  sqlite3_free( errmsg );
1957 
1958  // qgis.db is missing tbl_srs, create it
1959  if ( sqlite3_exec( database.get(),
1960  "DROP INDEX IF EXISTS idx_srsauthid;"
1961  "CREATE TABLE tbl_srs ("
1962  "srs_id INTEGER PRIMARY KEY,"
1963  "description text NOT NULL,"
1964  "projection_acronym text NOT NULL,"
1965  "ellipsoid_acronym NOT NULL,"
1966  "parameters text NOT NULL,"
1967  "srid integer,"
1968  "auth_name varchar,"
1969  "auth_id varchar,"
1970  "is_geo integer NOT NULL,"
1971  "deprecated boolean,"
1972  "wkt text);"
1973  "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);", nullptr, nullptr, &errmsg ) != SQLITE_OK )
1974  {
1975  if ( errorMessage )
1976  {
1977  *errorMessage = tr( "Creation of missing tbl_srs in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
1978  }
1979  sqlite3_free( errmsg );
1980  return false;
1981  }
1982  }
1983  else
1984  {
1985  // test if wkt column exists in database
1986  res = sqlite3_exec( database.get(), "SELECT wkt FROM tbl_srs LIMIT 0", nullptr, nullptr, &errmsg );
1987  if ( res != SQLITE_OK )
1988  {
1989  // need to add wkt column
1990  sqlite3_free( errmsg );
1991  if ( sqlite3_exec( database.get(),
1992  "DROP INDEX IF EXISTS idx_srsauthid;"
1993  "DROP TABLE IF EXISTS tbl_srs_bak;"
1994  "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
1995  "CREATE TABLE tbl_srs ("
1996  "srs_id INTEGER PRIMARY KEY,"
1997  "description text NOT NULL,"
1998  "projection_acronym text NOT NULL,"
1999  "ellipsoid_acronym NOT NULL,"
2000  "parameters text NOT NULL,"
2001  "srid integer,"
2002  "auth_name varchar,"
2003  "auth_id varchar,"
2004  "is_geo integer NOT NULL,"
2005  "deprecated boolean,"
2006  "wkt text);"
2007  "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2008  "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;"
2009  "DROP TABLE tbl_srs_bak", nullptr, nullptr, &errmsg ) != SQLITE_OK )
2010  {
2011  if ( errorMessage )
2012  {
2013  *errorMessage = tr( "Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2014  }
2015  sqlite3_free( errmsg );
2016  return false;
2017  }
2018  }
2019  }
2020 
2021  res = sqlite3_exec( database.get(), "SELECT acronym FROM tbl_projection LIMIT 0", nullptr, nullptr, &errmsg );
2022  if ( res != SQLITE_OK )
2023  {
2024  sqlite3_free( errmsg );
2025 
2026  // qgis.db is missing tbl_projection, create it
2027  if ( sqlite3_exec( database.get(),
2028  "CREATE TABLE tbl_projection ("
2029  "acronym varchar(20) NOT NULL PRIMARY KEY,"
2030  "name varchar(255) NOT NULL default '',"
2031  "notes varchar(255) NOT NULL default '',"
2032  "parameters varchar(255) NOT NULL default ''"
2033  ")", nullptr, nullptr, &errmsg ) != SQLITE_OK )
2034  {
2035  if ( errorMessage )
2036  {
2037  *errorMessage = tr( "Creation of missing tbl_projection in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2038  }
2039  sqlite3_free( errmsg );
2040  return false;
2041  }
2042  }
2043 
2044  res = sqlite3_exec( database.get(), "SELECT epsg FROM tbl_srs LIMIT 0", nullptr, nullptr, &errmsg );
2045  if ( res == SQLITE_OK )
2046  {
2047  // epsg column exists => need migration
2048  if ( sqlite3_exec( database.get(),
2049  "DROP INDEX IF EXISTS idx_srsauthid;"
2050  "DROP TABLE IF EXISTS tbl_srs_bak;"
2051  "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2052  "CREATE TABLE tbl_srs ("
2053  "srs_id INTEGER PRIMARY KEY,"
2054  "description text NOT NULL,"
2055  "projection_acronym text NOT NULL,"
2056  "ellipsoid_acronym NOT NULL,"
2057  "parameters text NOT NULL,"
2058  "srid integer,"
2059  "auth_name varchar,"
2060  "auth_id varchar,"
2061  "is_geo integer NOT NULL,"
2062  "deprecated boolean,"
2063  "wkt text);"
2064  "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2065  "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;"
2066  "DROP TABLE tbl_srs_bak", nullptr, nullptr, &errmsg ) != SQLITE_OK )
2067  {
2068  if ( errorMessage )
2069  {
2070  *errorMessage = tr( "Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2071  }
2072  sqlite3_free( errmsg );
2073  return false;
2074  }
2075  }
2076  else
2077  {
2078  sqlite3_free( errmsg );
2079  }
2080 
2081  if ( sqlite3_exec( database.get(), "DROP VIEW vw_srs", nullptr, nullptr, &errmsg ) != SQLITE_OK )
2082  {
2083  QgsDebugMsg( QStringLiteral( "vw_srs didn't exists in private qgis.db: %1" ).arg( errmsg ) );
2084  }
2085 
2086  if ( sqlite3_exec( database.get(),
2087  "CREATE VIEW vw_srs AS"
2088  " SELECT"
2089  " a.description AS description"
2090  ",a.srs_id AS srs_id"
2091  ",a.is_geo AS is_geo"
2092  ",coalesce(b.name,a.projection_acronym) AS name"
2093  ",a.parameters AS parameters"
2094  ",a.auth_name AS auth_name"
2095  ",a.auth_id AS auth_id"
2096  ",a.deprecated AS deprecated"
2097  " FROM tbl_srs a"
2098  " LEFT OUTER JOIN tbl_projection b ON a.projection_acronym=b.acronym"
2099  " ORDER BY coalesce(b.name,a.projection_acronym),a.description", nullptr, nullptr, &errmsg ) != SQLITE_OK )
2100  {
2101  if ( errorMessage )
2102  {
2103  *errorMessage = tr( "Update of view in private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2104  }
2105  sqlite3_free( errmsg );
2106  return false;
2107  }
2108  }
2109  return true;
2110 }
2111 
2112 void QgsApplication::setMaxThreads( int maxThreads )
2113 {
2114  QgsDebugMsgLevel( QStringLiteral( "maxThreads: %1" ).arg( maxThreads ), 2 );
2115 
2116  // make sure value is between 1 and #cores, if not set to -1 (use #cores)
2117  // 0 could be used to disable any parallel processing
2118  if ( maxThreads < 1 || maxThreads > QThread::idealThreadCount() )
2119  maxThreads = -1;
2120 
2121  // save value
2122  ABISYM( sMaxThreads ) = maxThreads;
2123 
2124  // if -1 use #cores
2125  if ( maxThreads == -1 )
2126  maxThreads = QThread::idealThreadCount();
2127 
2128  // set max thread count in QThreadPool
2129  QThreadPool::globalInstance()->setMaxThreadCount( maxThreads );
2130  QgsDebugMsgLevel( QStringLiteral( "set QThreadPool max thread count to %1" ).arg( QThreadPool::globalInstance()->maxThreadCount() ), 2 );
2131 }
2132 
2134 {
2135  return members()->mTaskManager;
2136 }
2137 
2139 {
2140  return members()->mColorSchemeRegistry;
2141 }
2142 
2144 {
2145  return members()->mPaintEffectRegistry;
2146 }
2147 
2149 {
2150  return members()->mRendererRegistry;
2151 }
2152 
2154 {
2155  return members()->mRasterRendererRegistry;
2156 }
2157 
2159 {
2160  if ( auto *lInstance = instance() )
2161  {
2162  if ( !instance()->mDataItemProviderRegistry )
2163  {
2164  lInstance->mDataItemProviderRegistry = new QgsDataItemProviderRegistry();
2165  }
2166  return lInstance->mDataItemProviderRegistry;
2167  }
2168  else
2169  {
2170  // no QgsApplication instance
2171  static QgsDataItemProviderRegistry *sDataItemProviderRegistry = nullptr;
2172  if ( !sDataItemProviderRegistry )
2173  sDataItemProviderRegistry = new QgsDataItemProviderRegistry();
2174  return sDataItemProviderRegistry;
2175  }
2176 }
2177 
2179 {
2180  return members()->mSvgCache;
2181 }
2182 
2184 {
2185  return members()->mImageCache;
2186 }
2187 
2189 {
2190  return members()->mSourceCache;
2191 }
2192 
2194 {
2195  return members()->mNetworkContentFetcherRegistry;
2196 }
2197 
2199 {
2200  return members()->mValidityCheckRegistry;
2201 }
2202 
2204 {
2205  return members()->mSymbolLayerRegistry;
2206 }
2207 
2209 {
2210  return members()->mCalloutRegistry;
2211 }
2212 
2214 {
2215  return members()->mLayoutItemRegistry;
2216 }
2217 
2219 {
2220  return members()->mAnnotationItemRegistry;
2221 }
2222 
2224 {
2225  return members()->mGpsConnectionRegistry;
2226 }
2227 
2229 {
2230  return members()->mPluginLayerRegistry;
2231 }
2232 
2234 {
2235  return members()->mClassificationMethodRegistry;
2236 }
2237 
2239 {
2240  return members()->mBookmarkManager;
2241 }
2242 
2244 {
2245  return members()->mStyleModel;
2246 }
2247 
2249 {
2250  return members()->mMessageLog;
2251 }
2252 
2254 {
2255  return members()->mProcessingRegistry;
2256 }
2257 
2259 {
2260  return members()->mConnectionRegistry;
2261 }
2262 
2264 {
2265  return members()->mPageSizeRegistry;
2266 }
2267 
2268 QgsAnnotationRegistry *QgsApplication::annotationRegistry()
2269 {
2270  return members()->mAnnotationRegistry;
2271 }
2272 
2274 {
2275  return members()->mNumericFormatRegistry;
2276 }
2277 
2279 {
2280  return members()->mFieldFormatterRegistry;
2281 }
2282 
2284 {
2285  return members()->m3DRendererRegistry;
2286 }
2287 
2289 {
2290  return members()->m3DSymbolRegistry;
2291 }
2292 
2294 {
2295  return members()->mScaleBarRendererRegistry;
2296 }
2297 
2299 {
2300  return members()->mProjectStorageRegistry;
2301 }
2302 
2304 {
2305  return members()->mLocalizedDataPathRegistry;
2306 }
2307 
2308 QgsApplication::ApplicationMembers::ApplicationMembers()
2309 {
2310  // don't use initializer lists or scoped pointers - as more objects are added here we
2311  // will need to be careful with the order of creation/destruction
2312  mLocalizedDataPathRegistry = new QgsLocalizedDataPathRegistry();
2313  mMessageLog = new QgsMessageLog();
2314  QgsRuntimeProfiler *profiler = QgsRuntimeProfiler::threadLocalInstance();
2315 
2316  {
2317  profiler->start( tr( "Create connection registry" ) );
2318  mConnectionRegistry = new QgsConnectionRegistry();
2319  profiler->end();
2320  }
2321  {
2322  profiler->start( tr( "Setup task manager" ) );
2323  mTaskManager = new QgsTaskManager();
2324  profiler->end();
2325  }
2326  {
2327  profiler->start( tr( "Setup action scope registry" ) );
2328  mActionScopeRegistry = new QgsActionScopeRegistry();
2329  profiler->end();
2330  }
2331  {
2332  profiler->start( tr( "Setup numeric formats" ) );
2333  mNumericFormatRegistry = new QgsNumericFormatRegistry();
2334  profiler->end();
2335  }
2336  {
2337  profiler->start( tr( "Setup field formats" ) );
2338  mFieldFormatterRegistry = new QgsFieldFormatterRegistry();
2339  profiler->end();
2340  }
2341  {
2342  profiler->start( tr( "Setup SVG cache" ) );
2343  mSvgCache = new QgsSvgCache();
2344  profiler->end();
2345  }
2346  {
2347  profiler->start( tr( "Setup image cache" ) );
2348  mImageCache = new QgsImageCache();
2349  profiler->end();
2350  }
2351  {
2352  profiler->start( tr( "Setup source cache" ) );
2353  mSourceCache = new QgsSourceCache();
2354  profiler->end();
2355  }
2356  {
2357  profiler->start( tr( "Setup color scheme registry" ) );
2358  mColorSchemeRegistry = new QgsColorSchemeRegistry();
2359  profiler->end();
2360  }
2361  {
2362  profiler->start( tr( "Setup paint effect" ) );
2363  mPaintEffectRegistry = new QgsPaintEffectRegistry();
2364  profiler->end();
2365  }
2366  {
2367  profiler->start( tr( "Setup symbol layer registry" ) );
2368  mSymbolLayerRegistry = new QgsSymbolLayerRegistry();
2369  profiler->end();
2370  }
2371  {
2372  profiler->start( tr( "Setup callout registry" ) );
2373  mCalloutRegistry = new QgsCalloutRegistry();
2374  profiler->end();
2375  }
2376  {
2377  profiler->start( tr( "Setup renderer registry" ) );
2378  mRendererRegistry = new QgsRendererRegistry();
2379  profiler->end();
2380  }
2381  {
2382  profiler->start( tr( "Setup raster renderer registry" ) );
2383  mRasterRendererRegistry = new QgsRasterRendererRegistry();
2384  profiler->end();
2385  }
2386  {
2387  profiler->start( tr( "Setup GPS registry" ) );
2388  mGpsConnectionRegistry = new QgsGpsConnectionRegistry();
2389  profiler->end();
2390  }
2391  {
2392  profiler->start( tr( "Setup plugin layer registry" ) );
2393  mPluginLayerRegistry = new QgsPluginLayerRegistry();
2394  profiler->end();
2395  }
2396  {
2397  profiler->start( tr( "Setup Processing registry" ) );
2398  mProcessingRegistry = new QgsProcessingRegistry();
2399  profiler->end();
2400  }
2401  mPageSizeRegistry = new QgsPageSizeRegistry();
2402  {
2403  profiler->start( tr( "Setup layout item registry" ) );
2404  mLayoutItemRegistry = new QgsLayoutItemRegistry();
2405  mLayoutItemRegistry->populate();
2406  profiler->end();
2407  }
2408  {
2409  profiler->start( tr( "Setup annotation registry" ) );
2410  mAnnotationRegistry = new QgsAnnotationRegistry();
2411  profiler->end();
2412  }
2413  {
2414  profiler->start( tr( "Setup annotation item registry" ) );
2415  mAnnotationItemRegistry = new QgsAnnotationItemRegistry();
2416  mAnnotationItemRegistry->populate();
2417  profiler->end();
2418  }
2419  {
2420  profiler->start( tr( "Setup 3D symbol registry" ) );
2421  m3DSymbolRegistry = new Qgs3DSymbolRegistry();
2422  profiler->end();
2423  }
2424  {
2425  profiler->start( tr( "Setup 3D renderer registry" ) );
2426  m3DRendererRegistry = new Qgs3DRendererRegistry();
2427  profiler->end();
2428  }
2429  {
2430  profiler->start( tr( "Setup project storage registry" ) );
2431  mProjectStorageRegistry = new QgsProjectStorageRegistry();
2432  profiler->end();
2433  }
2434  {
2435  profiler->start( tr( "Setup network content cache" ) );
2436  mNetworkContentFetcherRegistry = new QgsNetworkContentFetcherRegistry();
2437  profiler->end();
2438  }
2439  {
2440  profiler->start( tr( "Setup layout check registry" ) );
2441  mValidityCheckRegistry = new QgsValidityCheckRegistry();
2442  profiler->end();
2443  }
2444  {
2445  profiler->start( tr( "Setup classification registry" ) );
2446  mClassificationMethodRegistry = new QgsClassificationMethodRegistry();
2447  profiler->end();
2448  }
2449  {
2450  profiler->start( tr( "Setup bookmark manager" ) );
2451  mBookmarkManager = new QgsBookmarkManager( nullptr );
2452  profiler->end();
2453  }
2454  {
2455  profiler->start( tr( "Setup scalebar registry" ) );
2456  mScaleBarRendererRegistry = new QgsScaleBarRendererRegistry();
2457  profiler->end();
2458  }
2459 }
2460 
2461 QgsApplication::ApplicationMembers::~ApplicationMembers()
2462 {
2463  delete mStyleModel;
2464  delete mScaleBarRendererRegistry;
2465  delete mValidityCheckRegistry;
2466  delete mActionScopeRegistry;
2467  delete m3DRendererRegistry;
2468  delete m3DSymbolRegistry;
2469  delete mAnnotationRegistry;
2470  delete mColorSchemeRegistry;
2471  delete mFieldFormatterRegistry;
2472  delete mGpsConnectionRegistry;
2473  delete mMessageLog;
2474  delete mPaintEffectRegistry;
2475  delete mPluginLayerRegistry;
2476  delete mProcessingRegistry;
2477  delete mProjectStorageRegistry;
2478  delete mPageSizeRegistry;
2479  delete mAnnotationItemRegistry;
2480  delete mLayoutItemRegistry;
2481  delete mRasterRendererRegistry;
2482  delete mRendererRegistry;
2483  delete mSvgCache;
2484  delete mImageCache;
2485  delete mSourceCache;
2486  delete mCalloutRegistry;
2487  delete mSymbolLayerRegistry;
2488  delete mTaskManager;
2489  delete mNetworkContentFetcherRegistry;
2490  delete mClassificationMethodRegistry;
2491  delete mNumericFormatRegistry;
2492  delete mBookmarkManager;
2493  delete mConnectionRegistry;
2494  delete mLocalizedDataPathRegistry;
2495 }
2496 
2497 QgsApplication::ApplicationMembers *QgsApplication::members()
2498 {
2499  if ( auto *lInstance = instance() )
2500  {
2501  return lInstance->mApplicationMembers;
2502  }
2503  else
2504  {
2505  static QMutex sMemberMutex( QMutex::Recursive );
2506  QMutexLocker lock( &sMemberMutex );
2507  if ( !sApplicationMembers )
2508  sApplicationMembers = new ApplicationMembers();
2509  return sApplicationMembers;
2510  }
2511 }
qgssourcecache.h
QgsApplication::QGIS_ORGANIZATION_NAME
static const char * QGIS_ORGANIZATION_NAME
Definition: qgsapplication.h:151
QgsApplication::setPkgDataPath
static void setPkgDataPath(const QString &pkgDataPath)
Alters pkg data path - used by 3rd party apps.
Definition: qgsapplication.cpp:530
QgsConnectionRegistry
A registry for saved data provider connections, allowing retrieval of saved connections by name and p...
Definition: qgsconnectionregistry.h:39
QgsApplication::rasterRendererRegistry
static QgsRasterRendererRegistry * rasterRendererRegistry()
Returns the application's raster renderer registry, used for managing raster layer renderers.
Definition: qgsapplication.cpp:2153
QgsApplication::osName
static QString osName()
Returns a string name of the operating system QGIS is running on.
Definition: qgsapplication.cpp:1166
QgsGpsConnectionRegistry
A class to register / unregister existing GPS connections such that the information is available to a...
Definition: qgsgpsconnectionregistry.h:37
QgsApplication::processingRegistry
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers,...
Definition: qgsapplication.cpp:2253
qgsscalebarrendererregistry.h
QgsSettings::childKeys
QStringList childKeys() const
Returns a list of all top-level keys that can be read using the QSettings object.
Definition: qgssettings.cpp:128
QgsApplication::rendererRegistry
static QgsRendererRegistry * rendererRegistry()
Returns the application's renderer registry, used for managing vector layer renderers.
Definition: qgsapplication.cpp:2148
qgssvgcache.h
QgsApplication::Cursor
Cursor
The Cursor enum defines constants for QGIS custom cursors.
Definition: qgsapplication.h:362
qgsnumericformatregistry.h
QgsApplication::setMaxThreads
static void setMaxThreads(int maxThreads)
Set maximum concurrent thread count.
Definition: qgsapplication.cpp:2112
QgsSettings::remove
void remove(const QString &key, QgsSettings::Section section=QgsSettings::NoSection)
Removes the setting key and any sub-settings of key in a section.
Definition: qgssettings.cpp:205
QgsException
Defines a QGIS exception class.
Definition: qgsexception.h:35
sqlite3_database_unique_ptr::open
int open(const QString &path)
Opens the database at the specified file path.
Definition: qgssqliteutils.cpp:78
Q_GLOBAL_STATIC_WITH_ARGS
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
Definition: qgsauxiliarystorage.cpp:34
QgsApplication::libraryPath
static QString libraryPath()
Returns the path containing qgis_core, qgis_gui, qgispython (and other) libraries.
Definition: qgsapplication.cpp:1235
qgsruntimeprofiler.h
QgsApplication::~QgsApplication
~QgsApplication() override
Definition: qgsapplication.cpp:388
QgsApplication::pageSizeRegistry
static QgsPageSizeRegistry * pageSizeRegistry()
Returns the application's page size registry, used for managing layout page sizes.
Definition: qgsapplication.cpp:2263
QgsApplication::getThemeIcon
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
Definition: qgsapplication.cpp:626
QgsRuntimeProfiler
Provides a method of recording run time profiles of operations, allowing easy recording of their over...
Definition: qgsruntimeprofiler.h:174
QgsStyleModel
A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle ...
Definition: qgsstylemodel.h:108
QgsApplication::CrossHair
@ CrossHair
Precisely identify a point on the canvas.
Definition: qgsapplication.h:366
QgsApplication::buildOutputPath
static QString buildOutputPath()
Returns path to the build output directory. Valid only when running from build directory.
Definition: qgsapplication.cpp:1652
qgsdataitemproviderregistry.h
QgsApplication::maxThreads
static int maxThreads()
Gets maximum concurrent thread count.
Definition: qgsapplication.cpp:610
QgsSettings::value
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
Definition: qgssettings.cpp:174
QgsNumericFormatRegistry
The QgsNumericFormatRegistry manages registered classes of QgsNumericFormat.
Definition: qgsnumericformatregistry.h:39
QgsRuntimeProfiler::end
void end(const QString &group="startup")
End the current profile event.
Definition: qgsruntimeprofiler.cpp:238
qgslocalizeddatapathregistry.h
QgsApplication::nullRepresentationChanged
void nullRepresentationChanged()
This string is used to represent the value NULL throughout QGIS.
QgsDebugMsgLevel
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
QgsUserProfile::folder
const QString folder() const
The base folder for the user profile.
Definition: qgsuserprofile.cpp:30
qgstaskmanager.h
qgspluginlayerregistry.h
qgsexpression.h
qgsauthmanager.h
QgsAuthManager::instance
static QgsAuthManager * instance()
Enforce singleton pattern.
Definition: qgsauthmanager.cpp:89
QgsApplication::authorsFilePath
static QString authorsFilePath()
Returns the path to the authors file.
Definition: qgsapplication.cpp:941
QgsApplication::Sampler
@ Sampler
Color/Value picker.
Definition: qgsapplication.h:369
QgsSettings::Core
@ Core
Definition: qgssettings.h:70
qgsconnectionregistry.h
QgsApplication::shortNameRegExp
static QRegExp shortNameRegExp()
Returns the short name regular expression for line edit validator.
Definition: qgsapplication.cpp:1092
QgsApplication::annotationRegistry
static QgsAnnotationRegistry * annotationRegistry()
Returns the application's annotation registry, used for managing annotation types.
Definition: qgsapplication.cpp:2268
QgsApplication::notify
bool notify(QObject *receiver, QEvent *event) override
Catch exceptions when sending event to receiver.
Definition: qgsapplication.cpp:444
QgsApplication::i18nPath
static QString i18nPath()
Returns the path to the translation directory.
Definition: qgsapplication.cpp:975
QgsApplication::connectionRegistry
static QgsConnectionRegistry * connectionRegistry()
Returns the application's connection registry, used for managing saved data provider connections.
Definition: qgsapplication.cpp:2258
QgsApplication::createThemeFolder
static bool createThemeFolder()
Create the users theme folder.
Definition: qgsapplication.cpp:1749
QgsApplication::getThemeCursor
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
Definition: qgsapplication.cpp:656
qgsuserprofile.h
QgsApplication::setCustomVariables
static void setCustomVariables(const QVariantMap &customVariables)
Custom expression variables for this application.
Definition: qgsapplication.cpp:1801
qgssymbollayerutils.h
QgsApplication::prefixPath
static QString prefixPath()
Returns the path to the application prefix directory.
Definition: qgsapplication.cpp:555
qgsprojectstorageregistry.h
QgsUserProfileManager::resolveProfilesFolder
static QString resolveProfilesFolder(const QString &basePath=QString())
Resolves the profiles folder for the given path.
Definition: qgsuserprofilemanager.cpp:35
QgsDataItemProviderRegistry
This class keeps a list of data item providers that may add items to the browser tree.
Definition: qgsdataitemproviderregistry.h:40
QgsMessageLogNotifyBlocker
Temporarily blocks the application QgsMessageLog (see QgsApplication::messageLog()) from emitting the...
Definition: qgsmessagelog.h:104
QgsApplication::defaultStylePath
static QString defaultStylePath()
Returns the path to default style (works as a starting point).
Definition: qgsapplication.cpp:1220
QgsApplication::symbol3DRegistry
static Qgs3DSymbolRegistry * symbol3DRegistry()
Returns registry of available 3D symbols.
Definition: qgsapplication.cpp:2288
QgsApplication::init
static void init(QString profileFolder=QString())
This method initializes paths etc for QGIS.
Definition: qgsapplication.cpp:198
QgsSvgCache::svgAsImage
QImage svgAsImage(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, bool &fitsInCache, double fixedAspectRatio=0, bool blocking=false)
Gets SVG as QImage.
Definition: qgssvgcache.cpp:122
qgsfieldformatterregistry.h
QgsActionScopeRegistry
The action scope registry is an application wide registry that contains a list of available action sc...
Definition: qgsactionscoperegistry.h:44
QgsApplication::qgisAuthDatabaseFilePath
static QString qgisAuthDatabaseFilePath()
Returns the path to the user authentication database file: qgis-auth.db.
Definition: qgsapplication.cpp:1003
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:468
QgsApplication::setFileOpenEventReceiver
static void setFileOpenEventReceiver(QObject *receiver)
Sets the FileOpen event receiver.
Definition: qgsapplication.cpp:487
QgsApplication::gpsConnectionRegistry
static QgsGpsConnectionRegistry * gpsConnectionRegistry()
Returns the application's GPS connection registry, used for managing GPS connections.
Definition: qgsapplication.cpp:2223
QgsApplication::svgPaths
static QStringList svgPaths()
Returns the paths to svg directories.
Definition: qgsapplication.cpp:1049
QgsApplication::colorSchemeRegistry
static QgsColorSchemeRegistry * colorSchemeRegistry()
Returns the application's color scheme registry, used for managing color schemes.
Definition: qgsapplication.cpp:2138
qgsunittypes.h
QgsBookmarkManager
Manages storage of a set of bookmarks.
Definition: qgsbookmarkmanager.h:145
QgsSymbolLayerRegistry
Registry of available symbol layer classes.
Definition: qgssymbollayerregistry.h:145
QgsSettings
This class is a composition of two QSettings instances:
Definition: qgssettings.h:62
QgsApplication::setNullRepresentation
static void setNullRepresentation(const QString &nullRepresentation)
This string is used to represent the value NULL throughout QGIS.
Definition: qgsapplication.cpp:1861
qgspainteffectregistry.h
QgsPageSizeRegistry
A registry for known page sizes.
Definition: qgspagesizeregistry.h:74
qgsrasterrendererregistry.h
qgsactionscoperegistry.h
qgsgpsconnectionregistry.h
QgsApplication::instance
static QgsApplication * instance()
Returns the singleton instance of the QgsApplication.
Definition: qgsapplication.cpp:411
QgsApplication::projectStorageRegistry
static QgsProjectStorageRegistry * projectStorageRegistry()
Returns registry of available project storage implementations.
Definition: qgsapplication.cpp:2298
QgsApplication::appIconPath
static QString appIconPath()
Gets application icon.
Definition: qgsapplication.cpp:605
QgsApplication::sponsorsFilePath
static QString sponsorsFilePath()
Returns the path to the sponsors file.
Definition: qgsapplication.cpp:955
QgsDebugMsg
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
QgsApplication::actionScopeRegistry
static QgsActionScopeRegistry * actionScopeRegistry()
Returns the action scope registry.
Definition: qgsapplication.cpp:1875
QgsApplication::iconPath
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
Definition: qgsapplication.cpp:615
QgsApplication::registerOgrDrivers
static void registerOgrDrivers()
Register OGR drivers ensuring this only happens once.
Definition: qgsapplication.cpp:1514
QgsApplication::preNotify
void preNotify(QObject *receiver, QEvent *event, bool *done)
QgsSymbolLayerUtils::decodeColor
static QColor decodeColor(const QString &str)
Definition: qgssymbollayerutils.cpp:57
qgsnewsfeedparser.h
qgs3dsymbolregistry.h
Q_GLOBAL_STATIC
Q_GLOBAL_STATIC(QReadWriteLock, sDefinitionCacheLock)
QgsCoordinateTransform::invalidateCache
static void invalidateCache(bool disableCache=false)
Clears the internal cache used to initialize QgsCoordinateTransform objects.
Definition: qgscoordinatetransform.cpp:1099
pal
Definition: qgsdiagramrenderer.h:49
qgsannotationregistry.h
QgsApplication::platform
static QString platform()
Returns the QGIS platform name, e.g., "desktop" or "server".
Definition: qgsapplication.cpp:1189
QgsApplication::symbolLayerRegistry
static QgsSymbolLayerRegistry * symbolLayerRegistry()
Returns the application's symbol layer registry, used for managing symbol layers.
Definition: qgsapplication.cpp:2203
QgsApplication::skipGdalDriver
static void skipGdalDriver(const QString &driver)
Sets the GDAL_SKIP environment variable to include the specified driver and then calls GDALDriverMana...
Definition: qgsapplication.cpp:1664
QgsApplication::authManager
static QgsAuthManager * authManager()
Returns the application's authentication manager instance.
Definition: qgsapplication.cpp:1282
QgsApplication::requestForTranslatableObjects
void requestForTranslatableObjects(QgsTranslationContext *translationContext)
Emitted when project strings which require translation are being collected for inclusion in a ....
QgsStyle::defaultStyle
static QgsStyle * defaultStyle()
Returns default application-wide style.
Definition: qgsstyle.cpp:127
QgsApplication::getThemePixmap
static QPixmap getThemePixmap(const QString &name, const QColor &foreColor=QColor(), const QColor &backColor=QColor(), int size=16)
Helper to get a theme icon as a pixmap.
Definition: qgsapplication.cpp:721
QgsApplication::locale
static QString locale()
Returns the QGIS locale.
Definition: qgsapplication.cpp:1194
QgsCalloutRegistry
Registry of available callout classes.
Definition: qgscalloutsregistry.h:156
qgsapplication.h
QgsApplication::srsDatabaseFilePath
static QString srsDatabaseFilePath()
Returns the path to the srs.db file.
Definition: qgsapplication.cpp:1018
qgsnetworkcontentfetcherregistry.h
QgsApplication::initQgis
static void initQgis()
loads providers
Definition: qgsapplication.cpp:1255
Qgs3DRendererRegistry
Keeps track of available 3D renderers.
Definition: qgs3drendererregistry.h:70
QgsApplication::qgisSettingsDirPath
static QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
Definition: qgsapplication.cpp:993
QgsApplication::messageLog
static QgsMessageLog * messageLog()
Returns the application's message log.
Definition: qgsapplication.cpp:2248
QgsApplication::relativePathToAbsolutePath
static QString relativePathToAbsolutePath(const QString &rpath, const QString &targetPath)
Converts path relative to target to an absolute path.
Definition: qgsapplication.cpp:1592
qgsproviderregistry.h
QgsApplication::XDR
@ XDR
Definition: qgsapplication.h:486
QgsUserProfileManager::getProfile
QgsUserProfile * getProfile(const QString &defaultProfile="default", bool createNew=true, bool initSettings=true)
Returns the profile from the given root profile location.
Definition: qgsuserprofilemanager.cpp:40
QgsApplication::qgisMasterDatabaseFilePath
static QString qgisMasterDatabaseFilePath()
Returns the path to the master qgis.db file.
Definition: qgsapplication.cpp:988
QgsApplication::iconsPath
static QString iconsPath()
Returns the path to the icons image directory.
Definition: qgsapplication.cpp:1013
QgsMessageLog
Interface for logging messages from QGIS in GUI independent way.
Definition: qgsmessagelog.h:39
QgsAuthManager
Singleton offering an interface to manage the authentication configuration database and to utilize co...
Definition: qgsauthmanager.h:65
QgsApplication::metadataPath
static QString metadataPath()
Returns the path to the metadata directory.
Definition: qgsapplication.cpp:983
QgsApplication::nullRepresentation
static QString nullRepresentation()
This string is used to represent the value NULL throughout QGIS.
Definition: qgsapplication.cpp:1851
QgsClassificationMethodRegistry
This class manages all known classification methods.
Definition: qgsclassificationmethodregistry.h:39
QgsApplication::exitQgis
static void exitQgis()
deletes provider registry and map layer registry
Definition: qgsapplication.cpp:1302
QgsApplication::contributorsFilePath
static QString contributorsFilePath()
Returns the path to the contributors file.
Definition: qgsapplication.cpp:946
qgscalloutsregistry.h
QgsApplication::layoutTemplatePaths
static QStringList layoutTemplatePaths()
Returns the paths to layout template directories.
Definition: qgsapplication.cpp:1072
QgsApplication::developersMapFilePath
static QString developersMapFilePath()
Returns the path to the developers map file.
Definition: qgsapplication.cpp:950
qgsnetworkaccessmanager.h
QgsSvgCache
A cache for images / pictures derived from svg files.
Definition: qgssvgcache.h:108
QgsException::what
QString what() const
Definition: qgsexception.h:48
QgsColorSchemeRegistry::addDefaultSchemes
void addDefaultSchemes()
Adds all default color schemes to this color scheme.
Definition: qgscolorschemeregistry.cpp:45
qgssymbollayerregistry.h
QgsApplication::setUITheme
static void setUITheme(const QString &themeName)
Set the current UI theme used to style the interface.
Definition: qgsapplication.cpp:827
QgsApplication::defaultStyleModel
static QgsStyleModel * defaultStyleModel()
Returns a shared QgsStyleModel containing the default style library (see QgsStyle::defaultStyle()).
Definition: qgsapplication.cpp:2243
QgsApplication::dataItemProviderRegistry
static QgsDataItemProviderRegistry * dataItemProviderRegistry()
Returns the application's data item provider registry, which keeps a list of data item providers that...
Definition: qgsapplication.cpp:2158
qgsrendererregistry.h
QgsTaskManager
Task manager for managing a set of long-running QgsTask tasks.
Definition: qgstaskmanager.h:389
QgsApplication::taskManager
static QgsTaskManager * taskManager()
Returns the application's task manager, used for managing application wide background task handling.
Definition: qgsapplication.cpp:2133
QgsApplication::imageCache
static QgsImageCache * imageCache()
Returns the application's image cache, used for caching resampled versions of raster images.
Definition: qgsapplication.cpp:2183
CONN_POOL_MAX_CONCURRENT_CONNS
#define CONN_POOL_MAX_CONCURRENT_CONNS
Definition: qgsapplication.cpp:120
QgsApplication::createDatabase
static bool createDatabase(QString *errorMessage=nullptr)
initialize qgis.db
Definition: qgsapplication.cpp:1880
QgsApplication::collectTranslatableObjects
void collectTranslatableObjects(QgsTranslationContext *translationContext)
Emits the signal to collect all the strings of .qgs to be included in ts file.
Definition: qgsapplication.cpp:1846
QgsStyle::cleanDefaultStyle
static void cleanDefaultStyle()
Deletes the default style. Only to be used by QgsApplication::exitQgis()
Definition: qgsstyle.cpp:156
QgsApplication::profiler
static QgsRuntimeProfiler * profiler()
Returns the application runtime profiler.
Definition: qgsapplication.cpp:482
QgsApplication::endian
static endian_t endian()
Returns whether this machine uses big or little endian.
Definition: qgsapplication.cpp:1250
QgsApplication::endian_t
endian_t
Constants for endian-ness.
Definition: qgsapplication.h:485
QgsApplication::customVariablesChanged
void customVariablesChanged()
Emitted whenever a custom global variable changes.
QgsPaintEffectRegistry
Registry of available paint effects.
Definition: qgspainteffectregistry.h:175
Qgis::UI_SCALE_FACTOR
static const double UI_SCALE_FACTOR
UI scaling factor.
Definition: qgis.h:182
QgsSourceCache
A cache for source strings that returns a local file path containing the source content.
Definition: qgssourcecache.h:71
QgsApplication::validityCheckRegistry
static QgsValidityCheckRegistry * validityCheckRegistry()
Returns the application's validity check registry, used for managing validity checks.
Definition: qgsapplication.cpp:2198
QgsApplication::sourceCache
static QgsSourceCache * sourceCache()
Returns the application's source cache, used for caching embedded and remote source strings as local ...
Definition: qgsapplication.cpp:2188
QgsApplication::setCustomVariable
static void setCustomVariable(const QString &name, const QVariant &value)
Set a single custom expression variable.
Definition: qgsapplication.cpp:1816
QgsApplication::setAuthDatabaseDirPath
static void setAuthDatabaseDirPath(const QString &authDbDirPath)
Alters authentication data base directory path - used by 3rd party apps.
Definition: qgsapplication.cpp:546
QgsTranslationContext
Used for the collecting of strings from projects for translation and creation of ts files.
Definition: qgstranslationcontext.h:36
qgsstylemodel.h
QgsApplication::setThemeName
static void setThemeName(const QString &themeName)
Set the active theme to the specified theme.
Definition: qgsapplication.cpp:736
QgsApplication::QGIS_APPLICATION_NAME
static const char * QGIS_APPLICATION_NAME
Definition: qgsapplication.h:153
QgsApplication::event
bool event(QEvent *event) override
Watch for QFileOpenEvent.
Definition: qgsapplication.cpp:416
QgsScaleBarRendererRegistry
The QgsScaleBarRendererRegistry manages registered scalebar renderers.
Definition: qgsscalebarrendererregistry.h:34
QgsApplication::Select
@ Select
Select a rectangle.
Definition: qgsapplication.h:368
QgsApplication::pkgDataPath
static QString pkgDataPath()
Returns the common root path of all application data directories.
Definition: qgsapplication.cpp:578
QgsSettings::setValue
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Definition: qgssettings.cpp:289
QgsApplication::buildSourcePath
static QString buildSourcePath()
Returns path to the source directory. Valid only when running from build directory.
Definition: qgsapplication.cpp:1647
QgsApplication::classificationMethodRegistry
static QgsClassificationMethodRegistry * classificationMethodRegistry()
Returns the application's classification methods registry, used in graduated renderer.
Definition: qgsapplication.cpp:2233
QgsApplication::bookmarkManager
static QgsBookmarkManager * bookmarkManager()
Returns the application's bookmark manager, used for storing installation-wide bookmarks.
Definition: qgsapplication.cpp:2238
QgsRuntimeProfiler::start
void start(const QString &name, const QString &group="startup")
Start a profile event with the given name.
Definition: qgsruntimeprofiler.cpp:206
QgsAnnotationItemRegistry
Registry of available annotation item types.
Definition: qgsannotationitemregistry.h:143
QgsApplication::StyleSheetType
StyleSheetType
The StyleSheetType enum represents the stylesheet type that a widget supports.
Definition: qgsapplication.h:146
qgs3drendererregistry.h
QgsApplication::userStylePath
static QString userStylePath()
Returns the path to user's style.
Definition: qgsapplication.cpp:1087
QgsApplication
Extends QApplication to provide access to QGIS specific resources such as theme paths,...
Definition: qgsapplication.h:83
QgsNetworkAccessManager::instance
static QgsNetworkAccessManager * instance(Qt::ConnectionType connectionType=Qt::BlockingQueuedConnection)
Returns a pointer to the active QgsNetworkAccessManager for the current thread.
Definition: qgsnetworkaccessmanager.cpp:121
qgspagesizeregistry.h
QgsApplication::svgCache
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
Definition: qgsapplication.cpp:2178
QgsApplication::fieldFormatterRegistry
static QgsFieldFormatterRegistry * fieldFormatterRegistry()
Gets the registry of available field formatters.
Definition: qgsapplication.cpp:2278
qgsstyle.h
QgsApplication::themeName
static QString themeName()
Set the active theme to the specified theme.
Definition: qgsapplication.cpp:822
qgsmeshlayer.h
QgsApplication::registerGdalDriversFromSettings
static void registerGdalDriversFromSettings()
Register gdal drivers, excluding the ones mentioned in "gdal/skipList" setting.
Definition: qgsapplication.cpp:1705
QgsCoordinateReferenceSystem::invalidateCache
static void invalidateCache(bool disableCache=false)
Clears the internal cache used to initialize QgsCoordinateReferenceSystem objects.
Definition: qgscoordinatereferencesystem.cpp:3656
QgsColorSchemeRegistry
Registry of color schemes.
Definition: qgscolorschemeregistry.h:35
QgsApplication::setDefaultSvgPaths
static void setDefaultSvgPaths(const QStringList &pathList)
Alters default svg paths - used by 3rd party apps.
Definition: qgsapplication.cpp:541
QgsApplication::setSkippedGdalDrivers
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 ...
Definition: qgsapplication.cpp:1693
qgsreferencedgeometry.h
QgsApplication::userLoginName
static QString userLoginName()
Returns the user's operating system login account name.
Definition: qgsapplication.cpp:1097
QgsLocalizedDataPathRegistry
A registry class to hold localized data paths which can be used for basemaps, logos,...
Definition: qgslocalizeddatapathregistry.h:42
QgsApplication::layoutItemRegistry
static QgsLayoutItemRegistry * layoutItemRegistry()
Returns the application's layout item registry, used for layout item types.
Definition: qgsapplication.cpp:2213
QgsStringMap
QMap< QString, QString > QgsStringMap
Definition: qgis.h:758
qgslayoutrendercontext.h
qgsgeometry.h
QgsSettings::beginGroup
void beginGroup(const QString &prefix, QgsSettings::Section section=QgsSettings::NoSection)
Appends prefix to the current group.
Definition: qgssettings.cpp:87
QgsApplication::paintEffectRegistry
static QgsPaintEffectRegistry * paintEffectRegistry()
Returns the application's paint effect registry, used for managing paint effects.
Definition: qgsapplication.cpp:2143
QgsProjectStorageRegistry
Registry of storage backends that QgsProject may use.
Definition: qgsprojectstorageregistry.h:34
QgsApplication::renderer3DRegistry
static Qgs3DRendererRegistry * renderer3DRegistry()
Returns registry of available 3D renderers.
Definition: qgsapplication.cpp:2283
qgsuserprofilemanager.h
QgsRasterRendererRegistry
Registry for raster renderers.
Definition: qgsrasterrendererregistry.h:70
QgsApplication::maxConcurrentConnectionsPerPool
int maxConcurrentConnectionsPerPool() const
The maximum number of concurrent connections per connections pool.
Definition: qgsapplication.cpp:1836
QgsApplication::libexecPath
static QString libexecPath()
Returns the path with utility executables (help viewer, crssync, ...)
Definition: qgsapplication.cpp:1240
Qgs3DSymbolRegistry
Registry of available 3D symbol classes.
Definition: qgs3dsymbolregistry.h:184
QgsApplication::licenceFilePath
static QString licenceFilePath()
Returns the path to the licence file.
Definition: qgsapplication.cpp:970
QgsApplication::ZoomIn
@ ZoomIn
Zoom in.
Definition: qgsapplication.h:363
QgsApplication::deferredSkippedGdalDrivers
static QStringList deferredSkippedGdalDrivers()
Returns the list of gdal drivers that have been disabled in the current session, and thus,...
Definition: qgsapplication.cpp:1728
qgsimagecache.h
qgsprojutils.h
QgsApplication::Identify
@ Identify
Identify: obtain information about the object.
Definition: qgsapplication.h:365
qgsnetworkreply.h
QgsApplication::resolvePkgPath
static QString resolvePkgPath()
Calculate the application pkg path.
Definition: qgsapplication.cpp:741
QgsApplication::NDR
@ NDR
Definition: qgsapplication.h:487
QgsApplication::scaleIconSize
static int scaleIconSize(int standardSize, bool applyDevicePixelRatio=false)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...
Definition: qgsapplication.cpp:1826
QgsScopedRuntimeProfile
Scoped object for logging of the runtime for a single operation or group of operations.
Definition: qgsruntimeprofiler.h:328
qgssettings.h
QgsApplication::systemEnvVars
static QMap< QString, QString > systemEnvVars()
Returns the system environment variables passed to application.
Definition: qgsapplication.cpp:1082
qgscolorschemeregistry.h
QgsUserProfile
User profile contains information about the user profile folders on the machine.
Definition: qgsuserprofile.h:35
qgsvaliditycheckregistry.h
QgsApplication::setPluginPath
static void setPluginPath(const QString &pluginPath)
Alters plugin path - used by 3rd party apps.
Definition: qgsapplication.cpp:525
QgsApplication::qgisUserDatabaseFilePath
static QString qgisUserDatabaseFilePath()
Returns the path to the user qgis.db file.
Definition: qgsapplication.cpp:998
ABISYM
QObject * ABISYM(QgsApplication::mFileOpenEventReceiver)
QgsApplication::CapturePoint
@ CapturePoint
Select and capture a point or a feature.
Definition: qgsapplication.h:367
QgsApplication::numericFormatRegistry
static QgsNumericFormatRegistry * numericFormatRegistry()
Gets the registry of available numeric formats.
Definition: qgsapplication.cpp:2273
QgsApplication::calloutRegistry
static QgsCalloutRegistry * calloutRegistry()
Returns the application's callout registry, used for managing callout types.
Definition: qgsapplication.cpp:2208
QgsApplication::activeThemePath
static QString activeThemePath()
Returns the path to the currently active theme directory.
Definition: qgsapplication.cpp:590
QgsBookmarkManager::initialize
void initialize(const QString &filePath)
Initializes the bookmark manager.
Definition: qgsbookmarkmanager.cpp:494
QgsApplication::userThemesFolder
static QString userThemesFolder()
Returns the path to user's themes folder.
Definition: qgsapplication.cpp:1215
qgssqliteutils.h
QgsApplication::customVariables
static QVariantMap customVariables()
Custom expression variables for this application.
Definition: qgsapplication.cpp:1782
QgsApplication::localizedDataPathRegistry
static QgsLocalizedDataPathRegistry * localizedDataPathRegistry()
Returns the registry of data repositories These are used as paths for basemaps, logos,...
Definition: qgsapplication.cpp:2303
QgsApplication::defaultThemesFolder
static QString defaultThemesFolder()
Returns the path to default themes folder from install (works as a starting point).
Definition: qgsapplication.cpp:1225
QgsProcessingRegistry
Registry for various processing components, including providers, algorithms and various parameters an...
Definition: qgsprocessingregistry.h:40
QgsColorSchemeRegistry::initStyleScheme
void initStyleScheme()
Initializes the default random style color scheme for the user.
Definition: qgscolorschemeregistry.cpp:54
qgsannotationitemregistry.h
QgsApplication::splashPath
static QString splashPath()
Returns the path to the splash screen image directory.
Definition: qgsapplication.cpp:1008
qgsexception.h
qgsremappingproxyfeaturesink.h
QgsSettings::contains
bool contains(const QString &key, QgsSettings::Section section=QgsSettings::NoSection) const
Returns true if there exists a setting called key; returns false otherwise.
Definition: qgssettings.cpp:188
qgsbookmarkmanager.h
QgsApplication::setPrefixPath
static void setPrefixPath(const QString &prefixPath, bool useDefaultPaths=false)
Alters prefix path - used by 3rd party apps.
Definition: qgsapplication.cpp:504
QgsApplication::translatorsFilePath
static QString translatorsFilePath()
Returns the path to the sponsors file.
Definition: qgsapplication.cpp:965
QgsProjUtils::searchPaths
static QStringList searchPaths()
Returns the current list of Proj file search paths.
Definition: qgsprojutils.cpp:313
QgsLayoutItemRegistry
Registry of available layout item types.
Definition: qgslayoutitemregistry.h:300
qgslogger.h
QgsApplication::donorsFilePath
static QString donorsFilePath()
Returns the path to the donors file.
Definition: qgsapplication.cpp:960
QgsAuthManager::init
bool init(const QString &pluginPath=QString(), const QString &authDatabasePath=QString())
init initialize QCA, prioritize qca-ossl plugin and optionally set up the authentication database
Definition: qgsauthmanager.cpp:172
QgsApplication::qmlImportPath
static QString qmlImportPath()
Returns the path where QML components are installed for QGIS Quick library.
Definition: qgsapplication.cpp:1245
qgsfeaturestore.h
QgsImageCache
A cache for images derived from raster files.
Definition: qgsimagecache.h:97
QgsExpression::cleanRegisteredFunctions
static void cleanRegisteredFunctions()
Deletes all registered functions whose ownership have been transferred to the expression engine.
Definition: qgsexpressionfunction.cpp:7007
QgsApplication::skippedGdalDrivers
static QStringList skippedGdalDrivers()
Returns the list of gdal drivers that should be skipped (based on GDAL_SKIP environment variable)
Definition: qgsapplication.cpp:1688
QgsRendererRegistry
Registry of renderers.
Definition: qgsrendererregistry.h:225
sqlite3_database_unique_ptr
Unique pointer for sqlite3 databases, which automatically closes the database when the pointer goes o...
Definition: qgssqliteutils.h:119
qgslayoutitemregistry.h
QgsApplication::pluginLayerRegistry
static QgsPluginLayerRegistry * pluginLayerRegistry()
Returns the application's plugin layer registry, used for managing plugin layer types.
Definition: qgsapplication.cpp:2228
qgsclassificationmethodregistry.h
QgsEllipsoidUtils::invalidateCache
static void invalidateCache(bool disableCache=false)
Clears the internal cache used.
Definition: qgsellipsoidutils.cpp:499
QgsProviderRegistry::instance
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
Definition: qgsproviderregistry.cpp:48
QgsValidityCheckRegistry
This class keeps a list of QgsAbstractValidityCheck checks which can be used when performing validity...
Definition: qgsvaliditycheckregistry.h:37
QgsApplication::applyGdalSkippedDrivers
static void applyGdalSkippedDrivers()
Apply the skipped drivers list to gdal.
Definition: qgsapplication.cpp:1733
QgsApplication::QGIS_ORGANIZATION_DOMAIN
static const char * QGIS_ORGANIZATION_DOMAIN
Definition: qgsapplication.h:152
qgsprocessingregistry.h
QgsApplication::reportStyleSheet
static QString reportStyleSheet(QgsApplication::StyleSheetType styleSheetType=QgsApplication::StyleSheetType::Qt)
Returns a css style sheet for reports, the styleSheetType argument determines what type of stylesheet...
Definition: qgsapplication.cpp:1363
QgsApplication::defaultThemePath
static QString defaultThemePath()
Returns the path to the default theme directory.
Definition: qgsapplication.cpp:586
QgsPluginLayerRegistry
A registry of plugin layers types.
Definition: qgspluginlayerregistry.h:69
QgsApplication::networkContentFetcherRegistry
static QgsNetworkContentFetcherRegistry * networkContentFetcherRegistry()
Returns the application's network content registry used for fetching temporary files during QGIS sess...
Definition: qgsapplication.cpp:2193
qgsproject.h
QgsFieldFormatterRegistry
The QgsFieldFormatterRegistry manages registered classes of QgsFieldFormatter.
Definition: qgsfieldformatterregistry.h:38
QgsApplication::uiThemes
static QHash< QString, QString > uiThemes()
All themes found in ~/.qgis3/themes folder.
Definition: qgsapplication.cpp:916
QgsUserProfileManager
User profile manager is used to manager list, and manage user profiles on the users machine.
Definition: qgsuserprofilemanager.h:42
QgsApplication::restoreGdalDriver
static void restoreGdalDriver(const QString &driver)
Sets the GDAL_SKIP environment variable to exclude the specified driver and then calls GDALDriverMana...
Definition: qgsapplication.cpp:1674
QgsApplication::ZoomOut
@ ZoomOut
Zoom out.
Definition: qgsapplication.h:364
QgsApplication::absolutePathToRelativePath
static QString absolutePathToRelativePath(const QString &apath, const QString &targetPath)
Converts absolute path to path relative to target.
Definition: qgsapplication.cpp:1522
QgsApplication::pluginPath
static QString pluginPath()
Returns the path to the application plugin directory.
Definition: qgsapplication.cpp:573
QgsApplication::serverResourcesPath
static QString serverResourcesPath()
Returns the path to the server resources directory.
Definition: qgsapplication.cpp:1230
QgsApplication::annotationItemRegistry
static QgsAnnotationItemRegistry * annotationItemRegistry()
Returns the application's annotation item registry, used for annotation item types.
Definition: qgsapplication.cpp:2218
QgsApplication::userFullName
static QString userFullName()
Returns the user's operating system login account full display name.
Definition: qgsapplication.cpp:1132
QgsApplication::setTranslation
static void setTranslation(const QString &translation)
Set translation.
Definition: qgsapplication.cpp:1841
qgsmessagelog.h
QgsNetworkContentFetcherRegistry
Registry for temporary fetched files.
Definition: qgsnetworkcontentfetcherregistry.h:124
QgsApplication::scaleBarRendererRegistry
static QgsScaleBarRendererRegistry * scaleBarRendererRegistry()
Gets the registry of available scalebar renderers.
Definition: qgsapplication.cpp:2293
QgsApplication::showSettings
static QString showSettings()
Convenience function to get a summary of the paths used in this application instance useful for debug...
Definition: qgsapplication.cpp:1336