summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 7b20fdc..0df949e 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -1,212 +1,222 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of 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#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/applnk.h> 24#include <qpe/applnk.h>
25#include <qpe/qpedebug.h> 25#include <qpe/qpedebug.h>
26#include <qpe/config.h>
26#include <qpe/categories.h> 27#include <qpe/categories.h>
27#include <qpe/categoryselect.h> 28#include <qpe/categoryselect.h>
28#include <qpe/menubutton.h> 29#include <qpe/menubutton.h>
29#include <qpe/resource.h> 30#include <qpe/resource.h>
30#include <qpe/qpetoolbar.h> 31#include <qpe/qpetoolbar.h>
31 32
32#include <qtimer.h> 33#include <qtimer.h>
33#include <qdict.h> 34#include <qdict.h>
34#include <qfile.h> 35#include <qfile.h>
35#include <qfileinfo.h> 36#include <qfileinfo.h>
36#include <qhbox.h> 37#include <qhbox.h>
37#include <qiconview.h> 38#include <qiconview.h>
38#include <qpainter.h> 39#include <qpainter.h>
39#include <qregexp.h> 40#include <qregexp.h>
40#include <qtoolbutton.h> 41#include <qtoolbutton.h>
41 42
42class LauncherIconView : public QIconView { 43class LauncherIconView : public QIconView {
43public: 44public:
44 LauncherIconView( QWidget* parent, const char* name=0 ) : 45 LauncherIconView( QWidget* parent, const char* name=0 ) :
45 QIconView(parent,name), 46 QIconView(parent,name),
46 tf(""), 47 tf(""),
47 cf(0), 48 cf(0),
48 bsy(0) 49 bsy(0)
49 { 50 {
50 sortmeth = Name; 51 sortmeth = Name;
51 hidden.setAutoDelete(TRUE); 52 hidden.setAutoDelete(TRUE);
52 ike = FALSE; 53 ike = FALSE;
53 } 54 }
54 55
55 ~LauncherIconView() 56 ~LauncherIconView()
56 { 57 {
57#if 0 // debuggery 58#if 0 // debuggery
58 QListIterator<AppLnk> it(hidden); 59 QListIterator<AppLnk> it(hidden);
59 AppLnk* l; 60 AppLnk* l;
60 while ((l=it.current())) { 61 while ((l=it.current())) {
61 ++it; 62 ++it;
62 //qDebug("%p: hidden (should remove)",l); 63 //qDebug("%p: hidden (should remove)",l);
63 } 64 }
64#endif 65#endif
65 } 66 }
66 67
67 QIconViewItem* busyItem() const { return bsy; } 68 QIconViewItem* busyItem() const { return bsy; }
68 69
69 void updateCategoriesAndMimeTypes(); 70 void updateCategoriesAndMimeTypes();
70 71
71 void doAutoScroll() 72 void doAutoScroll()
72 { 73 {
73 // We don't want rubberbanding (yet) 74 // We don't want rubberbanding (yet)
74 } 75 }
75 76
76 void setBusy(bool on) 77 void setBusy(bool on)
77 { 78 {
78 QIconViewItem *c = on ? currentItem() : 0; 79 QIconViewItem *c = on ? currentItem() : 0;
79 if ( bsy != c ) { 80 if ( bsy != c ) {
80 QIconViewItem* o = bsy; 81 QIconViewItem* o = bsy;
81 bsy = c; 82 bsy = c;
82 if ( o ) o->repaint(); 83 if ( o ) o->repaint();
83 if ( c ) c->repaint(); 84 if ( c ) c->repaint();
84 } 85 }
85 } 86 }
86 87
87 bool inKeyEvent() const { return ike; } 88 bool inKeyEvent() const { return ike; }
88 void keyPressEvent(QKeyEvent* e) 89 void keyPressEvent(QKeyEvent* e)
89 { 90 {
90 ike = TRUE; 91 ike = TRUE;
91 if ( e->key() == Key_F33 ) { 92 if ( e->key() == Key_F33 ) {
92 // "OK" button 93 // "OK" button
93 returnPressed(currentItem()); 94 returnPressed(currentItem());
94 } 95 }
95 QIconView::keyPressEvent(e); 96 QIconView::keyPressEvent(e);
96 ike = FALSE; 97 ike = FALSE;
97 } 98 }
98 99
99 void addItem(AppLnk* app, bool resort=TRUE); 100 void addItem(AppLnk* app, bool resort=TRUE);
100 bool removeLink(const QString& linkfile); 101 bool removeLink(const QString& linkfile);
101 102
102 QStringList mimeTypes() const; 103 QStringList mimeTypes() const;
103 QStringList categories() const; 104 QStringList categories() const;
104 105
105 void clear() 106 void clear()
106 { 107 {
107 mimes.clear(); 108 mimes.clear();
108 cats.clear(); 109 cats.clear();
109 QIconView::clear(); 110 QIconView::clear();
110 hidden.clear(); 111 hidden.clear();
111 } 112 }
112 113
113 void addCatsAndMimes(AppLnk* app) 114 void addCatsAndMimes(AppLnk* app)
114 { 115 {
115 // QStringList c = app->categories(); 116 // QStringList c = app->categories();
116 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { 117 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) {
117 // cats.replace(*cit,(void*)1); 118 // cats.replace(*cit,(void*)1);
118 // } 119 // }
119 QString maj=app->type(); 120 QString maj=app->type();
120 int sl=maj.find('/'); 121 int sl=maj.find('/');
121 if (sl>=0) { 122 if (sl>=0) {
122 QString k = maj.left(sl); 123 QString k = maj.left(sl);
123 mimes.replace(k,(void*)1); 124 mimes.replace(k,(void*)1);
124 } 125 }
125 } 126 }
126 127
127 void drawBackground( QPainter *p, const QRect &r ) 128 void drawBackground( QPainter *p, const QRect &r )
128 { 129 {
130 Config config("qpe");
131 config.setGroup("Appearance");
132 QString backgroundImage = config.readEntry("BackgroundImage");
133
134 if (backgroundImage.isNull()) backgroundImage="qpe-background";
129 int backgroundMode = QPixmap::defaultDepth() >= 12 ? 1 : 0; 135 int backgroundMode = QPixmap::defaultDepth() >= 12 ? 1 : 0;
130 //int backgroundMode = 2; 136 //int backgroundMode = 2;
131 137
132 if ( backgroundMode == 1 ) { 138 if ( backgroundMode == 1 ) {
133 139
134 // Double buffer the background 140 // Double buffer the background
135 static QPixmap *bg = NULL; 141 static QPixmap *bg = NULL;
136 static QColor bgColor; 142 static QColor bgColor;
137 143
138 if ( (bg == NULL) || (bgColor != colorGroup().button()) ) { 144 if ( (bg == NULL) || (bgColor != colorGroup().button()) ) {
139 // Create a new background double buffer 145 // Create a new background double buffer
140 if (bg == NULL) 146 if (bg == NULL)
141 bg = new QPixmap( width(), height() ); 147 bg = new QPixmap( width(), height() );
142 bgColor = colorGroup().button(); 148 bgColor = colorGroup().button();
143 QPainter painter( bg ); 149 QPainter painter( bg );
144 150
145 painter.fillRect( QRect( 0, 0, width(), height() ), colorGroup().background().light(110)); 151 painter.fillRect( QRect( 0, 0, width(), height() ), colorGroup().background().light(110));
146 152 // Overlay the Qtopia logo in the center
147 // Overlay the Qtopia logo in the center 153 QImage logo;
148 QImage logo = Resource::loadImage( "qpe-background" ); 154 if (QFile::exists(backgroundImage)) {
155 logo = QImage(backgroundImage);
156 } else {
157 logo = Resource::loadImage(backgroundImage );
158 }
149 if ( !logo.isNull() ) 159 if ( !logo.isNull() )
150 painter.drawImage( (width() - logo.width()) / 2, 160 painter.drawImage( (width() - logo.width()) / 2,
151 (height() - logo.height()) / 2, logo ); 161 (height() - logo.height()) / 2, logo );
152 } 162 }
153 163
154 // Draw the double buffer to the widget (it is tiled for when the icon view is large) 164 // Draw the double buffer to the widget (it is tiled for when the icon view is large)
155 p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), 165 p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(),
156 (r.y() + contentsY()) % bg->height() ) ); 166 (r.y() + contentsY()) % bg->height() ) );
157 } else if ( backgroundMode == 2 ) { 167 } else if ( backgroundMode == 2 ) {
158 static QPixmap *bg = 0; 168 static QPixmap *bg = 0;
159 static QColor bgColor; 169 static QColor bgColor;
160 if ( !bg || (bgColor != colorGroup().background()) ) { 170 if ( !bg || (bgColor != colorGroup().background()) ) {
161 bgColor = colorGroup().background(); 171 bgColor = colorGroup().background();
162 bg = new QPixmap( width(), 9 ); 172 bg = new QPixmap( width(), 9 );
163 QPainter painter( bg ); 173 QPainter painter( bg );
164 for ( int i = 0; i < 3; i++ ) { 174 for ( int i = 0; i < 3; i++ ) {
165 painter.setPen( colorGroup().background().light(130) ); 175 painter.setPen( colorGroup().background().light(130) );
166 painter.drawLine( 0, i*3, width()-1, i*3 ); 176 painter.drawLine( 0, i*3, width()-1, i*3 );
167 painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); 177 painter.drawLine( 0, i*3+1, width()-1, i*3+1 );
168 painter.setPen( colorGroup().background().light(105) ); 178 painter.setPen( colorGroup().background().light(105) );
169 painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); 179 painter.drawLine( 0, i*3+2, width()-1, i*3+2 );
170 } 180 }
171 } 181 }
172 p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), 182 p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(),
173 (r.y() + contentsY()) % bg->height() ) ); 183 (r.y() + contentsY()) % bg->height() ) );
174 } else { 184 } else {
175 p->fillRect( r, QBrush( colorGroup().background().light(110) ) ); 185 p->fillRect( r, QBrush( colorGroup().background().light(110) ) );
176 } 186 }
177 } 187 }
178 188
179 void hideOrShowItems(bool resort); 189 void hideOrShowItems(bool resort);
180 190
181 void setTypeFilter(const QString& typefilter, bool resort) 191 void setTypeFilter(const QString& typefilter, bool resort)
182 { 192 {
183 tf = QRegExp(typefilter,FALSE,TRUE); 193 tf = QRegExp(typefilter,FALSE,TRUE);
184 hideOrShowItems(resort); 194 hideOrShowItems(resort);
185 } 195 }
186 196
187 void setCategoryFilter( int catfilter, bool resort ) 197 void setCategoryFilter( int catfilter, bool resort )
188 { 198 {
189 Categories cat; 199 Categories cat;
190 cat.load( categoryFileName() ); 200 cat.load( categoryFileName() );
191 QString str; 201 QString str;
192 if ( catfilter == -2 ) 202 if ( catfilter == -2 )
193 cf = 0; 203 cf = 0;
194 else 204 else
195 cf = catfilter; 205 cf = catfilter;
196 hideOrShowItems(resort); 206 hideOrShowItems(resort);
197 } 207 }
198 208
199 enum SortMethod { Name, Date, Type }; 209 enum SortMethod { Name, Date, Type };
200 210
201 void setSortMethod( SortMethod m ) 211 void setSortMethod( SortMethod m )
202 { 212 {
203 if ( sortmeth != m ) { 213 if ( sortmeth != m ) {
204 sortmeth = m; 214 sortmeth = m;
205 sort(); 215 sort();
206 } 216 }
207 } 217 }
208 218
209 int compare(const AppLnk* a, const AppLnk* b) 219 int compare(const AppLnk* a, const AppLnk* b)
210 { 220 {
211 switch (sortmeth) { 221 switch (sortmeth) {
212 case Name: 222 case Name: