[Amarok] first run: handle QDesktopServices::MusicLocation

Maximilian Kossick maximilian.kossick at googlemail.com
Fri Jan 15 19:17:06 CET 2010


This commit breaks MountPointManager::collectionFolder() for users
that are using Amarok already and did not select anything but the
MusicLocation as collection folder.

Collectionfolders is not set in amarokrc in that case, i.e
MountPointManager::collectionFolders() returns an empty list now

On Wed, Jan 13, 2010 at 12:57 PM, Rick W. Chen <stuffcorpse at archlinux.us> wrote:
> commit e969888134b68615a6c57acacd73ed85a814c152
> Author:     Rick W. Chen <stuffcorpse at archlinux.us>
> AuthorDate: Thu Jan 14 00:15:01 2010 +1300
> Commit:     Rick W. Chen <stuffcorpse at archlinux.us>
> CommitDate: Thu Jan 14 00:50:06 2010 +1300
>
>    first run: handle QDesktopServices::MusicLocation more graciously
>
>    On first run, a configuration dialog appears for the user to select
>    collection folders. However, if MusicLocation is set, it is scanned
>    automatically. This is unintuitive since scanning should only begin
>    after the user has chosen any folders.
>
>    This patch checks MusicLocation on first run, and if it is available a
>    message box is shown asking if the user wants to use that as a
>    collection folder.
>
>    If "Yes", the dialog returns to the main window and that path is scanned
>    into the collection. If "No", Amarok's configuration dialog pops up and
>    the user selects the folders manually (the previous behaviour). If "Cancel"
>    then nothing happens.
>
> diff --git a/ChangeLog b/ChangeLog
> index e7d84c0..43607e8 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -9,6 +9,8 @@ VERSION 2.2.3
>     * Searching covers from Last.fm using custom query in interactive mode.
>
>   CHANGES:
> +    * First run: Let users decided on how to handle music location set
> +      in standard desktop services.
>     * Improved cover fetching accuracy and speed.
>     * Usability: Better design of playback configuration dialog.
>     * Use millisecond accuracy for track bookmarks. Backwards compatible
> diff --git a/src/App.cpp b/src/App.cpp
> index 9172aad..07896fd 100644
> --- a/src/App.cpp
> +++ b/src/App.cpp
> @@ -69,6 +69,7 @@
>  #include <KStandardDirs>
>
>  #include <QByteArray>
> +#include <QDesktopServices>
>  #include <QFile>
>  #include <KPixmapCache>
>  #include <QStringList>
> @@ -737,7 +738,33 @@ App::continueInit()
>     {
>         if( config.readEntry( "First Run", true ) )
>         {
> -            slotConfigAmarok( "CollectionConfig" );
> +            const KUrl musicUrl = QDesktopServices::storageLocation( QDesktopServices::MusicLocation );
> +            const QString musicDir = musicUrl.toLocalFile( KUrl::RemoveTrailingSlash );
> +            const QDir dir( musicDir );
> +
> +            int result = KMessageBox::No;
> +            if( dir.exists() && dir.isReadable() )
> +            {
> +                result = KMessageBox::questionYesNoCancel(
> +                    mainWindow(),
> +                    i18n( "A music path, %1, is set in System Settings.\nWould you like to use that as a collection folder?", musicDir )
> +                    );
> +            }
> +
> +            switch( result )
> +            {
> +            case KMessageBox::Yes:
> +                MountPointManager::instance()->setCollectionFolders( QStringList() << musicDir );
> +                CollectionManager::instance()->startFullScan();
> +                break;
> +
> +            case KMessageBox::No:
> +                slotConfigAmarok( "CollectionConfig" );
> +                break;
> +
> +            default:
> +                break;
> +            }
>             config.writeEntry( "First Run", false );
>         }
>     }
> diff --git a/src/MountPointManager.cpp b/src/MountPointManager.cpp
> index 8485c49..021d178 100644
> --- a/src/MountPointManager.cpp
> +++ b/src/MountPointManager.cpp
> @@ -365,35 +365,12 @@ MountPointManager::collectionFolders()
>                 result.append( absPath );
>         }
>     }
> -
> -    if( result.isEmpty() )
> -    {
> -        const KUrl musicUrl = QDesktopServices::storageLocation( QDesktopServices::MusicLocation );
> -        const QString musicDir = musicUrl.toLocalFile( KUrl::RemoveTrailingSlash );
> -        debug() << "QDesktopServices::MusicLocation:" << musicDir;
> -
> -        if( !musicDir.isEmpty() )
> -        {
> -            const QDir dir( musicDir );
> -            if( dir != QDir::home() && dir.exists() )
> -            {
> -                result << musicDir;
> -            }
> -        }
> -    }
>     return result;
>  }
>
>  void
>  MountPointManager::setCollectionFolders( const QStringList &folders )
>  {
> -    if( folders.size() == 1 )
> -    {
> -        if( folders[0] == QDesktopServices::storageLocation( QDesktopServices::MusicLocation ) )
> -        {
> -            return;
> -        }
> -    }
>     typedef QMap<int, QStringList> FolderMap;
>     KConfigGroup folderConf = Amarok::config( "Collection Folders" );
>     FolderMap folderMap;
>
>
>


More information about the Amarok-devel mailing list