Bug 173796 - User Environment Path Settings
Summary: User Environment Path Settings
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist (vote)
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-28 23:38 UTC by Aaron Nixon
Modified: 2009-01-09 17:23 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch to add user folder settings (12.55 KB, patch)
2008-10-29 19:04 UTC, Aaron Nixon
Details
Patch for Branch 4.2 (11.06 KB, patch)
2009-01-09 02:45 UTC, Aaron Nixon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron Nixon 2008-10-28 23:38:52 UTC
Version:            (using Devel)
Compiler:          i686-pc-linux-gnu-4.1.2 
OS:                Linux
Installed from:    Compiled sources

Just thought it would be nice to include the rest of the user paths (To go along with Desktop, Autostart and Documents).

Primative code stuffs, but since the list that can be pulled from isn't dynamic, I don't think it really matters.

Lemme know if I missed anything.

Thanks!

Index: apps/konqueror/settings/konq/globalpaths.cpp                                                                                      
===================================================================                                                                      
--- apps/konqueror/settings/konq/globalpaths.cpp        (revision 877191)                                                                
+++ apps/konqueror/settings/konq/globalpaths.cpp        (working copy)                                                                   
@@ -75,18 +75,11 @@                                                                                                                      
 {                                                                                                                                       
   QLabel * tmpLabel;                                                                                                                    
                                                                                                                                         
-#undef RO_LASTROW                                                                                                                       
-#undef RO_LASTCOL                                                                                                                       
-#define RO_LASTROW 4   // 3 paths + last row                                                                                            
-#define RO_LASTCOL 2                                                                                                                    
-                                                                                                                                        
   int row = 0;                                                                                                                          
   QGridLayout *lay = new QGridLayout(this );                                                                                            
   lay->setSpacing( KDialog::spacingHint() );                                                                                            
   lay->setMargin(0);                                                                                                                    
                                                                                                                                         
-  lay->setRowStretch(RO_LASTROW,10); // last line grows                                                                                 
-                                                                                                                                        
   lay->setColumnStretch(0,0);                                                                                                           
   lay->setColumnStretch(1,0);                                                                                                           
   lay->setColumnStretch(2,10);                                                                                                          
@@ -99,12 +92,13 @@                                                                                                                      
                                                                                                                                         
   // Desktop Paths                                                                                                                      
   row++;                                                                                                                                
+                                                                                                                                        
   tmpLabel = new QLabel(i18n("Des&ktop path:"), this);                                                                                  
   lay->addWidget(tmpLabel, row, 0);                                                                                                     
   urDesktop = new KUrlRequester(this);                                                                                                  
   urDesktop->setMode( KFile::Directory | KFile::LocalOnly );                                                                            
   tmpLabel->setBuddy( urDesktop );                                                                                                      
-  lay->addWidget(urDesktop, row, 1, 1, RO_LASTCOL);                                                                                     
+  lay->addWidget(urDesktop, row, 1, 1, 2);                                                                                              
   connect(urDesktop, SIGNAL(textChanged(const QString &)), this, SLOT(changed()));                                                      
   QString wtstr = i18n("This folder contains all the files"                                                                             
                        " which you see on your desktop. You can change the location of this"                                            
@@ -114,12 +108,13 @@                                                                                                                    
   urDesktop->setWhatsThis( wtstr );                                                                                                     
                                                                                                                                         
   row++;                                                                                                                                
+                                                                                                                                        
   tmpLabel = new QLabel(i18n("A&utostart path:"), this);                                                                                
   lay->addWidget(tmpLabel, row, 0);                                                                                                     
   urAutostart = new KUrlRequester(this);                                                                                                
   urAutostart->setMode( KFile::Directory | KFile::LocalOnly );                                                                          
   tmpLabel->setBuddy( urAutostart );                                                                                                    
-  lay->addWidget(urAutostart, row, 1, 1, RO_LASTCOL);                                                                                   
+  lay->addWidget(urAutostart, row, 1, 1, 2);                                                                                            
   connect(urAutostart, SIGNAL(textChanged(const QString &)), this, SLOT(changed()));                                                    
   wtstr = i18n("This folder contains applications or"                                                                                   
                " links to applications (shortcuts) that you want to have started"                                                       
@@ -130,20 +125,78 @@                                                                                                                    
   urAutostart->setWhatsThis( wtstr );                                                                                                   
                                                                                                                                         
   row++;                                                                                                                                
+                                                                                                                                        
   tmpLabel = new QLabel(i18n("D&ocuments path:"), this);                                                                                
   lay->addWidget(tmpLabel, row, 0);                                                                                                     
-  urDocument = new KUrlRequester(this);                                                                                                 
-  urDocument->setMode( KFile::Directory | KFile::LocalOnly );                                                                           
-  tmpLabel->setBuddy( urDocument );                                                                                                     
-  lay->addWidget(urDocument, row, 1, 1, RO_LASTCOL);                                                                                    
-  connect(urDocument, SIGNAL(textChanged(const QString &)), this, SLOT(changed()));                                                     
+  urDocuments = new KUrlRequester(this);                                                                                                
+  urDocuments->setMode( KFile::Directory | KFile::LocalOnly );                                                                          
+  tmpLabel->setBuddy( urDocuments );                                                                                                    
+  lay->addWidget(urDocuments, row, 1, 1, 2);                                                                                            
+  connect(urDocuments, SIGNAL(textChanged(const QString &)), this, SLOT(changed()));                                                    
   wtstr = i18n("This folder will be used by default to "                                                                                
                "load or save documents from or to.");                                                                                   
   tmpLabel->setWhatsThis( wtstr );                                                                                                      
-  urDocument->setWhatsThis( wtstr );                                                                                                    
+  urDocuments->setWhatsThis( wtstr );                                                                                                   
                                                                                                                                         
-  // -- Bottom --                                                                                                                       
-  Q_ASSERT( row == RO_LASTROW-1 ); // if it fails here, check the row++ and RO_LASTROW above                                            
+  row++;                                                                                                                                
+                                                                                                                                        
+  tmpLabel = new QLabel(i18n("Dow&nloads path:"), this);                                                                                
+  lay->addWidget(tmpLabel, row, 0);                                                                                                     
+  urDownloads = new KUrlRequester(this);                                                                                                
+  urDownloads->setMode( KFile::Directory | KFile::LocalOnly );                                                                          
+  tmpLabel->setBuddy( urDownloads );                                                                                                    
+  lay->addWidget(urDownloads, row, 1, 1, 2);                                                                                            
+  connect(urDownloads, SIGNAL(textChanged(const QString &)), this, SLOT(changed()));                                                    
+  wtstr = i18n("This folder will be used by default to save downloaded files to.");                                                     
+  tmpLabel->setWhatsThis( wtstr );                                                                                                      
+  urDownloads->setWhatsThis( wtstr );                                                                                                   
+                                                                                                                                        
+  row++;                                                                                                                                
+                                                                                                                                        
+  tmpLabel = new QLabel(i18n("Mo&vies path:"), this);                                                                                   
+  lay->addWidget(tmpLabel, row, 0);                                                                                                     
+  urMovies = new KUrlRequester(this);                                                                                                   
+  urMovies->setMode( KFile::Directory | KFile::LocalOnly );                                                                             
+  tmpLabel->setBuddy( urMovies );                                                                                                       
+  lay->addWidget(urMovies, row, 1, 1, 2);                                                                                               
+  connect(urMovies, SIGNAL(textChanged(const QString &)), this, SLOT(changed()));                                                       
+  wtstr = i18n("This folder will be used by default to save and load your movies to and from.");                                        
+  tmpLabel->setWhatsThis( wtstr );                                                                                                      
+  urMovies->setWhatsThis( wtstr );                                                                                                      
+                                                                                                                                        
+  row++;                                                                                                                                
+                                                                                                                                        
+  tmpLabel = new QLabel(i18n("Pi&ctures path:"), this);                                                                                 
+  lay->addWidget(tmpLabel, row, 0);                                                                                                     
+  urPictures = new KUrlRequester(this);                                                                                                 
+  urPictures->setMode( KFile::Directory | KFile::LocalOnly );                                                                           
+  tmpLabel->setBuddy( urPictures );                                                                                                     
+  lay->addWidget(urPictures, row, 1, 1, 2);                                                                                             
+  connect(urPictures, SIGNAL(textChanged(const QString &)), this, SLOT(changed()));                                                     
+  wtstr = i18n("This folder will be used by default to save and load your pictures to and from.");                                      
+  tmpLabel->setWhatsThis( wtstr );                                                                                                      
+  urPictures->setWhatsThis( wtstr );                                                                                                    
+                                                                                                                                        
+  row++;                                                                                                                                
+                                                                                                                                        
+  tmpLabel = new QLabel(i18n("M&usic path:"), this);                                                                                    
+  lay->addWidget(tmpLabel, row, 0);                                                                                                     
+  urMusic = new KUrlRequester(this);                                                                                                    
+  urMusic->setMode( KFile::Directory | KFile::LocalOnly );                                                                              
+  tmpLabel->setBuddy( urMusic );                                                                                                        
+  lay->addWidget(urMusic, row, 1, 1, 2);                                                                                                
+  connect(urMusic, SIGNAL(textChanged(const QString &)), this, SLOT(changed()));                                                        
+  wtstr = i18n("This folder will be used by default to save and load your music to and from.");                                         
+  tmpLabel->setWhatsThis( wtstr );                                                                                                      
+  urMusic->setWhatsThis( wtstr );                                                                                                       
+                                                                                                                                        
+  row++;                                                                                                                                
+                                                                                                                                        
+  tmpLabel = new QLabel("", this);                                                                                                      
+                                                                                                                                        
+  lay->addWidget(tmpLabel, row, 1, 0, 2);                                                                                               
+                                                                                                                                        
+  lay->setRowStretch(row, 10); // last line grows                                                                                       
 }                                                                                                                                       
                                                                                                                                         
 void DesktopPathConfig::load()                                                                                                          
@@ -151,7 +204,11 @@                                                                                                                     
     // Desktop Paths                                                                                                                    
     urDesktop->setPath( KGlobalSettings::desktopPath() );                                                                               
     urAutostart->setPath( KGlobalSettings::autostartPath() );                                                                           
-    urDocument->setPath( KGlobalSettings::documentPath() );                                                                             
+    urDocuments->setPath( KGlobalSettings::documentPath() );                                                                            
+    urDownloads->setPath( KGlobalSettings::downloadPath() );                                                                            
+    urMovies->setPath( KGlobalSettings::videosPath() );                                                                                 
+    urPictures->setPath( KGlobalSettings::picturesPath() );                                                                             
+    urMusic->setPath( KGlobalSettings::musicPath() );                                                                                   
     changed();                                                                                                                          
 }                                                                                                                                       
                                                                                                                                         
@@ -160,7 +217,11 @@                                                                                                                     
     // Desktop Paths - keep defaults in sync with kglobalsettings.cpp                                                                   
     urDesktop->setPath( QDir::homePath() + "/Desktop/" );                                                                               
     urAutostart->setPath( KGlobal::dirs()->localkdedir() + "Autostart/" );                                                              
-    urDocument->setPath( QDir::homePath() );                                                                                            
+    urDocuments->setPath( QDir::homePath() + "/Documents/" );                                                                           
+    urDownloads->setPath( QDir::homePath() + "/Downloads/" );                                                                           
+    urMovies->setPath( QDir::homePath() + "/Movies/" );                                                                                 
+    urPictures->setPath( QDir::homePath() + "/Pictures/" );                                                                             
+    urMusic->setPath( QDir::homePath() + "/Music/" );                                                                                   
 }                                                                                                                                       
                                                                                                                                         
 void DesktopPathConfig::save()                                                                                                          
