summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2020-01-29 23:33:37 +0900
committerSlávek Banko <slavek.banko@axis.cz>2021-02-03 17:52:40 +0100
commitb3a875f92e4c58d8140321321aa4402b06c3f615 (patch)
tree9044a9c9e54a3e4fcbd67123de963e84420f903f
parent54800d9de61bed34b73dfdb2525a4878ae03858b (diff)
downloadtdelibs-b3a875f92e4c58d8140321321aa4402b06c3f615.tar.gz
tdelibs-b3a875f92e4c58d8140321321aa4402b06c3f615.zip
Make sure XDG folders are created prior to their usage.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit de79e754fa8118d34ea804d6b4fb7056b65487fd)
-rw-r--r--kdecore/kglobalsettings.cpp37
-rw-r--r--kio/kfile/kfilespeedbar.cpp44
2 files changed, 53 insertions, 28 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)
diff --git a/kio/kfile/kfilespeedbar.cpp b/kio/kfile/kfilespeedbar.cpp
index 49ca66cdc..5cf9ed3df 100644
--- a/kio/kfile/kfilespeedbar.cpp
+++ b/kio/kfile/kfilespeedbar.cpp
@@ -44,37 +44,27 @@ KFileSpeedBar::KFileSpeedBar( TQWidget *parent, const char *name )
if ( m_initializeSpeedbar )
{
- KURL u;
- u.setPath( KGlobalSettings::desktopPath() );
- insertItem( u, i18n("Desktop"), false );
-
-//TODO: win32
- if ((KGlobalSettings::documentPath() != (TQDir::homeDirPath()+"/")) &&
- TQDir(KGlobalSettings::documentPath()).exists())
+ insertItem(TQDir::homeDirPath(), i18n("Home Folder"), false, "folder_home");
+ insertItem(KGlobalSettings::desktopPath(), i18n("Desktop"), false, "folder_txt");
+ insertItem(KGlobalSettings::documentPath(), i18n("Documents"), false, "folder_txt");
+ insertItem(KGlobalSettings::downloadPath(), i18n( "Downloads" ), false, "folder_html");
+ insertItem(KGlobalSettings::musicPath(), i18n( "Music" ), false, "folder_sound");
+ insertItem(KGlobalSettings::picturesPath(), i18n( "Pictures" ), false, "folder_image");
+ insertItem(KGlobalSettings::publicSharePath(), i18n( "Public" ), false, "folder");
+ insertItem(KGlobalSettings::templatesPath(), i18n( "Templates" ), false, "folder_txt");
+ insertItem(KGlobalSettings::videosPath(), i18n( "Videos" ), false, "folder_video");
+
+ KURL u = "media:/";
+ if (KProtocolInfo::isKnownProtocol(u))
{
- u.setPath( KGlobalSettings::documentPath() );
- insertItem( u, i18n("Documents"), false, "folder_txt" );
+ insertItem(u, i18n("Storage Media"), false, KProtocolInfo::icon("media"));
}
- u.setPath( TQDir::homeDirPath() );
- insertItem( u, i18n("Home Folder"), false, "folder_home" );
-
- u = "media:/";
- if ( KProtocolInfo::isKnownProtocol( u ) )
- insertItem( u, i18n("Storage Media"), false, KProtocolInfo::icon( "media" ) );
-
- // now add in the speedbar
- insertItem(KGlobalSettings::downloadPath(), i18n( "Downloads" ), false, "folder_html" );
- insertItem(KGlobalSettings::musicPath(), i18n( "Music" ), false, "folder_sound" );
- insertItem(KGlobalSettings::picturesPath(), i18n( "Pictures" ), false, "folder_image" );
- insertItem(KGlobalSettings::publicSharePath(), i18n( "Public" ), false, "folder" );
- insertItem(KGlobalSettings::templatesPath(), i18n( "Templates" ), false, "folder" );
- insertItem(KGlobalSettings::videosPath(), i18n( "Videos" ), false, "folder_video" );
-
u = "remote:/";
- if ( KProtocolInfo::isKnownProtocol( u ) )
- insertItem( u, i18n("Network Folders"), false,
- KProtocolInfo::icon( "remote" ) );
+ if (KProtocolInfo::isKnownProtocol(u))
+ {
+ insertItem(u, i18n("Network Folders"), false, KProtocolInfo::icon("remote"));
+ }
}
}