extragear/multimedia/amarok

Mark Kretschmann kretschmann at kde.org
Thu Jan 1 16:53:56 CET 2009


SVN commit 904193 by markey:

Revert "Attempt to fix CV bug that showed misplaced containments after resizing and changing containments. "

This patch introduced serious regressions with the vertical sizing of
applets. This is the second time that I'm reverting this patch.

William, to be honest with you, this wasn't very nice of you to commit the same
buggy patch twice, and then letting others try to fix it up. I spent
about two hours on that today. Time that I could have invested better.

CCBUG: 176101
CCMAIL: vianasw at gmail.com
CCMAIL: amarok-devel at kde.org

 M  +0 -2      ChangeLog  
 M  +75 -76    src/context/ContextView.cpp  
 M  +3 -14     src/context/ContextView.h  


--- trunk/extragear/multimedia/amarok/ChangeLog #904192:904193
@@ -54,8 +54,6 @@
     * Lastfm Settings Dialog can now check to ensure username/password is 
       correct. (BR 144456)
     * Don't delete files if an error occurs during transfer. (BR 178701)
-    * Fix bug that showed misplaced applets in the Context View after resizing
-      the window and changing to another containment. (BR 176101)
     * MPRIS GetMetadata() call returns arturl for last.fm streams. (BR 178695)
     * Fix grouping of various artist albums in the playlist. (BR 175604)
     * Update statistics properly on windows and Mac versions.
--- trunk/extragear/multimedia/amarok/src/context/ContextView.cpp #904192:904193
@@ -296,7 +296,6 @@
         m_zoomLevel = Plasma::DesktopZoom;
         qreal factor = Plasma::scalingFactor( m_zoomLevel ) / matrix().m11();
         scale( factor, factor );
-        updateContainmentsGeometry();
 
         int count = contextScene()->containments().size();
         for( int i = 0; i < count; i++ )
@@ -306,7 +305,13 @@
             {
                 containment->hideTitle();
             }
-        }        
+        }
+        
+        updateContainmentsGeometry();
+        
+        qreal left, top, right, bottom;
+        containment->getContentsMargins( &left, &top, &right, &bottom );
+        setSceneRect( containment->geometry().adjusted( left, top, -right, -bottom )  );
 
     }
 
@@ -318,8 +323,7 @@
     DEBUG_BLOCK
     Q_UNUSED( fromContainment )
     if ( m_zoomLevel == Plasma::DesktopZoom )
-    {
-        updateContainmentsGeometry( true );
+    {        
         int count = contextScene()->containments().size();
         for( int i = 0; i < count; i++ )
         {
@@ -330,8 +334,7 @@
                 containment->setZoomLevel( Plasma::GroupZoom);
             }
         }
-        
-        m_zoomLevel = Plasma::GroupZoom;        
+        m_zoomLevel = Plasma::GroupZoom;
         debug() << "Scaling factor: " << Plasma::scalingFactor( m_zoomLevel );
         qreal factor = Plasma::scalingFactor( m_zoomLevel ) - 0.05;
         qreal s = factor / matrix().m11();
@@ -465,7 +468,7 @@
 
 
 void
-ContextView::updateContainmentsGeometry( bool updateAll )
+ContextView::updateContainmentsGeometry()
 {
     DEBUG_BLOCK
 
@@ -477,23 +480,26 @@
 
     if( m_zoomLevel == Plasma::DesktopZoom )
     {
-        qreal left, top, right, bottom;
-        containment()->getContentsMargins( &left, &top, &right, &bottom );
-        if( updateAll )
+        for( int i = last; i >= 0; i-- )
         {
-            foreach( Plasma::Containment *cont, contextScene()->containments() )
-            {
-                cont->resize( width + left + right, height + top + bottom );
-                cont->updateConstraints();
-            }
+            Plasma::Containment *cont = contextScene()->containments()[i];
+            
+            x = ( width + 25 ) * ( i % 2 );
+            y = ( height + 65 )* ( i / 2 );
+            debug() << "width: "  << width;
+            debug() << "height: " << height;
+            cont->resize( width + 20, height + 60 );
+            cont->setPos( rect().topLeft().x() + x, rect().topLeft().y() + y );
+            
+            debug() << "newPos: " << rect().topLeft().x() + x << "," << rect().topLeft().y() + y;
+            cont->updateConstraints();
+            debug() << "containment geometry:" << cont->geometry();
+
         }
-        else
-        {
-            containment()->resize( width + left + right, height + top + bottom );
-            containment()->updateConstraints();        
-            QRectF contRect( containment()->geometry() );
-            setSceneRect( contRect.adjusted( left, top, -right, -bottom ) );
-        }
+        qreal left, top, right, bottom;
+        containment()->getContentsMargins( &left, &top, &right, &bottom );
+        QRectF contRect( containment()->geometry() );
+        setSceneRect( contRect.adjusted( left, top, -right, -bottom ) );
     }
 }
 
@@ -585,54 +591,57 @@
 }
 
 void
