|
|
@ -87,42 +87,90 @@ TQColor *TDEGlobalSettings::alternateColor = 0;
|
|
|
|
|
|
|
|
|
|
|
|
TDEGlobalSettings::KMouseSettings *TDEGlobalSettings::s_mouseSettings = 0;
|
|
|
|
TDEGlobalSettings::KMouseSettings *TDEGlobalSettings::s_mouseSettings = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// helper function for reading xdg user dirs: it is required in order to take
|
|
|
|
// Helper function for reading xdg user dirs.
|
|
|
|
// care of locale stuff
|
|
|
|
// Returns sane values in case the user dir file can't be read
|
|
|
|
void readXdgUserDirs(TQString *desktop, TQString *documents, TQString *videos, TQString *music,
|
|
|
|
static void readXdgUserDirs(TQString *desktop, TQString *documents, TQString *download, TQString *music,
|
|
|
|
TQString *download, TQString *pictures, TQString *templates, TQString *publicShare)
|
|
|
|
TQString *pictures, TQString *publicShare, TQString *templates, TQString *videos)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQFile f( TQDir::homeDirPath() + "/.config/user-dirs.dirs" );
|
|
|
|
TQFile dirsFile(TQDir::homeDirPath() + "/.config/user-dirs.dirs");
|
|
|
|
|
|
|
|
if (dirsFile.open(IO_ReadOnly))
|
|
|
|
if (!f.open(IO_ReadOnly))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// set the codec for the current locale
|
|
|
|
|
|
|
|
TQTextStream s(&f);
|
|
|
|
|
|
|
|
s.setCodec( TQTextCodec::codecForLocale() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQString line = s.readLine();
|
|
|
|
|
|
|
|
while (!line.isNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (line.startsWith("XDG_DESKTOP_DIR="))
|
|
|
|
// set the codec for the current locale
|
|
|
|
*desktop = line.remove("XDG_DESKTOP_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
|
|
|
|
TQTextStream stream(&dirsFile);
|
|
|
|
else if (line.startsWith("XDG_DOCUMENTS_DIR="))
|
|
|
|
stream.setCodec(TQTextCodec::codecForLocale());
|
|
|
|
*documents = line.remove("XDG_DOCUMENTS_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
|
|
|
|
|
|
|
|
else if (line.startsWith("XDG_MUSIC_DIR="))
|
|
|
|
while (!stream.atEnd())
|
|
|
|
*videos = line.remove("XDG_MUSIC_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
|
|
|
|
{
|
|
|
|
else if (line.startsWith("XDG_DOWNLOAD_DIR="))
|
|
|
|
TQString line = stream.readLine();
|
|
|
|
*download = line.remove("XDG_DOWNLOAD_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
|
|
|
|
if (line.startsWith("XDG_DESKTOP_DIR="))
|
|
|
|
else if (line.startsWith("XDG_VIDEOS_DIR="))
|
|
|
|
{
|
|
|
|
*music = line.remove("XDG_VIDEOS_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
|
|
|
|
*desktop = line.remove("XDG_DESKTOP_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_DOCUMENTS_DIR="))
|
|
|
|
else if (line.startsWith("XDG_TEMPLATES_DIR="))
|
|
|
|
{
|
|
|
|
*templates = line.remove("XDG_TEMPLATES_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
|
|
|
|
*documents = line.remove("XDG_DOCUMENTS_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
|
|
|
|
else if (line.startsWith("XDG_PUBLICSHARE_DIR="))
|
|
|
|
}
|
|
|
|
*publicShare = line.remove("XDG_PUBLICSHARE_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
|
|
|
|
else if (line.startsWith("XDG_DOWNLOAD_DIR="))
|
|
|
|
|
|
|
|
{
|
|
|
|
line = s.readLine();
|
|
|
|
*download = line.remove("XDG_DOWNLOAD_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (line.startsWith("XDG_MUSIC_DIR="))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*music = line.remove("XDG_MUSIC_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_PUBLICSHARE_DIR="))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*publicShare = line.remove("XDG_PUBLICSHARE_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_VIDEOS_DIR="))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*videos = line.remove("XDG_VIDEOS_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dirsFile.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Use sane values in case some paths are missing
|
|
|
|
|
|
|
|
if (desktop->isEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*desktop = TQDir::homeDirPath() + "/" + i18n("Desktop") + "/";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (documents->isEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*documents = TQDir::homeDirPath() + "/" + i18n("Documents") + "/";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (download->isEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*download = TQDir::homeDirPath() + "/" + i18n("Downloads") + "/";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (music->isEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*music = TQDir::homeDirPath() + "/" + i18n("Music") + "/";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pictures->isEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*pictures = TQDir::homeDirPath() + "/" + i18n("Pictures") + "/";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (publicShare->isEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*publicShare = TQDir::homeDirPath() + "/" + i18n("Public") + "/";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (templates->isEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*templates = TQDir::homeDirPath() + "/" + i18n("Templates") + "/";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (videos->isEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*videos = TQDir::homeDirPath() + "/" + i18n("Videos") + "/";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int TDEGlobalSettings::dndEventDelay()
|
|
|
|
int TDEGlobalSettings::dndEventDelay()
|
|
|
@ -525,63 +573,61 @@ TQFont TDEGlobalSettings::largeFont(const TQString &text)
|
|
|
|
return *_largeFont;
|
|
|
|
return *_largeFont;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TDEGlobalSettings::initStatic() // should be called initPaths(). Don't put anything else here.
|
|
|
|
void TDEGlobalSettings::initPaths()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( s_desktopPath != 0 )
|
|
|
|
if (s_desktopPath)
|
|
|
|
return;
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
s_desktopPath = new TQString();
|
|
|
|
|
|
|
|
s_autostartPath = new TQString();
|
|
|
|
s_autostartPath = new TQString();
|
|
|
|
s_trashPath = new TQString();
|
|
|
|
s_trashPath = new TQString();
|
|
|
|
|
|
|
|
s_desktopPath = new TQString();
|
|
|
|
s_documentPath = new TQString();
|
|
|
|
s_documentPath = new TQString();
|
|
|
|
s_videosPath = new TQString();
|
|
|
|
|
|
|
|
s_musicPath = new TQString();
|
|
|
|
|
|
|
|
s_downloadPath = new TQString();
|
|
|
|
s_downloadPath = new TQString();
|
|
|
|
|
|
|
|
s_musicPath = new TQString();
|
|
|
|
s_picturesPath = new TQString();
|
|
|
|
s_picturesPath = new TQString();
|
|
|
|
s_templatesPath = new TQString();
|
|
|
|
|
|
|
|
s_publicSharePath = new TQString();
|
|
|
|
s_publicSharePath = new TQString();
|
|
|
|
|
|
|
|
s_templatesPath = new TQString();
|
|
|
|
|
|
|
|
s_videosPath = new TQString();
|
|
|
|
|
|
|
|
|
|
|
|
TDEConfigGroup g( TDEGlobal::config(), "Paths" );
|
|
|
|
TDEConfigGroup g( TDEGlobal::config(), "Paths" );
|
|
|
|
|
|
|
|
|
|
|
|
// Read desktop and documents path using XDG_USER_DIRS
|
|
|
|
// Read xdg folder paths
|
|
|
|
readXdgUserDirs(s_desktopPath, s_documentPath, s_musicPath, s_videosPath,
|
|
|
|
readXdgUserDirs(s_desktopPath, s_documentPath, s_downloadPath, s_musicPath,
|
|
|
|
s_downloadPath, s_picturesPath, s_templatesPath, s_publicSharePath);
|
|
|
|
s_picturesPath, s_publicSharePath, s_templatesPath, s_videosPath);
|
|
|
|
|
|
|
|
|
|
|
|
if (s_desktopPath->isEmpty() == true) {
|
|
|
|
|
|
|
|
*s_desktopPath = TQDir::homeDirPath() + "/Desktop/";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*s_desktopPath = TQDir::cleanDirPath( *s_desktopPath );
|
|
|
|
*s_desktopPath = TQDir::cleanDirPath(*s_desktopPath);
|
|
|
|
if ( !s_desktopPath->endsWith("/") )
|
|
|
|
if (!s_desktopPath->endsWith("/"))
|
|
|
|
s_desktopPath->append('/');
|
|
|
|
s_desktopPath->append('/');
|
|
|
|
|
|
|
|
|
|
|
|
*s_documentPath = TQDir::cleanDirPath( *s_documentPath );
|
|
|
|
*s_documentPath = TQDir::cleanDirPath(*s_documentPath);
|
|
|
|
if ( !s_documentPath->endsWith("/"))
|
|
|
|
if (!s_documentPath->endsWith("/"))
|
|
|
|
s_documentPath->append('/');
|
|
|
|
s_documentPath->append('/');
|
|
|
|
|
|
|
|
|
|
|
|
*s_musicPath = TQDir::cleanDirPath( *s_musicPath );
|
|
|
|
*s_downloadPath = TQDir::cleanDirPath(*s_downloadPath);
|
|
|
|
if ( !s_musicPath->endsWith("/"))
|
|
|
|
if (!s_downloadPath->endsWith("/"))
|
|
|
|
s_musicPath->append('/');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*s_videosPath = TQDir::cleanDirPath( *s_videosPath );
|
|
|
|
|
|
|
|
if ( !s_videosPath->endsWith("/"))
|
|
|
|
|
|
|
|
s_videosPath->append('/');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*s_downloadPath = TQDir::cleanDirPath( *s_downloadPath );
|
|
|
|
|
|
|
|
if ( !s_downloadPath->endsWith("/"))
|
|
|
|
|
|
|
|
s_downloadPath->append('/');
|
|
|
|
s_downloadPath->append('/');
|
|
|
|
|
|
|
|
|
|
|
|
*s_picturesPath = TQDir::cleanDirPath( *s_picturesPath );
|
|
|
|
*s_musicPath = TQDir::cleanDirPath(*s_musicPath);
|
|
|
|
if ( !s_picturesPath->endsWith("/"))
|
|
|
|
if (!s_musicPath->endsWith("/"))
|
|
|
|
|
|
|
|
s_musicPath->append('/');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*s_picturesPath = TQDir::cleanDirPath(*s_picturesPath);
|
|
|
|
|
|
|
|
if (!s_picturesPath->endsWith("/"))
|
|
|
|
s_picturesPath->append('/');
|
|
|
|
s_picturesPath->append('/');
|
|
|
|
|
|
|
|
|
|
|
|
*s_templatesPath = TQDir::cleanDirPath( *s_templatesPath );
|
|
|
|
*s_publicSharePath = TQDir::cleanDirPath(*s_publicSharePath);
|
|
|
|
if ( !s_templatesPath->endsWith("/"))
|
|
|
|
if (!s_publicSharePath->endsWith("/"))
|
|
|
|
|
|
|
|
s_publicSharePath->append('/');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*s_templatesPath = TQDir::cleanDirPath(*s_templatesPath);
|
|
|
|
|
|
|
|
if (!s_templatesPath->endsWith("/"))
|
|
|
|
s_templatesPath->append('/');
|
|
|
|
s_templatesPath->append('/');
|
|
|
|
|
|
|
|
|
|
|
|
*s_publicSharePath = TQDir::cleanDirPath( *s_publicSharePath );
|
|
|
|
*s_videosPath = TQDir::cleanDirPath(*s_videosPath);
|
|
|
|
if ( !s_publicSharePath->endsWith("/"))
|
|
|
|
if (!s_videosPath->endsWith("/"))
|
|
|
|
s_publicSharePath->append('/');
|
|
|
|
s_videosPath->append('/');
|
|
|
|
|
|
|
|
|
|
|
|
// Trash Path - TODO remove in KDE4 (tdeio_trash can't use it for interoperability reasons)
|
|
|
|
// Trash Path - TODO remove in KDE4 (tdeio_trash can't use it for interoperability reasons)
|
|
|
|
*s_trashPath = *s_desktopPath + i18n("Trash") + "/";
|
|
|
|
*s_trashPath = *s_desktopPath + i18n("Trash") + "/";
|
|
|
@ -647,18 +693,18 @@ void TDEGlobalSettings::rereadPathSettings()
|
|
|
|
s_desktopPath = 0L;
|
|
|
|
s_desktopPath = 0L;
|
|
|
|
delete s_documentPath;
|
|
|
|
delete s_documentPath;
|
|
|
|
s_documentPath = 0L;
|
|
|
|
s_documentPath = 0L;
|
|
|
|
delete s_videosPath;
|
|
|
|
|
|
|
|
s_videosPath = 0L;
|
|
|
|
|
|
|
|
delete s_picturesPath;
|
|
|
|
|
|
|
|
s_picturesPath = 0L;
|
|
|
|
|
|
|
|
delete s_downloadPath;
|
|
|
|
delete s_downloadPath;
|
|
|
|
s_downloadPath = 0L;
|
|
|
|
s_downloadPath = 0L;
|
|
|
|
delete s_musicPath;
|
|
|
|
delete s_musicPath;
|
|
|
|
s_musicPath = 0L;
|
|
|
|
s_musicPath = 0L;
|
|
|
|
delete s_templatesPath;
|
|
|
|
delete s_picturesPath;
|
|
|
|
s_templatesPath = 0L;
|
|
|
|
s_picturesPath = 0L;
|
|
|
|
delete s_publicSharePath;
|
|
|
|
delete s_publicSharePath;
|
|
|
|
s_publicSharePath = 0L;
|
|
|
|
s_publicSharePath = 0L;
|
|
|
|
|
|
|
|
delete s_templatesPath;
|
|
|
|
|
|
|
|
s_templatesPath = 0L;
|
|
|
|
|
|
|
|
delete s_videosPath;
|
|
|
|
|
|
|
|
s_videosPath = 0L;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TDEGlobalSettings::KMouseSettings & TDEGlobalSettings::mouseSettings()
|
|
|
|
TDEGlobalSettings::KMouseSettings & TDEGlobalSettings::mouseSettings()
|
|
|
|