Skip to content
Permalink
Browse files

Merge branch 'settings_17670' of https://github.com/NathanW2/QGIS int…

…o NathanW2-settings_17670
  • Loading branch information
elpaso committed Feb 12, 2018
2 parents a7870af + 3207600 commit 2ded9c2ece114d22d25522c54f2d4983f6a90d22
Showing with 62 additions and 6 deletions.
  1. +7 −3 resources/CMakeLists.txt
  2. +7 −2 src/app/main.cpp
  3. +43 −1 src/core/qgsapplication.cpp
  4. +5 −0 src/core/qgsapplication.h
@@ -1,7 +1,11 @@
INSTALL(FILES srs.db qgis.db symbology-style.xml spatialite.db customization.xml 2to3migration.txt
INSTALL(FILES srs.db
qgis.db
symbology-style.xml
spatialite.db
customization.xml
2to3migration.txt
qgis_global_settings.ini
DESTINATION ${QGIS_DATA_DIR}/resources)
INSTALL(FILES qgis_global_settings.ini
DESTINATION ${QGIS_DATA_DIR})
INSTALL(DIRECTORY cpt-city-qgis-min DESTINATION ${QGIS_DATA_DIR}/resources)
INSTALL(DIRECTORY themes DESTINATION ${QGIS_DATA_DIR}/resources)
INSTALL(DIRECTORY data DESTINATION ${QGIS_DATA_DIR}/resources)
@@ -798,6 +798,8 @@ int main( int argc, char *argv[] )
QCoreApplication::setAttribute( Qt::AA_DisableWindowContextHelpButton, true );
#endif

QgsApplication myApp( argc, argv, myUseGuiFlag );

// SetUp the QgsSettings Global Settings:
// - use the path specified with --globalsettingsfile path,
// - use the environment if not found
@@ -809,7 +811,8 @@ int main( int argc, char *argv[] )

if ( globalsettingsfile.isEmpty() )
{
QString default_globalsettingsfile = QgsApplication::pkgDataPath() + "/qgis_global_settings.ini";
QString default_globalsettingsfile = QgsApplication::resolvePkgPath() + "/resources/qgis_global_settings.ini";
QgsDebugMsg( "GLOABL SETTINGS FILE:" + default_globalsettingsfile );
if ( QFile::exists( default_globalsettingsfile ) )
{
globalsettingsfile = default_globalsettingsfile;
@@ -850,6 +853,8 @@ int main( int argc, char *argv[] )
}
delete globalSettings;

QgsDebugMsg( "CONFIG LOCAL STORAGE:" + configLocalStorageLocation );

QString rootProfileFolder = QgsUserProfileManager::resolveProfilesFolder( configLocalStorageLocation );
QgsUserProfileManager manager( rootProfileFolder );
QgsUserProfile *profile = manager.getProfile( profileName, true );
@@ -867,7 +872,7 @@ int main( int argc, char *argv[] )
QgsDebugMsg( QString( "\t - %1" ).arg( profileFolder ) );
QgsDebugMsg( QString( "\t - %1" ).arg( rootProfileFolder ) );

QgsApplication myApp( argc, argv, myUseGuiFlag, profileFolder );
myApp.init( profileFolder );

// Settings migration is only supported on the default profile for now.
if ( profileName == "default" )
@@ -91,9 +91,13 @@ QString ABISYM( QgsApplication::mLibraryPath );
QString ABISYM( QgsApplication::mLibexecPath );
QString ABISYM( QgsApplication::mThemeName );
QString ABISYM( QgsApplication::mUIThemeName );
QString ABISYM( QgsApplication::mProfilePath );

QStringList ABISYM( QgsApplication::mDefaultSvgPaths );
QMap<QString, QString> ABISYM( QgsApplication::mSystemEnvVars );
QString ABISYM( QgsApplication::mConfigPath );

bool ABISYM( QgsApplication::mInitialized ) = false;
bool ABISYM( QgsApplication::mRunningFromBuildDir ) = false;
QString ABISYM( QgsApplication::mBuildSourcePath );
#ifdef _MSC_VER
@@ -121,7 +125,7 @@ QgsApplication::QgsApplication( int &argc, char **argv, bool GUIenabled, const Q

mApplicationMembers = new ApplicationMembers();

init( profileFolder ); // init can also be called directly by e.g. unit tests that don't inherit QApplication.
ABISYM( mProfilePath ) = profileFolder;
}

void QgsApplication::init( QString profileFolder )
@@ -146,6 +150,8 @@ void QgsApplication::init( QString profileFolder )
delete profile;
}

ABISYM( mProfilePath ) = profileFolder;

qRegisterMetaType<QgsGeometry::Error>( "QgsGeometry::Error" );
qRegisterMetaType<QgsProcessingFeatureSourceDefinition>( "QgsProcessingFeatureSourceDefinition" );
qRegisterMetaType<QgsProcessingOutputLayerDefinition>( "QgsProcessingOutputLayerDefinition" );
@@ -259,6 +265,8 @@ void QgsApplication::init( QString profileFolder )
// this should be read from QgsSettings but we don't know where they are at this point
// so we read actual value in main.cpp
ABISYM( mMaxThreads ) = -1;

ABISYM( mInitialized ) = true;
}