-ContextView::setContainment( Plasma::Containment* newContainment )
+ContextView::setContainment( Plasma::Containment* containment )
 {
     DEBUG_BLOCK
-    if( newContainment->isContainment() )
+    if( containment != this->containment() )
     {
-        if( newContainment != containment() )
+        DEBUG_LINE_INFO
+//         disconnectContainment( this->containment() );
+        if( containment->isContainment() )
         {
             if( m_startupFinished )
-            {
-                //Resize the containment first because it probably had a wrong geometry.
-                //Be aware that plasma automatically change all other containments position so they don't overlap.
-                newContainment->resize( containment()->size() );
-                newContainment->updateConstraints();
-
-                //Plasma changes the containments placement but not inmediately so we can't rely on it yet
-                const QList< Plasma::Containment* > containments = contextScene()->containments();
-                int fromIndex = containments.indexOf( containment() );
-                qreal width = containment()->size().width();
-                qreal height = containment()->size().height();
-                qreal x = width * ( fromIndex % CONTAINMENT_COLUMNS );
-                qreal y = height * ( fromIndex / CONTAINMENT_COLUMNS );
-                m_startPos = QRectF( QPointF( x, y ), QSizeF( width, height ) );            
+                m_startPos = this->containment()->geometry();
                                                               
-                if( m_zoomLevel == Plasma::DesktopZoom )
-                {
-                    int toIndex = containments.indexOf( newContainment );
-                    x = width * ( toIndex % CONTAINMENT_COLUMNS );
-                    y = height * ( toIndex / CONTAINMENT_COLUMNS );
-                    m_destinationPos = QRectF( QPointF( x, y ), QSizeF( width, height ) );
+            m_containment = containment;
+            
+            //resize the containment and the scene to an appropriate size
+            qreal left, top, right, bottom;
+            containment->getContentsMargins( &left, &top, &right, &bottom );
 
-                    Containment* amarokContainment = qobject_cast<Containment*>( newContainment );
-
-                    if( amarokContainment )
-                        amarokContainment->setZoomLevel( Plasma::DesktopZoom );
-
-                    connect( Plasma::Animator::self(), SIGNAL( customAnimationFinished( int ) ),
-                            this, SLOT( animateContainmentChangeFinished( int ) ) );
-
-
-                    Plasma::Animator::self()->customAnimation( m_startPos.width() / 30, 250,
-                                                                Plasma::Animator::EaseInOutCurve,
-                                                                this, "animateContainmentChange" );
-                }
+            QSizeF correctSize( rect().size().width() + left - right , rect().size().height() + top - bottom );
+            if( m_zoomLevel == Plasma::DesktopZoom )
+            {                
+                containment->resize( correctSize );
+                setSceneRect( containment->contentsRect() );
             }
-            m_containment = newContainment;
-        }            
-     }
-     
+            else
+            {
+                containment->resize( correctSize );
+                debug() << "correct size: " << correctSize;
+                QRectF correctRect( 0, 0,
+                                    mapToScene( rect() ).boundingRect().width(),
+                                    mapToScene( rect() ).boundingRect().height() );
+                setSceneRect( correctRect );
+                debug() << "setSceneRect: " <<  mapToScene( rect() ).boundingRect() ;
+            }
+            
+            if( m_startupFinished && m_zoomLevel == Plasma::DesktopZoom )
+            {                
+                m_destinationPos = containment->geometry();
+                
+                Containment* amarokContainment = qobject_cast<Containment*>( containment );                
+                if( amarokContainment )
+                    amarokContainment->setZoomLevel( Plasma::DesktopZoom );
+                
+                Plasma::Animator::self()->customAnimation( m_startPos.width() / 30, 250,
+                                                           Plasma::Animator::EaseInOutCurve,                                                           
+                                                           this, "animateContainmentChange" );
+                debug() << "startPos: " << m_startPos;
+                debug() << "destinationPos: " << m_destinationPos;
+            }
+        }
+    }
 }
 
 
