Sophie

Sophie

distrib > Mandriva > 2009.0 > i586 > by-pkgid > d9b360ee2bb591aec74456d859429422 > files > 8

kdelibs4-4.1.2-5mdv2009.0.src.rpm

#
# Complete new implementation of xdg-user-dirs based on recent discussion at #kde-devel.
# Qt 4.4 implements partially the xdg spec except for XDG_DOWNLOAD_PATH ( TEMPLATES and PUBLICSHARED is not required ), which is done using part of the previous code.
# The reason to move for Qt code comes because portability to other platforms.
# KDE have Autostart path, so the same old code was kept and behavior remains the same.

--- kdeui/kernel/kglobalsettings.h	2008-05-21 08:08:18.000000000 -0300
+++ kdeui/kernel/kglobalsettings.h.new	2008-08-07 13:39:53.000000000 -0300
@@ -25,6 +25,7 @@
 #include <QtGui/QPalette>
 
 #define KDE_DEFAULT_SINGLECLICK true
+#define KDE_DEFAULT_SMOOTHSCROLL true
 #define KDE_DEFAULT_INSERTTEAROFFHANDLES 0
 #define KDE_DEFAULT_AUTOSELECTDELAY -1
 #define KDE_DEFAULT_CHANGECURSOR true
@@ -110,6 +111,13 @@
     static bool singleClick();
 
     /**
+     * Returns if item views should force smooth scrolling.
+     * @return true if smooth scrolling is enabled for item view, false otherwise.
+     * @since 4.2
+     */
+    static bool smoothScroll();
+
+    /**
      * This enum describes the return type for insertTearOffHandle() whether to insert
      * a handle or not. Applications who independently want to use handles in their popup menus
      * should test for Application level before calling the appropriate function in KMenu.
@@ -230,6 +238,29 @@
      */
     static QString documentPath();
 
+    /**
+     * The path where music are stored of the current user.
+     * @return the path of the music directory
+     */
+    static QString musicPath();
+
+    /**
+     * The path where videos are stored of the current user.
+     * @return the path of the video directory
+     */
+    static QString videosPath();
+
+    /**
+     * The path where download are stored of the current user.
+     * @return the path of the download directory
+     */
+    static QString downloadPath();
+
+    /**
+     * The path where pictures are stored of the current user.
+     * @return the path of the pictures directory
+     */
+    static QString picturesPath();
 
     /**
      * The default color to use for inactive titles.
--- kdeui/kernel/kglobalsettings.cpp	2008-07-03 02:06:28.000000000 -0300
+++ kdeui/kernel/kglobalsettings.cpp.new	2008-08-07 13:40:02.000000000 -0300
@@ -48,6 +48,7 @@
 #include <QApplication>
 #include <QtDBus/QtDBus>
 #include <QtGui/QStyleFactory>
+#include <QDesktopServices>
 
 // next two needed so we can set their palettes
 #include <QtGui/QToolTip>
@@ -74,9 +75,6 @@
 #include <stdlib.h>
 #include <kconfiggroup.h>
 
-static QString* s_desktopPath = 0;
-static QString* s_autostartPath = 0;
-static QString* s_documentPath = 0;
 static QFont *_generalFont = 0;
 static QFont *_fixedFont = 0;
 static QFont *_toolBarFont = 0;
@@ -120,18 +118,10 @@
         void applyCursorTheme();
 
         /**
-         * reads in all paths from kdeglobals
-         */
-        static void initPaths();
-        /**
          * drop cached values for fonts
          */
         static void rereadFontSettings();
         /**
-         * drop cached values for paths
-         */
-        static void rereadPathSettings();
-        /**
          * drop cached values for mouse settings
          */
         static void rereadMouseSettings();
@@ -177,6 +167,12 @@
     return g.readEntry("SingleClick", KDE_DEFAULT_SINGLECLICK );
 }
 
+bool KGlobalSettings::smoothScroll()
+{
+    KConfigGroup g( KGlobal::config(), "KDE" );
+    return g.readEntry("SmoothScroll", KDE_DEFAULT_SMOOTHSCROLL );
+}
+
 KGlobalSettings::TearOffHandle KGlobalSettings::insertTearOffHandle()
 {
     int tearoff;
@@ -497,51 +493,6 @@
     return *_smallestReadableFont;
 }
 
