View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002490 | Scribus | OS-Win32 | public | 2005-08-26 17:04 | 2005-09-25 20:52 |
Reporter | jghali | Assigned To | fschmid | ||
Priority | normal | Severity | tweak | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | Windows | OS | Windows | OS Version | 2000 SP4 |
Product Version | 1.3.1cvs | ||||
Fixed in Version | 1.3.1cvs | ||||
Summary | 0002490: ScPaths patches (win32 compatibility) | ||||
Description | The provided patch modify ScPaths class in the following manner : 1) modify constructor to properly initialize directories on win32 2) provide abstractions which return system fonts directories (OSX/Win32) 3) provide abstractions which return icc profiles directories (OSX/Win32/*nix) 2) and 3) will be used in patches soon to come... | ||||
Tags | No tags attached. | ||||
Patch | |||||
related to | 0002219 | closed | On Win32, add the ability to locate special directories and sytem fonts folder |
2005-08-26 17:04
|
scpaths_patches_win32.diff (4,912 bytes)
Index: scpaths.cpp =================================================================== RCS file: /cvs/Scribus/scribus/Attic/scpaths.cpp,v retrieving revision 1.1.2.5 diff -u -r1.1.2.5 scpaths.cpp --- scpaths.cpp 6 Jul 2005 20:07:15 -0000 1.1.2.5 +++ scpaths.cpp 26 Aug 2005 15:05:00 -0000 @@ -1,15 +1,20 @@ #include "scpaths.h" #include <qapplication.h> +#include <qdir.h> #include "scconfig.h" - // On Qt/Mac we need CoreFoundation to discover the location // of the app bundle. #ifdef BUILD_MAC_BUNDLE #include <CoreFoundation/CoreFoundation.h> #endif +#ifdef _WIN32 +#include <windows.h> +#include <shlobj.h> +#endif + // Init the singleton's "self" address to NULL ScPaths* ScPaths::m_instance = NULL; @@ -90,7 +95,17 @@ qDebug(QString("scpaths: plugin dir=%1").arg(m_pluginDir)); qDebug(QString("scpaths: qtplugins=%1").arg(QApplication::libraryPaths().join(":"))); */ -#endif // defined(BUILD_MAC_BUNDLE) +#elif defined(_WIN32) + QString appPath = qApp->applicationDirPath(); + m_shareDir = strdup(QString("%1/share/").arg(appPath)); + m_docDir = strdup(QString("%1/share/doc/").arg(appPath)); + m_iconDir = strdup(QString("%1/share/icons/").arg(appPath)); + m_sampleScriptDir = strdup(QString("%1/share/samples/").arg(appPath)); + m_scriptDir = strdup(QString("%1/share/scripts/").arg(appPath)); + m_templateDir = strdup(QString("%1/share/templates/").arg(appPath)); + m_libDir = strdup(QString("%1/libs/").arg(appPath)); + m_pluginDir = strdup(QString("%1/plugins/").arg(appPath)); +#endif } ScPaths::~ScPaths() {}; @@ -134,3 +149,67 @@ { return m_shareDir; } + +QStringList ScPaths::getSystemFontDirs(void) +{ + QStringList fontDirs; +#ifdef BUILD_MAC_BUNDLE + fontDirs.append(QDir::homeDirPath() + "/Library/Fonts/"); + fontDirs.append("/Library/Fonts/"); + fontDirs.append("/Network/Library/Fonts/"); + fontDirs.append("/System/Library/Fonts/"); +#else if defined(_WIN32) + fontDirs.append( getSpecialDir(CSIDL_FONTS) ); +#endif + return fontDirs; +} + +QStringList ScPaths::getSystemProfilesDirs(void) +{ + QStringList iccProfDirs; +#ifdef BUILD_MAC_BUNDLE + iccProfDirs.append(QDir::homeDirPath()+"/Library/ColorSync/Profiles/"); + iccProfDirs.append("/System/Library/ColorSync/Profiles/"); + iccProfDirs.append("/Library/ColorSync/Profiles/"); +#elif defined(Q_WS_X11) + iccProfDirs.append(QDir::homeDirPath()+"/color/icc/"); + iccProfDirs.append(QDir::homeDirPath()+"/.color/icc/"); + iccProfDirs.append("/usr/share/color/icc/"); +#elif defined(_WIN32) + // On Windows it's more complicated, profiles location depends on OS version + char sysDir[MAX_PATH + 1]; + OSVERSIONINFO osVersion; + ZeroMemory( &osVersion, sizeof(OSVERSIONINFO)); + osVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); // Necessary for GetVersionEx to succeed + GetVersionEx(&osVersion); // Get Windows version infos + GetSystemDirectory( sysDir, MAX_PATH ); // getSpecialDir(CSIDL_SYSTEM) fails on Win9x + QString winSysDir = QString(sysDir).replace('\\','/'); + if( osVersion.dwPlatformId == VER_PLATFORM_WIN32_NT ) // Windows NT/2k/XP + { + if( osVersion.dwMajorVersion >= 5 ) // for 2k and XP dwMajorVersion == 5 + iccProfDirs.append( winSysDir + "/Spool/Drivers/Color/"); + } + else if( osVersion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) // Windows 9x/Me + { + if( osVersion.dwMajorVersion >= 4 && osVersion.dwMinorVersion >= 10) // Win98 or WinMe + iccProfDirs.append( winSysDir + "/Color/"); + } +#endif + return iccProfDirs; +} + +QString ScPaths::getSpecialDir(int folder) +{ + QString qstr; +#if defined(_WIN32) + char dir[256]; + SHGetSpecialFolderPath(NULL, dir, folder , false); + qstr = dir; + if( !qstr.endsWith("\\") ) + qstr += "\\"; + qstr.replace( '\\', '/' ); +#else + Q_ASSERT(false); +#endif + return qstr; +} Index: scpaths.h =================================================================== RCS file: /cvs/Scribus/scribus/Attic/scpaths.h,v retrieving revision 1.1.2.3 diff -u -r1.1.2.3 scpaths.h --- scpaths.h 10 Aug 2005 07:14:56 -0000 1.1.2.3 +++ scpaths.h 26 Aug 2005 16:48:27 -0000 @@ -38,12 +38,20 @@ /** @brief Return path to the Scribus share directory */ const QString& shareDir() const; + /** @brief Return paths to system font directories*/ + static QStringList getSystemFontDirs(void); + /** @brief Return paths to system icc profiles directories*/ + static QStringList getSystemProfilesDirs(void); + protected: /** @brief Constructor. Use ScPaths::instance() instead. */ ScPaths(); /** @brief Destructor. Use ScPaths::destroy() instead. */ ~ScPaths(); + /** @brief Return path to a special directory, should be used only on Windows*/ + static QString getSpecialDir(int folder); + /** @brief Pointer to existing instance of ScPaths, if any. */ static ScPaths* m_instance; |
Date Modified | Username | Field | Change |
---|---|---|---|
2005-08-26 17:04 | jghali | New Issue | |
2005-08-26 17:04 | jghali | File Added: scpaths_patches_win32.diff | |
2005-08-26 19:14 |
|
Status | new => assigned |
2005-08-26 19:14 |
|
Assigned To | => fschmid |
2005-08-26 21:56 | fschmid | Status | assigned => resolved |
2005-08-26 21:56 | fschmid | Fixed in Version | => 1.3.1cvs |
2005-08-26 21:56 | fschmid | Resolution | open => fixed |
2005-08-26 23:07 | jghali | Relationship added | related to 0002219 |
2005-08-30 21:48 | jghali | Status | resolved => closed |
2005-09-25 20:52 | cbradney | Category | Internal => Win32 |
2014-10-08 18:38 | Kunda | Category | Win32 => OS-Win32 |