diff options
Diffstat (limited to 'kdecore/kglobalsettings.cpp')
-rw-r--r-- | kdecore/kglobalsettings.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/kdecore/kglobalsettings.cpp b/kdecore/kglobalsettings.cpp index 71f8f7c58..da153aeb7 100644 --- a/kdecore/kglobalsettings.cpp +++ b/kdecore/kglobalsettings.cpp @@ -173,6 +173,23 @@ static void readXdgUserDirs(TQString *desktop, TQString *documents, TQString *do } } +static void checkAndCreateXdgFolder(const TQString &folder, const TQString &path, KConfig *config) +{ + bool pathOk = true; + if (!TQDir(path).exists()) + { + if (!KStandardDirs::makeDir(path)) + { + pathOk = false; + } + } + + if (pathOk) + { + config->writePathEntry(folder, '"' + path + '"', true, false, false, false ); + } +} + int KGlobalSettings::dndEventDelay() { KConfigGroup g( KGlobal::config(), "General" ); @@ -642,12 +659,30 @@ void KGlobalSettings::initPaths() g.sync(); } + // Create folders if they do not exists. + KConfig *xdgconfig = new KConfig(TQDir::homeDirPath()+"/.config/user-dirs.dirs"); + checkAndCreateXdgFolder("XDG_DESKTOP_DIR", *s_desktopPath, xdgconfig); + checkAndCreateXdgFolder("XDG_DOCUMENTS_DIR", *s_documentPath, xdgconfig); + checkAndCreateXdgFolder("XDG_DOWNLOAD_DIR", *s_downloadPath, xdgconfig); + checkAndCreateXdgFolder("XDG_MUSIC_DIR", *s_musicPath, xdgconfig); + checkAndCreateXdgFolder("XDG_PICTURES_DIR", *s_picturesPath, xdgconfig); + checkAndCreateXdgFolder("XDG_PUBLICSHARE_DIR", *s_publicSharePath, xdgconfig); + checkAndCreateXdgFolder("XDG_TEMPLATES_DIR", *s_templatesPath, xdgconfig); + checkAndCreateXdgFolder("XDG_VIDEOS_DIR", *s_videosPath, xdgconfig); + xdgconfig->sync(); + // Autostart Path *s_autostartPath = KGlobal::dirs()->localkdedir() + "Autostart/"; *s_autostartPath = g.readPathEntry( "Autostart" , *s_autostartPath); *s_autostartPath = TQDir::cleanDirPath( *s_autostartPath ); - if ( !s_autostartPath->endsWith("/") ) + if (!s_autostartPath->endsWith("/")) + { s_autostartPath->append('/'); + } + if (!TQDir(*s_autostartPath).exists()) + { + KStandardDirs::makeDir(*s_autostartPath); + } // Make sure this app gets the notifications about those paths if (kapp) |