Skip to content

Commit 2ded9c2

Browse files
committed
Merge branch 'settings_17670' of https://github.com/NathanW2/QGIS into NathanW2-settings_17670
2 parents a7870af + 3207600 commit 2ded9c2

File tree

4 files changed

+62
-6
lines changed

4 files changed

+62
-6
lines changed

resources/CMakeLists.txt

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
INSTALL(FILES srs.db qgis.db symbology-style.xml spatialite.db customization.xml 2to3migration.txt
1+
INSTALL(FILES srs.db
2+
qgis.db
3+
symbology-style.xml
4+
spatialite.db
5+
customization.xml
6+
2to3migration.txt
7+
qgis_global_settings.ini
28
DESTINATION ${QGIS_DATA_DIR}/resources)
3-
INSTALL(FILES qgis_global_settings.ini
4-
DESTINATION ${QGIS_DATA_DIR})
59
INSTALL(DIRECTORY cpt-city-qgis-min DESTINATION ${QGIS_DATA_DIR}/resources)
610
INSTALL(DIRECTORY themes DESTINATION ${QGIS_DATA_DIR}/resources)
711
INSTALL(DIRECTORY data DESTINATION ${QGIS_DATA_DIR}/resources)

src/app/main.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,8 @@ int main( int argc, char *argv[] )
798798
QCoreApplication::setAttribute( Qt::AA_DisableWindowContextHelpButton, true );
799799
#endif
800800

801+
QgsApplication myApp( argc, argv, myUseGuiFlag );
802+
801803
// SetUp the QgsSettings Global Settings:
802804
// - use the path specified with --globalsettingsfile path,
803805
// - use the environment if not found
@@ -809,7 +811,8 @@ int main( int argc, char *argv[] )
809811

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

856+
QgsDebugMsg( "CONFIG LOCAL STORAGE:" + configLocalStorageLocation );
857+
853858
QString rootProfileFolder = QgsUserProfileManager::resolveProfilesFolder( configLocalStorageLocation );
854859
QgsUserProfileManager manager( rootProfileFolder );
855860
QgsUserProfile *profile = manager.getProfile( profileName, true );
@@ -867,7 +872,7 @@ int main( int argc, char *argv[] )
867872
QgsDebugMsg( QString( "\t - %1" ).arg( profileFolder ) );
868873
QgsDebugMsg( QString( "\t - %1" ).arg( rootProfileFolder ) );
869874

870-
QgsApplication myApp( argc, argv, myUseGuiFlag, profileFolder );
875+
myApp.init( profileFolder );
871876

872877
// Settings migration is only supported on the default profile for now.
873878
if ( profileName == "default" )

src/core/qgsapplication.cpp

+43-1
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,13 @@ QString ABISYM( QgsApplication::mLibraryPath );
9191
QString ABISYM( QgsApplication::mLibexecPath );
9292
QString ABISYM( QgsApplication::mThemeName );
9393
QString ABISYM( QgsApplication::mUIThemeName );
94+
QString ABISYM( QgsApplication::mProfilePath );
95+
9496
QStringList ABISYM( QgsApplication::mDefaultSvgPaths );
9597
QMap<QString, QString> ABISYM( QgsApplication::mSystemEnvVars );
9698
QString ABISYM( QgsApplication::mConfigPath );
99+
100+
bool ABISYM( QgsApplication::mInitialized ) = false;
97101
bool ABISYM( QgsApplication::mRunningFromBuildDir ) = false;
98102
QString ABISYM( QgsApplication::mBuildSourcePath );
99103
#ifdef _MSC_VER
@@ -121,7 +125,7 @@ QgsApplication::QgsApplication( int &argc, char **argv, bool GUIenabled, const Q
121125

122126
mApplicationMembers = new ApplicationMembers();
123127

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

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

153+
ABISYM( mProfilePath ) = profileFolder;
154+
149155
qRegisterMetaType<QgsGeometry::Error>( "QgsGeometry::Error" );
150156
qRegisterMetaType<QgsProcessingFeatureSourceDefinition>( "QgsProcessingFeatureSourceDefinition" );
151157
qRegisterMetaType<QgsProcessingOutputLayerDefinition>( "QgsProcessingOutputLayerDefinition" );
@@ -259,6 +265,8 @@ void QgsApplication::init( QString profileFolder )
259265
// this should be read from QgsSettings but we don't know where they are at this point
260266
// so we read actual value in main.cpp
261267
ABISYM( mMaxThreads ) = -1;
268+
269+
ABISYM( mInitialized ) = true;
262270
}
263271

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

588+
QString QgsApplication::resolvePkgPath()
589+
{
590+
#if defined(ANDROID)
591+
QString prefixPath( getenv( "QGIS_PREFIX_PATH" ) ? getenv( "QGIS_PREFIX_PATH" ) : QDir::homePath() );
592+
#else
593+
QString prefixPath( getenv( "QGIS_PREFIX_PATH" ) ? getenv( "QGIS_PREFIX_PATH" ) : applicationDirPath() );
594+
#endif
595+
QFile f;
596+
// "/../../.." is for Mac bundled app in build directory
597+
Q_FOREACH ( const QString &path, QStringList() << "" << "/.." << "/bin" << "/../../.." )
598+
{
599+
f.setFileName( prefixPath + path + "/qgisbuildpath.txt" );
600+
QgsDebugMsg( f.fileName() );
601+
if ( f.exists() )
602+
break;
603+
}
604+
605+
if ( f.exists() && f.open( QIODevice::ReadOnly ) )
606+
{
607+
QgsDebugMsg( "Running from build dir!" );
608+
return f.readLine().trimmed();
609+
}
610+
else
611+
{
612+
return prefixPath + '/' + QStringLiteral( QGIS_DATA_SUBDIR );
613+
}
614+
615+
}
616+
580617
QString QgsApplication::themeName()
581618
{
582619
return ABISYM( mThemeName );
@@ -951,6 +988,11 @@ QgsApplication::endian_t QgsApplication::endian()
951988

952989
void QgsApplication::initQgis()
953990
{
991+
if ( !ABISYM( mInitialized ) )
992+
{
993+
init( ABISYM( mProfilePath ) );
994+
}
995+
954996
// set the provider plugin path (this creates provider registry)
955997
QgsProviderRegistry::instance( pluginPath() );
956998

src/core/qgsapplication.h

+5
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ class CORE_EXPORT QgsApplication : public QApplication
184184
*/
185185
static void setThemeName( const QString &themeName );
186186

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

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

745748
static QString ABISYM( mConfigPath );
746749

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

0 commit comments

Comments
 (0)