fix for path to Program Files on Windows when it is not c:\program files

This commit is contained in:
ars_goldendict 2009-04-30 21:47:42 +00:00
parent 163d69b230
commit cc1a083493

View file

@ -12,6 +12,10 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#ifdef Q_OS_WIN32
#include "shlobj.h"
#endif
namespace Config { namespace Config {
namespace namespace
@ -155,17 +159,34 @@ Class load() throw( exError )
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
// get path to Program Files
wchar_t buf[ MAX_PATH ];
SHGetFolderPathW( NULL, CSIDL_PROGRAM_FILES, NULL, 0, buf );
QString pathToProgramFiles = QString::fromWCharArray( buf );
if ( pathToProgramFiles.isEmpty() )
pathToProgramFiles = "C:\\Program Files";
if ( QDir( pathToProgramFiles + "\\StarDict\\dic" ).exists() )
c.paths.push_back( Path( pathToProgramFiles + "\\StarDict\\dic", true ) );
if ( QDir( pathToProgramFiles + "\\StarDict\\WyabdcRealPeopleTTS" ).exists() )
c.soundDirs.push_back( SoundDir( pathToProgramFiles + "\\StarDict\\WyabdcRealPeopleTTS", "WyabdcRealPeopleTTS" ) );
else
if ( QDir( pathToProgramFiles + "\\WyabdcRealPeopleTTS" ).exists() )
c.soundDirs.push_back( SoundDir( pathToProgramFiles + "\\WyabdcRealPeopleTTS", "WyabdcRealPeopleTTS" ) );
// #### "C:/Program Files" is bad! will not work for German Windows etc. // #### "C:/Program Files" is bad! will not work for German Windows etc.
// #### should be replaced to system path // #### should be replaced to system path
if ( QDir( "C:/Program Files/StarDict/dic" ).exists() ) // if ( QDir( "C:/Program Files/StarDict/dic" ).exists() )
c.paths.push_back( Path( "C:/Program Files/StarDict/dic", true ) ); // c.paths.push_back( Path( "C:/Program Files/StarDict/dic", true ) );
//
// if ( QDir( "C:/Program Files/StarDict/WyabdcRealPeopleTTS" ).exists() )
// c.soundDirs.push_back( SoundDir( "C:/Program Files/StarDict/WyabdcRealPeopleTTS", "WyabdcRealPeopleTTS" ) );
// else
// if ( QDir( "C:/Program Files/WyabdcRealPeopleTTS" ).exists() )
// c.soundDirs.push_back( SoundDir( "C:/Program Files/WyabdcRealPeopleTTS", "WyabdcRealPeopleTTS" ) );
if ( QDir( "C:/Program Files/StarDict/WyabdcRealPeopleTTS" ).exists() )
c.soundDirs.push_back( SoundDir( "C:/Program Files/StarDict/WyabdcRealPeopleTTS", "WyabdcRealPeopleTTS" ) );
else
if ( QDir( "C:/Program Files/WyabdcRealPeopleTTS" ).exists() )
c.soundDirs.push_back( SoundDir( "C:/Program Files/WyabdcRealPeopleTTS", "WyabdcRealPeopleTTS" ) );
#endif #endif
#ifndef Q_OS_WIN32 #ifndef Q_OS_WIN32