From: nri Date: Tue, 20 May 2003 08:13:53 +0000 (+0000) Subject: NRI : Search resources with KERNEL_ROOT_DIR var. X-Git-Tag: V1_4_0~113 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5f9fbefa474983533a3a979a8cb40320a41d1433;p=modules%2Fkernel.git NRI : Search resources with KERNEL_ROOT_DIR var. --- diff --git a/src/RegistryDisplay/RegWidget.cxx b/src/RegistryDisplay/RegWidget.cxx index fd1371b29..5ca42e7d7 100644 --- a/src/RegistryDisplay/RegWidget.cxx +++ b/src/RegistryDisplay/RegWidget.cxx @@ -32,6 +32,8 @@ using namespace std; # include "HelpWindow.hxx" # include "IntervalWindow.hxx" +static QString addSlash( const QString& path ); + typedef int PIXELS; RegWidget* RegWidget::myRegWidgetPtr = 0; @@ -92,12 +94,31 @@ RegWidget::RegWidget(CORBA::ORB_var &orb, QWidget *parent, const char *name ) _tabWidget(0), _refresh(0), _interval(0), myInfoWindow(0), myHelpWindow(0), myIntervalWindow(0) { - char* dir = getenv( "CSF_ResourcesDefaults" ); + QString path( "" ); - if ( dir ) { - QDir qDir( dir ); - path = qDir.filePath( "default.png" ); + QString dir; + char* cenv; + cenv = getenv( "KERNEL_ROOT_DIR" ); + if ( cenv ) { + dir.sprintf( "%s", cenv ); + if ( !dir.isEmpty() ) { + dir = addSlash(dir) ; + dir = dir + "share" ; + dir = addSlash(dir) ; + dir = dir + "salome" ; + dir = addSlash(dir) ; + dir = dir + "resources" ; + dir = addSlash(dir) ; + QDir qDir( dir ); + path = qDir.filePath( "default.png" ); + } } +// char* dir = getenv( "CSF_ResourcesDefaults" ); +// QString path( "" ); +// if ( dir ) { +// QDir qDir( dir ); +// path = qDir.filePath( "default.png" ); +// } QPixmap pm ( path ); if ( !pm.isNull() ) setIcon( pm ); @@ -556,3 +577,17 @@ void InfoWindow::setText( const QString& text ) { myTextView->setText( text ); } + +QString addSlash( const QString& path ) +{ + if (!path.isNull()) { +#ifdef WNT + QChar slash ('\\'); +#else + QChar slash ('/'); +#endif + if ( path.at(path.length()-1) != slash ) + return path + slash; + } + return path; +} diff --git a/src/Session/InquireServersQThread.cxx b/src/Session/InquireServersQThread.cxx index 11319d499..42129cefe 100644 --- a/src/Session/InquireServersQThread.cxx +++ b/src/Session/InquireServersQThread.cxx @@ -505,6 +505,23 @@ QString findFile( QString filename ) QString dir; char* cenv; + // Try ${KERNEL_ROOT_DIR}/share/salome/resources directory + cenv = getenv( "KERNEL_ROOT_DIR" ); + if ( cenv ) { + dir.sprintf( "%s", cenv ); + if ( !dir.isEmpty() ) { + dir = addSlash(dir) ; + dir = dir + "share" ; + dir = addSlash(dir) ; + dir = dir + "salome" ; + dir = addSlash(dir) ; + dir = dir + "resources" ; + dir = addSlash(dir) ; + QFileInfo fileInfo( dir + filename ); + if ( fileInfo.isFile() && fileInfo.exists() ) + return fileInfo.filePath(); + } + } // Try CSF_ResourcesDefaults env.var directory ( or directory list ) cenv = getenv( "CSF_ResourcesDefaults" ); if ( cenv ) {