Skip to content
Permalink
Browse files

Merge pull request #6354 from elpaso/NathanW2-settings_17670

Nathan w2 settings 17670
  • Loading branch information
elpaso committed Feb 16, 2018
2 parents 14787ff + 26edd8a commit 0310c1d25334edef8abe9dd9f99f3d8ce935245b
@@ -143,6 +143,13 @@ for resources in their own datastores e.g. a Qt4 resource bundle.
be reverted to 'default'.
%End

static QString resolvePkgPath( );
%Docstring
Calculate the application pkg path

:return: the resolved pkg path
%End

static QString themeName();
%Docstring
Set the active theme to the specified theme.
@@ -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,7 @@ 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";
if ( QFile::exists( default_globalsettingsfile ) )
{
globalsettingsfile = default_globalsettingsfile;
@@ -862,12 +864,12 @@ int main( int argc, char *argv[] )
// Should be cleaned up in future to make this cleaner.
QgsSettings settings;

QgsDebugMsg( "User profile details:" );
QgsDebugMsg( QString( "\t - %1" ).arg( profileName ) );
QgsDebugMsg( QString( "\t - %1" ).arg( profileFolder ) );
QgsDebugMsg( QString( "\t - %1" ).arg( rootProfileFolder ) );
QgsDebugMsgLevel( QStringLiteral( "User profile details:" ), 2 );
QgsDebugMsgLevel( QStringLiteral( "\t - %1" ).arg( profileName ), 2 );
QgsDebugMsgLevel( QStringLiteral( "\t - %1" ).arg( profileFolder ), 2 );
QgsDebugMsgLevel( QStringLiteral( "\t - %1" ).arg( rootProfileFolder ), 2 );

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,36 @@ 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
const QStringList pathPrefixes = QStringList() << "" << "/.." << "/bin" << "/../../..";
for ( const QString &path : pathPrefixes )
{
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 +989,11 @@ QgsApplication::endian_t QgsApplication::endian()

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

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

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

/**
* Calculate the application pkg path
* \return the resolved pkg path
*/
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 +738,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 +751,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.
@@ -194,14 +194,6 @@ bool QgsServer::init()
QCoreApplication::setOrganizationDomain( QgsApplication::QGIS_ORGANIZATION_DOMAIN );
QCoreApplication::setApplicationName( QgsApplication::QGIS_APPLICATION_NAME );

#if !defined(Q_OS_WIN)
// Set the QGIS_PREFIX_PATH environnemnt instead of calling directly
// setPrefixPath: this will allow running server from build directory
// and get the paths accordingly
setenv( "QGIS_PREFIX_PATH", CMAKE_INSTALL_PREFIX, 1 );
#endif

//Default prefix path may be altered by environment variable
QgsApplication::init();

#if defined(SERVER_SKIP_ECW)
@@ -26,6 +26,7 @@
int main(int argc, char *argv[]) \
{ \
QgsApplication app(argc, argv, false); \
app.init(); \
app.setAttribute(Qt::AA_Use96Dpi, true); \
QTEST_DISABLE_KEYPAD_NAVIGATION \
QTEST_ADD_GPU_BLACKLIST_SUPPORT \
@@ -400,7 +400,6 @@ def test_wcs_getcapabilities_url(self):
item_found = False
for item in str(r).split("\\n"):
if "OnlineResource" in item:
print("OnlineResource: ", item)
self.assertEqual("\"my_wcs_advertised_url" in item, True)
item_found = True
self.assertTrue(item_found)

0 comments on commit 0310c1d

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