Index: libs/xdgbasedirs.cpp
===================================================================
--- libs/xdgbasedirs.cpp	(wersja 846037)
+++ libs/xdgbasedirs.cpp	(kopia robocza)
@@ -27,6 +27,12 @@
 
 #include <cstdlib>
 
+#ifdef Q_OS_WIN
+// for APPDATA path
+#define _WIN32_IE 0x0400
+#include <shlobj.h>
+#endif
+
 static QStringList alternateExecPaths( const QString& path )
 {
   QStringList pathList;
@@ -295,19 +301,27 @@
 
 QString XdgBaseDirsSingleton::homePath( const char *variable, const char *defaultSubDir )
 {
-  const QByteArray env = qgetenv( variable );
+  const QString env( QFile::decodeName( qgetenv( variable ) ) );
+#if defined(Q_OS_WIN) //krazy:exclude=cpp
+  QString appdata;
+  {
+    HWND hwnd = 0;
+    WCHAR appdata_path[ MAX_PATH + 1 ];
+    SHGetSpecialFolderPathW( hwnd, appdata_path, CSIDL_APPDATA, 0 );
+    appdata = QString::fromUtf16( reinterpret_cast<ushort*>( appdata_path ) );
+  }
+  QString home( QDir::fromNativeSeparators( appdata ) + QLatin1String( "/XDG" ) );
+#else
+  QString home( QDir::homePath() );
+#endif
 
   QString xdgPath;
   if ( env.isEmpty() ) {
-    xdgPath = QDir::homePath() + QLatin1Char( '/' ) + QLatin1String( defaultSubDir );
-#if defined(Q_OS_WIN) //krazy:exclude=cpp
-  } else if ( QDir::isAbsolutePath( QString::fromLocal8Bit( env ) ) ) {
-#else
-  } else if ( env.startsWith( '/' ) ) {
-#endif
-    xdgPath = QString::fromLocal8Bit( env );
+    xdgPath = home + QLatin1Char( '/' ) + QLatin1String( defaultSubDir );
+  } else if ( QDir::isAbsolutePath( env ) ) {
+    xdgPath = env;
   } else {
-    xdgPath = QDir::homePath() + QLatin1Char( '/' ) + QString::fromLocal8Bit( env );
+    xdgPath = home + QLatin1Char( '/' ) + env;
   }
 
   return xdgPath;
@@ -315,13 +329,13 @@
 
 QStringList XdgBaseDirsSingleton::systemPathList( const char *variable, const char *defaultDirList )
 {
-  const QByteArray env = qgetenv( variable );
+  const QString env( QFile::decodeName( qgetenv( variable ) ) );
 
   QString xdgDirList;
   if ( env.isEmpty() ) {
     xdgDirList = QLatin1String( defaultDirList );
   } else {
-    xdgDirList = QString::fromLocal8Bit( env );
+    xdgDirList = env;
   }
 
 #if defined(Q_OS_WIN) //krazy:exclude=cpp
