[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/multimedia/amarok/src/widgets
From:       Nikolaj Hald Nielsen <nhnFreespirit () gmail ! com>
Date:       2009-06-28 15:14:17
Message-ID: 1246202057.802577.21923.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 988746 by nhnielsen:

A bunch of small improvements to the ExpandingControlsWidget

 M  +36 -12    ExpandingControlsWidget.cpp  
 M  +3 -1      ExpandingControlsWidget.h  


--- trunk/extragear/multimedia/amarok/src/widgets/ExpandingControlsWidget.cpp \
#988745:988746 @@ -26,6 +26,9 @@
  , m_mainWidget( 0 )
  , m_expanded( false )
 {
+
+    setContentsMargins( 0, 0, 0, 0 );
+    
     m_divider = new HorizontalDivider( this );
     
     m_expandButton = new QToolButton( this );
@@ -33,6 +36,7 @@
     m_expandButton->setAutoRaise( true );
     m_expandButton->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Fixed );
     m_expandButton->setIcon( KIcon( "arrow-up" ) );
+    m_expandButton->setEnabled( false );
 
     connect( m_expandButton, SIGNAL( clicked() ), this, SLOT( toggleExpanded() ) );
 }
@@ -43,6 +47,10 @@
 
 void ExpandingControlsWidget::setMainWidget( QWidget * mainWidget )
 {
+
+    if ( !mainWidget )
+        return;
+    
     m_mainWidget = mainWidget;
     
     m_expandButton->setParent( 0 );
@@ -54,24 +62,40 @@
         m_mainWidget->hide();
 
     m_expandButton->setParent( this );
+    m_expandButton->show();
+    m_expandButton->setEnabled( true );
 }
 
 void ExpandingControlsWidget::toggleExpanded()
 {
-    if( m_expanded )
-    {
-        m_expanded = false;
-        m_mainWidget->hide();
-        m_expandButton->setIcon( KIcon( "arrow-up" ) );
-    }
-    else
-    {
-        m_expanded = true;
-        m_mainWidget->show();
-        m_expandButton->setIcon( KIcon( "arrow-down" ) );
-    }
+    setExpanded( !m_expanded );
 }
 
+void ExpandingControlsWidget::setExpanded( bool expanded )
+{
+   if ( !m_mainWidget )
+       return;
+
+   if ( m_expanded == expanded )
+       return;
+
+   m_expanded = expanded;
+
+   if( expanded )
+   {
+       m_expanded = true;
+       m_mainWidget->show();
+       m_expandButton->setIcon( KIcon( "arrow-down" ) );
+   }
+   else
+   {
+       m_expanded = false;
+       m_mainWidget->hide();
+       m_expandButton->setIcon( KIcon( "arrow-up" ) );
+   }
+    
+}
+
 #include "ExpandingControlsWidget.moc"
 
 
--- trunk/extragear/multimedia/amarok/src/widgets/ExpandingControlsWidget.h \
#988745:988746 @@ -30,7 +30,7 @@
 /**
 A widget for displaying controls that should not always be visible. Displays a thin \
"expand" button by default and expands to show the controls and a similar "collapse" \
when this is pressed.  
-	@author 
+	@author Nikolaj Hald Nielsen <nhnFreespirit@gmail.com>
 */
 class ExpandingControlsWidget : public KVBox
 {
@@ -40,6 +40,8 @@
     ~ExpandingControlsWidget();
     void setMainWidget( QWidget * mainWidget );
 
+    void setExpanded( bool expanded );
+
 protected slots:
     void toggleExpanded();
     


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic