summaryrefslogtreecommitdiffstats
path: root/opensuse/core/tdelibs.old/rubberband-selection.diff
blob: d2b75f17cf15ce5af7574431236fcbb7335ee852 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
Index: kdefx/kstyle.cpp
===================================================================
--- kdefx/kstyle.cpp.orig
+++ kdefx/kstyle.cpp
@@ -154,6 +154,7 @@ struct KStylePrivate
 	bool  menuAltKeyNavigation     : 1;
 	bool  menuDropShadow           : 1;
 	bool  sloppySubMenus           : 1;
+	bool  semiTransparentRubberband : 1;
 	int   popupMenuDelay;
 	float menuOpacity;
 
@@ -187,6 +188,7 @@ KStyle::KStyle( KStyleFlags flags, KStyl
 	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 @@ void KStyle::drawPrimitive( PrimitiveEle
 		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 );
 }
Index: kdeui/kiconview.cpp
===================================================================
--- kdeui/kiconview.cpp.orig
+++ kdeui/kiconview.cpp
@@ -548,7 +548,7 @@ void KIconViewItem::calcRect( const QStr
     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;
@@ -699,11 +699,13 @@ void KIconViewItem::paintPixmap( QPainte
 
 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 )
Index: kdeui/kjanuswidget.cpp
===================================================================
--- kdeui/kjanuswidget.cpp.orig
+++ kdeui/kjanuswidget.cpp
@@ -49,16 +49,19 @@ class KJanusWidget::IconListItem : publi
 {
   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;
 };
@@ -141,6 +144,8 @@ KJanusWidget::KJanusWidget( QWidget *par
 
       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 );
@@ -259,7 +264,7 @@ void KJanusWidget::slotReopen( QListView
 }
 
 QFrame *KJanusWidget::addPage( const QString &itemName, const QString &header,
-			       const QPixmap &pixmap )
+          const QPixmap &pixmap )
 {
   QStringList items;
   items << itemName;
@@ -269,8 +274,8 @@ QFrame *KJanusWidget::addPage( const QSt
 
 
 QVBox *KJanusWidget::addVBoxPage( const QStringList &items,
-				  const QString &header,
-				  const QPixmap &pixmap )
+          const QString &header,
+          const QPixmap &pixmap )
 {
   if( !mValid )
   {
@@ -721,6 +726,12 @@ void KJanusWidget::slotItemClicked(QList
     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; }
@@ -929,11 +940,11 @@ bool KJanusWidget::eventFilter( QObject
 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 )
@@ -995,6 +1006,45 @@ void KJanusWidget::IconListBox::setShowA
 }
 
 
+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 )
@@ -1006,6 +1056,7 @@ KJanusWidget::IconListItem::IconListItem
     mPixmap = defaultPixmap();
   }
   setText( text );
+  setCustomHighlighting( true );
   mMinimumWidth = 0;
 }
 
@@ -1017,6 +1068,36 @@ int KJanusWidget::IconListItem::expandMi
 }
 
 
+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;
@@ -1044,15 +1125,34 @@ const QPixmap &KJanusWidget::IconListIte
 
 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() );
   }
 }
 
@@ -1082,6 +1182,7 @@ int KJanusWidget::IconListItem::width( c
 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 )
@@ -1129,6 +1230,7 @@ void KJanusWidget::removePage( QWidget *
   }
 }
 
+
 QString KJanusWidget::pageTitle(int index) const
 {
   if (!d || !d->mIntToTitle.contains(index))
@@ -1137,6 +1239,7 @@ QString KJanusWidget::pageTitle(int inde
     return d->mIntToTitle[index];
 }
 
+
 QWidget *KJanusWidget::pageWidget(int index) const
 {
   if (!d || !d->mIntToPage.contains(index))
Index: kdeui/kjanuswidget.h
===================================================================
--- kdeui/kjanuswidget.h.orig
+++ kdeui/kjanuswidget.h
@@ -71,6 +71,8 @@ class KDEUI_EXPORT KJanusWidget : public
   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 @@ class KDEUI_EXPORT KJanusWidget : public
 	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 @@ class KDEUI_EXPORT KJanusWidget : public
   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);