@@ -179,10 +240,26 @@                                                                                                                    
     autostartURL.setPath( KGlobalSettings::autostartPath() );                                                                           
     KUrl newAutostartURL = urAutostart->url();                                                                                          
                                                                                                                                         
-    KUrl documentURL;                                                                                                                   
-    documentURL.setPath( KGlobalSettings::documentPath() );                                                                             
-    KUrl newDocumentURL = urDocument->url();                                                                                            
+    KUrl documentsURL;                                                                                                                  
+    documentsURL.setPath( KGlobalSettings::documentPath() );                                                                            
+    KUrl newDocumentsURL = urDocuments->url();                                                                                          
                                                                                                                                         
+    KUrl downloadsURL;                                                                                                                  
+    downloadsURL.setPath( KGlobalSettings::downloadPath() );                                                                            
+    KUrl newDownloadsURL = urDownloads->url();                                                                                          
+                                                                                                                                        
+    KUrl moviesURL;                                                                                                                     
+    moviesURL.setPath( KGlobalSettings::videosPath() );                                                                                 
+    KUrl newMoviesURL = urMovies->url();                                                                                                
+                                                                                                                                        
+    KUrl picturesURL;                                                                                                                   
+    picturesURL.setPath( KGlobalSettings::picturesPath() );                                                                             
+    KUrl newPicturesURL = urPictures->url();                                                                                            
+                                                                                                                                        
+    KUrl musicURL;                                                                                                                      
+    musicURL.setPath( KGlobalSettings::musicPath() );                                                                                   
+    KUrl newMusicURL = urMusic->url();                                                                                                  
+                                                                                                                                        
     if ( !newDesktopURL.equals( desktopURL, KUrl::CompareWithoutTrailingSlash ) )                                                       
     {                                                                                                                                   
         // Test which other paths were inside this one (as it is by default)                                                            
@@ -238,16 +315,16 @@                                                                                                                    
         }                                                                                                                               
     }                                                                                                                                   
                                                                                                                                         
