Sophie

Sophie

distrib > Mandriva > 2009.0 > i586 > by-pkgid > a4e51422fe1b8d073f47c12205a319a3 > files > 3

kdelibs-3.5.10-4.4mdv2009.0.src.rpm

--- kdefx/kstyle.cpp
+++ kdefx/kstyle.cpp
@@ -154,6 +154,7 @@
 	bool  menuAltKeyNavigation     : 1;
 	bool  menuDropShadow           : 1;
 	bool  sloppySubMenus           : 1;
+	bool  semiTransparentRubberband : 1;
 	int   popupMenuDelay;
 	float menuOpacity;
 
@@ -187,6 +188,7 @@
 	d->menuAltKeyNavigation = settings.readBoolEntry("/KStyle/Settings/MenuAltKeyNavigation", true);
 	d->scrollablePopupmenus = settings.readBoolEntry("/KStyle/Settings/ScrollablePopupMenus", false);
 	d->menuDropShadow       = settings.readBoolEntry("/KStyle/Settings/MenuDropShadow", false);
+	d->semiTransparentRubberband = settings.readBoolEntry("/KStyle/Settings/SemiTransparentRubberband", false);
 	d->menuHandler = NULL;
 
 	if (useMenuTransparency) {
@@ -553,7 +555,57 @@
 		else
 			// General handle, probably a kicker applet handle.
 			drawKStylePrimitive( KPE_GeneralHandle, p, widget, r, cg, flags, opt );
+#if QT_VERSION >= 0x030300
+#ifdef HAVE_XRENDER
+	} else if ( d->semiTransparentRubberband && pe == QStyle::PE_RubberBand ) {
+			QRect rect = r.normalize();
+			QPoint point;
+			point = p->xForm( point );
+	
+			static XRenderColor clr = { 0, 0, 0, 0 };
+			static unsigned long fillColor = 0;
+			if ( fillColor != cg.highlight().rgb() ) {
+				fillColor = cg.highlight().rgb();
+				
+				unsigned long color = fillColor << 8 | 0x40;
 
+				int red = (color >> 24) & 0xff;
+				int green = (color >> 16) & 0xff;
+				int blue = (color >> 8) & 0xff;
+				int alpha = (color >> 0) & 0xff;
+
+				red = red * alpha / 255;
+				green = green * alpha / 255;
+				blue = blue * alpha / 255;
+
+				clr.red = (red << 8) + red;
+				clr.green = (green << 8) + green;
+				clr.blue = (blue << 8) + blue;
+				clr.alpha = (alpha << 8) + alpha;
+			}
+		
+			XRenderFillRectangle(
+					p->device()->x11Display(),
+					PictOpOver,
+					p->device()->x11RenderHandle(),
+					&clr,
+					rect.x() + point.x(),
+					rect.y() + point.y(),
+					rect.width(),
+					rect.height() );
+
+			p->save();
+			p->setRasterOp( Qt::CopyROP );
+			p->setPen( QPen( cg.highlight().dark( 160 ), 1 ) );
+			p->setBrush( NoBrush );
+			p->drawRect(
+					rect.x() + point.x(),
+					rect.y() + point.y(),
+					rect.width(),
+					rect.height() );
+			p->restore();
+#endif
+#endif
 	} else
 		QCommonStyle::drawPrimitive( pe, p, r, cg, flags, opt );
 }
--- kdeui/kiconview.cpp
+++ kdeui/kiconview.cpp
@@ -545,7 +545,7 @@
     r = m_wordWrap->boundingRect();
 
     int realWidth = QMAX( QMIN( r.width() + 4, tw ), fm->width( "X" ) );
-    itemTextRect.setWidth( realWidth );
+    itemTextRect.setWidth( realWidth + 4 );
     itemTextRect.setHeight( r.height() );
 
     int w = 0;    int h = 0;    int y = 0;
