summaryrefslogtreecommitdiffstats
path: root/kdecore/kglobalsettings.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-12-11 03:46:01 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-12-11 03:46:01 +0000
commit865f314dd5ed55508f45a32973b709b79a541e36 (patch)
treedc1a3a884bb2fc10a89a3c46313897d22c5771eb /kdecore/kglobalsettings.cpp
parentce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (diff)
downloadtdelibs-865f314dd5ed55508f45a32973b709b79a541e36.tar.gz
tdelibs-865f314dd5ed55508f45a32973b709b79a541e36.zip
kdelibs update to Trinity v3.5.11
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1061230 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdecore/kglobalsettings.cpp')
-rw-r--r--kdecore/kglobalsettings.cpp51
1 files changed, 36 insertions, 15 deletions
diff --git a/kdecore/kglobalsettings.cpp b/kdecore/kglobalsettings.cpp
index b5539fb22..25e95f5c6 100644
--- a/kdecore/kglobalsettings.cpp
+++ b/kdecore/kglobalsettings.cpp
@@ -50,6 +50,10 @@ static QRgb qt_colorref2qrgb(COLORREF col)
#include <stdlib.h>
#include <kprotocolinfo.h>
+#include <qtextcodec.h>
+#include <qtextstream.h>
+#include <qfile.h>
+
#ifdef Q_WS_X11
#include <X11/Xlib.h>
#endif
@@ -77,6 +81,31 @@ QColor *KGlobalSettings::alternateColor = 0;
KGlobalSettings::KMouseSettings *KGlobalSettings::s_mouseSettings = 0;
+// helper function for reading xdg user dirs: it is required in order to take
+// care of locale stuff
+void readXdgUserDirs(QString *desktop, QString *documents)
+{
+ QFile f( QDir::homeDirPath() + "/.config/user-dirs.dirs" );
+
+ 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_DESKTOP_DIR="))
+ *desktop = line.remove("XDG_DESKTOP_DIR=").remove("\"").replace("$HOME", QDir::homeDirPath());
+ else if (line.startsWith("XDG_DOCUMENTS_DIR="))
+ *documents = line.remove("XDG_DOCUMENTS_DIR=").remove("\"").replace("$HOME", QDir::homeDirPath());
+
+ line = s.readLine();
+ }
+}
+
int KGlobalSettings::dndEventDelay()
{
KConfigGroup g( KGlobal::config(), "General" );
@@ -483,13 +512,17 @@ void KGlobalSettings::initStatic() // should be called initPaths(). Don't put an
KConfigGroup g( KGlobal::config(), "Paths" );
- // Desktop Path
- *s_desktopPath = QDir::homeDirPath() + "/Desktop/";
- *s_desktopPath = g.readPathEntry( "Desktop", *s_desktopPath);
+ // Read desktop and documents path using XDG_USER_DIRS
+ readXdgUserDirs(s_desktopPath, s_documentPath);
+
*s_desktopPath = QDir::cleanDirPath( *s_desktopPath );
if ( !s_desktopPath->endsWith("/") )
s_desktopPath->append('/');
+ *s_documentPath = QDir::cleanDirPath( *s_documentPath );
+ if ( !s_documentPath->endsWith("/"))
+ s_documentPath->append('/');
+
// Trash Path - TODO remove in KDE4 (kio_trash can't use it for interoperability reasons)
*s_trashPath = *s_desktopPath + i18n("Trash") + "/";
*s_trashPath = g.readPathEntry( "Trash" , *s_trashPath);
@@ -510,18 +543,6 @@ void KGlobalSettings::initStatic() // should be called initPaths(). Don't put an
if ( !s_autostartPath->endsWith("/") )
s_autostartPath->append('/');
- // Document Path
- *s_documentPath = g.readPathEntry( "Documents",
-#ifdef Q_WS_WIN
- getWin32ShellFoldersPath("Personal")
-#else
- QDir::homeDirPath()
-#endif
- );
- *s_documentPath = QDir::cleanDirPath( *s_documentPath );
- if ( !s_documentPath->endsWith("/"))
- s_documentPath->append('/');
-
// Make sure this app gets the notifications about those paths
if (kapp)
kapp->addKipcEventMask(KIPC::SettingsChanged);