--- src/api/evasetting.cpp.xdg-user-dir 2007-05-07 21:00:18.000000000 +0800 +++ src/api/evasetting.cpp 2007-10-02 00:07:44.000000000 +0800 @@ -24,10 +24,37 @@ #include <qdir.h> #include <qdatastream.h> +#include <qtextcodec.h> +#include <qtextstream.h> + #define DEFAULT_DOWNLOAD_DIR "Downloads" QString EvaSetting::filename = "eva.sys"; +// helper function for reading xdg user dirs: it is required in order to take +// care of locale stuff +void readXdgUserDirs(QString *downloads) +{ + QFile f( QDir::homeDirPath() + "/.config/user-dirs.dirs" ); + + *downloads = QDir::homeDirPath() + "/" + DEFAULT_DOWNLOAD_DIR; + if (!f.open(IO_ReadOnly)) + return; + + // set the codec for the current locale + QTextStream s(&f); + s.setCodec( QTextCodec::codecForLocale() ); + + QString line = s.readLine(); + while (!line.isNull()) + { + if (line.startsWith("XDG_DOWNLOAD_DIR=")) + *downloads = line.remove("XDG_DOWNLOAD_DIR=").remove("\"").replace("$HOME", QDir::homeDirPath()); + + line = s.readLine(); + } +} + EvaSetting::EvaSetting() { userList.setAutoDelete(true); @@ -43,7 +70,7 @@ return; } } - m_DownloadDir = home + "/" + DEFAULT_DOWNLOAD_DIR; + readXdgUserDirs(&m_DownloadDir); if (!d.exists(m_DownloadDir)){ if(!d.cd(home)){ printf("EvaSetting::constructor -- can't enter user's home directory");