QgsApplication::~QgsApplication()
@@ -577,6 +585,35 @@ void QgsApplication::setThemeName( const QString &themeName )
ABISYM( mThemeName ) = themeName;
}

QString QgsApplication::resolvePkgPath()
{
#if defined(ANDROID)
QString prefixPath( getenv( "QGIS_PREFIX_PATH" ) ? getenv( "QGIS_PREFIX_PATH" ) : QDir::homePath() );
#else
QString prefixPath( getenv( "QGIS_PREFIX_PATH" ) ? getenv( "QGIS_PREFIX_PATH" ) : applicationDirPath() );
#endif
QFile f;
// "/../../.." is for Mac bundled app in build directory
Q_FOREACH ( const QString &path, QStringList() << "" << "/.." << "/bin" << "/../../.." )
{
f.setFileName( prefixPath + path + "/qgisbuildpath.txt" );
QgsDebugMsg( f.fileName() );
if ( f.exists() )
break;
}

if ( f.exists() && f.open( QIODevice::ReadOnly ) )
{
QgsDebugMsg( "Running from build dir!" );
return f.readLine().trimmed();
}
else
{
return prefixPath + '/' + QStringLiteral( QGIS_DATA_SUBDIR );
}

}

QString QgsApplication::themeName()
{
return ABISYM( mThemeName );
@@ -951,6 +988,11 @@ QgsApplication::endian_t QgsApplication::endian()

void QgsApplication::initQgis()
{
if ( !ABISYM( mInitialized ) )
{
init( ABISYM( mProfilePath ) );
}

// set the provider plugin path (this creates provider registry)
QgsProviderRegistry::instance( pluginPath() );

@@ -184,6 +184,8 @@ class CORE_EXPORT QgsApplication : public QApplication
*/
static void setThemeName( const QString &themeName );

static QString resolvePkgPath( );

/**
* Set the active theme to the specified theme.
* The theme name should be a single word e.g. 'default','classic'.
@@ -732,6 +734,7 @@ class CORE_EXPORT QgsApplication : public QApplication
static QObject *ABISYM( mFileOpenEventReceiver );
static QStringList ABISYM( mFileOpenEventList );

static QString ABISYM( mProfilePath );
static QString ABISYM( mUIThemeName );
static QString ABISYM( mPrefixPath );
static QString ABISYM( mPluginPath );
@@ -744,6 +747,8 @@ class CORE_EXPORT QgsApplication : public QApplication

static QString ABISYM( mConfigPath );

static bool ABISYM( mInitialized );

//! True when running from build directory, i.e. without 'make install'
static bool ABISYM( mRunningFromBuildDir );
//! Path to the source directory. valid only when running from build directory.

0 comments on commit 2ded9c2

Please sign in to comment.
You can’t perform that action at this time.