summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2020-01-12 20:44:36 +0900
committerSlávek Banko <slavek.banko@axis.cz>2021-02-03 17:37:46 +0100
commita9bf4396088c2cc598e65654ae009c5e175db742 (patch)
tree13fa1cd3df1e14d217afa23761a7331d636ff6f3
parentfb65a4b2125e377acdf11080c6086154fddf16ac (diff)
downloadtdelibs-a9bf4396088c2cc598e65654ae009c5e175db742.tar.gz
tdelibs-a9bf4396088c2cc598e65654ae009c5e175db742.zip
Added support for XDG_PICTURES_DIR and XDG_TEMPLATES_DIR in TDE global settings.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit aca6b3d42409234a19e2910443d511328c0b025a)
-rw-r--r--kdecore/kglobalsettings.cpp27
-rw-r--r--kdecore/kglobalsettings.h14
2 files changed, 38 insertions, 3 deletions
diff --git a/kdecore/kglobalsettings.cpp b/kdecore/kglobalsettings.cpp
index 4da6beaa8..7696e74a8 100644
--- a/kdecore/kglobalsettings.cpp
+++ b/kdecore/kglobalsettings.cpp
@@ -66,6 +66,8 @@ TQString* KGlobalSettings::s_videosPath = 0;
TQString* KGlobalSettings::s_musicPath = 0;
TQString* KGlobalSettings::s_downloadPath = 0;
TQString* KGlobalSettings::s_picturesPath = 0;
+TQString* KGlobalSettings::s_templatesPath = 0;
+TQString* KGlobalSettings::s_publicSharePath = 0;
TQFont *KGlobalSettings::_generalFont = 0;
TQFont *KGlobalSettings::_fixedFont = 0;
TQFont *KGlobalSettings::_toolBarFont = 0;
@@ -87,7 +89,8 @@ 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(TQString *desktop, TQString *documents, TQString *videos, TQString *music, TQString *download, TQString *pictures)
+void readXdgUserDirs(TQString *desktop, TQString *documents, TQString *videos, TQString *music,
+ TQString *download, TQString *pictures, TQString *templates, TQString *publicShare)
{
TQFile f( TQDir::homeDirPath() + "/.config/user-dirs.dirs" );
@@ -113,6 +116,10 @@ void readXdgUserDirs(TQString *desktop, TQString *documents, TQString *videos, T
*music = line.remove("XDG_VIDEOS_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
else if (line.startsWith("XDG_PICTURES_DIR="))
*pictures = line.remove("XDG_PICTURES_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
+ else if (line.startsWith("XDG_TEMPLATES_DIR="))
+ *templates = line.remove("XDG_TEMPLATES_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
+ else if (line.startsWith("XDG_PUBLICSHARE_DIR="))
+ *publicShare = line.remove("XDG_PUBLICSHARE_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
line = s.readLine();
}
@@ -531,12 +538,14 @@ void KGlobalSettings::initStatic() // should be called initPaths(). Don't put an
s_musicPath = new TQString();
s_downloadPath = new TQString();
s_picturesPath = new TQString();
-
+ s_templatesPath = new TQString();
+ s_publicSharePath = new TQString();
KConfigGroup g( KGlobal::config(), "Paths" );
// Read desktop and documents path using XDG_USER_DIRS
- readXdgUserDirs(s_desktopPath, s_documentPath, s_musicPath, s_videosPath, s_downloadPath, s_picturesPath);
+ readXdgUserDirs(s_desktopPath, s_documentPath, s_musicPath, s_videosPath,
+ s_downloadPath, s_picturesPath, s_templatesPath, s_publicSharePath);
if (s_desktopPath->isEmpty() == true) {
*s_desktopPath = TQDir::homeDirPath() + "/Desktop/";
@@ -566,6 +575,14 @@ void KGlobalSettings::initStatic() // should be called initPaths(). Don't put an
if ( !s_picturesPath->endsWith("/"))
s_picturesPath->append('/');
+ *s_templatesPath = TQDir::cleanDirPath( *s_templatesPath );
+ if ( !s_templatesPath->endsWith("/"))
+ s_templatesPath->append('/');
+
+ *s_publicSharePath = TQDir::cleanDirPath( *s_publicSharePath );
+ if ( !s_publicSharePath->endsWith("/"))
+ s_publicSharePath->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);
@@ -638,6 +655,10 @@ void KGlobalSettings::rereadPathSettings()
s_downloadPath = 0L;
delete s_musicPath;
s_musicPath = 0L;
+ delete s_templatesPath;
+ s_templatesPath = 0L;
+ delete s_publicSharePath;
+ s_publicSharePath = 0L;
}
KGlobalSettings::KMouseSettings & KGlobalSettings::mouseSettings()
diff --git a/kdecore/kglobalsettings.h b/kdecore/kglobalsettings.h
index b4bf0497f..0ef6e1883 100644
--- a/kdecore/kglobalsettings.h
+++ b/kdecore/kglobalsettings.h
@@ -278,6 +278,18 @@ class KDECORE_EXPORT KGlobalSettings
static TQString picturesPath() { initStatic(); return *s_picturesPath; }
/**
+ * The path where templates are stored of the current user.
+ * @return the path of the templates directory
+ */
+ static TQString templatesPath() { initStatic(); return *s_templatesPath; }
+
+ /**
+ * The path of the public share of the current user.
+ * @return the path of the public share directory
+ */
+ static TQString publicSharePath() { initStatic(); return *s_publicSharePath; }
+
+ /**
* The default color to use when highlighting toolbar buttons.
* @return the toolbar highlight color
*/
@@ -584,6 +596,8 @@ private:
static TQString* s_trashPath;
static TQString* s_documentPath;
static TQString* s_picturesPath;
+ static TQString* s_templatesPath;
+ static TQString* s_publicSharePath;
static TQString* s_downloadPath;
static TQString* s_musicPath;
static TQString* s_videosPath;