author | drw <drw> | 2002-05-18 22:25:24 (UTC) |
---|---|---|
committer | drw <drw> | 2002-05-18 22:25:24 (UTC) |
commit | aa2cff2e8838829125c0ff4efe969b3835c79fa7 (patch) (unidiff) | |
tree | b47056d32711ee7bc3f24dcf86a6832df78f2815 | |
parent | be9add24a65c8ad89bc5425aa4d42c4b598a50be (diff) | |
download | opie-aa2cff2e8838829125c0ff4efe969b3835c79fa7.zip opie-aa2cff2e8838829125c0ff4efe969b3835c79fa7.tar.gz opie-aa2cff2e8838829125c0ff4efe969b3835c79fa7.tar.bz2 |
Added ability to turn off background image.
-rw-r--r-- | core/launcher/launcherview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index 1598d13..30afe64 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp | |||
@@ -39,257 +39,257 @@ | |||
39 | #include <qpainter.h> | 39 | #include <qpainter.h> |
40 | #include <qregexp.h> | 40 | #include <qregexp.h> |
41 | #include <qtoolbutton.h> | 41 | #include <qtoolbutton.h> |
42 | 42 | ||
43 | class LauncherIconView : public QIconView { | 43 | class LauncherIconView : public QIconView { |
44 | public: | 44 | public: |
45 | QColor iconText; | 45 | QColor iconText; |
46 | QColor background; | 46 | QColor background; |
47 | 47 | ||
48 | LauncherIconView( QWidget* parent, const char* name=0 ) : | 48 | LauncherIconView( QWidget* parent, const char* name=0 ) : |
49 | QIconView(parent,name), | 49 | QIconView(parent,name), |
50 | tf(""), | 50 | tf(""), |
51 | cf(0), | 51 | cf(0), |
52 | bsy(0) | 52 | bsy(0) |
53 | { | 53 | { |
54 | sortmeth = Name; | 54 | sortmeth = Name; |
55 | hidden.setAutoDelete(TRUE); | 55 | hidden.setAutoDelete(TRUE); |
56 | ike = FALSE; | 56 | ike = FALSE; |
57 | 57 | ||
58 | Config config( "qpe" ); | 58 | Config config( "qpe" ); |
59 | config.setGroup( "Appearance" ); | 59 | config.setGroup( "Appearance" ); |
60 | iconText = QColor( config.readEntry( "LauncherIconText", "#000000" ) ); | 60 | iconText = QColor( config.readEntry( "LauncherIconText", "#000000" ) ); |
61 | background = QColor( config.readEntry( "LauncherBackground", "#FFFFFF" ) ); | 61 | background = QColor( config.readEntry( "LauncherBackground", "#FFFFFF" ) ); |
62 | } | 62 | } |
63 | 63 | ||
64 | ~LauncherIconView() | 64 | ~LauncherIconView() |
65 | { | 65 | { |
66 | #if 0 // debuggery | 66 | #if 0 // debuggery |
67 | QListIterator<AppLnk> it(hidden); | 67 | QListIterator<AppLnk> it(hidden); |
68 | AppLnk* l; | 68 | AppLnk* l; |
69 | while ((l=it.current())) { | 69 | while ((l=it.current())) { |
70 | ++it; | 70 | ++it; |
71 | //qDebug("%p: hidden (should remove)",l); | 71 | //qDebug("%p: hidden (should remove)",l); |
72 | } | 72 | } |
73 | #endif | 73 | #endif |
74 | } | 74 | } |
75 | 75 | ||
76 | QIconViewItem* busyItem() const { return bsy; } | 76 | QIconViewItem* busyItem() const { return bsy; } |
77 | 77 | ||
78 | void updateCategoriesAndMimeTypes(); | 78 | void updateCategoriesAndMimeTypes(); |
79 | 79 | ||
80 | void doAutoScroll() | 80 | void doAutoScroll() |
81 | { | 81 | { |
82 | // We don't want rubberbanding (yet) | 82 | // We don't want rubberbanding (yet) |
83 | } | 83 | } |
84 | 84 | ||
85 | void setBusy(bool on) | 85 | void setBusy(bool on) |
86 | { | 86 | { |
87 | QIconViewItem *c = on ? currentItem() : 0; | 87 | QIconViewItem *c = on ? currentItem() : 0; |
88 | if ( bsy != c ) { | 88 | if ( bsy != c ) { |
89 | QIconViewItem* o = bsy; | 89 | QIconViewItem* o = bsy; |
90 | bsy = c; | 90 | bsy = c; |
91 | if ( o ) o->repaint(); | 91 | if ( o ) o->repaint(); |
92 | if ( c ) c->repaint(); | 92 | if ( c ) c->repaint(); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | bool inKeyEvent() const { return ike; } | 96 | bool inKeyEvent() const { return ike; } |
97 | void keyPressEvent(QKeyEvent* e) | 97 | void keyPressEvent(QKeyEvent* e) |
98 | { | 98 | { |
99 | ike = TRUE; | 99 | ike = TRUE; |
100 | if ( e->key() == Key_F33 ) { | 100 | if ( e->key() == Key_F33 ) { |
101 | // "OK" button | 101 | // "OK" button |
102 | returnPressed(currentItem()); | 102 | returnPressed(currentItem()); |
103 | } | 103 | } |
104 | QIconView::keyPressEvent(e); | 104 | QIconView::keyPressEvent(e); |
105 | ike = FALSE; | 105 | ike = FALSE; |
106 | } | 106 | } |
107 | 107 | ||
108 | void addItem(AppLnk* app, bool resort=TRUE); | 108 | void addItem(AppLnk* app, bool resort=TRUE); |
109 | bool removeLink(const QString& linkfile); | 109 | bool removeLink(const QString& linkfile); |
110 | 110 | ||
111 | QStringList mimeTypes() const; | 111 | QStringList mimeTypes() const; |
112 | QStringList categories() const; | 112 | QStringList categories() const; |
113 | 113 | ||
114 | void clear() | 114 | void clear() |
115 | { | 115 | { |
116 | mimes.clear(); | 116 | mimes.clear(); |
117 | cats.clear(); | 117 | cats.clear(); |
118 | QIconView::clear(); | 118 | QIconView::clear(); |
119 | hidden.clear(); | 119 | hidden.clear(); |
120 | } | 120 | } |
121 | 121 | ||
122 | void addCatsAndMimes(AppLnk* app) | 122 | void addCatsAndMimes(AppLnk* app) |
123 | { | 123 | { |
124 | // QStringList c = app->categories(); | 124 | // QStringList c = app->categories(); |
125 | // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { | 125 | // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { |
126 | // cats.replace(*cit,(void*)1); | 126 | // cats.replace(*cit,(void*)1); |
127 | // } | 127 | // } |
128 | QString maj=app->type(); | 128 | QString maj=app->type(); |
129 | int sl=maj.find('/'); | 129 | int sl=maj.find('/'); |
130 | if (sl>=0) { | 130 | if (sl>=0) { |
131 | QString k = maj.left(sl); | 131 | QString k = maj.left(sl); |
132 | mimes.replace(k,(void*)1); | 132 | mimes.replace(k,(void*)1); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | void drawBackground( QPainter *p, const QRect &r ) | 136 | void drawBackground( QPainter *p, const QRect &r ) |
137 | { | 137 | { |
138 | Config config("qpe"); | 138 | Config config("qpe"); |
139 | config.setGroup("Appearance"); | 139 | config.setGroup("Appearance"); |
140 | QString backgroundImage = config.readEntry("BackgroundImage","launcher/opie-background"); | 140 | QString backgroundImage = config.readEntry("BackgroundImage","launcher/opie-background"); |
141 | // if (backgroundImage.isNull()) backgroundImage="launcher/opie-background"; | 141 | // if (backgroundImage.isNull()) backgroundImage="launcher/opie-background"; |
142 | int backgroundMode = QPixmap::defaultDepth() >= 12 ? 1 : 0; | 142 | int backgroundMode = QPixmap::defaultDepth() >= 12 ? 1 : 0; |
143 | //int backgroundMode = 2; | 143 | //int backgroundMode = 2; |
144 | 144 | ||
145 | if ( backgroundMode == 1 ) { | 145 | if ( backgroundMode == 1 ) { |
146 | 146 | ||
147 | // Double buffer the background | 147 | // Double buffer the background |
148 | static QPixmap *bg = NULL; | 148 | static QPixmap *bg = NULL; |
149 | static QColor bgColor; | 149 | static QColor bgColor; |
150 | 150 | ||
151 | if ( (bg == NULL) || (bgColor != colorGroup().button()) ) { | 151 | if ( (bg == NULL) || (bgColor != colorGroup().button()) ) { |
152 | // Create a new background double buffer | 152 | // Create a new background double buffer |
153 | if (bg == NULL) | 153 | if (bg == NULL) |
154 | bg = new QPixmap( width(), height() ); | 154 | bg = new QPixmap( width(), height() ); |
155 | bgColor = colorGroup().button(); | 155 | bgColor = colorGroup().button(); |
156 | QPainter painter( bg ); | 156 | QPainter painter( bg ); |
157 | 157 | ||
158 | // painter.fillRect( QRect( 0, 0, width(), height() ), colorGroup().background().light(110)); | 158 | // painter.fillRect( QRect( 0, 0, width(), height() ), colorGroup().background().light(110)); |
159 | painter.fillRect( QRect( 0, 0, width(), height() ), background); | 159 | painter.fillRect( QRect( 0, 0, width(), height() ), background); |
160 | // Overlay the Qtopia logo in the center | 160 | // Overlay the Qtopia logo in the center |
161 | QImage logo; | 161 | QImage logo; |
162 | if (QFile::exists(backgroundImage)) { | 162 | if (QFile::exists(backgroundImage)) { |
163 | logo = QImage(backgroundImage); | 163 | logo = QImage(backgroundImage); |
164 | } else { | 164 | } else { |
165 | logo = Resource::loadImage(backgroundImage ); | 165 | logo = Resource::loadImage(backgroundImage ); |
166 | } | 166 | } |
167 | if ( !logo.isNull() ) | 167 | if ( !logo.isNull() && config.readBoolEntry( "UseBackgroundImage", TRUE ) ) |
168 | painter.drawImage( (width() - logo.width()) / 2, | 168 | painter.drawImage( (width() - logo.width()) / 2, |
169 | (height() - logo.height()) / 2, logo ); | 169 | (height() - logo.height()) / 2, logo ); |
170 | } | 170 | } |
171 | 171 | ||
172 | // Draw the double buffer to the widget (it is tiled for when the icon view is large) | 172 | // Draw the double buffer to the widget (it is tiled for when the icon view is large) |
173 | p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), | 173 | p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), |
174 | (r.y() + contentsY()) % bg->height() ) ); | 174 | (r.y() + contentsY()) % bg->height() ) ); |
175 | } else if ( backgroundMode == 2 ) { | 175 | } else if ( backgroundMode == 2 ) { |
176 | static QPixmap *bg = 0; | 176 | static QPixmap *bg = 0; |
177 | static QColor bgColor; | 177 | static QColor bgColor; |
178 | if ( !bg || (bgColor != colorGroup().background()) ) { | 178 | if ( !bg || (bgColor != colorGroup().background()) ) { |
179 | bgColor = colorGroup().background(); | 179 | bgColor = colorGroup().background(); |
180 | bg = new QPixmap( width(), 9 ); | 180 | bg = new QPixmap( width(), 9 ); |
181 | QPainter painter( bg ); | 181 | QPainter painter( bg ); |
182 | for ( int i = 0; i < 3; i++ ) { | 182 | for ( int i = 0; i < 3; i++ ) { |
183 | painter.setPen( colorGroup().background().light(130) ); | 183 | painter.setPen( colorGroup().background().light(130) ); |
184 | painter.drawLine( 0, i*3, width()-1, i*3 ); | 184 | painter.drawLine( 0, i*3, width()-1, i*3 ); |
185 | painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); | 185 | painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); |
186 | painter.setPen( colorGroup().background().light(105) ); | 186 | painter.setPen( colorGroup().background().light(105) ); |
187 | painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); | 187 | painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); |
188 | } | 188 | } |
189 | } | 189 | } |
190 | p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), | 190 | p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), |
191 | (r.y() + contentsY()) % bg->height() ) ); | 191 | (r.y() + contentsY()) % bg->height() ) ); |
192 | } else { | 192 | } else { |
193 | p->fillRect( r, QBrush( colorGroup().background().light(110) ) ); | 193 | p->fillRect( r, QBrush( colorGroup().background().light(110) ) ); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | void hideOrShowItems(bool resort); | 197 | void hideOrShowItems(bool resort); |
198 | 198 | ||
199 | void setTypeFilter(const QString& typefilter, bool resort) | 199 | void setTypeFilter(const QString& typefilter, bool resort) |
200 | { | 200 | { |
201 | tf = QRegExp(typefilter,FALSE,TRUE); | 201 | tf = QRegExp(typefilter,FALSE,TRUE); |
202 | hideOrShowItems(resort); | 202 | hideOrShowItems(resort); |
203 | } | 203 | } |
204 | 204 | ||
205 | void setCategoryFilter( int catfilter, bool resort ) | 205 | void setCategoryFilter( int catfilter, bool resort ) |
206 | { | 206 | { |
207 | Categories cat; | 207 | Categories cat; |
208 | cat.load( categoryFileName() ); | 208 | cat.load( categoryFileName() ); |
209 | QString str; | 209 | QString str; |
210 | if ( catfilter == -2 ) | 210 | if ( catfilter == -2 ) |
211 | cf = 0; | 211 | cf = 0; |
212 | else | 212 | else |
213 | cf = catfilter; | 213 | cf = catfilter; |
214 | hideOrShowItems(resort); | 214 | hideOrShowItems(resort); |
215 | } | 215 | } |
216 | 216 | ||
217 | enum SortMethod { Name, Date, Type }; | 217 | enum SortMethod { Name, Date, Type }; |
218 | 218 | ||
219 | void setSortMethod( SortMethod m ) | 219 | void setSortMethod( SortMethod m ) |
220 | { | 220 | { |
221 | if ( sortmeth != m ) { | 221 | if ( sortmeth != m ) { |
222 | sortmeth = m; | 222 | sortmeth = m; |
223 | sort(); | 223 | sort(); |
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | int compare(const AppLnk* a, const AppLnk* b) | 227 | int compare(const AppLnk* a, const AppLnk* b) |
228 | { | 228 | { |
229 | switch (sortmeth) { | 229 | switch (sortmeth) { |
230 | case Name: | 230 | case Name: |
231 | return a->name().compare(b->name()); | 231 | return a->name().compare(b->name()); |
232 | case Date: { | 232 | case Date: { |
233 | QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); | 233 | QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); |
234 | QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); | 234 | QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); |
235 | return fa.lastModified().secsTo(fb.lastModified()); | 235 | return fa.lastModified().secsTo(fb.lastModified()); |
236 | } | 236 | } |
237 | case Type: | 237 | case Type: |
238 | return a->type().compare(b->type()); | 238 | return a->type().compare(b->type()); |
239 | } | 239 | } |
240 | return 0; | 240 | return 0; |
241 | } | 241 | } |
242 | 242 | ||
243 | protected: | 243 | protected: |
244 | 244 | ||
245 | void styleChange( QStyle &old ) | 245 | void styleChange( QStyle &old ) |
246 | { | 246 | { |
247 | QIconView::styleChange( old ); | 247 | QIconView::styleChange( old ); |
248 | //### duplicated code from LauncherView constructor | 248 | //### duplicated code from LauncherView constructor |
249 | int dw = QApplication::desktop()->width(); | 249 | int dw = QApplication::desktop()->width(); |
250 | setGridX( (dw-13-style().scrollBarExtent().width())/3 ); // tweaked for 8pt+dw=176 and 10pt+dw=240 | 250 | setGridX( (dw-13-style().scrollBarExtent().width())/3 ); // tweaked for 8pt+dw=176 and 10pt+dw=240 |
251 | } | 251 | } |
252 | 252 | ||
253 | private: | 253 | private: |
254 | QList<AppLnk> hidden; | 254 | QList<AppLnk> hidden; |
255 | QDict<void> mimes; | 255 | QDict<void> mimes; |
256 | QDict<void> cats; | 256 | QDict<void> cats; |
257 | SortMethod sortmeth; | 257 | SortMethod sortmeth; |
258 | QRegExp tf; | 258 | QRegExp tf; |
259 | int cf; | 259 | int cf; |
260 | QIconViewItem* bsy; | 260 | QIconViewItem* bsy; |
261 | bool ike; | 261 | bool ike; |
262 | 262 | ||
263 | }; | 263 | }; |
264 | 264 | ||
265 | 265 | ||
266 | bool LauncherView::bsy=FALSE; | 266 | bool LauncherView::bsy=FALSE; |
267 | 267 | ||
268 | void LauncherView::setBusy(bool on) | 268 | void LauncherView::setBusy(bool on) |
269 | { | 269 | { |
270 | icons->setBusy(on); | 270 | icons->setBusy(on); |
271 | } | 271 | } |
272 | 272 | ||
273 | class LauncherItem : public QIconViewItem | 273 | class LauncherItem : public QIconViewItem |
274 | { | 274 | { |
275 | public: | 275 | public: |
276 | LauncherItem( QIconView *parent, AppLnk* applnk ); | 276 | LauncherItem( QIconView *parent, AppLnk* applnk ); |
277 | ~LauncherItem() | 277 | ~LauncherItem() |
278 | { | 278 | { |
279 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 279 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
280 | if ( liv->busyItem() == this ) | 280 | if ( liv->busyItem() == this ) |
281 | liv->setBusy(FALSE); | 281 | liv->setBusy(FALSE); |
282 | delete app; | 282 | delete app; |
283 | } | 283 | } |
284 | 284 | ||
285 | AppLnk* appLnk() const { return app; } | 285 | AppLnk* appLnk() const { return app; } |
286 | AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; } | 286 | AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; } |
287 | 287 | ||
288 | virtual int compare ( QIconViewItem * i ) const; | 288 | virtual int compare ( QIconViewItem * i ) const; |
289 | 289 | ||
290 | void paintItem( QPainter *p, const QColorGroup &cg ) | 290 | void paintItem( QPainter *p, const QColorGroup &cg ) |
291 | { | 291 | { |
292 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 292 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
293 | QBrush oldBrush( liv->itemTextBackground() ); | 293 | QBrush oldBrush( liv->itemTextBackground() ); |
294 | QColorGroup mycg( cg ); | 294 | QColorGroup mycg( cg ); |
295 | if ( liv->currentItem() == this ) { | 295 | if ( liv->currentItem() == this ) { |