-    if ( !newDocumentURL.equals( documentURL, KUrl::CompareWithoutTrailingSlash ) )                                                     
+    if ( !newDocumentsURL.equals( documentsURL, KUrl::CompareWithoutTrailingSlash ) )                                                   
     {                                                                                                                                   
         bool pathOk = true;                                                                                                             
-        QString path = urDocument->url().path();                                                                                        
+        QString path = urDocuments->url().path();                                                                                       
         if (!QDir(path).exists())                                                                                                       
         {                                                                                                                               
             if (!KStandardDirs::makeDir(path))                                                                                          
             {                                                                                                                           
                 KMessageBox::sorry(this, KIO::buildErrorString(KIO::ERR_COULD_NOT_MKDIR, path));                                        
-                urDocument->setPath(documentURL.path());                                                                                
+                urDocuments->setPath(documentsURL.path());                                                                              
                 pathOk = false;                                                                                                         
             }                                                                                                                           
         }                                                                                                                               
@@ -259,6 +336,90 @@                                                                                                                     
         }                                                                                                                               
     }                                                                                                                                   
                                                                                                                                         
+    if ( !newDownloadsURL.equals( downloadsURL, KUrl::CompareWithoutTrailingSlash ) )                                                   
+    {                                                                                                                                   
+        bool pathOk = true;                                                                                                             
+        QString path = urDownloads->url().path();                                                                                       
+        if (!QDir(path).exists())                                                                                                       
+        {                                                                                                                               
+            if (!KStandardDirs::makeDir(path))                                                                                          
+            {                                                                                                                           
+                KMessageBox::sorry(this, KIO::buildErrorString(KIO::ERR_COULD_NOT_MKDIR, path));                                        
+                urDownloads->setPath(downloadsURL.path());                                                                              
+                pathOk = false;                                                                                                         
+            }                                                                                                                           
+        }                                                                                                                               
+                                                                                                                                        
+        if (pathOk)                                                                                                                     
+        {                                                                                                                               
+            configGroup.writePathEntry( "Download", path, KConfigBase::Normal | KConfigBase::Global );                                  
+            pathChanged = true;                                                                                                         
+        }                                                                                                                               
+    }                                                                                                                                   
+                                                                                                                                        
+    if ( !newMoviesURL.equals( moviesURL, KUrl::CompareWithoutTrailingSlash ) )                                                         
+    {                                                                                                                                   
+        bool pathOk = true;                                                                                                             
+        QString path = urMovies->url().path();                                                                                          
+        if (!QDir(path).exists())                                                                                                       
+        {                                                                                                                               
+            if (!KStandardDirs::makeDir(path))                                                                                          
+            {                                                                                                                           
+                KMessageBox::sorry(this, KIO::buildErrorString(KIO::ERR_COULD_NOT_MKDIR, path));                                        
+                urMovies->setPath(moviesURL.path());                                                                                    
+                pathOk = false;                                                                                                         
+            }                                                                                                                           
+        }                                                                                                                               
+                                                                                                                                        
+        if (pathOk)                                                                                                                     
+        {                                                                                                                               
+            configGroup.writePathEntry( "Videos", path, KConfigBase::Normal | KConfigBase::Global );                                    
+            pathChanged = true;                                                                                                         
+        }                                                                                                                               
+    }                                                                                                                                   
+                                                                                                                                        
+    if ( !newPicturesURL.equals( picturesURL, KUrl::CompareWithoutTrailingSlash ) )                                                     
+    {                                                                                                                                   
+        bool pathOk = true;                                                                                                             
+        QString path = urPictures->url().path();                                                                                        
+        if (!QDir(path).exists())                                                                                                       
+        {                                                                                                                               
+            if (!KStandardDirs::makeDir(path))                                                                                          
+            {                                                                                                                           
+                KMessageBox::sorry(this, KIO::buildErrorString(KIO::ERR_COULD_NOT_MKDIR, path));                                        
+                urPictures->setPath(picturesURL.path());                                                                                
+                pathOk = false;                                                                                                         
+            }                                                                                                                           
+        }                                                                                                                               
+                                                                                                                                        
+        if (pathOk)                                                                                                                     
+        {                                                                                                                               
+            configGroup.writePathEntry( "Pictures", path, KConfigBase::Normal | KConfigBase::Global );                                  
+            pathChanged = true;                                                                                                         
+        }                                                                                                                               
+    }                                                                                                                                   
+                                                                                                                                        
+    if ( !newMusicURL.equals( musicURL, KUrl::CompareWithoutTrailingSlash ) )                                                           
+    {                                                                                                                                   
+        bool pathOk = true;                                                                                                             
+        QString path = urMusic->url().path();                                                                                           
+        if (!QDir(path).exists())                                                                                                       
+        {                                                                                                                               
+            if (!KStandardDirs::makeDir(path))                                                                                          
+            {                                                                                                                           
+                KMessageBox::sorry(this, KIO::buildErrorString(KIO::ERR_COULD_NOT_MKDIR, path));                                        
+                urMusic->setPath(musicURL.path());                                                                                      
+                pathOk = false;                                                                                                         
+            }                                                                                                                           
+        }                                                                                                                               
+                                                                                                                                        
+        if (pathOk)                                                                                                                     
+        {                                                                                                                               
+            configGroup.writePathEntry( "Music", path, KConfigBase::Normal | KConfigBase::Global );                                     
+            pathChanged = true;                                                                                                         
+        }                                                                                                                               
+    }                                                                                                                                   
+                                                                                                                                        
     config->sync();                                                                                                                     
                                                                                                                                         
     if (pathChanged)                                                                                                                    
