Git commit a5628ac3399cb731eadb9d9c9bf84af1112ba9ae by Bart Cerneels.
Committed on 03/06/2011 at 12:43.
Pushed by shanachie into branch 'master'.

Remove the add button from the applet toolbar.

Artyness++ live from the Randa sprint.
GUI: The applet explorer opens when config is clicked.
DIGEST:Amarok Artyness++ @ Randa

M  +1    -0    ChangeLog     
M  +0    -1    src/context/ToolbarView.cpp     
M  +9    -81   src/context/toolbar/AppletToolbar.cpp     
M  +1    -3    src/context/toolbar/AppletToolbar.h     

http://commits.kde.org/amarok/a5628ac3399cb731eadb9d9c9bf84af1112ba9ae

diff --git a/ChangeLog b/ChangeLog
index 372d098..662c6e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,7 @@ VERSION 2.4.2-Beta 1
     * Option to scrobble composer as artist to Last.fm (Thanks to Nicholas 
Wilson)
 
   CHANGES:
+    * Removed the add button in the context toolbar. Applet explorer is opened 
on config.
     * Easier to understand Dynamic playlists
     * Now Amarok requires ffmpeg-0.6 or newer. 
     * Use KImageCache if possible (kdelibs 4.5.0 and later), which should
diff --git a/src/context/ToolbarView.cpp b/src/context/ToolbarView.cpp
index b676ead..110806f 100644
--- a/src/context/ToolbarView.cpp
+++ b/src/context/ToolbarView.cpp
@@ -215,7 +215,6 @@ Context::ToolbarView::appletAdded( Plasma::Applet* applet, 
int loc )
 void
 Context::ToolbarView::refreshOverlays()
 {
-    m_toolbar.data()->refreshAddIcons();
 }
 
 void
diff --git a/src/context/toolbar/AppletToolbar.cpp 
b/src/context/toolbar/AppletToolbar.cpp
index 018dfb2..712e6a0 100644
--- a/src/context/toolbar/AppletToolbar.cpp
+++ b/src/context/toolbar/AppletToolbar.cpp
@@ -39,7 +39,6 @@ Context::AppletToolbar::AppletToolbar( QGraphicsItem* parent )
     , m_configMode( false )
     , m_appletLayout( 0 )
     , m_cont( 0 )
-    , m_addItem( 0 )
     , m_configItem( 0 )
 {    
     Context::Containment* cont = dynamic_cast<Context::Containment*>( parent );
@@ -53,13 +52,6 @@ Context::AppletToolbar::AppletToolbar( QGraphicsItem* parent 
)
 
     m_appletLayout = new QGraphicsLinearLayout( Qt::Horizontal, this );
     
-    m_addItem = new AppletToolbarAddItem( this, m_cont, true );
-    connect( m_addItem, SIGNAL( hideAppletExplorer() ), this, SIGNAL( 
hideAppletExplorer() ) );
-    connect( m_addItem, SIGNAL( showAppletExplorer() ), this, SIGNAL( 
showAppletExplorer() ) );
- 
-    
-    m_appletLayout->addItem( m_addItem );
-    m_appletLayout->setAlignment( m_addItem, Qt::AlignRight );
     m_appletLayout->setContentsMargins( 3, 3, 3, 3 );
     m_appletLayout->setSpacing( 4 );
 
@@ -128,16 +120,6 @@ Context::AppletToolbar::appletRemoved( Plasma::Applet* 
applet )
             app->deleteLater();
         }
     }
-    // if all applets are removed, re-add the add item
-    if( m_appletLayout->count() == 2 && m_configMode )
-    {
-        toggleConfigMode();
-        m_appletLayout->removeItem( m_configItem );
-        delete m_configItem;
-        m_configItem = 0;
-        m_appletLayout->insertItem( 0, m_addItem );
-        m_addItem->show();
-    }
 }
 
 QSizeF
