From 56ea83f582c53aa3762d403bb7d07f5780a2f615 Mon Sep 17 00:00:00 2001 From: "Juergen E. Fischer" Date: Mon, 18 Jun 2012 18:26:31 +0200 Subject: [PATCH] move QGIS_PREFIX_PATH support to QgsApplication --- ms-windows/osgeo4w/browser.bat.tmpl | 3 +- ms-windows/osgeo4w/package.cmd | 6 ++-- ms-windows/osgeo4w/qgis.bat.tmpl | 3 +- src/browser/main.cpp | 56 ----------------------------- src/core/qgsapplication.cpp | 18 +++++++--- src/crssync/main.cpp | 6 ---- 6 files changed, 21 insertions(+), 71 deletions(-) diff --git a/ms-windows/osgeo4w/browser.bat.tmpl b/ms-windows/osgeo4w/browser.bat.tmpl index 538f92cf357..c9544b2d10f 100644 --- a/ms-windows/osgeo4w/browser.bat.tmpl +++ b/ms-windows/osgeo4w/browser.bat.tmpl @@ -5,4 +5,5 @@ call "%OSGEO4W_ROOT%"\bin\o4w_env.bat call "%OSGEO4W_ROOT%"\apps\grass\grass-@grassversion@\etc\env.bat @echo off path %PATH%;%OSGEO4W_ROOT%\apps\@package@\bin;%OSGEO4W_ROOT%\apps\grass\grass-@grassversion@\lib -start "Quantum GIS Browser" /B "%OSGEO4W_ROOT%"\apps\@package@\bin\qbrowser.exe %* +set QGIS_PREFIX_PATH=@osgeo4w_msys@/apps/@package@ +start "Quantum GIS Browser" /B "%OSGEO4W_ROOT%"\@package@-browser.exe %* diff --git a/ms-windows/osgeo4w/package.cmd b/ms-windows/osgeo4w/package.cmd index 3792e523749..9b408cb07ba 100755 --- a/ms-windows/osgeo4w/package.cmd +++ b/ms-windows/osgeo4w/package.cmd @@ -206,11 +206,13 @@ tar -C %OSGEO4W_ROOT% -cjf %PACKAGENAME%-server-%VERSION%-%PACKAGE%.tar.bz2 ^ >>%LOG% 2>&1 if errorlevel 1 goto error +move apps\%PACKAGENAME%\bin\qgis.exe bin\%PACKAGENAME%.exe +move apps\%PACKAGENAME%\bin\qbrowser.exe bin\%PACKAGENAME%-browser.exe tar -C %OSGEO4W_ROOT% -cjf %PACKAGENAME%-%VERSION%-%PACKAGE%.tar.bz2 ^ --exclude-from exclude ^ --exclude "*.pyc" ^ - "apps/%PACKAGENAME%/bin/qbrowser.exe" ^ - "apps/%PACKAGENAME%/bin/qgis.exe" ^ + "bin/%PACKAGENAME%-browser.exe" ^ + "bin/%PACKAGENAME%.exe" ^ "apps/%PACKAGENAME%/bin/qgis.reg.tmpl" ^ "apps/%PACKAGENAME%/i18n/" ^ "apps/%PACKAGENAME%/icons/" ^ diff --git a/ms-windows/osgeo4w/qgis.bat.tmpl b/ms-windows/osgeo4w/qgis.bat.tmpl index d9776368a44..bc2041b20e3 100755 --- a/ms-windows/osgeo4w/qgis.bat.tmpl +++ b/ms-windows/osgeo4w/qgis.bat.tmpl @@ -5,4 +5,5 @@ call "%OSGEO4W_ROOT%"\bin\o4w_env.bat call "%OSGEO4W_ROOT%"\apps\grass\grass-@grassversion@\etc\env.bat @echo off path %PATH%;%OSGEO4W_ROOT%\apps\@package@\bin;%OSGEO4W_ROOT%\apps\grass\grass-@grassversion@\lib -start "Quantum GIS" /B "%OSGEO4W_ROOT%"\apps\@package@\bin\qgis.exe %* +set QGIS_PREFIX_PATH=@osgeo4w_msys@/apps/@package@ +start "Quantum GIS" /B "%OSGEO4W_ROOT%"\bin\@package@.exe %* diff --git a/src/browser/main.cpp b/src/browser/main.cpp index 34b83eea9e7..c94706cceb0 100644 --- a/src/browser/main.cpp +++ b/src/browser/main.cpp @@ -34,14 +34,6 @@ int main( int argc, char ** argv ) QgsApplication a( argc, argv, true ); a.setThemeName( settings.value( "/Themes", "default" ).toString() ); - - // load providers -#if defined(Q_WS_WIN) - QString prefixPath = QApplication::applicationDirPath(); -#else - QString prefixPath = QApplication::applicationDirPath() + "/.."; -#endif - a.setPrefixPath( prefixPath, true ); a.initQgis(); // Set up the QSettings environment must be done after qapp is created @@ -49,54 +41,6 @@ int main( int argc, char ** argv ) QCoreApplication::setOrganizationDomain( "qgis.org" ); QCoreApplication::setApplicationName( "QGIS" ); -#if 0 - QString myTranslationCode = ""; - - // This is mostly copy from Help viewer - not sure if important -#if defined(Q_WS_MACX) - // If we're on Mac, we have the resource library way above us... - a.setPkgDataPath( QgsApplication::prefixPath() + "/../../../../" + QString( QGIS_DATA_SUBDIR ) ); -#elif defined(Q_WS_WIN) - a.setPkgDataPath( QgsApplication::prefixPath() + "/" QGIS_DATA_SUBDIR ); -#else - a.setPkgDataPath( QgsApplication::prefixPath() + "/../" QGIS_DATA_SUBDIR ); -#endif - - QString i18nPath = QgsApplication::i18nPath(); - if ( myTranslationCode.isEmpty() ) - { - myTranslationCode = QLocale::system().name(); - - QSettings settings; - if ( settings.value( "locale/overrideFlag", false ).toBool() ) - { - myTranslationCode = settings.value( "locale/userLocale", "en_US" ).toString(); - } - } - QgsDebugMsg( QString( "Setting translation to %1/qgis_%2" ).arg( i18nPath ).arg( myTranslationCode ) ); - - /* Translation file for Qt. - * The strings from the QMenuBar context section are used by Qt/Mac to shift - * the About, Preferences and Quit items to the Mac Application menu. - * These items must be translated identically in both qt_ and qgis_ files. - */ - - QTranslator qttor( 0 ); - if ( qttor.load( QString( "qt_" ) + myTranslationCode, i18nPath ) ) - { - a.installTranslator( &qttor ); - } - - /* Translation file for QGIS. - */ - - QTranslator qgistor( 0 ); - if ( qgistor.load( QString( "qgis_" ) + myTranslationCode, i18nPath ) ) - { - a.installTranslator( &qgistor ); - } -#endif - QgsBrowser w; a.connect( &a, SIGNAL( aboutToQuit() ), &w, SLOT( saveWindowState() ) ); diff --git a/src/core/qgsapplication.cpp b/src/core/qgsapplication.cpp index a2d244c4f27..2bdc8659f9f 100644 --- a/src/core/qgsapplication.cpp +++ b/src/core/qgsapplication.cpp @@ -127,14 +127,22 @@ void QgsApplication::init( QString customConfigPath ) } else { + char *prefixPath = getenv( "QGIS_PREFIX_PATH" ); + if ( !prefixPath ) + { #if defined(Q_WS_MACX) || defined(Q_WS_WIN32) || defined(WIN32) - setPrefixPath( applicationDirPath(), true ); + setPrefixPath( applicationDirPath(), true ); #else - QDir myDir( applicationDirPath() ); - myDir.cdUp(); - QString myPrefix = myDir.absolutePath(); - setPrefixPath( myPrefix, true ); + QDir myDir( applicationDirPath() ); + myDir.cdUp(); + QString myPrefix = myDir.absolutePath(); + setPrefixPath( myPrefix, true ); #endif + } + else + { + setPrefixPath( prefixPath, true ); + } } if ( !customConfigPath.isEmpty() ) diff --git a/src/crssync/main.cpp b/src/crssync/main.cpp index 14d5253a834..fb0895d0e98 100644 --- a/src/crssync/main.cpp +++ b/src/crssync/main.cpp @@ -40,12 +40,6 @@ int main( int argc, char ** argv ) { QgsApplication a( argc, argv, false ); - if ( !QgsApplication::isRunningFromBuildDir() ) - { - char *prefixPath = getenv( "QGIS_PREFIX_PATH" ); - a.setPrefixPath( prefixPath ? prefixPath : CMAKE_INSTALL_PREFIX, true ); - } - std::cout << "Synchronizing CRS database with PROJ definitions." << std::endl; CPLPushErrorHandler( showError );