@@ -301,7 +462,6 @@                                                                                                                      
             KIO::ListJob* job = KIO::listDir( src );                                                                                    
             connect( job, SIGNAL( entries( KIO::Job *, const KIO::UDSEntryList& ) ),                                                    
                      this, SLOT( slotEntries( KIO::Job *, const KIO::UDSEntryList& ) ) );                                               
-            qApp->enter_loop();                                                                                                         
                                                                                                                                         
             if (m_ok)                                                                                                                   
             {                                                                                                                           
@@ -313,8 +473,6 @@                                                                                                                      
             KIO::Job * job = KIO::move( src, dest );                                                                                    
             job->ui()->setWindow(this);                                                                                                 
             connect( job, SIGNAL( result( KJob * ) ), this, SLOT( slotResult( KJob * ) ) );                                             
-            // wait for job                                                                                                             
-            qApp->enter_loop();                                                                                                         
         }
     }
     kDebug() << "DesktopPathConfig::slotResult returning " << m_ok;
@@ -342,9 +500,7 @@
         KIO::Job * moveJob = KIO::move( file.url(), m_copyToDest );
         moveJob->ui()->setWindow(this);
         connect( moveJob, SIGNAL( result( KJob * ) ), this, SLOT( slotResult( KJob * ) ) );
