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