@@ -696,11 +696,13 @@
 
 void KIconViewItem::paintText( QPainter *p, const QColorGroup &cg )
 {
-    int textX = textRect( false ).x() + 2;
+    int textX = textRect( false ).x() + 4;
     int textY = textRect( false ).y();
 
     if ( isSelected() ) {
-        p->fillRect( textRect( false ), cg.highlight() );
+	p->setBrush(QBrush(cg.highlight()));
+	p->setPen(QPen(cg.highlight()));
+	p->drawRoundRect( textRect( false ) ,1000/textRect(false).width(),1000/textRect(false).height() );		
         p->setPen( QPen( cg.highlightedText() ) );
     } else {
         if ( iconView()->itemTextBackground() != NoBrush )
--- kdeui/kjanuswidget.cpp
+++ kdeui/kjanuswidget.cpp
@@ -49,16 +49,19 @@
 {
   public:
     IconListItem( QListBox *listbox, const QPixmap &pixmap,
-		   const QString &text );
+                  const QString &text );
     virtual int height( const QListBox *lb ) const;
     virtual int width( const QListBox *lb ) const;
     int expandMinimumWidth( int width );
+    void highlight( bool erase );        
 
   protected:
     const QPixmap &defaultPixmap();
     void paint( QPainter *painter );
-
+    
   private:
+    void paintContents( QPainter *painter );  
+  
     QPixmap mPixmap;
     int mMinimumWidth;
 };
@@ -142,6 +145,8 @@
 
       mIconList->verticalScrollBar()->installEventFilter( this );
       connect( mIconList, SIGNAL(selectionChanged()), SLOT(slotShowPage()));
+      connect( mIconList, SIGNAL(onItem(QListBoxItem *)), SLOT(slotOnItem(QListBoxItem *)));
+
       hbox->addSpacing( KDialog::marginHint() );
       page = new QFrame( this );
       hbox->addWidget( page, 10 );
@@ -260,7 +265,7 @@
 }
 
 QFrame *KJanusWidget::addPage( const QString &itemName, const QString &header,
-			       const QPixmap &pixmap )
+          const QPixmap &pixmap )
 {
   QStringList items;
   items << itemName;
@@ -270,8 +275,8 @@
 
 
 QVBox *KJanusWidget::addVBoxPage( const QStringList &items,
-				  const QString &header,
-				  const QPixmap &pixmap )
+          const QString &header,
+          const QPixmap &pixmap )
 {
   if( !mValid )
   {
@@ -722,6 +727,12 @@
     it->setOpen(!it->isOpen());
 }
 
+// hack because qt does not support Q_OBJECT in nested classes
+void KJanusWidget::slotOnItem(QListBoxItem *qitem)
+{
+  mIconList->slotOnItem( qitem );
+}  
+
 void KJanusWidget::setFocus()
 {
   if( !mValid ) { return; }
@@ -930,11 +941,11 @@
 KJanusWidget::IconListBox::IconListBox( QWidget *parent, const char *name,
 					WFlags f )
   :KListBox( parent, name, f ), mShowAll(false), mHeightValid(false),
-   mWidthValid(false)
+   mWidthValid(false),
+   mOldItem(0) 
 {
 }
 
-
 void KJanusWidget::IconListBox::updateMinimumHeight()
 {
   if( mShowAll && !mHeightValid )
@@ -996,6 +1007,45 @@
 }
 
 
+void KJanusWidget::IconListBox::leaveEvent( QEvent *ev )
+{
+  KListBox::leaveEvent( ev ); 
+
+  if ( mOldItem && !mOldItem->isSelected() )
+  {
+    ((KJanusWidget::IconListItem *) mOldItem)->highlight( true );
+    mOldItem = 0;
+  }
+} 
+
+// hack because qt does not support Q_OBJECT in nested classes
+void KJanusWidget::IconListBox::slotOnItem(QListBoxItem *qitem)
+{
+  KListBox::slotOnItem( qitem );
+
+  if ( qitem == mOldItem )
+  {
+    return;
+  }
+ 
+  if ( mOldItem && !mOldItem->isSelected() )
+  {
+    ((KJanusWidget::IconListItem *) mOldItem)->highlight( true );
+  }
+
+  KJanusWidget::IconListItem *item = dynamic_cast< KJanusWidget::IconListItem * >( qitem );
+  if ( item && !item->isSelected() )
+  {      
+    item->highlight( false );
+    mOldItem = item;
+  }
+  else
+  {
+    mOldItem = 0;
+  }
+}  
+
+
 
 KJanusWidget::IconListItem::IconListItem( QListBox *listbox, const QPixmap &pixmap,
                                           const QString &text )
@@ -1007,6 +1057,7 @@
     mPixmap = defaultPixmap();
   }
   setText( text );
+  setCustomHighlighting( true );
   mMinimumWidth = 0;
 }
 