@@ -727,22 +736,22 @@
         
     if( m_startPos.left() < m_destinationPos.left() )
     {
-        incrementX = progress * ( m_destinationPos.width() + left + INTER_CONTAINMENT_MARGIN );
+        incrementX = progress * ( m_destinationPos.width() + left + 5 );
         x = m_startPos.left() + incrementX;
     }
     else if ( m_startPos.left() > m_destinationPos.left() )
     {
-        incrementX = progress * ( m_destinationPos.width() );
+        incrementX = progress * ( m_destinationPos.width() + 5 );
         x = m_startPos.left() - incrementX;
     }
     if( m_startPos.top() < m_destinationPos.top() )
     {
-        incrementY = progress * ( m_destinationPos.height() + top + INTER_CONTAINMENT_MARGIN );
+        incrementY = progress * ( m_destinationPos.height() + top + 5 );
         y = m_startPos.top() + incrementY;
     }
     else if( m_startPos.top() > m_destinationPos.top() )
     {
-        incrementY = progress * ( m_destinationPos.height() );
+        incrementY = progress * ( m_destinationPos.height() + 5 );
         y = m_startPos.top() - incrementY;
     }
     
@@ -751,16 +760,6 @@
 }
 
 void
-ContextView::animateContainmentChangeFinished( int id )
-{
-    Q_UNUSED( id )
-    updateContainmentsGeometry( true );
-    disconnect( Plasma::Animator::self(), SIGNAL( customAnimationFinished( int ) ),
-                             this, SLOT( animateContainmentChangeFinished( int ) ) );
-}
-
-
-void
 ContextView::findContainmentForApplet( QString pluginName, int rowSpan )
 {
     DEBUG_BLOCK
--- trunk/extragear/multimedia/amarok/src/context/ContextView.h #904192:904193
@@ -38,9 +38,6 @@
 namespace Context
 {
 
-static const int INTER_CONTAINMENT_MARGIN = 6;
-static const int CONTAINMENT_COLUMNS = 2;
-    
 class ContextScene;
 class ControlBox;
 
@@ -129,12 +126,10 @@
     void disconnectContainment( Plasma::Containment* containment );
     
     /**
-    * Set the current containment or all containments geometry in the scene with the same geometry as the
-    * Context View widget.
-    * @arg updateAll if true updates all containments else only the current containment.
+    * Set all containments geometry in the scene with the same geometry as the Context View widget 
     */
-    void updateContainmentsGeometry( bool updateAll = false );
-    
+    void updateContainmentsGeometry();
+
     void centerOnZoom( qreal factor, Plasma::ZoomDirection direction );
     
     void loadConfig();
@@ -164,12 +159,6 @@
     void zoomInFinished( int id );
     void zoomOutFinished( int id );
     void animateContainmentChange( qreal progress, int id );
-
-    /**
-    * Correct containments geometries after containment change animation has finished
-    * @arg id the id of the custom animation
-    */
-    void animateContainmentChangeFinished( int id );
 };
 
 } // Context namespace


More information about the Amarok-devel mailing list