summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-02-16 19:20:06 (UTC)
committer mickeyl <mickeyl>2005-02-16 19:20:06 (UTC)
commit5ad21664e5db417a18682903a660f4651c68ff12 (patch) (unidiff)
tree12fc6b3e45b3575cf71c2b5dd1e26c4592f5381b
parent4fc6942eed4abdc0d4b5e1b3460a32852731c7b4 (diff)
downloadopie-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
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp29
-rw-r--r--core/launcher/launcherview.h7
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
@@ -263,137 +263,154 @@ void LauncherItem::resetIcon()
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
272void LauncherItem::setEyePixmap(const QPixmap&aIcon) 272void 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
283QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0; 283QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0;
284 284
285LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) 285LauncherIconView::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
297LauncherIconView::~LauncherIconView() 305LauncherIconView::~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
310int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) 318int 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
326void LauncherIconView::setSortMethod( SortMethod m ) 334void 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
334void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) 342void 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
343void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) 351void 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
349void LauncherIconView::setItemTextPos( ItemTextPos pos ) 357void LauncherIconView::setItemTextPos( ItemTextPos pos )
350{ 358{
351 calculateGrid( pos ); 359 calculateGrid( pos );
352 QIconView::setItemTextPos( pos ); 360 QIconView::setItemTextPos( pos );
353} 361}
354 362
355void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) 363void 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
366void LauncherIconView::addCatsAndMimes(AppLnk* app) 383void 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
381void LauncherIconView::setBusy(bool on) 398void 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;
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
@@ -8,110 +8,108 @@
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
31class CategorySelect; 31class CategorySelect;
32class LauncherIconView; 32class LauncherIconView;
33class LauncherItem; 33class LauncherItem;
34class QIconViewItem; 34class QIconViewItem;
35class QLabel; 35class QLabel;
36class QWidgetStack; 36class QWidgetStack;
37class MenuButton; 37class MenuButton;
38class QComboBox; 38class QComboBox;
39 39
40
41
42enum BusyIndicatorType { 40enum BusyIndicatorType {
43 BIT_Normal = 0, 41 BIT_Normal = 0,
44 BIT_Animated 42 BIT_Animated
45}; 43};
46 44
47class LauncherView : public QVBox 45class LauncherView : public QVBox
48{ 46{
49 Q_OBJECT 47 Q_OBJECT
50 48
51public: 49public:
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
90signals: 88signals:
91 void clicked( const AppLnk * ); 89 void clicked( const AppLnk * );
92 void rightPressed( AppLnk * ); 90 void rightPressed( AppLnk * );
93 91
94protected slots: 92protected 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
105protected: 103protected:
106 void paletteChange( const QPalette & ); 104 void paletteChange( const QPalette & );
107 105
108 void fontChanged(const QFont &); 106 void fontChanged(const QFont &);
109 107
110private: 108private:
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;
@@ -170,86 +168,87 @@ public:
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
218protected: 216protected:
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
229protected slots: 227protected 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
233private: 231private:
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