@@ -1018,6 +1069,36 @@
 }
 
 
+void KJanusWidget::IconListItem::highlight( bool erase )
+{   
+   QRect r = listBox()->itemRect( this );
+   r.addCoords( 1, 1, -1, -1 );  
+   
+   QPainter p( listBox()->viewport() );
+   p.setClipRegion( r );
+   
+   const QColorGroup &cg = listBox()->colorGroup();
+   if ( erase )
+   {
+      p.setPen( cg.base() );
+      p.setBrush( cg.base() );
+      p.drawRect( r );
+   }
+   else
+   {
+      p.setBrush( cg.highlight().light( 120 ) );
+      p.drawRect( r );
+
+      p.setPen( cg.highlight().dark( 140 ) );
+      p.drawRect( r ); 
+   }
+      
+   p.setPen( cg.foreground() );
+   p.translate( r.x() - 1, r.y() - 1 );
+   paintContents( &p );
+}
+
+
 const QPixmap &KJanusWidget::IconListItem::defaultPixmap()
 {
   static QPixmap *pix=0;
@@ -1045,15 +1126,34 @@
 
 void KJanusWidget::IconListItem::paint( QPainter *painter )
 {
+  QRect itemPaintRegion( listBox()->itemRect( this ) );
+  QRect r( 1, 1, itemPaintRegion.width() - 2, itemPaintRegion.height() - 2);
+
+  if ( isSelected() )
+  {
+    painter->eraseRect( r );
+
+    painter->save();
+    painter->setPen( listBox()->colorGroup().highlight().dark( 160 ) );
+    painter->drawRect( r );
+    painter->restore();
+  }
+
+  paintContents( painter );
+}
+
+
+void KJanusWidget::IconListItem::paintContents( QPainter *painter )
+{
   QFontMetrics fm = painter->fontMetrics();
   int ht = fm.boundingRect( 0, 0, 0, 0, Qt::AlignCenter, text() ).height();
   int wp = mPixmap.width();
   int hp = mPixmap.height();
+  painter->drawPixmap( (mMinimumWidth - wp) / 2, 5, mPixmap );
 
-  painter->drawPixmap( (mMinimumWidth-wp)/2, 5, mPixmap );
   if( !text().isEmpty() )
   {
-    painter->drawText( 0, hp+7, mMinimumWidth, ht, Qt::AlignCenter, text() );
+    painter->drawText( 1, hp + 7, mMinimumWidth - 2, ht, Qt::AlignCenter, text() );
   }
 }
 
@@ -1083,6 +1183,7 @@
 void KJanusWidget::virtual_hook( int, void* )
 { /*BASE::virtual_hook( id, data );*/ }
 
+
 // TODO: In TreeList, if the last child of a node is removed, and there is no corrsponding widget for that node, allow the caller to
 // delete the node.
 void KJanusWidget::removePage( QWidget *page )
@@ -1130,6 +1231,7 @@
   }
 }
 
+
 QString KJanusWidget::pageTitle(int index) const
 {
   if (!d || !d->mIntToTitle.contains(index))
@@ -1138,6 +1240,7 @@
     return d->mIntToTitle[index];
 }
 
+
 QWidget *KJanusWidget::pageWidget(int index) const
 {
   if (!d || !d->mIntToPage.contains(index))
--- kdeui/kjanuswidget.h
+++ kdeui/kjanuswidget.h
@@ -71,6 +71,8 @@
   private:
     class IconListBox : public KListBox
     {
+      friend class KJanusWidget;
+
       public:
         IconListBox( QWidget *parent=0, const char *name=0, WFlags f=0 );
 	void updateMinimumHeight();
@@ -79,10 +81,15 @@
 	void invalidateWidth();
 	void setShowAll( bool showAll );
 
+      protected:
+    	void slotOnItem( QListBoxItem *item );
+	virtual void leaveEvent( QEvent * );
+    
       private:
 	bool mShowAll;
 	bool mHeightValid;
 	bool mWidthValid;
+	QListBoxItem *mOldItem;	
     };
 
   public:
@@ -558,6 +565,8 @@
   private slots:
     bool slotShowPage();
     void slotFontChanged();
+
+    void slotOnItem(QListBoxItem *item);
     void slotItemClicked(QListViewItem *it);
     void pageGone(QObject *obj); // signal from the added page's "destroyed" signal
     void slotReopen(QListViewItem *item);