[amarok] src/context: Add analyzer applet to the user's existing config.

Mark Kretschmann kretschmann at kde.org
Fri May 24 19:17:28 UTC 2013


Git commit 7f7de7db91c6d544785f89613843dbc361195c76 by Mark Kretschmann.
Committed on 24/05/2013 at 19:56.
Pushed by markey into branch 'master'.

Add analyzer applet to the user's existing config.

This trickery is needed to give the new analyzer applet some
visibility when upgrading to Amarok 2.8. We rewrite the
config carefully so that the applet gets inserted in a sane position.
We also take care not to re-add this applet, in case the user
has explicitly removed it earlier.

Testing welcome to ensure that no special cases are ignored that
could screw up the config somehow.

CCMAIL: amarok-devel at kde.org

M  +22   -0    src/context/ContextView.cpp

http://commits.kde.org/amarok/7f7de7db91c6d544785f89613843dbc361195c76

diff --git a/src/context/ContextView.cpp b/src/context/ContextView.cpp
index d53f09b..f195fa7 100644
--- a/src/context/ContextView.cpp
+++ b/src/context/ContextView.cpp
@@ -215,6 +215,28 @@ ContextView::loadConfig()
         if( containment )
         {
             KConfigGroup cg( &conf, QString( "Containment %1" ).arg( i ) );
+
+            // Special case: If this is the first time that the user runs an Amarok version
+            // containing the Analyzer applet, modify the user's config so that the applet
+            // will become active. We do this for discoverability and prettiness.
+            // Remove this code in a future Amarok release (possibly 3.0)
+            const bool firstTimeWithAnalyzer = Amarok::config( "Context View" ).readEntry( "firstTimeWithAnalyzer", true );
+            if( firstTimeWithAnalyzer )
+            {
+                Amarok::config( "Context View" ).writeEntry( "firstTimeWithAnalyzer", false );
+                QStringList plugins = cg.readEntry( "plugins", QStringList() );
+                if( !plugins.contains( "analyzer" ) )
+                {
+                    // If there are no applets enabled at all, add the analyzer as only applet.
+                    // Else, put it at the second position, which is most likely below the Currenttrack applet.
+                    if( plugins.empty() )
+                        plugins.append( "analyzer" );
+                    else
+                        plugins.insert( 1, "analyzer" );
+
+                    cg.writeEntry( "plugins", plugins );
+                }
+            }
             containment->loadConfig( cg );
         }
     }


More information about the Amarok-devel mailing list