diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-01-28 23:12:32 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-01-28 23:12:32 +0900 |
commit | 394c9f5c0e1b464aa8bc22bd65c5268acd43994d (patch) | |
tree | 39db9b6670e6ffce93a53f790593e15c0394997d /tdeio | |
parent | ecd1e4bd401a00be11f4d8bbaff01718f29f9118 (diff) | |
download | tdelibs-394c9f5c0e1b464aa8bc22bd65c5268acd43994d.tar.gz tdelibs-394c9f5c0e1b464aa8bc22bd65c5268acd43994d.zip |
Improved support for XDG folders without requiring xdg-user-dirs to be installed.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'tdeio')
-rw-r--r-- | tdeio/tdefile/kpropertiesdialog.cpp | 23 | ||||
-rw-r--r-- | tdeio/tdefile/tdefilespeedbar.cpp | 59 |
2 files changed, 12 insertions, 70 deletions
diff --git a/tdeio/tdefile/kpropertiesdialog.cpp b/tdeio/tdefile/kpropertiesdialog.cpp index 0aaf2f40e..ae8aae85d 100644 --- a/tdeio/tdefile/kpropertiesdialog.cpp +++ b/tdeio/tdefile/kpropertiesdialog.cpp @@ -2630,13 +2630,7 @@ KURLPropsPlugin::KURLPropsPlugin( KPropertiesDialog *_props ) KFileItem * item = properties->item(); - if (item && item->mimetype() == "media/builtin-mydocuments") { - URLStr = TQString::null; - TDEConfig xdguserconfig( TQDir::homeDirPath()+"/.config/user-dirs.dirs" ); - URLEdit->setMode(KFile::Directory); - URLEdit->setURL( xdguserconfig.readPathEntry( "XDG_DOCUMENTS_DIR", TQDir::homeDirPath() + "/Documents").remove( "\"" )); - } - else if (item && item->mimetype().startsWith("media/builtin-")) { + if (item && item->mimetype().startsWith("media/builtin-")) { URLEdit->setEnabled(false); } @@ -2679,20 +2673,7 @@ void KURLPropsPlugin::applyChanges() TQString path = properties->kurl().path(); KFileItem * item = properties->item(); - if (item && item->mimetype() == "media/builtin-mydocuments") { - TDEConfig xdgconfig(TQDir::homeDirPath()+"/.config/user-dirs.dirs" ); - if (xdgconfig.isReadOnly()) { - KMessageBox::sorry( 0, i18n("<qt>Could not save properties. You do not have " - "sufficient access to write to <b>%1</b>.</qt>").arg(path)); - return; - } - else { - xdgconfig.writePathEntry( "XDG_DOCUMENTS_DIR", '"'+ URLEdit->url() + '"', true, false, false, false ); - xdgconfig.sync(); - return; - } - } - else if (item && item->mimetype().startsWith("media/builtin-")) { + if (item && item->mimetype().startsWith("media/builtin-")) { return; } diff --git a/tdeio/tdefile/tdefilespeedbar.cpp b/tdeio/tdefile/tdefilespeedbar.cpp index 3f84bbbc4..635474122 100644 --- a/tdeio/tdefile/tdefilespeedbar.cpp +++ b/tdeio/tdefile/tdefilespeedbar.cpp @@ -57,58 +57,19 @@ KFileSpeedBar::KFileSpeedBar( TQWidget *parent, const char *name ) } u.setPath( TQDir::homeDirPath() ); - insertItem( u, i18n("Home Folder"), false, - "folder_home" ); + insertItem( u, i18n("Home Folder"), false, "folder_home" ); u = "media:/"; if ( KProtocolInfo::isKnownProtocol( u ) ) - insertItem( u, i18n("Storage Media"), false, - KProtocolInfo::icon( "media" ) ); - - if ( TQFile::exists( TQDir::homeDirPath()+"/.config/user-dirs.dirs" ) ) - { - TQString download, music, pictures, videos, templates, publicShares; - - TQFile f( TQDir::homeDirPath()+"/.config/user-dirs.dirs" ); - if (!f.open(IO_ReadOnly)) - return; - - TQTextStream s( &f ); - s.setCodec( TQTextCodec::codecForLocale() ); - - // read the xdg user dirs - TQString line = s.readLine(); - while (!line.isNull()) - { - if (line.startsWith("XDG_DOWNLOAD_DIR=")) - 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_VIDEOS_DIR=")) - videos = line.remove("XDG_VIDEOS_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_PUBLICSHARES_DIR=")) - publicShares = line.remove("XDG_PUBLICSHARES_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath()); - - line = s.readLine(); - } - // now add in the speedbar - if (!download.isEmpty()) - insertItem( download, i18n( "Downloads" ), false, "folder_html" ); - if (!music.isEmpty()) - insertItem( music, i18n( "Music" ), false, "folder_sound" ); - if (!pictures.isEmpty()) - insertItem( pictures, i18n( "Pictures" ), false, "folder_image" ); - if (!videos.isEmpty()) - insertItem( videos, i18n( "Videos" ), false, "folder_video" ); - if (!templates.isEmpty()) - insertItem( templates, i18n( "Templates" ), false, "folder_video" ); - if (!publicShares.isEmpty()) - insertItem( publicShares, i18n( "Public" ), false, "folder_video" ); - } + insertItem( u, i18n("Storage Media"), false, KProtocolInfo::icon( "media" ) ); + + // now add in the speedbar + insertItem(TDEGlobalSettings::downloadPath(), i18n( "Downloads" ), false, "folder_html" ); + insertItem(TDEGlobalSettings::musicPath(), i18n( "Music" ), false, "folder_sound" ); + insertItem(TDEGlobalSettings::picturesPath(), i18n( "Pictures" ), false, "folder_image" ); + insertItem(TDEGlobalSettings::publicSharePath(), i18n( "Public" ), false, "folder" ); + insertItem(TDEGlobalSettings::templatesPath(), i18n( "Templates" ), false, "folder" ); + insertItem(TDEGlobalSettings::videosPath(), i18n( "Videos" ), false, "folder_video" ); u = "remote:/"; if ( KProtocolInfo::isKnownProtocol( u ) ) |