author | alwin <alwin> | 2004-11-09 00:44:31 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-11-09 00:44:31 (UTC) |
commit | 5bfef5f15db1698505405605f6ed50b9d7855a22 (patch) (unidiff) | |
tree | 5199765dbc2a4c4eac0c7aa12dd1e30f6610c9eb | |
parent | 4638c11f127d420818e2356359ae6f2223fb4407 (diff) | |
download | opie-5bfef5f15db1698505405605f6ed50b9d7855a22.zip opie-5bfef5f15db1698505405605f6ed50b9d7855a22.tar.gz opie-5bfef5f15db1698505405605f6ed50b9d7855a22.tar.bz2 |
again some improvements to image icons
-rw-r--r-- | core/launcher/launcherview.cpp | 23 | ||||
-rw-r--r-- | core/launcher/launcherview.h | 2 |
2 files changed, 17 insertions, 8 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index 42704ba..72313e3 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp | |||
@@ -1,1174 +1,1181 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "launcherview.h" | 21 | #include "launcherview.h" |
22 | 22 | ||
23 | /* OPIE */ | 23 | /* OPIE */ |
24 | #include <opie2/odebug.h> | 24 | #include <opie2/odebug.h> |
25 | #include <qtopia/qpeapplication.h> | 25 | #include <qtopia/qpeapplication.h> |
26 | #include <qtopia/private/categories.h> | 26 | #include <qtopia/private/categories.h> |
27 | #include <qtopia/categoryselect.h> | 27 | #include <qtopia/categoryselect.h> |
28 | #include <qtopia/mimetype.h> | 28 | #include <qtopia/mimetype.h> |
29 | #include <qtopia/resource.h> | 29 | #include <qtopia/resource.h> |
30 | using namespace Opie::Core; | 30 | using namespace Opie::Core; |
31 | 31 | ||
32 | #include <qpe/qcopenvelope_qws.h> | 32 | #include <qpe/qcopenvelope_qws.h> |
33 | 33 | ||
34 | /* QT */ | 34 | /* QT */ |
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include <qfileinfo.h> | 36 | #include <qfileinfo.h> |
37 | #include <qiconview.h> | 37 | #include <qiconview.h> |
38 | #include <qobjectlist.h> | 38 | #include <qobjectlist.h> |
39 | 39 | ||
40 | 40 | ||
41 | // These define how the busy icon is animated and highlighted | 41 | // These define how the busy icon is animated and highlighted |
42 | #define BRIGHTEN_BUSY_ICON | 42 | #define BRIGHTEN_BUSY_ICON |
43 | //#define ALPHA_FADE_BUSY_ICON | 43 | //#define ALPHA_FADE_BUSY_ICON |
44 | //#define USE_ANIMATED_BUSY_ICON_OVERLAY | 44 | //#define USE_ANIMATED_BUSY_ICON_OVERLAY |
45 | #define BOUNCE_BUSY_ICON | 45 | #define BOUNCE_BUSY_ICON |
46 | 46 | ||
47 | 47 | ||
48 | class BgPixmap | 48 | class BgPixmap |
49 | { | 49 | { |
50 | public: | 50 | public: |
51 | BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} | 51 | BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} |
52 | QPixmap pm; | 52 | QPixmap pm; |
53 | int ref; | 53 | int ref; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | 56 | ||
57 | static QMap<QString,BgPixmap*> *bgCache = 0; | 57 | static QMap<QString,BgPixmap*> *bgCache = 0; |
58 | 58 | ||
59 | static void cleanup_cache() | 59 | static void cleanup_cache() |
60 | { | 60 | { |
61 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); | 61 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); |
62 | while ( it != bgCache->end() ) { | 62 | while ( it != bgCache->end() ) { |
63 | QMap<QString,BgPixmap*>::Iterator curr = it; | 63 | QMap<QString,BgPixmap*>::Iterator curr = it; |
64 | ++it; | 64 | ++it; |
65 | delete (*curr); | 65 | delete (*curr); |
66 | bgCache->remove( curr ); | 66 | bgCache->remove( curr ); |
67 | } | 67 | } |
68 | delete bgCache; | 68 | delete bgCache; |
69 | bgCache = 0; | 69 | bgCache = 0; |
70 | } | 70 | } |
71 | 71 | ||
72 | 72 | ||
73 | class LauncherItem : public QIconViewItem | 73 | class LauncherItem : public QIconViewItem |
74 | { | 74 | { |
75 | public: | 75 | public: |
76 | enum iconstate_t { | 76 | enum iconstate_t { |
77 | BASE_ICON, | 77 | BASE_ICON, |
78 | WAITING_ICON, | 78 | WAITING_ICON, |
79 | EYE_ICON | 79 | EYE_ICON |
80 | }; | 80 | }; |
81 | 81 | ||
82 | LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); | 82 | LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); |
83 | ~LauncherItem(); | 83 | ~LauncherItem(); |
84 | 84 | ||
85 | AppLnk *appLnk() const { return app; } | 85 | AppLnk *appLnk() const { return app; } |
86 | AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } | 86 | AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } |
87 | 87 | ||
88 | void animateIcon(); | 88 | void animateIcon(); |
89 | void resetIcon(); | 89 | void resetIcon(); |
90 | bool isEyeImage()const{return m_EyeImage;} | 90 | bool isEyeImage()const{return m_EyeImage;} |
91 | 91 | ||
92 | virtual int compare ( QIconViewItem * i ) const; | 92 | virtual int compare ( QIconViewItem * i ) const; |
93 | void paintItem( QPainter *p, const QColorGroup &cg ); | 93 | void paintItem( QPainter *p, const QColorGroup &cg ); |
94 | 94 | ||
95 | void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } | 95 | void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } |
96 | void setEyePixmap(const QPixmap&aIcon); | 96 | void setEyePixmap(const QPixmap&aIcon); |
97 | virtual QPixmap*pixmap()const; | 97 | virtual QPixmap*pixmap()const; |
98 | 98 | ||
99 | protected: | 99 | protected: |
100 | bool isBigIcon; | 100 | bool isBigIcon; |
101 | int iteration; | 101 | int iteration; |
102 | AppLnk* app; | 102 | AppLnk* app; |
103 | 103 | ||
104 | private: | 104 | private: |
105 | void paintAnimatedIcon( QPainter *p ); | 105 | void paintAnimatedIcon( QPainter *p ); |
106 | BusyIndicatorType busyType; | 106 | BusyIndicatorType busyType; |
107 | int psize; | 107 | int psize; |
108 | QPixmap m_iPixmap; | 108 | QPixmap m_iPixmap; |
109 | bool m_EyeImage; | 109 | bool m_EyeImage; |
110 | iconstate_t m_EyeImageSet; | 110 | iconstate_t m_EyeImageSet; |
111 | }; | 111 | }; |
112 | 112 | ||
113 | LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) | 113 | LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) |
114 | : QIconViewItem( parent, applnk->name(), | 114 | : QIconViewItem( parent, applnk->name(), |
115 | bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), | 115 | bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), |
116 | isBigIcon( bigIcon ), | 116 | isBigIcon( bigIcon ), |
117 | iteration(0), | 117 | iteration(0), |
118 | app(applnk), // Takes ownership | 118 | app(applnk), // Takes ownership |
119 | psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), | 119 | psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), |
120 | m_iPixmap(), | 120 | m_iPixmap(), |
121 | m_EyeImage(false), | 121 | m_EyeImage(false), |
122 | m_EyeImageSet(BASE_ICON) | 122 | m_EyeImageSet(BASE_ICON) |
123 | { | 123 | { |
124 | if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { | 124 | if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { |
125 | m_EyeImage = true; | 125 | m_EyeImage = true; |
126 | m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap()); | 126 | m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap()); |
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
130 | LauncherItem::~LauncherItem() | 130 | LauncherItem::~LauncherItem() |
131 | { | 131 | { |
132 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 132 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
133 | if ( liv->busyItem() == this ) | 133 | if ( liv->busyItem() == this ) |
134 | liv->setBusy(FALSE); | 134 | liv->setBusy(FALSE); |
135 | delete app; | 135 | delete app; |
136 | } | 136 | } |
137 | 137 | ||
138 | QPixmap*LauncherItem::pixmap()const | 138 | QPixmap*LauncherItem::pixmap()const |
139 | { | 139 | { |
140 | if (m_EyeImage && m_EyeImageSet == BASE_ICON) { | 140 | if (m_EyeImage && m_EyeImageSet == BASE_ICON) { |
141 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 141 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
142 | liv->requestEyePix(this); | 142 | liv->requestEyePix(this); |
143 | } | 143 | } |
144 | return QIconViewItem::pixmap(); | 144 | return QIconViewItem::pixmap(); |
145 | } | 145 | } |
146 | 146 | ||
147 | int LauncherItem::compare ( QIconViewItem * i ) const | 147 | int LauncherItem::compare ( QIconViewItem * i ) const |
148 | { | 148 | { |
149 | LauncherIconView* view = (LauncherIconView*)iconView(); | 149 | LauncherIconView* view = (LauncherIconView*)iconView(); |
150 | return view->compare(app,((LauncherItem *)i)->appLnk()); | 150 | return view->compare(app,((LauncherItem *)i)->appLnk()); |
151 | } | 151 | } |
152 | 152 | ||
153 | void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) | 153 | void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) |
154 | { | 154 | { |
155 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 155 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
156 | QBrush oldBrush( liv->itemTextBackground() ); | 156 | QBrush oldBrush( liv->itemTextBackground() ); |
157 | QColorGroup mycg( cg ); | 157 | QColorGroup mycg( cg ); |
158 | if ( liv->currentItem() == this ) { | 158 | if ( liv->currentItem() == this ) { |
159 | liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); | 159 | liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); |
160 | mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); | 160 | mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); |
161 | } | 161 | } |
162 | 162 | ||
163 | QIconViewItem::paintItem(p,mycg); | 163 | QIconViewItem::paintItem(p,mycg); |
164 | 164 | ||
165 | // Paint animation overlay | 165 | // Paint animation overlay |
166 | if ( liv->busyItem() == this ) | 166 | if ( liv->busyItem() == this ) |
167 | paintAnimatedIcon(p); | 167 | paintAnimatedIcon(p); |
168 | 168 | ||
169 | if ( liv->currentItem() == this ) | 169 | if ( liv->currentItem() == this ) |
170 | liv->setItemTextBackground( oldBrush ); | 170 | liv->setItemTextBackground( oldBrush ); |
171 | } | 171 | } |
172 | 172 | ||
173 | void LauncherItem::paintAnimatedIcon( QPainter *p ) | 173 | void LauncherItem::paintAnimatedIcon( QPainter *p ) |
174 | { | 174 | { |
175 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 175 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
176 | int pic = iteration % 16; | 176 | int pic = iteration % 16; |
177 | int w = pixmap()->width(), h = pixmap()->height(); | 177 | int w = pixmap()->width(), h = pixmap()->height(); |
178 | QPixmap dblBuf( w, h + 4 ); | 178 | QPixmap dblBuf( w, h + 4 ); |
179 | QPainter p2( &dblBuf ); | 179 | QPainter p2( &dblBuf ); |
180 | int x1, y1; | 180 | int x1, y1; |
181 | if ( liv->itemTextPos() == QIconView::Bottom ) { | 181 | if ( liv->itemTextPos() == QIconView::Bottom ) { |
182 | x1 = x() + (width() - w) / 2 - liv->contentsX(); | 182 | x1 = x() + (width() - w) / 2 - liv->contentsX(); |
183 | y1 = y() - liv->contentsY(); | 183 | y1 = y() - liv->contentsY(); |
184 | } else { | 184 | } else { |
185 | x1 = x() - liv->contentsX(); | 185 | x1 = x() - liv->contentsX(); |
186 | y1 = y() + (height() - h) / 2 - liv->contentsY(); | 186 | y1 = y() + (height() - h) / 2 - liv->contentsY(); |
187 | } | 187 | } |
188 | y1 -= 2; | 188 | y1 -= 2; |
189 | p2.translate(-x1,-y1); | 189 | p2.translate(-x1,-y1); |
190 | liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); | 190 | liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); |
191 | int bounceY = 2; | 191 | int bounceY = 2; |
192 | #ifdef BOUNCE_BUSY_ICON | 192 | #ifdef BOUNCE_BUSY_ICON |
193 | if ( busyType == BIT_Animated ) { | 193 | if ( busyType == BIT_Animated ) { |
194 | bounceY = 4 - ((iteration+2)%8); | 194 | bounceY = 4 - ((iteration+2)%8); |
195 | bounceY = bounceY < 0 ? -bounceY : bounceY; | 195 | bounceY = bounceY < 0 ? -bounceY : bounceY; |
196 | } | 196 | } |
197 | #endif | 197 | #endif |
198 | p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); | 198 | p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); |
199 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 199 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
200 | p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); | 200 | p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); |
201 | #else | 201 | #else |
202 | Q_UNUSED( pic ) | 202 | Q_UNUSED( pic ) |
203 | #endif | 203 | #endif |
204 | p->drawPixmap( x1, y1, dblBuf ); | 204 | p->drawPixmap( x1, y1, dblBuf ); |
205 | } | 205 | } |
206 | 206 | ||
207 | void LauncherItem::animateIcon() | 207 | void LauncherItem::animateIcon() |
208 | { | 208 | { |
209 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 209 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
210 | 210 | ||
211 | if ( liv->busyItem() != this || !app ) | 211 | if ( liv->busyItem() != this || !app ) |
212 | return; | 212 | return; |
213 | 213 | ||
214 | // Highlight the icon | 214 | // Highlight the icon |
215 | if ( iteration == 0 ) { | 215 | if ( iteration == 0 ) { |
216 | QPixmap src = (isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap())); | 216 | QPixmap src = (isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap())); |
217 | QImage img = src.convertToImage(); | 217 | QImage img = src.convertToImage(); |
218 | QRgb *rgb; | 218 | QRgb *rgb; |
219 | int count; | 219 | int count; |
220 | if ( img.depth() == 32 ) { | 220 | if ( img.depth() == 32 ) { |
221 | rgb = (QRgb*)img.bits(); | 221 | rgb = (QRgb*)img.bits(); |
222 | count = img.bytesPerLine()/sizeof(QRgb)*img.height(); | 222 | count = img.bytesPerLine()/sizeof(QRgb)*img.height(); |
223 | } else { | 223 | } else { |
224 | rgb = img.colorTable(); | 224 | rgb = img.colorTable(); |
225 | count = img.numColors(); | 225 | count = img.numColors(); |
226 | } | 226 | } |
227 | for ( int r = 0; r < count; r++, rgb++ ) { | 227 | for ( int r = 0; r < count; r++, rgb++ ) { |
228 | #if defined(BRIGHTEN_BUSY_ICON) | 228 | #if defined(BRIGHTEN_BUSY_ICON) |
229 | QColor c(*rgb); | 229 | QColor c(*rgb); |
230 | int h, s, v; | 230 | int h, s, v; |
231 | c.hsv(&h,&s,&v); | 231 | c.hsv(&h,&s,&v); |
232 | c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); | 232 | c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); |
233 | *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); | 233 | *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); |
234 | #elif defined(ALPHA_FADE_BUSY_ICON) | 234 | #elif defined(ALPHA_FADE_BUSY_ICON) |
235 | *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); | 235 | *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); |
236 | #endif | 236 | #endif |
237 | } | 237 | } |
238 | src.convertFromImage( img ); | 238 | src.convertFromImage( img ); |
239 | setPixmap( src ); | 239 | setPixmap( src ); |
240 | } | 240 | } |
241 | 241 | ||
242 | iteration++; | 242 | iteration++; |
243 | 243 | ||
244 | // Paint animation overlay | 244 | // Paint animation overlay |
245 | QPainter p( liv->viewport() ); | 245 | QPainter p( liv->viewport() ); |
246 | paintAnimatedIcon( &p ); | 246 | paintAnimatedIcon( &p ); |
247 | } | 247 | } |
248 | 248 | ||
249 | void LauncherItem::resetIcon() | 249 | void LauncherItem::resetIcon() |
250 | { | 250 | { |
251 | iteration = 0; | 251 | iteration = 0; |
252 | setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()))); | 252 | setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()))); |
253 | } | 253 | } |
254 | 254 | ||
255 | void LauncherItem::setEyePixmap(const QPixmap&aIcon) | 255 | void LauncherItem::setEyePixmap(const QPixmap&aIcon) |
256 | { | 256 | { |
257 | if (!isEyeImage()) return; | 257 | if (!isEyeImage()) return; |
258 | m_iPixmap = aIcon; | 258 | m_iPixmap = aIcon; |
259 | setPixmap(aIcon); | 259 | setPixmap(aIcon); |
260 | m_EyeImageSet = EYE_ICON; | 260 | m_EyeImageSet = EYE_ICON; |
261 | } | 261 | } |
262 | 262 | ||
263 | //=========================================================================== | 263 | //=========================================================================== |
264 | // Implemantation of LauncherIconview start | 264 | // Implemantation of LauncherIconview start |
265 | //=========================================================================== | 265 | //=========================================================================== |
266 | LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) | 266 | LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) |
267 | : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white) | 267 | : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white) |
268 | { | 268 | { |
269 | m_EyeCallBack = 0; | 269 | m_EyeCallBack = 0; |
270 | sortmeth = Name; | 270 | sortmeth = Name; |
271 | hidden.setAutoDelete(TRUE); | 271 | hidden.setAutoDelete(TRUE); |
272 | ike = FALSE; | 272 | ike = FALSE; |
273 | calculateGrid( Bottom ); | 273 | calculateGrid( Bottom ); |
274 | connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer())); | 274 | connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer())); |
275 | } | 275 | } |
276 | 276 | ||
277 | LauncherIconView::~LauncherIconView() | 277 | LauncherIconView::~LauncherIconView() |
278 | { | 278 | { |
279 | #if 0 // debuggery | 279 | #if 0 // debuggery |
280 | QListIterator<AppLnk> it(hidden); | 280 | QListIterator<AppLnk> it(hidden); |
281 | AppLnk* l; | 281 | AppLnk* l; |
282 | while ((l=it.current())) { | 282 | while ((l=it.current())) { |
283 | ++it; | 283 | ++it; |
284 | //odebug << "" << l << ": hidden (should remove)" << oendl; | 284 | //odebug << "" << l << ": hidden (should remove)" << oendl; |
285 | } | 285 | } |
286 | #endif | 286 | #endif |
287 | } | 287 | } |
288 | 288 | ||
289 | int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) | 289 | int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) |
290 | { | 290 | { |
291 | switch (sortmeth) { | 291 | switch (sortmeth) { |
292 | case Name: | 292 | case Name: |
293 | return a->name().lower().compare(b->name().lower()); | 293 | return a->name().lower().compare(b->name().lower()); |
294 | case Date: { | 294 | case Date: { |
295 | QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); | 295 | QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); |
296 | QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); | 296 | QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); |
297 | return fa.lastModified().secsTo(fb.lastModified()); | 297 | return fa.lastModified().secsTo(fb.lastModified()); |
298 | } | 298 | } |
299 | case Type: | 299 | case Type: |
300 | return a->type().compare(b->type()); | 300 | return a->type().compare(b->type()); |
301 | } | 301 | } |
302 | return 0; | 302 | return 0; |
303 | } | 303 | } |
304 | 304 | ||
305 | void LauncherIconView::setSortMethod( SortMethod m ) | 305 | void LauncherIconView::setSortMethod( SortMethod m ) |
306 | { | 306 | { |
307 | if ( sortmeth != m ) { | 307 | if ( sortmeth != m ) { |
308 | sortmeth = m; | 308 | sortmeth = m; |
309 | sort(); | 309 | sort(); |
310 | } | 310 | } |
311 | } | 311 | } |
312 | 312 | ||
313 | void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) | 313 | void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) |
314 | { | 314 | { |
315 | Categories cat; | 315 | Categories cat; |
316 | cat.load( categoryFileName() ); | 316 | cat.load( categoryFileName() ); |
317 | QString str; | 317 | QString str; |
318 | if ( catfilter == -2 ) | 318 | if ( catfilter == -2 ) |
319 | cf = 0; | 319 | cf = 0; |
320 | else | 320 | else |
321 | cf = catfilter; | 321 | cf = catfilter; |
322 | hideOrShowItems(resort); | 322 | hideOrShowItems(resort); |
323 | } | 323 | } |
324 | 324 | ||
325 | void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) | 325 | void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) |
326 | { | 326 | { |
327 | tf = QRegExp(typefilter,FALSE,TRUE); | 327 | tf = QRegExp(typefilter,FALSE,TRUE); |
328 | hideOrShowItems(resort); | 328 | hideOrShowItems(resort); |
329 | } | 329 | } |
330 | 330 | ||
331 | void LauncherIconView::setItemTextPos( ItemTextPos pos ) | 331 | void LauncherIconView::setItemTextPos( ItemTextPos pos ) |
332 | { | 332 | { |
333 | calculateGrid( pos ); | 333 | calculateGrid( pos ); |
334 | QIconView::setItemTextPos( pos ); | 334 | QIconView::setItemTextPos( pos ); |
335 | } | 335 | } |
336 | 336 | ||
337 | void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) | 337 | void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) |
338 | { | 338 | { |
339 | if ( !bgPixmap.isNull() ) { | 339 | if ( !bgPixmap.isNull() ) { |
340 | p->drawTiledPixmap( r, bgPixmap, | 340 | p->drawTiledPixmap( r, bgPixmap, |
341 | QPoint( (r.x() + contentsX()) % bgPixmap.width(), | 341 | QPoint( (r.x() + contentsX()) % bgPixmap.width(), |
342 | (r.y() + contentsY()) % bgPixmap.height() ) ); | 342 | (r.y() + contentsY()) % bgPixmap.height() ) ); |
343 | } else { | 343 | } else { |
344 | p->fillRect( r, bgColor ); | 344 | p->fillRect( r, bgColor ); |
345 | } | 345 | } |
346 | } | 346 | } |
347 | 347 | ||
348 | void LauncherIconView::addCatsAndMimes(AppLnk* app) | 348 | void LauncherIconView::addCatsAndMimes(AppLnk* app) |
349 | { | 349 | { |
350 | // QStringList c = app->categories(); | 350 | // QStringList c = app->categories(); |
351 | // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { | 351 | // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { |
352 | // cats.replace(*cit,(void*)1); | 352 | // cats.replace(*cit,(void*)1); |
353 | // } | 353 | // } |
354 | QString maj=app->type(); | 354 | QString maj=app->type(); |
355 | int sl=maj.find('/'); | 355 | int sl=maj.find('/'); |
356 | if (sl>=0) { | 356 | if (sl>=0) { |
357 | QString k; | 357 | QString k; |
358 | k = maj.left(12) == "application/" ? maj : maj.left(sl); | 358 | k = maj.left(12) == "application/" ? maj : maj.left(sl); |
359 | mimes.replace(k,(void*)1); | 359 | mimes.replace(k,(void*)1); |
360 | } | 360 | } |
361 | } | 361 | } |
362 | 362 | ||
363 | void LauncherIconView::setBusy(bool on) | 363 | void LauncherIconView::setBusy(bool on) |
364 | { | 364 | { |
365 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 365 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
366 | if ( busyPix.isNull() ) { | 366 | if ( busyPix.isNull() ) { |
367 | int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | 367 | int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); |
368 | busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); | 368 | busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); |
369 | } | 369 | } |
370 | #endif | 370 | #endif |
371 | 371 | ||
372 | if ( on ) { | 372 | if ( on ) { |
373 | busyTimer = startTimer( 100 ); | 373 | busyTimer = startTimer( 100 ); |
374 | } else { | 374 | } else { |
375 | if ( busyTimer ) { | 375 | if ( busyTimer ) { |
376 | killTimer( busyTimer ); | 376 | killTimer( busyTimer ); |
377 | busyTimer = 0; | 377 | busyTimer = 0; |
378 | } | 378 | } |
379 | } | 379 | } |
380 | 380 | ||
381 | LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; | 381 | LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; |
382 | 382 | ||
383 | if ( bsy != c ) { | 383 | if ( bsy != c ) { |
384 | LauncherItem *oldBusy = bsy; | 384 | LauncherItem *oldBusy = bsy; |
385 | bsy = c; | 385 | bsy = c; |
386 | if ( oldBusy ) { | 386 | if ( oldBusy ) { |
387 | oldBusy->resetIcon(); | 387 | oldBusy->resetIcon(); |
388 | } | 388 | } |
389 | if ( bsy ) { | 389 | if ( bsy ) { |
390 | bsy->setBusyIndicatorType( busyType ) ; | 390 | bsy->setBusyIndicatorType( busyType ) ; |
391 | bsy->animateIcon(); | 391 | bsy->animateIcon(); |
392 | } | 392 | } |
393 | } | 393 | } |
394 | } | 394 | } |
395 | 395 | ||
396 | void LauncherIconView::clear() | 396 | void LauncherIconView::clear() |
397 | { | 397 | { |
398 | mimes.clear(); | 398 | mimes.clear(); |
399 | cats.clear(); | 399 | cats.clear(); |
400 | QIconView::clear(); | 400 | QIconView::clear(); |
401 | hidden.clear(); | 401 | hidden.clear(); |
402 | } | 402 | } |
403 | 403 | ||
404 | QStringList LauncherIconView::mimeTypes() const | 404 | QStringList LauncherIconView::mimeTypes() const |
405 | { | 405 | { |
406 | QStringList r; | 406 | QStringList r; |
407 | QDictIterator<void> it(mimes); | 407 | QDictIterator<void> it(mimes); |
408 | while (it.current()) { | 408 | while (it.current()) { |
409 | r.append(it.currentKey()); | 409 | r.append(it.currentKey()); |
410 | ++it; | 410 | ++it; |
411 | } | 411 | } |
412 | r.sort(); | 412 | r.sort(); |
413 | return r; | 413 | return r; |
414 | } | 414 | } |
415 | 415 | ||
416 | LauncherItem*LauncherIconView::findDocItem(const QString&fname) | 416 | LauncherItem*LauncherIconView::findDocItem(const QString&fname) |
417 | { | 417 | { |
418 | LauncherItem* item = (LauncherItem*)firstItem(); | 418 | LauncherItem* item = (LauncherItem*)firstItem(); |
419 | while (item) { | 419 | while (item) { |
420 | if (item->appLnk()->file()==fname) { | 420 | if (item->appLnk()->file()==fname) { |
421 | break; | 421 | break; |
422 | } | 422 | } |
423 | item = (LauncherItem*)item->nextItem(); | 423 | item = (LauncherItem*)item->nextItem(); |
424 | } | 424 | } |
425 | return item; | 425 | return item; |
426 | } | 426 | } |
427 | 427 | ||
428 | void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) | 428 | void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) |
429 | { | 429 | { |
430 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | 430 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); |
431 | if (s!=width) return; | 431 | if (s!=width) return; |
432 | LauncherItem*item = findDocItem(aFile); | 432 | LauncherItem*item = 0; |
433 | QMap<QString,LauncherItem*>::Iterator it; | ||
434 | if ( ( it = m_itemCache.find(aFile))!=m_itemCache.end()) { | ||
435 | item = it.data(); | ||
436 | m_itemCache.remove(it); | ||
437 | } else { | ||
438 | item = findDocItem(aFile); | ||
439 | } | ||
433 | if (!item||!item->isEyeImage()) return; | 440 | if (!item||!item->isEyeImage()) return; |
434 | item->setEyePixmap(aPixmap); | 441 | item->setEyePixmap(aPixmap); |
435 | } | 442 | } |
436 | 443 | ||
437 | void LauncherIconView::checkCallback() | 444 | void LauncherIconView::checkCallback() |
438 | { | 445 | { |
439 | if (m_EyeCallBack) { | 446 | if (!m_EyeCallBack) { |
440 | return; | 447 | m_EyeCallBack = new LauncherThumbReceiver(); |
448 | connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), | ||
449 | this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); | ||
450 | m_eyeTimer.changeInterval(600000); | ||
441 | } | 451 | } |
442 | m_EyeCallBack = new LauncherThumbReceiver(); | ||
443 | connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), | ||
444 | this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); | ||
445 | } | 452 | } |
446 | 453 | ||
447 | void LauncherIconView::addCheckItem(AppLnk* app) | 454 | void LauncherIconView::addCheckItem(AppLnk* app) |
448 | { | 455 | { |
449 | LauncherItem*item = new LauncherItem( this, app, bigIcns ); | 456 | LauncherItem*item = new LauncherItem( this, app, bigIcns ); |
450 | if (item->isEyeImage()) { | 457 | if (item->isEyeImage()) { |
451 | checkCallback(); | 458 | checkCallback(); |
452 | } | 459 | } |
453 | } | 460 | } |
454 | 461 | ||
455 | void LauncherIconView::requestEyePix(const LauncherItem*item) | 462 | void LauncherIconView::requestEyePix(const LauncherItem*item) |
456 | { | 463 | { |
457 | if (!item) return; | 464 | if (!item) return; |
458 | if (item->isEyeImage()) { | 465 | if (item->isEyeImage()) { |
459 | m_eyeTimer.changeInterval(600000); | ||
460 | checkCallback(); | 466 | checkCallback(); |
461 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | 467 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); |
468 | m_itemCache[item->appLnk()->file()]=(LauncherItem*)item; | ||
462 | m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); | 469 | m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); |
463 | } | 470 | } |
464 | } | 471 | } |
465 | 472 | ||
466 | void LauncherIconView::stopEyeTimer() | 473 | void LauncherIconView::stopEyeTimer() |
467 | { | 474 | { |
468 | odebug << "Launcherview: delete opie-eye handle" << oendl; | ||
469 | if (m_EyeCallBack) { | 475 | if (m_EyeCallBack) { |
470 | delete m_EyeCallBack; | 476 | delete m_EyeCallBack; |
471 | m_EyeCallBack=0; | 477 | m_EyeCallBack=0; |
472 | } | 478 | } |
479 | m_itemCache.clear(); | ||
473 | m_eyeTimer.stop(); | 480 | m_eyeTimer.stop(); |
474 | } | 481 | } |
475 | 482 | ||
476 | void LauncherIconView::addItem(AppLnk* app, bool resort) | 483 | void LauncherIconView::addItem(AppLnk* app, bool resort) |
477 | { | 484 | { |
478 | addCatsAndMimes(app); | 485 | addCatsAndMimes(app); |
479 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) | 486 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) |
480 | && (cf == 0 || app->categories().contains(cf) | 487 | && (cf == 0 || app->categories().contains(cf) |
481 | || cf == -1 && app->categories().count() == 0 ) ) { | 488 | || cf == -1 && app->categories().count() == 0 ) ) { |
482 | addCheckItem(app); | 489 | addCheckItem(app); |
483 | } else { | 490 | } else { |
484 | hidden.append(app); | 491 | hidden.append(app); |
485 | } | 492 | } |
486 | if ( resort ){ | 493 | if ( resort ){ |
487 | sort(); | 494 | sort(); |
488 | } | 495 | } |
489 | } | 496 | } |
490 | 497 | ||
491 | void LauncherIconView::updateCategoriesAndMimeTypes() | 498 | void LauncherIconView::updateCategoriesAndMimeTypes() |
492 | { | 499 | { |
493 | mimes.clear(); | 500 | mimes.clear(); |
494 | cats.clear(); | 501 | cats.clear(); |
495 | LauncherItem* item = (LauncherItem*)firstItem(); | 502 | LauncherItem* item = (LauncherItem*)firstItem(); |
496 | while (item) { | 503 | while (item) { |
497 | addCatsAndMimes(item->appLnk()); | 504 | addCatsAndMimes(item->appLnk()); |
498 | item = (LauncherItem*)item->nextItem(); | 505 | item = (LauncherItem*)item->nextItem(); |
499 | } | 506 | } |
500 | QListIterator<AppLnk> it(hidden); | 507 | QListIterator<AppLnk> it(hidden); |
501 | AppLnk* l; | 508 | AppLnk* l; |
502 | while ((l=it.current())) { | 509 | while ((l=it.current())) { |
503 | addCatsAndMimes(l); | 510 | addCatsAndMimes(l); |
504 | ++it; | 511 | ++it; |
505 | } | 512 | } |
506 | } | 513 | } |
507 | 514 | ||
508 | void LauncherIconView::hideOrShowItems(bool resort) | 515 | void LauncherIconView::hideOrShowItems(bool resort) |
509 | { | 516 | { |
510 | viewport()->setUpdatesEnabled( FALSE ); | 517 | viewport()->setUpdatesEnabled( FALSE ); |
511 | hidden.setAutoDelete(FALSE); | 518 | hidden.setAutoDelete(FALSE); |
512 | QList<AppLnk> links=hidden; | 519 | QList<AppLnk> links=hidden; |
513 | hidden.clear(); | 520 | hidden.clear(); |
514 | hidden.setAutoDelete(TRUE); | 521 | hidden.setAutoDelete(TRUE); |
515 | LauncherItem* item = (LauncherItem*)firstItem(); | 522 | LauncherItem* item = (LauncherItem*)firstItem(); |
516 | while (item) { | 523 | while (item) { |
517 | links.append(item->takeAppLnk()); | 524 | links.append(item->takeAppLnk()); |
518 | item = (LauncherItem*)item->nextItem(); | 525 | item = (LauncherItem*)item->nextItem(); |
519 | } | 526 | } |
520 | clear(); | 527 | clear(); |
521 | QListIterator<AppLnk> it(links); | 528 | QListIterator<AppLnk> it(links); |
522 | AppLnk* l; | 529 | AppLnk* l; |
523 | while ((l=it.current())) { | 530 | while ((l=it.current())) { |
524 | addItem(l,FALSE); | 531 | addItem(l,FALSE); |
525 | ++it; | 532 | ++it; |
526 | } | 533 | } |
527 | if ( resort && !autoArrange() ) | 534 | if ( resort && !autoArrange() ) |
528 | sort(); | 535 | sort(); |
529 | viewport()->setUpdatesEnabled( TRUE ); | 536 | viewport()->setUpdatesEnabled( TRUE ); |
530 | } | 537 | } |
531 | 538 | ||
532 | bool LauncherIconView::removeLink(const QString& linkfile) | 539 | bool LauncherIconView::removeLink(const QString& linkfile) |
533 | { | 540 | { |
534 | LauncherItem* item = (LauncherItem*)firstItem(); | 541 | LauncherItem* item = (LauncherItem*)firstItem(); |
535 | AppLnk* l; | 542 | AppLnk* l; |
536 | bool did = FALSE; | 543 | bool did = FALSE; |
537 | DocLnk dl(linkfile); | 544 | DocLnk dl(linkfile); |
538 | while (item) { | 545 | while (item) { |
539 | l = item->appLnk(); | 546 | l = item->appLnk(); |
540 | LauncherItem *nextItem = (LauncherItem *)item->nextItem(); | 547 | LauncherItem *nextItem = (LauncherItem *)item->nextItem(); |
541 | if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() && | 548 | if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() && |
542 | ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) { | 549 | ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) { |
543 | delete item; | 550 | delete item; |
544 | did = TRUE; | 551 | did = TRUE; |
545 | } | 552 | } |
546 | item = nextItem; | 553 | item = nextItem; |
547 | } | 554 | } |
548 | QListIterator<AppLnk> it(hidden); | 555 | QListIterator<AppLnk> it(hidden); |
549 | while ((l=it.current())) { | 556 | while ((l=it.current())) { |
550 | ++it; | 557 | ++it; |
551 | if ( l->linkFileKnown() && l->linkFile() == linkfile | 558 | if ( l->linkFileKnown() && l->linkFile() == linkfile |
552 | || l->file() == linkfile | 559 | || l->file() == linkfile |
553 | || dl.isValid() && dl.file() == l->file() ) { | 560 | || dl.isValid() && dl.file() == l->file() ) { |
554 | hidden.removeRef(l); | 561 | hidden.removeRef(l); |
555 | did = TRUE; | 562 | did = TRUE; |
556 | } | 563 | } |
557 | } | 564 | } |
558 | return did; | 565 | return did; |
559 | } | 566 | } |
560 | 567 | ||
561 | void LauncherIconView::timerEvent( QTimerEvent *te ) | 568 | void LauncherIconView::timerEvent( QTimerEvent *te ) |
562 | { | 569 | { |
563 | if ( te->timerId() == busyTimer ) { | 570 | if ( te->timerId() == busyTimer ) { |
564 | if ( bsy ) | 571 | if ( bsy ) |
565 | bsy->animateIcon(); | 572 | bsy->animateIcon(); |
566 | } else { | 573 | } else { |
567 | QIconView::timerEvent( te ); | 574 | QIconView::timerEvent( te ); |
568 | } | 575 | } |
569 | } | 576 | } |
570 | 577 | ||
571 | void LauncherIconView::setBigIcons( bool bi ) | 578 | void LauncherIconView::setBigIcons( bool bi ) |
572 | { | 579 | { |
573 | bigIcns = bi; | 580 | bigIcns = bi; |
574 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 581 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
575 | busyPix.resize(0,0); | 582 | busyPix.resize(0,0); |
576 | #endif | 583 | #endif |
577 | } | 584 | } |
578 | 585 | ||
579 | QIconViewItem* LauncherIconView::busyItem() const | 586 | QIconViewItem* LauncherIconView::busyItem() const |
580 | { | 587 | { |
581 | return bsy; | 588 | return bsy; |
582 | } | 589 | } |
583 | 590 | ||
584 | void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } | 591 | void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } |
585 | 592 | ||
586 | void LauncherIconView::calculateGrid( ItemTextPos pos ) | 593 | void LauncherIconView::calculateGrid( ItemTextPos pos ) |
587 | { | 594 | { |
588 | int dw = QApplication::desktop()->width(); | 595 | int dw = QApplication::desktop()->width(); |
589 | int viewerWidth = dw-style().scrollBarExtent().width(); | 596 | int viewerWidth = dw-style().scrollBarExtent().width(); |
590 | if ( pos == Bottom ) { | 597 | if ( pos == Bottom ) { |
591 | int cols = 3; | 598 | int cols = 3; |
592 | if ( viewerWidth <= 200 ) | 599 | if ( viewerWidth <= 200 ) |
593 | cols = 2; | 600 | cols = 2; |
594 | else if ( viewerWidth >= 400 ) | 601 | else if ( viewerWidth >= 400 ) |
595 | cols = viewerWidth/96; | 602 | cols = viewerWidth/96; |
596 | setSpacing( 4 ); | 603 | setSpacing( 4 ); |
597 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); | 604 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); |
598 | setGridY( fontMetrics().height()*2+24 ); | 605 | setGridY( fontMetrics().height()*2+24 ); |
599 | } else { | 606 | } else { |
600 | int cols = 2; | 607 | int cols = 2; |
601 | if ( viewerWidth < 150 ) | 608 | if ( viewerWidth < 150 ) |
602 | cols = 1; | 609 | cols = 1; |
603 | else if ( viewerWidth >= 400 ) | 610 | else if ( viewerWidth >= 400 ) |
604 | cols = viewerWidth/150; | 611 | cols = viewerWidth/150; |
605 | setSpacing( 2 ); | 612 | setSpacing( 2 ); |
606 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); | 613 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); |
607 | setGridY( fontMetrics().height()+2 ); | 614 | setGridY( fontMetrics().height()+2 ); |
608 | } | 615 | } |
609 | } | 616 | } |
610 | 617 | ||
611 | void LauncherIconView::styleChange( QStyle &old ) | 618 | void LauncherIconView::styleChange( QStyle &old ) |
612 | { | 619 | { |
613 | QIconView::styleChange( old ); | 620 | QIconView::styleChange( old ); |
614 | calculateGrid( itemTextPos() ); | 621 | calculateGrid( itemTextPos() ); |
615 | } | 622 | } |
616 | 623 | ||
617 | void LauncherIconView::keyPressEvent(QKeyEvent* e) | 624 | void LauncherIconView::keyPressEvent(QKeyEvent* e) |
618 | { | 625 | { |
619 | ike = TRUE; | 626 | ike = TRUE; |
620 | if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { | 627 | if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { |
621 | if ( (e->state() & ShiftButton) ) | 628 | if ( (e->state() & ShiftButton) ) |
622 | emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); | 629 | emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); |
623 | else | 630 | else |
624 | returnPressed(currentItem()); | 631 | returnPressed(currentItem()); |
625 | } | 632 | } |
626 | 633 | ||
627 | QIconView::keyPressEvent(e); | 634 | QIconView::keyPressEvent(e); |
628 | ike = FALSE; | 635 | ike = FALSE; |
629 | } | 636 | } |
630 | 637 | ||
631 | //=========================================================================== | 638 | //=========================================================================== |
632 | // Implemantation of LauncherIconview end | 639 | // Implemantation of LauncherIconview end |
633 | //=========================================================================== | 640 | //=========================================================================== |
634 | 641 | ||
635 | 642 | ||
636 | //=========================================================================== | 643 | //=========================================================================== |
637 | LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) | 644 | LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) |
638 | : QVBox( parent, name, fl ) | 645 | : QVBox( parent, name, fl ) |
639 | { | 646 | { |
640 | catmb = 0; | 647 | catmb = 0; |
641 | icons = new LauncherIconView( this ); | 648 | icons = new LauncherIconView( this ); |
642 | setFocusProxy(icons); | 649 | setFocusProxy(icons); |
643 | QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); | 650 | QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); |
644 | 651 | ||
645 | icons->setItemsMovable( FALSE ); | 652 | icons->setItemsMovable( FALSE ); |
646 | icons->setAutoArrange( TRUE ); | 653 | icons->setAutoArrange( TRUE ); |
647 | icons->setSorting( TRUE ); | 654 | icons->setSorting( TRUE ); |
648 | icons->setFrameStyle( QFrame::NoFrame ); | 655 | icons->setFrameStyle( QFrame::NoFrame ); |
649 | icons->setMargin( 0 ); | 656 | icons->setMargin( 0 ); |
650 | icons->setSelectionMode( QIconView::NoSelection ); | 657 | icons->setSelectionMode( QIconView::NoSelection ); |
651 | icons->setBackgroundMode( PaletteBase ); | 658 | icons->setBackgroundMode( PaletteBase ); |
652 | icons->setResizeMode( QIconView::Fixed ); | 659 | icons->setResizeMode( QIconView::Fixed ); |
653 | vmode = (ViewMode)-1; | 660 | vmode = (ViewMode)-1; |
654 | setViewMode( Icon ); | 661 | setViewMode( Icon ); |
655 | 662 | ||
656 | connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), | 663 | connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), |
657 | SLOT(itemClicked(int,QIconViewItem*)) ); | 664 | SLOT(itemClicked(int,QIconViewItem*)) ); |
658 | connect( icons, SIGNAL(selectionChanged()), | 665 | connect( icons, SIGNAL(selectionChanged()), |
659 | SLOT(selectionChanged()) ); | 666 | SLOT(selectionChanged()) ); |
660 | connect( icons, SIGNAL(returnPressed(QIconViewItem*)), | 667 | connect( icons, SIGNAL(returnPressed(QIconViewItem*)), |
661 | SLOT(returnPressed(QIconViewItem*)) ); | 668 | SLOT(returnPressed(QIconViewItem*)) ); |
662 | connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), | 669 | connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), |
663 | SLOT(itemPressed(int,QIconViewItem*)) ); | 670 | SLOT(itemPressed(int,QIconViewItem*)) ); |
664 | 671 | ||
665 | tools = 0; | 672 | tools = 0; |
666 | setBackgroundType( Ruled, QString::null ); | 673 | setBackgroundType( Ruled, QString::null ); |
667 | } | 674 | } |
668 | 675 | ||
669 | LauncherView::~LauncherView() | 676 | LauncherView::~LauncherView() |
670 | { | 677 | { |
671 | if ( bgCache && bgCache->contains( bgName ) ) | 678 | if ( bgCache && bgCache->contains( bgName ) ) |
672 | (*bgCache)[bgName]->ref--; | 679 | (*bgCache)[bgName]->ref--; |
673 | } | 680 | } |
674 | 681 | ||
675 | 682 | ||
676 | bool LauncherView::bsy=FALSE; | 683 | bool LauncherView::bsy=FALSE; |
677 | 684 | ||
678 | void LauncherView::setBusy(bool on) | 685 | void LauncherView::setBusy(bool on) |
679 | { | 686 | { |
680 | icons->setBusy(on); | 687 | icons->setBusy(on); |
681 | } | 688 | } |
682 | 689 | ||
683 | void LauncherView::setBusyIndicatorType( const QString& type ) { | 690 | void LauncherView::setBusyIndicatorType( const QString& type ) { |
684 | if ( type. lower ( ) == "animated" ) | 691 | if ( type. lower ( ) == "animated" ) |
685 | icons->setBusyIndicatorType( BIT_Animated ) ; | 692 | icons->setBusyIndicatorType( BIT_Animated ) ; |
686 | else | 693 | else |
687 | icons->setBusyIndicatorType( BIT_Normal ) ; | 694 | icons->setBusyIndicatorType( BIT_Normal ) ; |
688 | } | 695 | } |
689 | 696 | ||
690 | void LauncherView::hideIcons() | 697 | void LauncherView::hideIcons() |
691 | { | 698 | { |
692 | icons->hide(); | 699 | icons->hide(); |
693 | } | 700 | } |
694 | 701 | ||
695 | void LauncherView::setToolsEnabled(bool y) | 702 | void LauncherView::setToolsEnabled(bool y) |
696 | { | 703 | { |
697 | if ( !y != !tools ) { | 704 | if ( !y != !tools ) { |
698 | if ( y ) { | 705 | if ( y ) { |
699 | tools = new QHBox(this); | 706 | tools = new QHBox(this); |
700 | 707 | ||
701 | // Type filter | 708 | // Type filter |
702 | typemb = new QComboBox(tools); | 709 | typemb = new QComboBox(tools); |
703 | QSizePolicy p = typemb->sizePolicy(); | 710 | QSizePolicy p = typemb->sizePolicy(); |
704 | p.setHorData(QSizePolicy::Expanding); | 711 | p.setHorData(QSizePolicy::Expanding); |
705 | typemb->setSizePolicy(p); | 712 | typemb->setSizePolicy(p); |
706 | 713 | ||
707 | // Category filter | 714 | // Category filter |
708 | updateTools(); | 715 | updateTools(); |
709 | tools->show(); | 716 | tools->show(); |
710 | 717 | ||
711 | } else { | 718 | } else { |
712 | delete tools; | 719 | delete tools; |
713 | tools = 0; | 720 | tools = 0; |
714 | } | 721 | } |
715 | } | 722 | } |
716 | } | 723 | } |
717 | 724 | ||
718 | void LauncherView::updateTools() | 725 | void LauncherView::updateTools() |
719 | { | 726 | { |
720 | disconnect( typemb, SIGNAL(activated(int)), | 727 | disconnect( typemb, SIGNAL(activated(int)), |
721 | this, SLOT(showType(int)) ); | 728 | this, SLOT(showType(int)) ); |
722 | if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)), | 729 | if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)), |
723 | this, SLOT(showCategory(int)) ); | 730 | this, SLOT(showCategory(int)) ); |
724 | 731 | ||
725 | // ### I want to remove this | 732 | // ### I want to remove this |
726 | icons->updateCategoriesAndMimeTypes(); | 733 | icons->updateCategoriesAndMimeTypes(); |
727 | 734 | ||
728 | QString prev; | 735 | QString prev; |
729 | 736 | ||
730 | // Type filter | 737 | // Type filter |
731 | QStringList types; | 738 | QStringList types; |
732 | typelist = icons->mimeTypes(); | 739 | typelist = icons->mimeTypes(); |
733 | for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { | 740 | for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { |
734 | QString t = *it; | 741 | QString t = *it; |
735 | if ( t.left(12) == "application/" ) { | 742 | if ( t.left(12) == "application/" ) { |
736 | MimeType mt(t); | 743 | MimeType mt(t); |
737 | const AppLnk* app = mt.application(); | 744 | const AppLnk* app = mt.application(); |
738 | if ( app ) | 745 | if ( app ) |
739 | t = app->name(); | 746 | t = app->name(); |
740 | else | 747 | else |
741 | t = t.mid(12); | 748 | t = t.mid(12); |
742 | } else { | 749 | } else { |
743 | t[0] = t[0].upper(); | 750 | t[0] = t[0].upper(); |
744 | } | 751 | } |
745 | types += t; | 752 | types += t; |
746 | } | 753 | } |
747 | types << tr("All types"); | 754 | types << tr("All types"); |
748 | prev = typemb->currentText(); | 755 | prev = typemb->currentText(); |
749 | typemb->clear(); | 756 | typemb->clear(); |
750 | typemb->insertStringList(types); | 757 | typemb->insertStringList(types); |
751 | for (int i=0; i<typemb->count(); i++) { | 758 | for (int i=0; i<typemb->count(); i++) { |
752 | if ( typemb->text(i) == prev ) { | 759 | if ( typemb->text(i) == prev ) { |
753 | typemb->setCurrentItem(i); | 760 | typemb->setCurrentItem(i); |
754 | break; | 761 | break; |
755 | } | 762 | } |
756 | } | 763 | } |
757 | if ( prev.isNull() ) | 764 | if ( prev.isNull() ) |
758 | typemb->setCurrentItem(typemb->count()-1); | 765 | typemb->setCurrentItem(typemb->count()-1); |
759 | 766 | ||
760 | int pcat = catmb ? catmb->currentCategory() : -2; | 767 | int pcat = catmb ? catmb->currentCategory() : -2; |
761 | if ( !catmb ) | 768 | if ( !catmb ) |
762 | catmb = new CategorySelect(tools); | 769 | catmb = new CategorySelect(tools); |
763 | Categories cats( 0 ); | 770 | Categories cats( 0 ); |
764 | cats.load( categoryFileName() ); | 771 | cats.load( categoryFileName() ); |
765 | QArray<int> vl( 0 ); | 772 | QArray<int> vl( 0 ); |
766 | catmb->setCategories( vl, "Document View", // No tr | 773 | catmb->setCategories( vl, "Document View", // No tr |
767 | tr("Document View") ); | 774 | tr("Document View") ); |
768 | catmb->setRemoveCategoryEdit( TRUE ); | 775 | catmb->setRemoveCategoryEdit( TRUE ); |
769 | catmb->setAllCategories( TRUE ); | 776 | catmb->setAllCategories( TRUE ); |
770 | catmb->setCurrentCategory(pcat); | 777 | catmb->setCurrentCategory(pcat); |
771 | 778 | ||
772 | // if type has changed we need to redisplay | 779 | // if type has changed we need to redisplay |
773 | if ( typemb->currentText() != prev ) | 780 | if ( typemb->currentText() != prev ) |
774 | showType( typemb->currentItem() ); | 781 | showType( typemb->currentItem() ); |
775 | 782 | ||
776 | connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); | 783 | connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); |
777 | connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); | 784 | connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); |
778 | } | 785 | } |
779 | 786 | ||
780 | void LauncherView::sortBy(int s) | 787 | void LauncherView::sortBy(int s) |
781 | { | 788 | { |
782 | icons->setSortMethod((LauncherIconView::SortMethod)s); | 789 | icons->setSortMethod((LauncherIconView::SortMethod)s); |
783 | } | 790 | } |
784 | 791 | ||
785 | void LauncherView::showType(int t) | 792 | void LauncherView::showType(int t) |
786 | { | 793 | { |
787 | if ( t >= (int)typelist.count() ) { | 794 | if ( t >= (int)typelist.count() ) { |
788 | icons->setTypeFilter("",TRUE); | 795 | icons->setTypeFilter("",TRUE); |
789 | } else { | 796 | } else { |
790 | QString ty = typelist[t]; | 797 | QString ty = typelist[t]; |
791 | if ( !ty.contains('/') ) | 798 | if ( !ty.contains('/') ) |
792 | ty += "/*"; | 799 | ty += "/*"; |
793 | icons->setTypeFilter(ty,TRUE); | 800 | icons->setTypeFilter(ty,TRUE); |
794 | } | 801 | } |
795 | } | 802 | } |
796 | 803 | ||
797 | void LauncherView::showCategory( int c ) | 804 | void LauncherView::showCategory( int c ) |
798 | { | 805 | { |
799 | icons->setCategoryFilter( c, TRUE ); | 806 | icons->setCategoryFilter( c, TRUE ); |
800 | } | 807 | } |
801 | 808 | ||
802 | void LauncherView::setViewMode( ViewMode m ) | 809 | void LauncherView::setViewMode( ViewMode m ) |
803 | { | 810 | { |
804 | if ( vmode != m ) { | 811 | if ( vmode != m ) { |
805 | bool bigIcons = m == Icon; | 812 | bool bigIcons = m == Icon; |
806 | icons->viewport()->setUpdatesEnabled( FALSE ); | 813 | icons->viewport()->setUpdatesEnabled( FALSE ); |
807 | icons->setBigIcons( bigIcons ); | 814 | icons->setBigIcons( bigIcons ); |
808 | switch ( m ) { | 815 | switch ( m ) { |
809 | case List: | 816 | case List: |
810 | icons->setItemTextPos( QIconView::Right ); | 817 | icons->setItemTextPos( QIconView::Right ); |
811 | break; | 818 | break; |
812 | case Icon: | 819 | case Icon: |
813 | icons->setItemTextPos( QIconView::Bottom ); | 820 | icons->setItemTextPos( QIconView::Bottom ); |
814 | break; | 821 | break; |
815 | } | 822 | } |
816 | icons->hideOrShowItems( FALSE ); | 823 | icons->hideOrShowItems( FALSE ); |
817 | icons->viewport()->setUpdatesEnabled( TRUE ); | 824 | icons->viewport()->setUpdatesEnabled( TRUE ); |
818 | vmode = m; | 825 | vmode = m; |
819 | } | 826 | } |
820 | } | 827 | } |
821 | 828 | ||
822 | // | 829 | // |
823 | // User images may require scaling. | 830 | // User images may require scaling. |
824 | // | 831 | // |
825 | QImage LauncherView::loadBackgroundImage(QString &bgName) | 832 | QImage LauncherView::loadBackgroundImage(QString &bgName) |
826 | { | 833 | { |
827 | QImageIO imgio; | 834 | QImageIO imgio; |
828 | QSize ds = qApp->desktop()->size(); // should be launcher, not desktop | 835 | QSize ds = qApp->desktop()->size(); // should be launcher, not desktop |
829 | bool further_scaling = TRUE; | 836 | bool further_scaling = TRUE; |
830 | 837 | ||
831 | imgio.setFileName( bgName ); | 838 | imgio.setFileName( bgName ); |
832 | imgio.setParameters("GetHeaderInformation"); | 839 | imgio.setParameters("GetHeaderInformation"); |
833 | 840 | ||
834 | if (imgio.read() == FALSE) { | 841 | if (imgio.read() == FALSE) { |
835 | return imgio.image(); | 842 | return imgio.image(); |
836 | } | 843 | } |
837 | 844 | ||
838 | if (imgio.image().width() < ds.width() && | 845 | if (imgio.image().width() < ds.width() && |
839 | imgio.image().height() < ds.height()) { | 846 | imgio.image().height() < ds.height()) { |
840 | further_scaling = FALSE; | 847 | further_scaling = FALSE; |
841 | } | 848 | } |
842 | 849 | ||
843 | if (!imgio.image().bits()) { | 850 | if (!imgio.image().bits()) { |
844 | // | 851 | // |
845 | // Scale and load. Note we don't scale up. | 852 | // Scale and load. Note we don't scale up. |
846 | // | 853 | // |
847 | QString param( "Scale( %1, %2, ScaleMin )" ); // No tr | 854 | QString param( "Scale( %1, %2, ScaleMin )" ); // No tr |
848 | imgio.setParameters(further_scaling ? | 855 | imgio.setParameters(further_scaling ? |
849 | param.arg(ds.width()).arg(ds.height()).latin1() : | 856 | param.arg(ds.width()).arg(ds.height()).latin1() : |
850 | ""); | 857 | ""); |
851 | imgio.read(); | 858 | imgio.read(); |
852 | } else { | 859 | } else { |
853 | if (further_scaling) { | 860 | if (further_scaling) { |
854 | int t1 = imgio.image().width() * ds.height(); | 861 | int t1 = imgio.image().width() * ds.height(); |
855 | int t2 = imgio.image().height() * ds.width(); | 862 | int t2 = imgio.image().height() * ds.width(); |
856 | int dsth = ds.height(); | 863 | int dsth = ds.height(); |
857 | int dstw = ds.width(); | 864 | int dstw = ds.width(); |
858 | 865 | ||
859 | if (t1 > t2) { | 866 | if (t1 > t2) { |
860 | dsth = t2 / imgio.image().width(); | 867 | dsth = t2 / imgio.image().width(); |
861 | } else { | 868 | } else { |
862 | dstw = t1 / imgio.image().height(); | 869 | dstw = t1 / imgio.image().height(); |
863 | } | 870 | } |
864 | 871 | ||
865 | // | 872 | // |
866 | // Loader didn't scale for us. Do it manually. | 873 | // Loader didn't scale for us. Do it manually. |
867 | // | 874 | // |
868 | return imgio.image().smoothScale(dstw, dsth); | 875 | return imgio.image().smoothScale(dstw, dsth); |
869 | } | 876 | } |
870 | } | 877 | } |
871 | 878 | ||
872 | return imgio.image(); | 879 | return imgio.image(); |
873 | } | 880 | } |
874 | 881 | ||
875 | void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) | 882 | void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) |
876 | { | 883 | { |
877 | if ( !bgCache ) { | 884 | if ( !bgCache ) { |
878 | bgCache = new QMap<QString,BgPixmap*>; | 885 | bgCache = new QMap<QString,BgPixmap*>; |
879 | qAddPostRoutine( cleanup_cache ); | 886 | qAddPostRoutine( cleanup_cache ); |
880 | } | 887 | } |
881 | 888 | ||
882 | if ( bgCache->contains( bgName ) ) | 889 | if ( bgCache->contains( bgName ) ) |
883 | (*bgCache)[bgName]->ref--; | 890 | (*bgCache)[bgName]->ref--; |
884 | bgName = ""; | 891 | bgName = ""; |
885 | 892 | ||
886 | QPixmap bg; | 893 | QPixmap bg; |
887 | 894 | ||
888 | switch ( t ) { | 895 | switch ( t ) { |
889 | case Ruled: { | 896 | case Ruled: { |
890 | bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr | 897 | bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr |
891 | if ( bgCache->contains( bgName ) ) { | 898 | if ( bgCache->contains( bgName ) ) { |
892 | (*bgCache)[bgName]->ref++; | 899 | (*bgCache)[bgName]->ref++; |
893 | bg = (*bgCache)[bgName]->pm; | 900 | bg = (*bgCache)[bgName]->pm; |
894 | } else { | 901 | } else { |
895 | bg.resize( width(), 9 ); | 902 | bg.resize( width(), 9 ); |
896 | QPainter painter( &bg ); | 903 | QPainter painter( &bg ); |
897 | for ( int i = 0; i < 3; i++ ) { | 904 | for ( int i = 0; i < 3; i++ ) { |
898 | painter.setPen( white ); | 905 | painter.setPen( white ); |
899 | painter.drawLine( 0, i*3, width()-1, i*3 ); | 906 | painter.drawLine( 0, i*3, width()-1, i*3 ); |
900 | painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); | 907 | painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); |
901 | painter.setPen( colorGroup().background().light(105) ); | 908 | painter.setPen( colorGroup().background().light(105) ); |
902 | painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); | 909 | painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); |
903 | } | 910 | } |
904 | painter.end(); | 911 | painter.end(); |
905 | bgCache->insert( bgName, new BgPixmap(bg) ); | 912 | bgCache->insert( bgName, new BgPixmap(bg) ); |
906 | } | 913 | } |
907 | break; | 914 | break; |
908 | } | 915 | } |
909 | 916 | ||
910 | case Image: | 917 | case Image: |
911 | if (!val.isEmpty()) { | 918 | if (!val.isEmpty()) { |
912 | bgName = val; | 919 | bgName = val; |
913 | if ( bgCache->contains( bgName ) ) { | 920 | if ( bgCache->contains( bgName ) ) { |
914 | (*bgCache)[bgName]->ref++; | 921 | (*bgCache)[bgName]->ref++; |
915 | bg = (*bgCache)[bgName]->pm; | 922 | bg = (*bgCache)[bgName]->pm; |
916 | } else { | 923 | } else { |
917 | QString imgFile = bgName; | 924 | QString imgFile = bgName; |
918 | bool tile = FALSE; | 925 | bool tile = FALSE; |
919 | if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) { | 926 | if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) { |
920 | imgFile = Resource::findPixmap( imgFile ); | 927 | imgFile = Resource::findPixmap( imgFile ); |
921 | tile = TRUE; | 928 | tile = TRUE; |
922 | } | 929 | } |
923 | QImage img = loadBackgroundImage(imgFile); | 930 | QImage img = loadBackgroundImage(imgFile); |
924 | 931 | ||
925 | 932 | ||
926 | if ( img.depth() == 1 ) | 933 | if ( img.depth() == 1 ) |
927 | img = img.convertDepth(8); | 934 | img = img.convertDepth(8); |
928 | img.setAlphaBuffer(FALSE); | 935 | img.setAlphaBuffer(FALSE); |
929 | bg.convertFromImage(img); | 936 | bg.convertFromImage(img); |
930 | bgCache->insert( bgName, new BgPixmap(bg) ); | 937 | bgCache->insert( bgName, new BgPixmap(bg) ); |
931 | } | 938 | } |
932 | } | 939 | } |
933 | break; | 940 | break; |
934 | 941 | ||
935 | case SolidColor: | 942 | case SolidColor: |
936 | default: | 943 | default: |
937 | break; | 944 | break; |
938 | } | 945 | } |
939 | 946 | ||
940 | const QObjectList *list = queryList( "QWidget", 0, FALSE ); | 947 | const QObjectList *list = queryList( "QWidget", 0, FALSE ); |
941 | QObject *obj; | 948 | QObject *obj; |
942 | for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) { | 949 | for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) { |
943 | if ( obj->isWidgetType() ) { | 950 | if ( obj->isWidgetType() ) { |
944 | QWidget *w = (QWidget*)obj; | 951 | QWidget *w = (QWidget*)obj; |
945 | w->setBackgroundPixmap( bg ); | 952 | w->setBackgroundPixmap( bg ); |
946 | if ( bgName.isEmpty() ) { | 953 | if ( bgName.isEmpty() ) { |
947 | // Solid Color | 954 | // Solid Color |
948 | if ( val.isEmpty() ) | 955 | if ( val.isEmpty() ) |
949 | w->setBackgroundColor( colorGroup().base() ); | 956 | w->setBackgroundColor( colorGroup().base() ); |
950 | else | 957 | else |
951 | w->setBackgroundColor( val ); | 958 | w->setBackgroundColor( val ); |
952 | } else { | 959 | } else { |
953 | // Ruled or Image pixmap | 960 | // Ruled or Image pixmap |
954 | w->setBackgroundOrigin( ParentOrigin ); | 961 | w->setBackgroundOrigin( ParentOrigin ); |
955 | } | 962 | } |
956 | } | 963 | } |
957 | } | 964 | } |
958 | delete list; | 965 | delete list; |
959 | 966 | ||
960 | bgType = t; | 967 | bgType = t; |
961 | icons->viewport()->update(); | 968 | icons->viewport()->update(); |
962 | 969 | ||
963 | QTimer::singleShot( 1000, this, SLOT(flushBgCache()) ); | 970 | QTimer::singleShot( 1000, this, SLOT(flushBgCache()) ); |
964 | } | 971 | } |
965 | 972 | ||
966 | void LauncherView::setTextColor( const QColor &tc ) | 973 | void LauncherView::setTextColor( const QColor &tc ) |
967 | { | 974 | { |
968 | textCol = tc; | 975 | textCol = tc; |
969 | QColorGroup cg = icons->colorGroup(); | 976 | QColorGroup cg = icons->colorGroup(); |
970 | cg.setColor( QColorGroup::Text, tc ); | 977 | cg.setColor( QColorGroup::Text, tc ); |
971 | icons->setPalette( QPalette(cg,cg,cg) ); | 978 | icons->setPalette( QPalette(cg,cg,cg) ); |
972 | icons->viewport()->update(); | 979 | icons->viewport()->update(); |
973 | } | 980 | } |
974 | 981 | ||
975 | void LauncherView::setViewFont( const QFont &f ) | 982 | void LauncherView::setViewFont( const QFont &f ) |
976 | { | 983 | { |
977 | icons->setFont( f ); | 984 | icons->setFont( f ); |
978 | icons->hideOrShowItems( FALSE ); | 985 | icons->hideOrShowItems( FALSE ); |
979 | } | 986 | } |
980 | 987 | ||
981 | void LauncherView::clearViewFont() | 988 | void LauncherView::clearViewFont() |
982 | { | 989 | { |
983 | icons->unsetFont(); | 990 | icons->unsetFont(); |
984 | icons->hideOrShowItems( FALSE ); | 991 | icons->hideOrShowItems( FALSE ); |
985 | } | 992 | } |
986 | 993 | ||
987 | void LauncherView::resizeEvent(QResizeEvent *e) | 994 | void LauncherView::resizeEvent(QResizeEvent *e) |
988 | { | 995 | { |
989 | // qDebug("LauncherView resize event"); | 996 | // qDebug("LauncherView resize event"); |
990 | QVBox::resizeEvent( e ); | 997 | QVBox::resizeEvent( e ); |
991 | // commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere... | 998 | // commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere... |
992 | // if ( e->size().width() != e->oldSize().width() ) | 999 | // if ( e->size().width() != e->oldSize().width() ) |
993 | sort(); | 1000 | sort(); |
994 | } | 1001 | } |
995 | 1002 | ||
996 | void LauncherView::selectionChanged() | 1003 | void LauncherView::selectionChanged() |
997 | { | 1004 | { |
998 | QIconViewItem* item = icons->currentItem(); | 1005 | QIconViewItem* item = icons->currentItem(); |
999 | if ( item && item->isSelected() ) { | 1006 | if ( item && item->isSelected() ) { |
1000 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 1007 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
1001 | if ( icons->inKeyEvent() ) // not for mouse press | 1008 | if ( icons->inKeyEvent() ) // not for mouse press |
1002 | emit clicked( appLnk ); | 1009 | emit clicked( appLnk ); |
1003 | item->setSelected(FALSE); | 1010 | item->setSelected(FALSE); |
1004 | } | 1011 | } |
1005 | } | 1012 | } |
1006 | 1013 | ||
1007 | void LauncherView::returnPressed( QIconViewItem *item ) | 1014 | void LauncherView::returnPressed( QIconViewItem *item ) |
1008 | { | 1015 | { |
1009 | if ( item ) { | 1016 | if ( item ) { |
1010 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 1017 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
1011 | emit clicked( appLnk ); | 1018 | emit clicked( appLnk ); |
1012 | } | 1019 | } |
1013 | } | 1020 | } |
1014 | 1021 | ||
1015 | void LauncherView::itemClicked( int btn, QIconViewItem *item ) | 1022 | void LauncherView::itemClicked( int btn, QIconViewItem *item ) |
1016 | { | 1023 | { |
1017 | if ( item ) { | 1024 | if ( item ) { |
1018 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 1025 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
1019 | if ( btn == LeftButton ) { | 1026 | if ( btn == LeftButton ) { |
1020 | // Make sure it's the item we execute that gets highlighted | 1027 | // Make sure it's the item we execute that gets highlighted |
1021 | icons->setCurrentItem( item ); | 1028 | icons->setCurrentItem( item ); |
1022 | emit clicked( appLnk ); | 1029 | emit clicked( appLnk ); |
1023 | } | 1030 | } |
1024 | item->setSelected(FALSE); | 1031 | item->setSelected(FALSE); |
1025 | } | 1032 | } |
1026 | } | 1033 | } |
1027 | 1034 | ||
1028 | void LauncherView::itemPressed( int btn, QIconViewItem *item ) | 1035 | void LauncherView::itemPressed( int btn, QIconViewItem *item ) |
1029 | { | 1036 | { |
1030 | if ( item ) { | 1037 | if ( item ) { |
1031 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 1038 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
1032 | if ( btn == RightButton ) | 1039 | if ( btn == RightButton ) |
1033 | emit rightPressed( appLnk ); | 1040 | emit rightPressed( appLnk ); |
1034 | else if ( btn == ShiftButton ) | 1041 | else if ( btn == ShiftButton ) |
1035 | emit rightPressed( appLnk ); | 1042 | emit rightPressed( appLnk ); |
1036 | item->setSelected(FALSE); | 1043 | item->setSelected(FALSE); |
1037 | } | 1044 | } |
1038 | } | 1045 | } |
1039 | 1046 | ||
1040 | void LauncherView::removeAllItems() | 1047 | void LauncherView::removeAllItems() |
1041 | { | 1048 | { |
1042 | icons->clear(); | 1049 | icons->clear(); |
1043 | } | 1050 | } |
1044 | 1051 | ||
1045 | bool LauncherView::removeLink(const QString& linkfile) | 1052 | bool LauncherView::removeLink(const QString& linkfile) |
1046 | { | 1053 | { |
1047 | return icons->removeLink(linkfile); | 1054 | return icons->removeLink(linkfile); |
1048 | } | 1055 | } |
1049 | 1056 | ||
1050 | void LauncherView::setSortEnabled( bool v ) | 1057 | void LauncherView::setSortEnabled( bool v ) |
1051 | { | 1058 | { |
1052 | icons->setSorting( v ); | 1059 | icons->setSorting( v ); |
1053 | if ( v ) | 1060 | if ( v ) |
1054 | sort(); | 1061 | sort(); |
1055 | } | 1062 | } |
1056 | 1063 | ||
1057 | void LauncherView::setUpdatesEnabled( bool u ) | 1064 | void LauncherView::setUpdatesEnabled( bool u ) |
1058 | { | 1065 | { |
1059 | icons->setUpdatesEnabled( u ); | 1066 | icons->setUpdatesEnabled( u ); |
1060 | } | 1067 | } |
1061 | 1068 | ||
1062 | void LauncherView::sort() | 1069 | void LauncherView::sort() |
1063 | { | 1070 | { |
1064 | icons->sort(); | 1071 | icons->sort(); |
1065 | } | 1072 | } |
1066 | 1073 | ||
1067 | void LauncherView::addItem(AppLnk* app, bool resort) | 1074 | void LauncherView::addItem(AppLnk* app, bool resort) |
1068 | { | 1075 | { |
1069 | icons->addItem(app,resort); | 1076 | icons->addItem(app,resort); |
1070 | } | 1077 | } |
1071 | 1078 | ||
1072 | void LauncherView::paletteChange( const QPalette &p ) | 1079 | void LauncherView::paletteChange( const QPalette &p ) |
1073 | { | 1080 | { |
1074 | icons->unsetPalette(); | 1081 | icons->unsetPalette(); |
1075 | QVBox::paletteChange( p ); | 1082 | QVBox::paletteChange( p ); |
1076 | if ( bgType == Ruled ) | 1083 | if ( bgType == Ruled ) |
1077 | setBackgroundType( Ruled, QString::null ); | 1084 | setBackgroundType( Ruled, QString::null ); |
1078 | QColorGroup cg = icons->colorGroup(); | 1085 | QColorGroup cg = icons->colorGroup(); |
1079 | cg.setColor( QColorGroup::Text, textCol ); | 1086 | cg.setColor( QColorGroup::Text, textCol ); |
1080 | icons->setPalette( QPalette(cg,cg,cg) ); | 1087 | icons->setPalette( QPalette(cg,cg,cg) ); |
1081 | } | 1088 | } |
1082 | 1089 | ||
1083 | void LauncherView::fontChanged(const QFont&) | 1090 | void LauncherView::fontChanged(const QFont&) |
1084 | { | 1091 | { |
1085 | odebug << "LauncherView::fontChanged()" << oendl; | 1092 | odebug << "LauncherView::fontChanged()" << oendl; |
1086 | icons->hideOrShowItems( FALSE ); | 1093 | icons->hideOrShowItems( FALSE ); |
1087 | } | 1094 | } |
1088 | 1095 | ||
1089 | void LauncherView::relayout(void) | 1096 | void LauncherView::relayout(void) |
1090 | { | 1097 | { |
1091 | icons->hideOrShowItems(FALSE); | 1098 | icons->hideOrShowItems(FALSE); |
1092 | } | 1099 | } |
1093 | 1100 | ||
1094 | void LauncherView::flushBgCache() | 1101 | void LauncherView::flushBgCache() |
1095 | { | 1102 | { |
1096 | if ( !bgCache ) | 1103 | if ( !bgCache ) |
1097 | return; | 1104 | return; |
1098 | // remove unreferenced backgrounds. | 1105 | // remove unreferenced backgrounds. |
1099 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); | 1106 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); |
1100 | while ( it != bgCache->end() ) { | 1107 | while ( it != bgCache->end() ) { |
1101 | QMap<QString,BgPixmap*>::Iterator curr = it; | 1108 | QMap<QString,BgPixmap*>::Iterator curr = it; |
1102 | ++it; | 1109 | ++it; |
1103 | if ( (*curr)->ref == 0 ) { | 1110 | if ( (*curr)->ref == 0 ) { |
1104 | delete (*curr); | 1111 | delete (*curr); |
1105 | bgCache->remove( curr ); | 1112 | bgCache->remove( curr ); |
1106 | } | 1113 | } |
1107 | } | 1114 | } |
1108 | } | 1115 | } |
1109 | 1116 | ||
1110 | /* | 1117 | /* |
1111 | * Launcherthumbnail handling for image files | 1118 | * Launcherthumbnail handling for image files |
1112 | */ | 1119 | */ |
1113 | 1120 | ||
1114 | /* special image handling - based on opie eye */ | 1121 | /* special image handling - based on opie eye */ |
1115 | QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { | 1122 | QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { |
1116 | s >> inf.file >> inf.pixmap >> inf.width >> inf.height; | 1123 | s >> inf.file >> inf.pixmap >> inf.width >> inf.height; |
1117 | return s; | 1124 | return s; |
1118 | } | 1125 | } |
1119 | 1126 | ||
1120 | QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { | 1127 | QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { |
1121 | return s << inf.file << inf.width << inf.height; | 1128 | return s << inf.file << inf.width << inf.height; |
1122 | } | 1129 | } |
1123 | 1130 | ||
1124 | LauncherThumbReceiver::LauncherThumbReceiver() | 1131 | LauncherThumbReceiver::LauncherThumbReceiver() |
1125 | :QObject() | 1132 | :QObject() |
1126 | { | 1133 | { |
1127 | QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); | 1134 | QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); |
1128 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), | 1135 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), |
1129 | this, SLOT(recieve(const QCString&,const QByteArray&)) ); | 1136 | this, SLOT(recieve(const QCString&,const QByteArray&)) ); |
1130 | 1137 | ||
1131 | { | 1138 | { |
1132 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 1139 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
1133 | } | 1140 | } |
1134 | } | 1141 | } |
1135 | 1142 | ||
1136 | LauncherThumbReceiver::~LauncherThumbReceiver() | 1143 | LauncherThumbReceiver::~LauncherThumbReceiver() |
1137 | { | 1144 | { |
1138 | { | 1145 | { |
1139 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 1146 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
1140 | } | 1147 | } |
1141 | } | 1148 | } |
1142 | 1149 | ||
1143 | void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) | 1150 | void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) |
1144 | { | 1151 | { |
1145 | PixmapInfos pixinfos; | 1152 | PixmapInfos pixinfos; |
1146 | QDataStream stream( at, IO_ReadOnly ); | 1153 | QDataStream stream( at, IO_ReadOnly ); |
1147 | 1154 | ||
1148 | /* we are just interested in thumbmails */ | 1155 | /* we are just interested in thumbmails */ |
1149 | if ( str == "pixmapsHandled(PixmapList)" ) | 1156 | if ( str == "pixmapsHandled(PixmapList)" ) |
1150 | stream >> pixinfos; | 1157 | stream >> pixinfos; |
1151 | 1158 | ||
1152 | for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { | 1159 | for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { |
1153 | emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); | 1160 | emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); |
1154 | } | 1161 | } |
1155 | } | 1162 | } |
1156 | 1163 | ||
1157 | void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) | 1164 | void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) |
1158 | { | 1165 | { |
1159 | PixmapInfo rItem; | 1166 | PixmapInfo rItem; |
1160 | rItem.file = file; | 1167 | rItem.file = file; |
1161 | rItem.width = width; | 1168 | rItem.width = width; |
1162 | rItem.height = height; | 1169 | rItem.height = height; |
1163 | m_inThumbNail.append(rItem); | 1170 | m_inThumbNail.append(rItem); |
1164 | QTimer::singleShot(0, this, SLOT(sendRequest())); | 1171 | QTimer::singleShot(0, this, SLOT(sendRequest())); |
1165 | } | 1172 | } |
1166 | 1173 | ||
1167 | void LauncherThumbReceiver::sendRequest() | 1174 | void LauncherThumbReceiver::sendRequest() |
1168 | { | 1175 | { |
1169 | if (m_inThumbNail.count()>0) { | 1176 | if (m_inThumbNail.count()>0) { |
1170 | QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); | 1177 | QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); |
1171 | env << m_inThumbNail; | 1178 | env << m_inThumbNail; |
1172 | m_inThumbNail.clear(); | 1179 | m_inThumbNail.clear(); |
1173 | } | 1180 | } |
1174 | } | 1181 | } |
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h index ebb1362..94c367c 100644 --- a/core/launcher/launcherview.h +++ b/core/launcher/launcherview.h | |||
@@ -1,244 +1,246 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LAUNCHERVIEW_H | 20 | #ifndef LAUNCHERVIEW_H |
21 | #define LAUNCHERVIEW_H | 21 | #define LAUNCHERVIEW_H |
22 | 22 | ||
23 | #include <qtopia/storage.h> | 23 | #include <qtopia/storage.h> |
24 | #include <qtopia/applnk.h> | 24 | #include <qtopia/applnk.h> |
25 | 25 | ||
26 | #include <qvbox.h> | 26 | #include <qvbox.h> |
27 | #include <qiconview.h> | 27 | #include <qiconview.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qmap.h> | ||
29 | 30 | ||
30 | class CategorySelect; | 31 | class CategorySelect; |
31 | class LauncherIconView; | 32 | class LauncherIconView; |
32 | class LauncherItem; | 33 | class LauncherItem; |
33 | class QIconViewItem; | 34 | class QIconViewItem; |
34 | class QLabel; | 35 | class QLabel; |
35 | class QWidgetStack; | 36 | class QWidgetStack; |
36 | class MenuButton; | 37 | class MenuButton; |
37 | class QComboBox; | 38 | class QComboBox; |
38 | 39 | ||
39 | 40 | ||
40 | 41 | ||
41 | enum BusyIndicatorType { | 42 | enum BusyIndicatorType { |
42 | BIT_Normal = 0, | 43 | BIT_Normal = 0, |
43 | BIT_Animated | 44 | BIT_Animated |
44 | }; | 45 | }; |
45 | 46 | ||
46 | class LauncherView : public QVBox | 47 | class LauncherView : public QVBox |
47 | { | 48 | { |
48 | Q_OBJECT | 49 | Q_OBJECT |
49 | 50 | ||
50 | public: | 51 | public: |
51 | LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 52 | LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
52 | ~LauncherView(); | 53 | ~LauncherView(); |
53 | 54 | ||
54 | void hideIcons(); | 55 | void hideIcons(); |
55 | 56 | ||
56 | bool removeLink(const QString& linkfile); | 57 | bool removeLink(const QString& linkfile); |
57 | void addItem(AppLnk* app, bool resort=TRUE); | 58 | void addItem(AppLnk* app, bool resort=TRUE); |
58 | void removeAllItems(); | 59 | void removeAllItems(); |
59 | void setSortEnabled(bool); | 60 | void setSortEnabled(bool); |
60 | void setUpdatesEnabled(bool); | 61 | void setUpdatesEnabled(bool); |
61 | void sort(); | 62 | void sort(); |
62 | 63 | ||
63 | void setToolsEnabled(bool); | 64 | void setToolsEnabled(bool); |
64 | void updateTools(); | 65 | void updateTools(); |
65 | 66 | ||
66 | void setBusy(bool); | 67 | void setBusy(bool); |
67 | void setBusyIndicatorType( const QString& ); | 68 | void setBusyIndicatorType( const QString& ); |
68 | 69 | ||
69 | enum ViewMode { Icon, List }; | 70 | enum ViewMode { Icon, List }; |
70 | void setViewMode( ViewMode m ); | 71 | void setViewMode( ViewMode m ); |
71 | ViewMode viewMode() const { return vmode; } | 72 | ViewMode viewMode() const { return vmode; } |
72 | 73 | ||
73 | enum BackgroundType { Ruled, SolidColor, Image }; | 74 | enum BackgroundType { Ruled, SolidColor, Image }; |
74 | void setBackgroundType( BackgroundType t, const QString & ); | 75 | void setBackgroundType( BackgroundType t, const QString & ); |
75 | BackgroundType backgroundType() const { return bgType; } | 76 | BackgroundType backgroundType() const { return bgType; } |
76 | 77 | ||
77 | void setTextColor( const QColor & ); | 78 | void setTextColor( const QColor & ); |
78 | QColor textColor() const { return textCol; } | 79 | QColor textColor() const { return textCol; } |
79 | 80 | ||
80 | void setViewFont( const QFont & ); | 81 | void setViewFont( const QFont & ); |
81 | void clearViewFont(); | 82 | void clearViewFont(); |
82 | 83 | ||
83 | void relayout(void); | 84 | void relayout(void); |
84 | 85 | ||
85 | signals: | 86 | signals: |
86 | void clicked( const AppLnk * ); | 87 | void clicked( const AppLnk * ); |
87 | void rightPressed( AppLnk * ); | 88 | void rightPressed( AppLnk * ); |
88 | 89 | ||
89 | protected slots: | 90 | protected slots: |
90 | void selectionChanged(); | 91 | void selectionChanged(); |
91 | void returnPressed( QIconViewItem *item ); | 92 | void returnPressed( QIconViewItem *item ); |
92 | void itemClicked( int, QIconViewItem * ); | 93 | void itemClicked( int, QIconViewItem * ); |
93 | void itemPressed( int, QIconViewItem * ); | 94 | void itemPressed( int, QIconViewItem * ); |
94 | void sortBy(int); | 95 | void sortBy(int); |
95 | void showType(int); | 96 | void showType(int); |
96 | void showCategory( int ); | 97 | void showCategory( int ); |
97 | void resizeEvent(QResizeEvent *); | 98 | void resizeEvent(QResizeEvent *); |
98 | void flushBgCache(); | 99 | void flushBgCache(); |
99 | 100 | ||
100 | protected: | 101 | protected: |
101 | void paletteChange( const QPalette & ); | 102 | void paletteChange( const QPalette & ); |
102 | 103 | ||
103 | void fontChanged(const QFont &); | 104 | void fontChanged(const QFont &); |
104 | 105 | ||
105 | private: | 106 | private: |
106 | static bool bsy; | 107 | static bool bsy; |
107 | QWidget* tools; | 108 | QWidget* tools; |
108 | LauncherIconView* icons; | 109 | LauncherIconView* icons; |
109 | QComboBox *typemb; | 110 | QComboBox *typemb; |
110 | QStringList typelist; | 111 | QStringList typelist; |
111 | CategorySelect *catmb; | 112 | CategorySelect *catmb; |
112 | ViewMode vmode; | 113 | ViewMode vmode; |
113 | BackgroundType bgType; | 114 | BackgroundType bgType; |
114 | QString bgName; | 115 | QString bgName; |
115 | QColor textCol; | 116 | QColor textCol; |
116 | 117 | ||
117 | QImage loadBackgroundImage(QString &fname); | 118 | QImage loadBackgroundImage(QString &fname); |
118 | 119 | ||
119 | }; | 120 | }; |
120 | 121 | ||
121 | /* from opie-eye */ | 122 | /* from opie-eye */ |
122 | struct PixmapInfo { | 123 | struct PixmapInfo { |
123 | PixmapInfo() : width( -1 ), height( -1 ) {} | 124 | PixmapInfo() : width( -1 ), height( -1 ) {} |
124 | bool operator==( const PixmapInfo& r ) { | 125 | bool operator==( const PixmapInfo& r ) { |
125 | if ( width != r.width ) return false; | 126 | if ( width != r.width ) return false; |
126 | if ( height != r.height ) return false; | 127 | if ( height != r.height ) return false; |
127 | if ( file != r.file ) return false; | 128 | if ( file != r.file ) return false; |
128 | return true; | 129 | return true; |
129 | } | 130 | } |
130 | int width, height; | 131 | int width, height; |
131 | QString file; | 132 | QString file; |
132 | QPixmap pixmap; | 133 | QPixmap pixmap; |
133 | }; | 134 | }; |
134 | 135 | ||
135 | class LauncherThumbReceiver:public QObject | 136 | class LauncherThumbReceiver:public QObject |
136 | { | 137 | { |
137 | Q_OBJECT | 138 | Q_OBJECT |
138 | typedef QValueList<PixmapInfo> PixmapInfos; | 139 | typedef QValueList<PixmapInfo> PixmapInfos; |
139 | public: | 140 | public: |
140 | LauncherThumbReceiver(); | 141 | LauncherThumbReceiver(); |
141 | ~LauncherThumbReceiver(); | 142 | ~LauncherThumbReceiver(); |
142 | void requestThumb(const QString&file,int width,int height); | 143 | void requestThumb(const QString&file,int width,int height); |
143 | 144 | ||
144 | public slots: | 145 | public slots: |
145 | void recieve( const QCString&, const QByteArray& ); | 146 | void recieve( const QCString&, const QByteArray& ); |
146 | protected slots: | 147 | protected slots: |
147 | virtual void sendRequest(); | 148 | virtual void sendRequest(); |
148 | 149 | ||
149 | signals: | 150 | signals: |
150 | void sig_Thumbnail(const QPixmap&,const QString&,int); | 151 | void sig_Thumbnail(const QPixmap&,const QString&,int); |
151 | 152 | ||
152 | protected: | 153 | protected: |
153 | PixmapInfos m_inThumbNail; | 154 | PixmapInfos m_inThumbNail; |
154 | }; | 155 | }; |
155 | 156 | ||
156 | class LauncherIconView : public QIconView { | 157 | class LauncherIconView : public QIconView { |
157 | Q_OBJECT | 158 | Q_OBJECT |
158 | public: | 159 | public: |
159 | LauncherIconView( QWidget* parent, const char* name=0 ); | 160 | LauncherIconView( QWidget* parent, const char* name=0 ); |
160 | ~LauncherIconView(); | 161 | ~LauncherIconView(); |
161 | QIconViewItem* busyItem() const; | 162 | QIconViewItem* busyItem() const; |
162 | 163 | ||
163 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 164 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
164 | QPixmap busyPixmap() const { return busyPix; } | 165 | QPixmap busyPixmap() const { return busyPix; } |
165 | #endif | 166 | #endif |
166 | void setBigIcons( bool bi ); | 167 | void setBigIcons( bool bi ); |
167 | void updateCategoriesAndMimeTypes(); | 168 | void updateCategoriesAndMimeTypes(); |
168 | void setBusyIndicatorType ( BusyIndicatorType t ); | 169 | void setBusyIndicatorType ( BusyIndicatorType t ); |
169 | void doAutoScroll() | 170 | void doAutoScroll() |
170 | { | 171 | { |
171 | // We don't want rubberbanding (yet) | 172 | // We don't want rubberbanding (yet) |
172 | } | 173 | } |
173 | 174 | ||
174 | void setBusy(bool on); | 175 | void setBusy(bool on); |
175 | bool inKeyEvent() const { return ike; } | 176 | bool inKeyEvent() const { return ike; } |
176 | 177 | ||
177 | void addItem(AppLnk* app, bool resort=TRUE); | 178 | void addItem(AppLnk* app, bool resort=TRUE); |
178 | bool removeLink(const QString& linkfile); | 179 | bool removeLink(const QString& linkfile); |
179 | 180 | ||
180 | QStringList mimeTypes() const; | 181 | QStringList mimeTypes() const; |
181 | QStringList categories() const; | 182 | QStringList categories() const; |
182 | void clear(); | 183 | void clear(); |
183 | void addCatsAndMimes(AppLnk* app); | 184 | void addCatsAndMimes(AppLnk* app); |
184 | 185 | ||
185 | void setBackgroundOrigin( QWidget::BackgroundOrigin ) {} | 186 | void setBackgroundOrigin( QWidget::BackgroundOrigin ) {} |
186 | 187 | ||
187 | void setBackgroundPixmap( const QPixmap &pm ) { | 188 | void setBackgroundPixmap( const QPixmap &pm ) { |
188 | bgPixmap = pm; | 189 | bgPixmap = pm; |
189 | } | 190 | } |
190 | 191 | ||
191 | void setBackgroundColor( const QColor &c ) { | 192 | void setBackgroundColor( const QColor &c ) { |
192 | bgColor = c; | 193 | bgColor = c; |
193 | } | 194 | } |
194 | 195 | ||
195 | void drawBackground( QPainter *p, const QRect &r ); | 196 | void drawBackground( QPainter *p, const QRect &r ); |
196 | void setItemTextPos( ItemTextPos pos ); | 197 | void setItemTextPos( ItemTextPos pos ); |
197 | void hideOrShowItems(bool resort); | 198 | void hideOrShowItems(bool resort); |
198 | 199 | ||
199 | void setTypeFilter(const QString& typefilter, bool resort); | 200 | void setTypeFilter(const QString& typefilter, bool resort); |
200 | void setCategoryFilter( int catfilter, bool resort ); | 201 | void setCategoryFilter( int catfilter, bool resort ); |
201 | 202 | ||
202 | enum SortMethod { Name, Date, Type }; | 203 | enum SortMethod { Name, Date, Type }; |
203 | 204 | ||
204 | void setSortMethod( SortMethod m ); | 205 | void setSortMethod( SortMethod m ); |
205 | int compare(const AppLnk* a, const AppLnk* b); | 206 | int compare(const AppLnk* a, const AppLnk* b); |
206 | void requestEyePix(const LauncherItem*which); | 207 | void requestEyePix(const LauncherItem*which); |
207 | 208 | ||
208 | protected: | 209 | protected: |
209 | virtual void timerEvent( QTimerEvent *te ); | 210 | virtual void timerEvent( QTimerEvent *te ); |
210 | void styleChange( QStyle &old ); | 211 | void styleChange( QStyle &old ); |
211 | void calculateGrid( ItemTextPos pos ); | 212 | void calculateGrid( ItemTextPos pos ); |
212 | void focusInEvent( QFocusEvent * ) {} | 213 | void focusInEvent( QFocusEvent * ) {} |
213 | void focusOutEvent( QFocusEvent * ) {} | 214 | void focusOutEvent( QFocusEvent * ) {} |
214 | LauncherItem*findDocItem(const QString&); | 215 | LauncherItem*findDocItem(const QString&); |
215 | void addCheckItem(AppLnk* app); | 216 | void addCheckItem(AppLnk* app); |
216 | void checkCallback(); | 217 | void checkCallback(); |
217 | virtual void keyPressEvent(QKeyEvent* e); | 218 | virtual void keyPressEvent(QKeyEvent* e); |
218 | 219 | ||
219 | protected slots: | 220 | protected slots: |
220 | void setEyePixmap(const QPixmap&,const QString&,int width); | 221 | void setEyePixmap(const QPixmap&,const QString&,int width); |
221 | void stopEyeTimer(); | 222 | void stopEyeTimer(); |
222 | 223 | ||
223 | private: | 224 | private: |
224 | QList<AppLnk> hidden; | 225 | QList<AppLnk> hidden; |
225 | QDict<void> mimes; | 226 | QDict<void> mimes; |
226 | QDict<void> cats; | 227 | QDict<void> cats; |
227 | SortMethod sortmeth; | 228 | SortMethod sortmeth; |
228 | QRegExp tf; | 229 | QRegExp tf; |
229 | int cf; | 230 | int cf; |
230 | LauncherItem* bsy; | 231 | LauncherItem* bsy; |
231 | int busyTimer; | 232 | int busyTimer; |
232 | bool ike; | 233 | bool ike; |
233 | bool bigIcns; | 234 | bool bigIcns; |
234 | QPixmap bgPixmap; | 235 | QPixmap bgPixmap; |
235 | QColor bgColor; | 236 | QColor bgColor; |
236 | LauncherThumbReceiver*m_EyeCallBack; | 237 | LauncherThumbReceiver*m_EyeCallBack; |
237 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 238 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
238 | QPixmap busyPix; | 239 | QPixmap busyPix; |
239 | #endif | 240 | #endif |
240 | BusyIndicatorType busyType; | 241 | BusyIndicatorType busyType; |
241 | QTimer m_eyeTimer; | 242 | QTimer m_eyeTimer; |
243 | QMap<QString,LauncherItem*> m_itemCache; | ||
242 | }; | 244 | }; |
243 | 245 | ||
244 | #endif // LAUNCHERVIEW_H | 246 | #endif // LAUNCHERVIEW_H |