@@ -159,7 +141,7 @@ void
 Context::AppletToolbar::appletAdded( Plasma::Applet* applet, int loc ) // SLOT
 {
     DEBUG_BLOCK
-    
+
     debug() << "inserting applet icon in position" << loc;
     if( !m_configItem )
     {
@@ -168,28 +150,25 @@ Context::AppletToolbar::appletAdded( Plasma::Applet* 
applet, int loc ) // SLOT
         m_appletLayout->addItem( m_configItem );
         m_appletLayout->setAlignment( m_configItem, Qt::AlignRight );
     }
-  
+
     if( m_configMode )
     {
-        // loc doesn't take into account additional + icons, also we need to 
add 1 more + icon
         Context::AppletToolbarAppletItem* item = new 
Context::AppletToolbarAppletItem( this, applet );
         item->setConfigEnabled( true );
-        connect( item, SIGNAL( appletChosen( Plasma::Applet* ) ), this, 
SIGNAL( showApplet( Plasma::Applet* ) ) );
-        
+        connect( item, SIGNAL( appletChosen( Plasma::Applet* ) ),
+                 this, SIGNAL( showApplet( Plasma::Applet* ) ) );
+
         // add the item
         m_appletLayout->insertItem( loc, item );
     }
     else
     {
         Context::AppletToolbarAppletItem* item = new 
Context::AppletToolbarAppletItem( this, applet );
-        connect( item, SIGNAL( appletChosen( Plasma::Applet* ) ), this, 
SIGNAL( showApplet( Plasma::Applet* ) ) );
+        connect( item, SIGNAL( appletChosen( Plasma::Applet* ) ),
+                 this, SIGNAL( showApplet( Plasma::Applet* ) ) );
         m_appletLayout->insertItem( loc, item );
-        // since we have an applet, we remove the add applet button
-        // would be better to check if it is in there (otherwise we try to 
erase it on each add)
-        // but there is no QGraphicsLinearLayout->contains() or ->indexOf()
-        m_addItem->hide();
-        m_appletLayout->removeItem( m_addItem );
     }
+
     // notifications for others who need to know when the layout is done 
adding the applet
     emit appletAddedToToolbar( applet, loc );
 }
@@ -203,24 +182,7 @@ Context::AppletToolbar::toggleConfigMode() // SLOT
         // place add icons in all possible places that the user can add an icon
 
         m_configMode = true;
-
-        int loc = -1;                        // location of the configure icon
-        int count = m_appletLayout->count(); // save now so we don't check 
count after adding :)
-        for( int i = 0; i < count; i++ ) // tell each applet we are configuring
-        {
-            QGraphicsLayoutItem *item = m_appletLayout->itemAt( i );
-
-            Context::AppletToolbarAppletItem* appletItem = dynamic_cast< 
Context::AppletToolbarAppletItem* >( item );
-            if( appletItem )
-                appletItem->setConfigEnabled( true );
-
-            Context::AppletToolbarConfigItem* configItem = dynamic_cast< 
Context::AppletToolbarConfigItem* >( item );
-            if( configItem )
-                loc = i;
-        }
-
-        if( loc >= 0 )
-            newAddItem( loc );
+        emit showAppletExplorer();
     }
     else
     {
@@ -246,38 +208,4 @@ Context::AppletToolbar::toggleConfigMode() // SLOT
     emit configModeToggled();
 }
 
-void
-Context::AppletToolbar::refreshAddIcons() // SLOT
-{
-    foreach( AppletToolbarAddItem* item, m_configAddIcons )
-    {
-        m_appletLayout->removeItem( item );
-        item->deleteLater();
-    }
-    m_configAddIcons.clear();
-
-    int loc = -1;
-    for( int i = 0; i < m_appletLayout->count(); ++i )
-    {
-        QGraphicsLayoutItem *item = m_appletLayout->itemAt( i );
-        Context::AppletToolbarConfigItem* configItem = dynamic_cast< 
Context::AppletToolbarConfigItem* >( item );
-        if( configItem )
-            loc = i;
-    }
-
-    if( loc >=0 )
-        newAddItem( loc );
-}
-
-void 
-Context::AppletToolbar::newAddItem( int loc )
-{
-    DEBUG_BLOCK
-    Context::AppletToolbarAddItem* additem = new 
Context::AppletToolbarAddItem( this, m_cont, false );
-    connect( additem, SIGNAL( hideAppletExplorer() ), this, SIGNAL( 
hideAppletExplorer() ) );
-    connect( additem, SIGNAL( showAppletExplorer() ), this, SIGNAL( 
showAppletExplorer() ) );
-    m_appletLayout->insertItem( loc, additem );
-    m_configAddIcons << additem;
-}
-
 #include "AppletToolbar.moc"
diff --git a/src/context/toolbar/AppletToolbar.h 
b/src/context/toolbar/AppletToolbar.h
index 68f9de7..2be003c 100644
--- a/src/context/toolbar/AppletToolbar.h
+++ b/src/context/toolbar/AppletToolbar.h
@@ -56,8 +56,7 @@ class AppletToolbar : public QGraphicsWidget
         bool configEnabled() const;
         
         void appletRemoved( Plasma::Applet* applet );
-        
-        void refreshAddIcons();
+
     signals:
         void showApplet( Plasma::Applet* );
         void addAppletToContainment( const QString& pluginName, int loc );
@@ -94,7 +93,6 @@ class AppletToolbar : public QGraphicsWidget
         QGraphicsLinearLayout* m_appletLayout;
                 
         Containment* m_cont;
-        AppletToolbarAddItem* m_addItem;
         AppletToolbarConfigItem* m_configItem;
 };
 

Reply via email to