-        qApp->enter_loop();
     }
-    qApp->exit_loop();
 }

 void DesktopPathConfig::slotResult( KJob * job )
@@ -358,7 +514,6 @@

         static_cast<KIO::Job*>(job)->ui()->showErrorMessage();
     }
-    qApp->exit_loop();
 }

 #include "globalpaths.moc"

Index: apps/konqueror/settings/konq/globalpaths.h
===================================================================
--- apps/konqueror/settings/konq/globalpaths.h  (revision 877191)
+++ apps/konqueror/settings/konq/globalpaths.h  (working copy)
@@ -61,7 +61,11 @@
     // Desktop Paths
     KUrlRequester *urDesktop;
     KUrlRequester *urAutostart;
-    KUrlRequester *urDocument;
+    KUrlRequester *urDocuments;
+    KUrlRequester *urDownloads;
+    KUrlRequester *urMovies;
+    KUrlRequester *urPictures;
+    KUrlRequester *urMusic;

     bool moveDir( const KUrl & src, const KUrl & dest, const QString & type );
     bool m_ok;
Comment 1 Aaron Nixon 2008-10-28 23:41:35 UTC
Actually,

Should get rid of the empty label.

This stuff isn't needed:
  tmpLabel = new QLabel("", this);

  lay->addWidget(tmpLabel, row, 1, 0, 2);
