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