summaryrefslogtreecommitdiff
blob: 3b255c444714aa39a5457fd671315dc372451b11 (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
diff -purN kdelibs-3.5.3.orig/kdeui/kiconview.cpp kdelibs-3.5.3.pertty/kdeui/kiconview.cpp
--- kdelibs-3.5.3.orig/kdeui/kiconview.cpp	2005-10-10 10:06:38.000000000 -0500
+++ kdelibs-3.5.3.pertty/kdeui/kiconview.cpp	2006-06-03 13:40:40.000000000 -0500
@@ -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 )
diff -purN kdelibs-3.5.3.orig/kdeui/kjanuswidget.cpp kdelibs-3.5.3.pertty/kdeui/kjanuswidget.cpp
--- kdelibs-3.5.3.orig/kdeui/kjanuswidget.cpp	2005-11-08 16:38:47.000000000 -0600
+++ kdelibs-3.5.3.pertty/kdeui/kjanuswidget.cpp	2006-06-03 13:40:40.000000000 -0500
@@ -53,12 +53,14 @@ class KJanusWidget::IconListItem : publi
     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 +143,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 );
@@ -721,6 +725,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 +939,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 +1005,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 +1055,7 @@ KJanusWidget::IconListItem::IconListItem
     mPixmap = defaultPixmap();
   }
   setText( text );
+  setCustomHighlighting( true );
   mMinimumWidth = 0;
 }
 
@@ -1017,6 +1067,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,6 +1124,25 @@ 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();
@@ -1052,7 +1151,7 @@ void KJanusWidget::IconListItem::paint( 
   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() );
   }
 }
 
diff -purN kdelibs-3.5.3.orig/kdeui/kjanuswidget.h kdelibs-3.5.3.pertty/kdeui/kjanuswidget.h
--- kdelibs-3.5.3.orig/kdeui/kjanuswidget.h	2005-10-10 10:06:38.000000000 -0500
+++ kdelibs-3.5.3.pertty/kdeui/kjanuswidget.h	2006-06-03 13:40:40.000000000 -0500
@@ -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);