15 #ifndef QGSAPPLICATION_H
16 #define QGSAPPLICATION_H
18 #include "qgis_core.h"
19 #include <QApplication>
21 #include <QStringList>
26 #include "qgsconfig.h"
55 class QgsAnnotationRegistry;
97 static char **qtgui_ArgvToC( PyObject *argvlist,
int &argc )
101 argc = PyList_GET_SIZE( argvlist );
105 if ( ( argv = (
char ** )sipMalloc( 2 * ( argc + 1 ) *
sizeof(
char * ) ) ) == NULL )
109 for (
int a = 0; a < argc; ++a )
113 if ( ( arg = PyBytes_AsString( PyList_GET_ITEM( argvlist, a ) ) ) == NULL ||
114 ( argv[a] = (
char * )sipMalloc( strlen( arg ) + 1 ) ) == NULL )
117 strcpy( argv[a], arg );
118 argv[a + argc + 1] = argv[a];
121 argv[argc + argc + 1] = argv[argc] = NULL;
128 static void qtgui_UpdatePyArgv( PyObject *argvlist,
int argc,
char **argv )
130 for (
int a = 0, na = 0; a < argc; ++a )
133 if ( argv[na] == argv[a + argc + 1] )
136 PyList_SetSlice( argvlist, na, na + 1, NULL );
174 QgsApplication(
int &argc,
char **argv,
bool GUIenabled,
const QString &profileFolder = QString(),
const QString &platformName =
"external" );
185 QgsApplication( SIP_PYLIST argv,
bool GUIenabled, QString profileFolder = QString(), QString platformName =
"external" ) / PostHook = __pyQtQAppHook__ / [(
int &argc,
char **argv,
bool GUIenabled,
const QString &profileFolder = QString(),
const QString &platformName =
"desktop" )];
193 if ( ( argv = qtgui_ArgvToC( a0, argc ) ) == NULL )
198 static int nargc = argc;
200 sipCpp =
new sipQgsApplication( nargc, argv, a1, *a2, *a3 );
203 qtgui_UpdatePyArgv( a0, argc, argv );
224 static void init( QString profileFolder = QString() )
SIP_SKIP;
227 bool event( QEvent *event ) override;
230 bool notify( QObject *receiver, QEvent *event ) override;
233 static
void setFileOpenEventReceiver( QObject *receiver );
245 static
void setThemeName( const QString &themeName );
251 static QString resolvePkgPath();
260 static QString themeName();
269 static
void setUITheme( const QString &themeName );
277 static QHash<QString, QString> uiThemes();
280 static QString authorsFilePath();
287 static QString contributorsFilePath();
295 static QString developersMapFilePath();
298 static QString sponsorsFilePath();
301 static QString donorsFilePath();
304 static QString serverResourcesPath();
309 static QString translatorsFilePath();
314 static QString licenceFilePath();
317 static QString i18nPath();
323 static QString metadataPath();
326 static QString qgisMasterDatabaseFilePath();
329 static QString qgisSettingsDirPath();
332 static QString qgisUserDatabaseFilePath();
335 static QString qgisAuthDatabaseFilePath();
338 static QString splashPath();
341 static QString iconsPath();
344 static QString srsDatabaseFilePath();
351 static
void setSvgPaths( const QStringList &svgPaths );
354 static QStringList svgPaths();
360 static QStringList layoutTemplatePaths();
363 static QMap<QString, QString> systemEnvVars();
366 static QString prefixPath();
369 static QString pluginPath();
372 static QString pkgDataPath();
375 static QString activeThemePath();
378 static QString defaultThemePath();
384 static QString iconPath( const QString &iconFile );
393 static QIcon getThemeIcon( const QString &name, const QColor &fillColor = QColor(), const QColor &strokeColor = QColor() );
416 static QCursor getThemeCursor( Cursor cursor );
426 static QPixmap getThemePixmap(
const QString &name,
const QColor &foreColor = QColor(),
const QColor &backColor = QColor(),
int size = 16 );
429 static QString userStylePath();
436 static QRegularExpression shortNameRegularExpression();
443 static QString userLoginName();
450 static QString userFullName();
457 static QString osName();
466 static int systemMemorySizeMb();
473 static QString platform();
479 static QString locale();
487 static void setLocale(
const QLocale &locale );
490 static QString userThemesFolder();
493 static QString defaultStylePath();
496 static QString defaultThemesFolder();
499 static QString libraryPath();
502 static QString libexecPath();
510 static QString qmlImportPath();
513 static void setPrefixPath(
const QString &prefixPath,
bool useDefaultPaths =
false );
516 static void setPluginPath(
const QString &pluginPath );
519 static void setPkgDataPath(
const QString &pkgDataPath );
522 static void setDefaultSvgPaths(
const QStringList &pathList );
525 static void setAuthDatabaseDirPath(
const QString &authDbDirPath );
528 static void initQgis();
531 static bool createDatabase( QString *errorMessage =
nullptr );
534 static bool createThemeFolder();
537 static void exitQgis();
540 static QString appIconPath();
550 static endian_t endian();
572 static QString showSettings();
581 static void registerOgrDrivers();
584 static QString absolutePathToRelativePath(
const QString &apath,
const QString &targetPath );
586 static QString relativePathToAbsolutePath(
const QString &rpath,
const QString &targetPath );
590 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
591 static QString cfgIntDir()
SIP_SKIP;
593 static QString buildSourcePath();
596 static QString buildOutputPath();
603 static void skipGdalDriver(
const QString &driver );
610 static void restoreGdalDriver(
const QString &driver );
616 static QStringList skippedGdalDrivers();
624 static void applyGdalSkippedDrivers();
630 static void registerGdalDriversFromSettings();
638 static QStringList deferredSkippedGdalDrivers();
646 static void setSkippedGdalDrivers(
const QStringList &skippedGdalDrivers,
647 const QStringList &deferredSkippedGdalDrivers );
653 static int maxThreads();
660 static void setMaxThreads(
int maxThreads );
872 static QgsAnnotationRegistry *annotationRegistry()
SIP_SKIP;
953 static QString nullRepresentation();
958 static
void setNullRepresentation( const QString &nullRepresentation );
967 static QVariantMap customVariables();
976 static
void setCustomVariables( const QVariantMap &customVariables );
983 static
void setCustomVariable( const QString &name, const QVariant &value );
994 static
int scaleIconSize(
int standardSize,
bool applyDevicePixelRatio = false );
1004 int maxConcurrentConnectionsPerPool() const;
1011 static
void setTranslation( const QString &translation );
1018 QString translation() const;
1043 bool x11EventFilter( XEvent *event );
1049 void preNotify( QObject *receiver, QEvent *event,
bool *done )
SIP_SKIP;
1055 void customVariablesChanged();
1061 void nullRepresentationChanged();
1077 void localeChanged();
1082 static void copyPath(
const QString &src,
const QString &dst );
1083 static QObject *
ABISYM( mFileOpenEventReceiver );
1085 static bool ABISYM( mInitialized );
1088 static bool ABISYM( mRunningFromBuildDir );
1093 static int ABISYM( sMaxThreads );
1095 QMap<QString, QIcon> mIconCache;
1096 QMap<Cursor, QCursor> mCursorCache;
1098 QTranslator *mQgisTranslator =
nullptr;
1099 QTranslator *mQtTranslator =
nullptr;
1100 QTranslator *mQtBaseTranslator =
nullptr;
1105 struct ApplicationMembers
1112 QgsAnnotationRegistry *mAnnotationRegistry =
nullptr;
1128 std::unique_ptr<QgsProjectStorageRegistry> mProjectStorageRegistry;
1148 QString mNullRepresentation;
1149 QStringList mSvgPathCache;
1150 bool mSvgPathCacheValid =
false;
1152 ApplicationMembers();
1153 ~ApplicationMembers();
1157 ApplicationMembers *mApplicationMembers =
nullptr;
1159 static ApplicationMembers *sApplicationMembers;
1163 static ApplicationMembers *members();
1165 static void invalidateCaches();
1167 friend class TestQgsApplication;