Skip to content

Commit

Permalink
Merge branch 'settings_17670' of https://github.com/NathanW2/QGIS int…
Browse files Browse the repository at this point in the history
…o NathanW2-settings_17670
  • Loading branch information
elpaso committed Feb 12, 2018
2 parents a7870af + 3207600 commit 2ded9c2
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 6 deletions.
10 changes: 7 additions & 3 deletions resources/CMakeLists.txt
@@ -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)
Expand Down
9 changes: 7 additions & 2 deletions src/app/main.cpp
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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 );
Expand All @@ -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" )
Expand Down
44 changes: 43 additions & 1 deletion src/core/qgsapplication.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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 )
Expand All @@ -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" );
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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() );

Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsapplication.h
Expand Up @@ -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'.
Expand Down Expand Up @@ -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 );
Expand All @@ -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.
Expand Down

0 comments on commit 2ded9c2

Please sign in to comment.