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