Comment 2 David Faure 2008-10-29 17:39:44 UTC
Good idea, but the patch is not usable when pasted inline.
Can you attach it as a file in this bug report? ("Add an attachment" at the bottom of the form). Thanks!
Comment 3 Aaron Nixon 2008-10-29 19:04:55 UTC
Created attachment 28223 [details]
Patch to add user folder settings

Submiting patch.
Comment 4 Aaron Nixon 2008-10-29 19:06:37 UTC
There you go, also FYI I removed the KD3support enter_loop and exit_loop calls.
Comment 5 Aaron Nixon 2009-01-09 02:45:15 UTC
Created attachment 30043 [details]
Patch for Branch 4.2

This new patch should apply to the KDE 4.2 branch with the new changes in it ^_^

Though I feel as if I'm missing something because it's not storing the path on save (At least it doesn't seem to).

Any help would be appreciated.

Thanks!
Comment 6 David Faure 2009-01-09 12:50:11 UTC
Thanks for the patch. I'll take over -- I want to get rid of the code duplication, and the bug you're seeing is probably due to removing enter_loop/exit_loop without using the qt4/kde4 equivalents instead :)
I guess job->exec() will do the job - hehe, no pun intended.
Comment 7 David Faure 2009-01-09 17:23:52 UTC
SVN commit 908359 by dfaure:

GUI: Support for new user-configurable paths (download, movie, picture, music)
Uses the XDG user-dirs.dirs file for saving, since that's where KGlobalSettings/QDesktopService reads from nowadays.
Based on patch by Aaron Nixon, thanks! With additional code factorization and XDG support by me.
BUG: 173796


 M  +131 -151  globalpaths.cpp  
 M  +8 -0      globalpaths.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=908359