-void KGlobalSettings::Private::initPaths()
-{
-    //this code is duplicated in kde_config.cpp.in
-
-    if ( s_desktopPath != 0 )
-        return;
-
-    KGlobalSettings::self(); // listen to changes
-
-    s_desktopPath = new QString();
-    s_autostartPath = new QString();
-    s_documentPath = new QString();
-
-    KConfigGroup g( KGlobal::config(), "Paths" );
-
-    // Desktop Path
-    *s_desktopPath = QDir::homePath() + "/Desktop/";
-    *s_desktopPath = g.readPathEntry( "Desktop", *s_desktopPath);
-    *s_desktopPath = QDir::cleanPath( *s_desktopPath );
-    if ( !s_desktopPath->endsWith('/') ) {
-        s_desktopPath->append( QLatin1Char( '/' ) );
-    }
-
-    // Autostart Path
-    *s_autostartPath = KGlobal::dirs()->localkdedir() + "Autostart/";
-    *s_autostartPath = g.readPathEntry( "Autostart" , *s_autostartPath);
-    *s_autostartPath = QDir::cleanPath( *s_autostartPath );
-    if ( !s_autostartPath->endsWith('/') ) {
-        s_autostartPath->append( QLatin1Char( '/' ) );
-    }
-
-    // Document Path
-    *s_documentPath = g.readPathEntry( "Documents",
-#ifdef Q_WS_WIN
-        getWin32ShellFoldersPath("Personal")
-#else
-        QDir::homePath()
-#endif
-    );
-    *s_documentPath = QDir::cleanPath( *s_documentPath );
-    if ( !s_documentPath->endsWith('/')) {
-        s_documentPath->append( QLatin1Char( '/' ) );
-    }
-}
-
 void KGlobalSettings::Private::rereadFontSettings()
 {
     delete _generalFont;
@@ -560,16 +511,6 @@
     _smallestReadableFont = 0L;
 }
 
-void KGlobalSettings::Private::rereadPathSettings()
-{
-    delete s_autostartPath;
-    s_autostartPath = 0L;
-    delete s_desktopPath;
-    s_desktopPath = 0L;
-    delete s_documentPath;
-    s_documentPath = 0L;
-}
-
 KGlobalSettings::KMouseSettings & KGlobalSettings::mouseSettings()
 {
     if ( ! s_mouseSettings )
@@ -630,20 +571,60 @@
 
 QString KGlobalSettings::desktopPath()
 {
-    Private::initPaths();
-    return *s_desktopPath;
+	return QDesktopServices::storageLocation( QDesktopServices::DesktopLocation );
 }
 
+// Autostart is not a XDG path, so we keep with old kdelibs code code
 QString KGlobalSettings::autostartPath()
 {
-    Private::initPaths();
-    return *s_autostartPath;
+    QString s_autostartPath;
+    KConfigGroup g( KGlobal::config(), "Paths" );
+    s_autostartPath = KGlobal::dirs()->localkdedir() + "Autostart/";
+    s_autostartPath = g.readPathEntry( "Autostart" , s_autostartPath );
+    s_autostartPath = QDir::cleanPath( s_autostartPath );
+    if ( !s_autostartPath.endsWith( '/' ) ) {
+        s_autostartPath.append( QLatin1Char( '/' ) );
+    }
+    return s_autostartPath;
 }
 
 QString KGlobalSettings::documentPath()
 {
-    Private::initPaths();
-    return *s_documentPath;
+    return QDesktopServices::storageLocation( QDesktopServices::DocumentsLocation );
+}
+
+QString KGlobalSettings::downloadPath()
+{
+    // Qt 4.4.1 does not have DOWNLOAD, so we based on old code for now
+    QString downloadPath = QDir::homePath();
+#ifndef Q_WS_WIN
+    QString xdgUserDirs = QDir::homePath() + QLatin1String( "/.config/user-dirs.dirs" );
+    if( QFile::exists( xdgUserDirs ) ) {
+        KConfig xdgUserConf( xdgUserDirs, KConfig::SimpleConfig );
+        KConfigGroup g( &xdgUserConf, "" );
+        downloadPath  = g.readPathEntry( "XDG_DOWNLOAD_DIR", downloadPath ).remove(  '"' );
+    }
+#endif
+    downloadPath = QDir::cleanPath( downloadPath );
+    if ( !downloadPath.endsWith( '/' ) ) {
+        downloadPath.append( QLatin1Char(  '/' ) );
+    }
+    return downloadPath;
+}
+
+QString KGlobalSettings::videosPath()
+{
+    return QDesktopServices::storageLocation( QDesktopServices::MoviesLocation );
+}
+
+QString KGlobalSettings::picturesPath()
+{
+    return QDesktopServices::storageLocation( QDesktopServices::PicturesLocation );
+}
+
+QString KGlobalSettings::musicPath()
+{
+    return QDesktopServices::storageLocation( QDesktopServices::MusicLocation );
 }
 
 bool KGlobalSettings::isMultiHead()
@@ -808,9 +789,7 @@
         KGlobal::config()->reparseConfiguration();
         rereadOtherSettings();
         SettingsCategory category = static_cast<SettingsCategory>(arg);
-        if (category == SETTINGS_PATHS) {
-            KGlobalSettings::Private::rereadPathSettings();
-        } else if (category == SETTINGS_MOUSE) {
+        if (category == SETTINGS_MOUSE) {
             KGlobalSettings::Private::rereadMouseSettings();
         }
         propagateSettings(category);