-rw-r--r-- | core/launcher/launcher.cpp | 664 | ||||
-rw-r--r-- | core/launcher/launcherview.cpp | 449 |
2 files changed, 555 insertions, 558 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 0573330..8fe41f7 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -75,57 +75,57 @@ CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : | |||
75 | stack = 0; | 75 | stack = 0; |
76 | } | 76 | } |
77 | 77 | ||
78 | void CategoryTabWidget::prevTab() | 78 | void CategoryTabWidget::prevTab() |
79 | { | 79 | { |
80 | if ( categoryBar ) { | 80 | if ( categoryBar ) { |
81 | int n = categoryBar->count(); | 81 | int n = categoryBar->count(); |
82 | int tab = categoryBar->currentTab(); | 82 | int tab = categoryBar->currentTab(); |
83 | if ( tab >= 0 ) | 83 | if ( tab >= 0 ) |
84 | categoryBar->setCurrentTab( (tab - 1 + n)%n ); | 84 | categoryBar->setCurrentTab( (tab - 1 + n)%n ); |
85 | } | 85 | } |
86 | } | 86 | } |
87 | 87 | ||
88 | void CategoryTabWidget::nextTab() | 88 | void CategoryTabWidget::nextTab() |
89 | { | 89 | { |
90 | if ( categoryBar ) { | 90 | if ( categoryBar ) { |
91 | int n = categoryBar->count(); | 91 | int n = categoryBar->count(); |
92 | int tab = categoryBar->currentTab(); | 92 | int tab = categoryBar->currentTab(); |
93 | categoryBar->setCurrentTab( (tab + 1)%n ); | 93 | categoryBar->setCurrentTab( (tab + 1)%n ); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | void CategoryTabWidget::addItem( const QString& linkfile ) | 97 | void CategoryTabWidget::addItem( const QString& linkfile ) |
98 | { | 98 | { |
99 | int i=0; | 99 | int i=0; |
100 | AppLnk *app = new AppLnk(linkfile); | 100 | AppLnk *app = new AppLnk(linkfile); |
101 | if ( !app->isValid() ) { | 101 | if ( !app->isValid() ) { |
102 | delete app; | 102 | delete app; |
103 | return; | 103 | return; |
104 | } | 104 | } |
105 | if ( !app->file().isEmpty() ) { | 105 | if ( !app->file().isEmpty() ) { |
106 | // A document | 106 | // A document |
107 | delete app; | 107 | delete app; |
108 | app = new DocLnk(linkfile); | 108 | app = new DocLnk(linkfile); |
109 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); | 109 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); |
110 | return; | 110 | return; |
111 | } | 111 | } |
112 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { | 112 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { |
113 | if ( !(*it).isEmpty() ) { | 113 | if ( !(*it).isEmpty() ) { |
114 | QRegExp tf(*it,FALSE,TRUE); | 114 | QRegExp tf(*it,FALSE,TRUE); |
115 | if ( tf.match(app->type()) >= 0 ) { | 115 | if ( tf.match(app->type()) >= 0 ) { |
116 | ((LauncherView*)stack->widget(i))->addItem(app); | 116 | ((LauncherView*)stack->widget(i))->addItem(app); |
117 | return; | 117 | return; |
118 | } | 118 | } |
119 | i++; | 119 | i++; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, | 124 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, |
125 | AppLnkSet* docFolder, const QList<FileSystem> &fs) | 125 | AppLnkSet* docFolder, const QList<FileSystem> &fs) |
126 | { | 126 | { |
127 | delete categoryBar; | 127 | delete categoryBar; |
128 | categoryBar = new CategoryTabBar( this ); | 128 | categoryBar = new CategoryTabBar( this ); |
129 | QPalette pal = categoryBar->palette(); | 129 | QPalette pal = categoryBar->palette(); |
130 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 130 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
131 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 131 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
@@ -136,35 +136,35 @@ void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, | |||
136 | tabs=0; | 136 | tabs=0; |
137 | 137 | ||
138 | ids.clear(); | 138 | ids.clear(); |
139 | 139 | ||
140 | QStringList types = rootFolder->types(); | 140 | QStringList types = rootFolder->types(); |
141 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 141 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
142 | if ( !(*it).isEmpty() ) { | 142 | if ( !(*it).isEmpty() ) { |
143 | newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); | 143 | newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); |
144 | } | 144 | } |
145 | } | 145 | } |
146 | QListIterator<AppLnk> it( rootFolder->children() ); | 146 | QListIterator<AppLnk> it( rootFolder->children() ); |
147 | AppLnk* l; | 147 | AppLnk* l; |
148 | while ( (l=it.current()) ) { | 148 | while ( (l=it.current()) ) { |
149 | if ( l->type() == "Separator" ) { | 149 | if ( l->type() == "Separator" ) { |
150 | rootFolder->remove(l); | 150 | rootFolder->remove(l); |
151 | delete l; | 151 | delete l; |
152 | } else { | 152 | } else { |
153 | int i=0; | 153 | int i=0; |
154 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 154 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
155 | if ( *it == l->type() ) | 155 | if ( *it == l->type() ) |
156 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); | 156 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); |
157 | i++; | 157 | i++; |
158 | } | 158 | } |
159 | } | 159 | } |
160 | ++it; | 160 | ++it; |
161 | } | 161 | } |
162 | rootFolder->detachChildren(); | 162 | rootFolder->detachChildren(); |
163 | for (int i=0; i<tabs; i++) | 163 | for (int i=0; i<tabs; i++) |
164 | ((LauncherView*)stack->widget(i))->sort(); | 164 | ((LauncherView*)stack->widget(i))->sort(); |
165 | 165 | ||
166 | // all documents | 166 | // all documents |
167 | docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents")); | 167 | docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents")); |
168 | docview->populate( docFolder, QString::null ); | 168 | docview->populate( docFolder, QString::null ); |
169 | docFolder->detachChildren(); | 169 | docFolder->detachChildren(); |
170 | docview->setFileSystems(fs); | 170 | docview->setFileSystems(fs); |
@@ -187,28 +187,28 @@ void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> | |||
187 | } | 187 | } |
188 | 188 | ||
189 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) | 189 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) |
190 | { | 190 | { |
191 | LauncherView* view = new LauncherView( stack ); | 191 | LauncherView* view = new LauncherView( stack ); |
192 | connect( view, SIGNAL(clicked(const AppLnk*)), | 192 | connect( view, SIGNAL(clicked(const AppLnk*)), |
193 | this, SIGNAL(clicked(const AppLnk*))); | 193 | this, SIGNAL(clicked(const AppLnk*))); |
194 | connect( view, SIGNAL(rightPressed(AppLnk*)), | 194 | connect( view, SIGNAL(rightPressed(AppLnk*)), |
195 | this, SIGNAL(rightPressed(AppLnk*))); | 195 | this, SIGNAL(rightPressed(AppLnk*))); |
196 | ids.append(id); | 196 | ids.append(id); |
197 | categoryBar->addTab( new QTab( pm, label ) ); | 197 | categoryBar->addTab( new QTab( pm, label ) ); |
198 | stack->addWidget( view, tabs++ ); | 198 | stack->addWidget( view, tabs++ ); |
199 | return view; | 199 | return view; |
200 | } | 200 | } |
201 | 201 | ||
202 | void CategoryTabWidget::updateLink(const QString& linkfile) | 202 | void CategoryTabWidget::updateLink(const QString& linkfile) |
203 | { | 203 | { |
204 | int i=0; | 204 | int i=0; |
205 | LauncherView* view; | 205 | LauncherView* view; |
206 | while ((view = (LauncherView*)stack->widget(i++))) { | 206 | while ((view = (LauncherView*)stack->widget(i++))) { |
207 | if ( view->removeLink(linkfile) ) | 207 | if ( view->removeLink(linkfile) ) |
208 | break; | 208 | break; |
209 | } | 209 | } |
210 | addItem(linkfile); | 210 | addItem(linkfile); |
211 | docview->updateTools(); | 211 | docview->updateTools(); |
212 | } | 212 | } |
213 | 213 | ||
214 | void CategoryTabWidget::paletteChange( const QPalette &p ) | 214 | void CategoryTabWidget::paletteChange( const QPalette &p ) |
@@ -221,16 +221,16 @@ void CategoryTabWidget::paletteChange( const QPalette &p ) | |||
221 | categoryBar->update(); | 221 | categoryBar->update(); |
222 | } | 222 | } |
223 | 223 | ||
224 | void CategoryTabWidget::setBusy(bool on) | 224 | void CategoryTabWidget::setBusy(bool on) |
225 | { | 225 | { |
226 | if ( on ) | 226 | if ( on ) |
227 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); | 227 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); |
228 | else | 228 | else |
229 | for (int i=0; i<tabs; i++) | 229 | for (int i=0; i<tabs; i++) |
230 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); | 230 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); |
231 | } | 231 | } |
232 | 232 | ||
233 | 233 | ||
234 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) | 234 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) |
235 | : QTabBar( parent, name ) | 235 | : QTabBar( parent, name ) |
236 | { | 236 | { |
@@ -242,13 +242,13 @@ CategoryTabBar::~CategoryTabBar() | |||
242 | { | 242 | { |
243 | } | 243 | } |
244 | 244 | ||
245 | void CategoryTabBar::layoutTabs() | 245 | void CategoryTabBar::layoutTabs() |
246 | { | 246 | { |
247 | if ( !count() ) | 247 | if ( !count() ) |
248 | return; | 248 | return; |
249 | 249 | ||
250 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; | 250 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; |
251 | int hiddenTabWidth = -12; | 251 | int hiddenTabWidth = -12; |
252 | int middleTab = currentTab(); | 252 | int middleTab = currentTab(); |
253 | int hframe, vframe, overlap; | 253 | int hframe, vframe, overlap; |
254 | style().tabbarMetrics( this, hframe, vframe, overlap ); | 254 | style().tabbarMetrics( this, hframe, vframe, overlap ); |
@@ -256,62 +256,62 @@ void CategoryTabBar::layoutTabs() | |||
256 | int x = 0; | 256 | int x = 0; |
257 | QRect r; | 257 | QRect r; |
258 | QTab *t; | 258 | QTab *t; |
259 | int available = width()-1; | 259 | int available = width()-1; |
260 | int required = 0; | 260 | int required = 0; |
261 | for ( int i = 0; i < count(); i++ ) { | 261 | for ( int i = 0; i < count(); i++ ) { |
262 | t = tab(i); | 262 | t = tab(i); |
263 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { | 263 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { |
264 | if ( i != middleTab ) { | 264 | if ( i != middleTab ) { |
265 | // required += hiddenTabWidth + hframe - overlap; | 265 | // required += hiddenTabWidth + hframe - overlap; |
266 | available -= hiddenTabWidth + hframe - overlap; | 266 | available -= hiddenTabWidth + hframe - overlap; |
267 | if ( t->iconSet() != 0 ) | 267 | if ( t->iconSet() != 0 ) |
268 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 268 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
269 | } else { | 269 | } else { |
270 | required += fm.width( t->text() ) + hframe - overlap; | 270 | required += fm.width( t->text() ) + hframe - overlap; |
271 | if ( t->iconSet() != 0 ) | 271 | if ( t->iconSet() != 0 ) |
272 | required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 272 | required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
273 | } | 273 | } |
274 | } | 274 | } |
275 | for ( int i = 0; i < count(); i++ ) { | 275 | for ( int i = 0; i < count(); i++ ) { |
276 | t = tab(i); | 276 | t = tab(i); |
277 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { | 277 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { |
278 | if ( i != middleTab ) { | 278 | if ( i != middleTab ) { |
279 | int w = hiddenTabWidth; | 279 | int w = hiddenTabWidth; |
280 | int ih = 0; | 280 | int ih = 0; |
281 | if ( t->iconSet() != 0 ) { | 281 | if ( t->iconSet() != 0 ) { |
282 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 282 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
283 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 283 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
284 | } | 284 | } |
285 | int h = QMAX( fm.height(), ih ); | 285 | int h = QMAX( fm.height(), ih ); |
286 | h = QMAX( h, QApplication::globalStrut().height() ); | 286 | h = QMAX( h, QApplication::globalStrut().height() ); |
287 | 287 | ||
288 | h += vframe; | 288 | h += vframe; |
289 | w += hframe; | 289 | w += hframe; |
290 | 290 | ||
291 | t->setRect( QRect(x, 0, w, h) ); | 291 | t->setRect( QRect(x, 0, w, h) ); |
292 | x += t->rect().width() - overlap; | 292 | x += t->rect().width() - overlap; |
293 | r = r.unite( t->rect() ); | 293 | r = r.unite( t->rect() ); |
294 | } else { | 294 | } else { |
295 | int w = fm.width( t->text() ); | 295 | int w = fm.width( t->text() ); |
296 | int ih = 0; | 296 | int ih = 0; |
297 | if ( t->iconSet() != 0 ) { | 297 | if ( t->iconSet() != 0 ) { |
298 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 298 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
299 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 299 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
300 | } | 300 | } |
301 | int h = QMAX( fm.height(), ih ); | 301 | int h = QMAX( fm.height(), ih ); |
302 | h = QMAX( h, QApplication::globalStrut().height() ); | 302 | h = QMAX( h, QApplication::globalStrut().height() ); |
303 | 303 | ||
304 | h += vframe; | 304 | h += vframe; |
305 | w += hframe; | 305 | w += hframe; |
306 | 306 | ||
307 | // t->setRect( QRect(x, 0, w * available/required, h) ); | 307 | // t->setRect( QRect(x, 0, w * available/required, h) ); |
308 | t->setRect( QRect(x, 0, available, h) ); | 308 | t->setRect( QRect(x, 0, available, h) ); |
309 | x += t->rect().width() - overlap; | 309 | x += t->rect().width() - overlap; |
310 | r = r.unite( t->rect() ); | 310 | r = r.unite( t->rect() ); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | 313 | ||
314 | QRect rr = tab(count()-1)->rect(); | 314 | QRect rr = tab(count()-1)->rect(); |
315 | rr.setRight(width()-1); | 315 | rr.setRight(width()-1); |
316 | tab(count()-1)->setRect( rr ); | 316 | tab(count()-1)->setRect( rr ); |
317 | 317 | ||
@@ -337,71 +337,71 @@ void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const | |||
337 | style().drawTab( p, this, t, selected ); | 337 | style().drawTab( p, this, t, selected ); |
338 | #endif | 338 | #endif |
339 | 339 | ||
340 | QRect r( t->rect() ); | 340 | QRect r( t->rect() ); |
341 | QFont f( font() ); | 341 | QFont f( font() ); |
342 | if ( selected ) | 342 | if ( selected ) |
343 | f.setBold( TRUE ); | 343 | f.setBold( TRUE ); |
344 | p->setFont( f ); | 344 | p->setFont( f ); |
345 | 345 | ||
346 | int iw = 0; | 346 | int iw = 0; |
347 | int ih = 0; | 347 | int ih = 0; |
348 | if ( t->iconSet() != 0 ) { | 348 | if ( t->iconSet() != 0 ) { |
349 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; | 349 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; |
350 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 350 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
351 | } | 351 | } |
352 | int w = iw + p->fontMetrics().width( t->text() ) + 4; | 352 | int w = iw + p->fontMetrics().width( t->text() ) + 4; |
353 | int h = QMAX(p->fontMetrics().height() + 4, ih ); | 353 | int h = QMAX(p->fontMetrics().height() + 4, ih ); |
354 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, | 354 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, |
355 | r.top() + (r.height()-h)/2, w, h ), t, | 355 | r.top() + (r.height()-h)/2, w, h ), t, |
356 | #if QT_VERSION >= 300 | 356 | #if QT_VERSION >= 300 |
357 | t->identifier() == keyboardFocusTab() | 357 | t->identifier() == keyboardFocusTab() |
358 | #else | 358 | #else |
359 | t->identitifer() == keyboardFocusTab() | 359 | t->identitifer() == keyboardFocusTab() |
360 | #endif | 360 | #endif |
361 | ); | 361 | ); |
362 | } | 362 | } |
363 | 363 | ||
364 | 364 | ||
365 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, | 365 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, |
366 | QTab* t, bool has_focus ) const | 366 | QTab* t, bool has_focus ) const |
367 | { | 367 | { |
368 | QRect r = t->rect(); | 368 | QRect r = t->rect(); |
369 | // if ( t->id != currentTab() ) | 369 | // if ( t->id != currentTab() ) |
370 | //r.moveBy( 1, 1 ); | 370 | //r.moveBy( 1, 1 ); |
371 | // | 371 | // |
372 | if ( t->iconSet() ) { | 372 | if ( t->iconSet() ) { |
373 | // the tab has an iconset, draw it in the right mode | 373 | // the tab has an iconset, draw it in the right mode |
374 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; | 374 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; |
375 | if ( mode == QIconSet::Normal && has_focus ) | 375 | if ( mode == QIconSet::Normal && has_focus ) |
376 | mode = QIconSet::Active; | 376 | mode = QIconSet::Active; |
377 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); | 377 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); |
378 | int pixw = pixmap.width(); | 378 | int pixw = pixmap.width(); |
379 | int pixh = pixmap.height(); | 379 | int pixh = pixmap.height(); |
380 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); | 380 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); |
381 | r.setLeft( r.left() + pixw + 5 ); | 381 | r.setLeft( r.left() + pixw + 5 ); |
382 | } | 382 | } |
383 | 383 | ||
384 | QRect tr = r; | 384 | QRect tr = r; |
385 | 385 | ||
386 | if ( r.width() < 20 ) | 386 | if ( r.width() < 20 ) |
387 | return; | 387 | return; |
388 | 388 | ||
389 | if ( t->isEnabled() && isEnabled() ) { | 389 | if ( t->isEnabled() && isEnabled() ) { |
390 | #if defined(_WS_WIN32_) | 390 | #if defined(_WS_WIN32_) |
391 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) | 391 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) |
392 | p->setPen( colorGroup().buttonText() ); | 392 | p->setPen( colorGroup().buttonText() ); |
393 | else | 393 | else |
394 | p->setPen( colorGroup().foreground() ); | 394 | p->setPen( colorGroup().foreground() ); |
395 | #else | 395 | #else |
396 | p->setPen( colorGroup().foreground() ); | 396 | p->setPen( colorGroup().foreground() ); |
397 | #endif | 397 | #endif |
398 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 398 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
399 | } else { | 399 | } else { |
400 | p->setPen( palette().disabled().foreground() ); | 400 | p->setPen( palette().disabled().foreground() ); |
401 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 401 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
402 | } | 402 | } |
403 | } | 403 | } |
404 | 404 | ||
405 | //--------------------------------------------------------------------------- | 405 | //--------------------------------------------------------------------------- |
406 | 406 | ||
407 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) | 407 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) |
@@ -420,17 +420,17 @@ Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) | |||
420 | 420 | ||
421 | tabs = new CategoryTabWidget( this ); | 421 | tabs = new CategoryTabWidget( this ); |
422 | tabs->setMaximumWidth( qApp->desktop()->width() ); | 422 | tabs->setMaximumWidth( qApp->desktop()->width() ); |
423 | setCentralWidget( tabs ); | 423 | setCentralWidget( tabs ); |
424 | 424 | ||
425 | connect( tabs, SIGNAL(selected(const QString&)), | 425 | connect( tabs, SIGNAL(selected(const QString&)), |
426 | this, SLOT(viewSelected(const QString&)) ); | 426 | this, SLOT(viewSelected(const QString&)) ); |
427 | connect( tabs, SIGNAL(clicked(const AppLnk*)), | 427 | connect( tabs, SIGNAL(clicked(const AppLnk*)), |
428 | this, SLOT(select(const AppLnk*))); | 428 | this, SLOT(select(const AppLnk*))); |
429 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), | 429 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), |
430 | this, SLOT(properties(AppLnk*))); | 430 | this, SLOT(properties(AppLnk*))); |
431 | 431 | ||
432 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 432 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
433 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 433 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
434 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 434 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
435 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); | 435 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); |
436 | #endif | 436 | #endif |
@@ -452,24 +452,24 @@ Launcher::~Launcher() | |||
452 | 452 | ||
453 | static bool isVisibleWindow(int wid) | 453 | static bool isVisibleWindow(int wid) |
454 | { | 454 | { |
455 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 455 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
456 | QWSWindow* w; | 456 | QWSWindow* w; |
457 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 457 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
458 | if ( w->winId() == wid ) | 458 | if ( w->winId() == wid ) |
459 | return !w->isFullyObscured(); | 459 | return !w->isFullyObscured(); |
460 | } | 460 | } |
461 | return FALSE; | 461 | return FALSE; |
462 | } | 462 | } |
463 | 463 | ||
464 | void Launcher::showMaximized() | 464 | void Launcher::showMaximized() |
465 | { | 465 | { |
466 | if ( isVisibleWindow( winId() ) ) | 466 | if ( isVisibleWindow( winId() ) ) |
467 | doMaximize(); | 467 | doMaximize(); |
468 | else | 468 | else |
469 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); | 469 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); |
470 | } | 470 | } |
471 | 471 | ||
472 | void Launcher::doMaximize() | 472 | void Launcher::doMaximize() |
473 | { | 473 | { |
474 | QMainWindow::showMaximized(); | 474 | QMainWindow::showMaximized(); |
475 | } | 475 | } |
@@ -480,18 +480,18 @@ void Launcher::updateMimeTypes() | |||
480 | updateMimeTypes(rootFolder); | 480 | updateMimeTypes(rootFolder); |
481 | } | 481 | } |
482 | 482 | ||
483 | void Launcher::updateMimeTypes(AppLnkSet* folder) | 483 | void Launcher::updateMimeTypes(AppLnkSet* folder) |
484 | { | 484 | { |
485 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { | 485 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { |
486 | AppLnk *app = it.current(); | 486 | AppLnk *app = it.current(); |
487 | if ( app->type() == "Folder" ) | 487 | if ( app->type() == "Folder" ) |
488 | updateMimeTypes((AppLnkSet *)app); | 488 | updateMimeTypes((AppLnkSet *)app); |
489 | else { | 489 | else { |
490 | MimeType::registerApp(*app); | 490 | MimeType::registerApp(*app); |
491 | } | 491 | } |
492 | } | 492 | } |
493 | } | 493 | } |
494 | 494 | ||
495 | void Launcher::loadDocs() | 495 | void Launcher::loadDocs() |
496 | { | 496 | { |
497 | delete docsFolder; | 497 | delete docsFolder; |
@@ -528,313 +528,313 @@ void Launcher::nextView() | |||
528 | } | 528 | } |
529 | 529 | ||
530 | 530 | ||
531 | void Launcher::select( const AppLnk *appLnk ) | 531 | void Launcher::select( const AppLnk *appLnk ) |
532 | { | 532 | { |
533 | if ( appLnk->type() == "Folder" ) { | 533 | if ( appLnk->type() == "Folder" ) { |
534 | // Not supported: flat is simpler for the user | 534 | // Not supported: flat is simpler for the user |
535 | } else { | 535 | } else { |
536 | if ( appLnk->exec().isNull() ) { | 536 | if ( appLnk->exec().isNull() ) { |
537 | QMessageBox::information(this,tr("No application"), | 537 | QMessageBox::information(this,tr("No application"), |
538 | tr("<p>No application is defined for this document." | 538 | tr("<p>No application is defined for this document." |
539 | "<p>Type is %1.").arg(appLnk->type())); | 539 | "<p>Type is %1.").arg(appLnk->type())); |
540 | return; | 540 | return; |
541 | } | 541 | } |
542 | tabs->setBusy(TRUE); | 542 | tabs->setBusy(TRUE); |
543 | emit executing( appLnk ); | 543 | emit executing( appLnk ); |
544 | appLnk->execute(); | 544 | appLnk->execute(); |
545 | } | 545 | } |
546 | } | 546 | } |
547 | 547 | ||
548 | void Launcher::externalSelected(const AppLnk *appLnk) | 548 | void Launcher::externalSelected(const AppLnk *appLnk) |
549 | { | 549 | { |
550 | tabs->setBusy(TRUE); | 550 | tabs->setBusy(TRUE); |
551 | emit executing( appLnk ); | 551 | emit executing( appLnk ); |
552 | } | 552 | } |
553 | 553 | ||
554 | void Launcher::properties( AppLnk *appLnk ) | 554 | void Launcher::properties( AppLnk *appLnk ) |
555 | { | 555 | { |
556 | if ( appLnk->type() == "Folder" ) { | 556 | if ( appLnk->type() == "Folder" ) { |
557 | // Not supported: flat is simpler for the user | 557 | // Not supported: flat is simpler for the user |
558 | } else { | 558 | } else { |
559 | in_lnk_props = TRUE; | 559 | in_lnk_props = TRUE; |
560 | got_lnk_change = FALSE; | 560 | got_lnk_change = FALSE; |
561 | LnkProperties prop(appLnk); | 561 | LnkProperties prop(appLnk); |
562 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 562 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
563 | prop.showMaximized(); | 563 | prop.showMaximized(); |
564 | prop.exec(); | 564 | prop.exec(); |
565 | in_lnk_props = FALSE; | 565 | in_lnk_props = FALSE; |
566 | if ( got_lnk_change ) { | 566 | if ( got_lnk_change ) { |
567 | updateLink(lnk_change); | 567 | updateLink(lnk_change); |
568 | } | 568 | } |
569 | } | 569 | } |
570 | } | 570 | } |
571 | 571 | ||
572 | void Launcher::updateLink(const QString& link) | 572 | void Launcher::updateLink(const QString& link) |
573 | { | 573 | { |
574 | if (link.isNull()) | 574 | if (link.isNull()) |
575 | updateTabs(); | 575 | updateTabs(); |
576 | else if (link.isEmpty()) | 576 | else if (link.isEmpty()) |
577 | updateDocs(); | 577 | updateDocs(); |
578 | else | 578 | else |
579 | tabs->updateLink(link); | 579 | tabs->updateLink(link); |
580 | } | 580 | } |
581 | 581 | ||
582 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | 582 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) |
583 | { | 583 | { |
584 | QDataStream stream( data, IO_ReadOnly ); | 584 | QDataStream stream( data, IO_ReadOnly ); |
585 | if ( msg == "linkChanged(QString)" ) { | 585 | if ( msg == "linkChanged(QString)" ) { |
586 | QString link; | 586 | QString link; |
587 | stream >> link; | 587 | stream >> link; |
588 | if ( in_lnk_props ) { | 588 | if ( in_lnk_props ) { |
589 | got_lnk_change = TRUE; | 589 | got_lnk_change = TRUE; |
590 | lnk_change = link; | 590 | lnk_change = link; |
591 | } else { | 591 | } else { |
592 | updateLink(link); | 592 | updateLink(link); |
593 | } | 593 | } |
594 | } else if ( msg == "busy()" ) { | 594 | } else if ( msg == "busy()" ) { |
595 | emit busy(); | 595 | emit busy(); |
596 | } else if ( msg == "notBusy(QString)" ) { | 596 | } else if ( msg == "notBusy(QString)" ) { |
597 | QString app; | 597 | QString app; |
598 | stream >> app; | 598 | stream >> app; |
599 | tabs->setBusy(FALSE); | 599 | tabs->setBusy(FALSE); |
600 | emit notBusy(app); | 600 | emit notBusy(app); |
601 | } else if ( msg == "mkdir(QString)" ) { | 601 | } else if ( msg == "mkdir(QString)" ) { |
602 | QString dir; | 602 | QString dir; |
603 | stream >> dir; | 603 | stream >> dir; |
604 | if ( !dir.isEmpty() ) | 604 | if ( !dir.isEmpty() ) |
605 | mkdir( dir ); | 605 | mkdir( dir ); |
606 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { | 606 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
607 | QString baseFile, sigFile; | 607 | QString baseFile, sigFile; |
608 | stream >> baseFile >> sigFile; | 608 | stream >> baseFile >> sigFile; |
609 | QRsync::generateSignature( baseFile, sigFile ); | 609 | QRsync::generateSignature( baseFile, sigFile ); |
610 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | 610 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
611 | QString baseFile, sigFile, deltaFile; | 611 | QString baseFile, sigFile, deltaFile; |
612 | stream >> baseFile >> sigFile >> deltaFile; | 612 | stream >> baseFile >> sigFile >> deltaFile; |
613 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 613 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
614 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { | 614 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
615 | QString baseFile, deltaFile; | 615 | QString baseFile, deltaFile; |
616 | stream >> baseFile >> deltaFile; | 616 | stream >> baseFile >> deltaFile; |
617 | if ( !QFile::exists( baseFile ) ) { | 617 | if ( !QFile::exists( baseFile ) ) { |
618 | QFile f( baseFile ); | 618 | QFile f( baseFile ); |
619 | f.open( IO_WriteOnly ); | 619 | f.open( IO_WriteOnly ); |
620 | f.close(); | 620 | f.close(); |
621 | } | 621 | } |
622 | QRsync::applyDiff( baseFile, deltaFile ); | 622 | QRsync::applyDiff( baseFile, deltaFile ); |
623 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 623 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
624 | e << baseFile; | 624 | e << baseFile; |
625 | } else if ( msg == "rdiffCleanup()" ) { | 625 | } else if ( msg == "rdiffCleanup()" ) { |
626 | mkdir( "/tmp/rdiff" ); | 626 | mkdir( "/tmp/rdiff" ); |
627 | QDir dir; | 627 | QDir dir; |
628 | dir.setPath( "/tmp/rdiff" ); | 628 | dir.setPath( "/tmp/rdiff" ); |
629 | QStringList entries = dir.entryList(); | 629 | QStringList entries = dir.entryList(); |
630 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 630 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
631 | dir.remove( *it ); | 631 | dir.remove( *it ); |
632 | } else if ( msg == "sendHandshakeInfo()" ) { | 632 | } else if ( msg == "sendHandshakeInfo()" ) { |
633 | QString home = getenv( "HOME" ); | 633 | QString home = getenv( "HOME" ); |
634 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 634 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
635 | e << home; | 635 | e << home; |
636 | int locked = (int) Desktop::screenLocked(); | 636 | int locked = (int) Desktop::screenLocked(); |
637 | e << locked; | 637 | e << locked; |
638 | // register an app for autostart | 638 | // register an app for autostart |
639 | // if clear is send the list is cleared. | 639 | // if clear is send the list is cleared. |
640 | } else if ( msg == "autoStart(QString)" ) { | 640 | } else if ( msg == "autoStart(QString)" ) { |
641 | QString appName; | 641 | QString appName; |
642 | stream >> appName; | 642 | stream >> appName; |
643 | Config cfg( "autostart" ); | 643 | Config cfg( "autostart" ); |
644 | cfg.setGroup( "AutoStart" ); | 644 | cfg.setGroup( "AutoStart" ); |
645 | if ( appName.compare("clear") == 0){ | 645 | if ( appName.compare("clear") == 0){ |
646 | cfg.writeEntry("Apps", ""); | 646 | cfg.writeEntry("Apps", ""); |
647 | } | 647 | } |
648 | } else if ( msg == "autoStart(QString,QString)" ) { | 648 | } else if ( msg == "autoStart(QString,QString)" ) { |
649 | QString modifier, appName; | 649 | QString modifier, appName; |
650 | stream >> modifier >> appName; | 650 | stream >> modifier >> appName; |
651 | Config cfg( "autostart" ); | 651 | Config cfg( "autostart" ); |
652 | cfg.setGroup( "AutoStart" ); | 652 | cfg.setGroup( "AutoStart" ); |
653 | if ( modifier.compare("add") == 0 ){ | 653 | if ( modifier.compare("add") == 0 ){ |
654 | // only add it appname is entered | 654 | // only add it appname is entered |
655 | if (!appName.isEmpty()) { | 655 | if (!appName.isEmpty()) { |
656 | cfg.writeEntry("Apps", appName); | 656 | cfg.writeEntry("Apps", appName); |
657 | } | 657 | } |
658 | } else if (modifier.compare("remove") == 0 ) { | 658 | } else if (modifier.compare("remove") == 0 ) { |
659 | // need to change for multiple entries | 659 | // need to change for multiple entries |
660 | // actually remove is right now simular to clear, but in future there | 660 | // actually remove is right now simular to clear, but in future there |
661 | // should be multiple apps in autostart possible. | 661 | // should be multiple apps in autostart possible. |
662 | QString checkName; | 662 | QString checkName; |
663 | checkName = cfg.readEntry("Apps", ""); | 663 | checkName = cfg.readEntry("Apps", ""); |
664 | if (checkName == appName) { | 664 | if (checkName == appName) { |
665 | cfg.writeEntry("Apps", ""); | 665 | cfg.writeEntry("Apps", ""); |
666 | } | 666 | } |
667 | } | 667 | } |
668 | } else if ( msg == "sendCardInfo()" ) { | 668 | } else if ( msg == "sendCardInfo()" ) { |
669 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 669 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
670 | const QList<FileSystem> &fs = storage->fileSystems(); | 670 | const QList<FileSystem> &fs = storage->fileSystems(); |
671 | QListIterator<FileSystem> it ( fs ); | 671 | QListIterator<FileSystem> it ( fs ); |
672 | QString s; | 672 | QString s; |
673 | QString homeDir = getenv("HOME"); | 673 | QString homeDir = getenv("HOME"); |
674 | QString hardDiskHome; | 674 | QString hardDiskHome; |
675 | for ( ; it.current(); ++it ) { | 675 | for ( ; it.current(); ++it ) { |
676 | if ( (*it)->isRemovable() ) | 676 | if ( (*it)->isRemovable() ) |
677 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " | 677 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " |
678 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 678 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
679 | + " " + (*it)->options() + ";"; | 679 | + " " + (*it)->options() + ";"; |
680 | else if ( (*it)->disk() == "/dev/mtdblock1" || | 680 | else if ( (*it)->disk() == "/dev/mtdblock1" || |
681 | (*it)->disk() == "/dev/mtdblock/1" ) | 681 | (*it)->disk() == "/dev/mtdblock/1" ) |
682 | s += (*it)->name() + "=" + homeDir + "/Documents " | 682 | s += (*it)->name() + "=" + homeDir + "/Documents " |
683 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 683 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
684 | + " " + (*it)->options() + ";"; | 684 | + " " + (*it)->options() + ";"; |
685 | else if ( (*it)->name().contains( "Hard Disk") && | 685 | else if ( (*it)->name().contains( "Hard Disk") && |
686 | homeDir.contains( (*it)->path() ) && | 686 | homeDir.contains( (*it)->path() ) && |
687 | (*it)->path().length() > hardDiskHome.length() ) | 687 | (*it)->path().length() > hardDiskHome.length() ) |
688 | hardDiskHome = | 688 | hardDiskHome = |
689 | (*it)->name() + "=" + homeDir + "/Documents " | 689 | (*it)->name() + "=" + homeDir + "/Documents " |
690 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 690 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
691 | + " " + (*it)->options() + ";"; | 691 | + " " + (*it)->options() + ";"; |
692 | } | 692 | } |
693 | if ( !hardDiskHome.isEmpty() ) | 693 | if ( !hardDiskHome.isEmpty() ) |
694 | s += hardDiskHome; | 694 | s += hardDiskHome; |
695 | 695 | ||
696 | e << s; | 696 | e << s; |
697 | } else if ( msg == "sendSyncDate(QString)" ) { | 697 | } else if ( msg == "sendSyncDate(QString)" ) { |
698 | QString app; | 698 | QString app; |
699 | stream >> app; | 699 | stream >> app; |
700 | Config cfg( "qpe" ); | 700 | Config cfg( "qpe" ); |
701 | cfg.setGroup("SyncDate"); | 701 | cfg.setGroup("SyncDate"); |
702 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); | 702 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); |
703 | e << app << cfg.readEntry( app ); | 703 | e << app << cfg.readEntry( app ); |
704 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), | 704 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), |
705 | //cfg.readEntry( app ).latin1() ); | 705 | //cfg.readEntry( app ).latin1() ); |
706 | } else if ( msg == "setSyncDate(QString,QString)" ) { | 706 | } else if ( msg == "setSyncDate(QString,QString)" ) { |
707 | QString app, date; | 707 | QString app, date; |
708 | stream >> app >> date; | 708 | stream >> app >> date; |
709 | Config cfg( "qpe" ); | 709 | Config cfg( "qpe" ); |
710 | cfg.setGroup("SyncDate"); | 710 | cfg.setGroup("SyncDate"); |
711 | cfg.writeEntry( app, date ); | 711 | cfg.writeEntry( app, date ); |
712 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); | 712 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); |
713 | } else if ( msg == "startSync(QString)" ) { | 713 | } else if ( msg == "startSync(QString)" ) { |
714 | QString what; | 714 | QString what; |
715 | stream >> what; | 715 | stream >> what; |
716 | delete syncDialog; syncDialog = 0; | 716 | delete syncDialog; syncDialog = 0; |
717 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, | 717 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, |
718 | WStyle_Tool | WStyle_Customize | | 718 | WStyle_Tool | WStyle_Customize | |
719 | Qt::WStyle_StaysOnTop ); | 719 | Qt::WStyle_StaysOnTop ); |
720 | syncDialog->showMaximized(); | 720 | syncDialog->showMaximized(); |
721 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); | 721 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); |
722 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), | 722 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), |
723 | SLOT( cancelSync() ) ); | 723 | SLOT( cancelSync() ) ); |
724 | } | 724 | } |
725 | else if ( msg == "stopSync()") { | 725 | else if ( msg == "stopSync()") { |
726 | delete syncDialog; syncDialog = 0; | 726 | delete syncDialog; syncDialog = 0; |
727 | } else if ( msg == "getAllDocLinks()" ) { | 727 | } else if ( msg == "getAllDocLinks()" ) { |
728 | loadDocs(); | 728 | loadDocs(); |
729 | 729 | ||
730 | QString contents; | 730 | QString contents; |
731 | 731 | ||
732 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { | 732 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { |
733 | DocLnk *doc = it.current(); | 733 | DocLnk *doc = it.current(); |
734 | QFileInfo fi( doc->file() ); | 734 | QFileInfo fi( doc->file() ); |
735 | if ( !fi.exists() ) | 735 | if ( !fi.exists() ) |
736 | continue; | 736 | continue; |
737 | 737 | ||
738 | bool fake = !doc->linkFileKnown(); | 738 | bool fake = !doc->linkFileKnown(); |
739 | if ( !fake ) { | 739 | if ( !fake ) { |
740 | QFile f( doc->linkFile() ); | 740 | QFile f( doc->linkFile() ); |
741 | if ( f.open( IO_ReadOnly ) ) { | 741 | if ( f.open( IO_ReadOnly ) ) { |
742 | QTextStream ts( &f ); | 742 | QTextStream ts( &f ); |
743 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 743 | ts.setEncoding( QTextStream::UnicodeUTF8 ); |
744 | contents += ts.read(); | 744 | contents += ts.read(); |
745 | f.close(); | 745 | f.close(); |
746 | } else | 746 | } else |
747 | fake = TRUE; | 747 | fake = TRUE; |
748 | } | 748 | } |
749 | if (fake) { | 749 | if (fake) { |
750 | contents += "[Desktop Entry]\n"; | 750 | contents += "[Desktop Entry]\n"; |
751 | contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; | 751 | contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; |
752 | contents += "File = "+doc->file()+"\n"; | 752 | contents += "File = "+doc->file()+"\n"; |
753 | contents += "Name = "+doc->name()+"\n"; | 753 | contents += "Name = "+doc->name()+"\n"; |
754 | contents += "Type = "+doc->type()+"\n"; | 754 | contents += "Type = "+doc->type()+"\n"; |
755 | } | 755 | } |
756 | contents += QString("Size = %1\n").arg( fi.size() ); | 756 | contents += QString("Size = %1\n").arg( fi.size() ); |
757 | } | 757 | } |
758 | 758 | ||
759 | //qDebug( "sending length %d", contents.length() ); | 759 | //qDebug( "sending length %d", contents.length() ); |
760 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); | 760 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); |
761 | e << contents; | 761 | e << contents; |
762 | 762 | ||
763 | //qDebug( "================ \n\n%s\n\n===============", | 763 | qDebug( "================ \n\n%s\n\n===============", |
764 | //contents.latin1() ); | 764 | contents.latin1() ); |
765 | 765 | ||
766 | delete docsFolder; | 766 | delete docsFolder; |
767 | docsFolder = 0; | 767 | docsFolder = 0; |
768 | } | 768 | } |
769 | } | 769 | } |
770 | 770 | ||
771 | void Launcher::cancelSync() | 771 | void Launcher::cancelSync() |
772 | { | 772 | { |
773 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); | 773 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); |
774 | } | 774 | } |
775 | 775 | ||
776 | void Launcher::storageChanged() | 776 | void Launcher::storageChanged() |
777 | { | 777 | { |
778 | if ( in_lnk_props ) { | 778 | if ( in_lnk_props ) { |
779 | got_lnk_change = TRUE; | 779 | got_lnk_change = TRUE; |
780 | lnk_change = ""; | 780 | lnk_change = ""; |
781 | } else { | 781 | } else { |
782 | updateDocs(); | 782 | updateDocs(); |
783 | } | 783 | } |
784 | } | 784 | } |
785 | 785 | ||
786 | 786 | ||
787 | bool Launcher::mkdir(const QString &localPath) | 787 | bool Launcher::mkdir(const QString &localPath) |
788 | { | 788 | { |
789 | QDir fullDir(localPath); | 789 | QDir fullDir(localPath); |
790 | if (fullDir.exists()) | 790 | if (fullDir.exists()) |
791 | return true; | 791 | return true; |
792 | 792 | ||
793 | // at this point the directory doesn't exist | 793 | // at this point the directory doesn't exist |
794 | // go through the directory tree and start creating the direcotories | 794 | // go through the directory tree and start creating the direcotories |
795 | // that don't exist; if we can't create the directories, return false | 795 | // that don't exist; if we can't create the directories, return false |
796 | 796 | ||
797 | QString dirSeps = "/"; | 797 | QString dirSeps = "/"; |
798 | int dirIndex = localPath.find(dirSeps); | 798 | int dirIndex = localPath.find(dirSeps); |
799 | QString checkedPath; | 799 | QString checkedPath; |
800 | 800 | ||
801 | // didn't find any seps; weird, use the cur dir instead | 801 | // didn't find any seps; weird, use the cur dir instead |
802 | if (dirIndex == -1) { | 802 | if (dirIndex == -1) { |
803 | //qDebug("No seperators found in path %s", localPath.latin1()); | 803 | //qDebug("No seperators found in path %s", localPath.latin1()); |
804 | checkedPath = QDir::currentDirPath(); | 804 | checkedPath = QDir::currentDirPath(); |
805 | } | 805 | } |
806 | 806 | ||
807 | while (checkedPath != localPath) { | 807 | while (checkedPath != localPath) { |
808 | // no more seperators found, use the local path | 808 | // no more seperators found, use the local path |
809 | if (dirIndex == -1) | 809 | if (dirIndex == -1) |
810 | checkedPath = localPath; | 810 | checkedPath = localPath; |
811 | else { | 811 | else { |
812 | // the next directory to check | 812 | // the next directory to check |
813 | checkedPath = localPath.left(dirIndex) + "/"; | 813 | checkedPath = localPath.left(dirIndex) + "/"; |
814 | // advance the iterator; the next dir seperator | 814 | // advance the iterator; the next dir seperator |
815 | dirIndex = localPath.find(dirSeps, dirIndex+1); | 815 | dirIndex = localPath.find(dirSeps, dirIndex+1); |
816 | } | 816 | } |
817 | 817 | ||
818 | QDir checkDir(checkedPath); | 818 | QDir checkDir(checkedPath); |
819 | if (!checkDir.exists()) { | 819 | if (!checkDir.exists()) { |
820 | //qDebug("mkdir making dir %s", checkedPath.latin1()); | 820 | //qDebug("mkdir making dir %s", checkedPath.latin1()); |
821 | 821 | ||
822 | if (!checkDir.mkdir(checkedPath)) { | 822 | if (!checkDir.mkdir(checkedPath)) { |
823 | qDebug("Unable to make directory %s", checkedPath.latin1()); | 823 | qDebug("Unable to make directory %s", checkedPath.latin1()); |
824 | return FALSE; | 824 | return FALSE; |
825 | } | 825 | } |
826 | } | 826 | } |
827 | 827 | ||
828 | } | 828 | } |
829 | return TRUE; | 829 | return TRUE; |
830 | } | 830 | } |
831 | 831 | ||
832 | void Launcher::preloadApps() | 832 | void Launcher::preloadApps() |
833 | { | 833 | { |
834 | Config cfg("Launcher"); | 834 | Config cfg("Launcher"); |
835 | cfg.setGroup("Preload"); | 835 | cfg.setGroup("Preload"); |
836 | QStringList apps = cfg.readListEntry("Apps",','); | 836 | QStringList apps = cfg.readListEntry("Apps",','); |
837 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { | 837 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { |
838 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | 838 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); |
839 | } | 839 | } |
840 | } | 840 | } |
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index 764f088..538ad79 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp | |||
@@ -40,209 +40,209 @@ | |||
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"); |
133 | 133 | ||
134 | if (backgroundImage.isNull()) backgroundImage="qpe-background"; | 134 | if (backgroundImage.isNull()) backgroundImage="qpe-background"; |
135 | int backgroundMode = QPixmap::defaultDepth() >= 12 ? 1 : 0; | 135 | int backgroundMode = QPixmap::defaultDepth() >= 12 ? 1 : 0; |
136 | //int backgroundMode = 2; | 136 | //int backgroundMode = 2; |
137 | 137 | ||
138 | if ( backgroundMode == 1 ) { | 138 | if ( backgroundMode == 1 ) { |
139 | 139 | ||
140 | // Double buffer the background | 140 | // Double buffer the background |
141 | static QPixmap *bg = NULL; | 141 | static QPixmap *bg = NULL; |
142 | static QColor bgColor; | 142 | static QColor bgColor; |
143 | 143 | ||
144 | if ( (bg == NULL) || (bgColor != colorGroup().button()) ) { | 144 | if ( (bg == NULL) || (bgColor != colorGroup().button()) ) { |
145 | // Create a new background double buffer | 145 | // Create a new background double buffer |
146 | if (bg == NULL) | 146 | if (bg == NULL) |
147 | bg = new QPixmap( width(), height() ); | 147 | bg = new QPixmap( width(), height() ); |
148 | bgColor = colorGroup().button(); | 148 | bgColor = colorGroup().button(); |
149 | QPainter painter( bg ); | 149 | QPainter painter( bg ); |
150 | 150 | ||
151 | painter.fillRect( QRect( 0, 0, width(), height() ), colorGroup().background().light(110)); | 151 | painter.fillRect( QRect( 0, 0, width(), height() ), colorGroup().background().light(110)); |
152 | // Overlay the Qtopia logo in the center | 152 | // Overlay the Qtopia logo in the center |
153 | QImage logo; | 153 | QImage logo; |
154 | if (QFile::exists(backgroundImage)) { | 154 | if (QFile::exists(backgroundImage)) { |
155 | logo = QImage(backgroundImage); | 155 | logo = QImage(backgroundImage); |
156 | } else { | 156 | } else { |
157 | logo = Resource::loadImage(backgroundImage ); | 157 | logo = Resource::loadImage(backgroundImage ); |
158 | } | 158 | } |
159 | if ( !logo.isNull() ) | 159 | if ( !logo.isNull() ) |
160 | painter.drawImage( (width() - logo.width()) / 2, | 160 | painter.drawImage( (width() - logo.width()) / 2, |
161 | (height() - logo.height()) / 2, logo ); | 161 | (height() - logo.height()) / 2, logo ); |
162 | } | 162 | } |
163 | 163 | ||
164 | // 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) |
165 | p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), | 165 | p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), |
166 | (r.y() + contentsY()) % bg->height() ) ); | 166 | (r.y() + contentsY()) % bg->height() ) ); |
167 | } else if ( backgroundMode == 2 ) { | 167 | } else if ( backgroundMode == 2 ) { |
168 | static QPixmap *bg = 0; | 168 | static QPixmap *bg = 0; |
169 | static QColor bgColor; | 169 | static QColor bgColor; |
170 | if ( !bg || (bgColor != colorGroup().background()) ) { | 170 | if ( !bg || (bgColor != colorGroup().background()) ) { |
171 | bgColor = colorGroup().background(); | 171 | bgColor = colorGroup().background(); |
172 | bg = new QPixmap( width(), 9 ); | 172 | bg = new QPixmap( width(), 9 ); |
173 | QPainter painter( bg ); | 173 | QPainter painter( bg ); |
174 | for ( int i = 0; i < 3; i++ ) { | 174 | for ( int i = 0; i < 3; i++ ) { |
175 | painter.setPen( colorGroup().background().light(130) ); | 175 | painter.setPen( colorGroup().background().light(130) ); |
176 | painter.drawLine( 0, i*3, width()-1, i*3 ); | 176 | painter.drawLine( 0, i*3, width()-1, i*3 ); |
177 | painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); | 177 | painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); |
178 | painter.setPen( colorGroup().background().light(105) ); | 178 | painter.setPen( colorGroup().background().light(105) ); |
179 | painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); | 179 | painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), | 182 | p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), |
183 | (r.y() + contentsY()) % bg->height() ) ); | 183 | (r.y() + contentsY()) % bg->height() ) ); |
184 | } else { | 184 | } else { |
185 | p->fillRect( r, QBrush( colorGroup().background().light(110) ) ); | 185 | p->fillRect( r, QBrush( colorGroup().background().light(110) ) ); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | void hideOrShowItems(bool resort); | 189 | void hideOrShowItems(bool resort); |
190 | 190 | ||
191 | void setTypeFilter(const QString& typefilter, bool resort) | 191 | void setTypeFilter(const QString& typefilter, bool resort) |
192 | { | 192 | { |
193 | tf = QRegExp(typefilter,FALSE,TRUE); | 193 | tf = QRegExp(typefilter,FALSE,TRUE); |
194 | hideOrShowItems(resort); | 194 | hideOrShowItems(resort); |
195 | } | 195 | } |
196 | 196 | ||
197 | void setCategoryFilter( int catfilter, bool resort ) | 197 | void setCategoryFilter( int catfilter, bool resort ) |
198 | { | 198 | { |
199 | Categories cat; | 199 | Categories cat; |
200 | cat.load( categoryFileName() ); | 200 | cat.load( categoryFileName() ); |
201 | QString str; | 201 | QString str; |
202 | if ( catfilter == -2 ) | 202 | if ( catfilter == -2 ) |
203 | cf = 0; | 203 | cf = 0; |
204 | else | 204 | else |
205 | cf = catfilter; | 205 | cf = catfilter; |
206 | hideOrShowItems(resort); | 206 | hideOrShowItems(resort); |
207 | } | 207 | } |
208 | 208 | ||
209 | enum SortMethod { Name, Date, Type }; | 209 | enum SortMethod { Name, Date, Type }; |
210 | 210 | ||
211 | void setSortMethod( SortMethod m ) | 211 | void setSortMethod( SortMethod m ) |
212 | { | 212 | { |
213 | if ( sortmeth != m ) { | 213 | if ( sortmeth != m ) { |
214 | sortmeth = m; | 214 | sortmeth = m; |
215 | sort(); | 215 | sort(); |
216 | } | 216 | } |
217 | } | 217 | } |
218 | 218 | ||
219 | int compare(const AppLnk* a, const AppLnk* b) | 219 | int compare(const AppLnk* a, const AppLnk* b) |
220 | { | 220 | { |
221 | switch (sortmeth) { | 221 | switch (sortmeth) { |
222 | case Name: | 222 | case Name: |
223 | return a->name().compare(b->name()); | 223 | return a->name().compare(b->name()); |
224 | case Date: { | 224 | case Date: { |
225 | QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); | 225 | QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); |
226 | QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); | 226 | QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); |
227 | return fa.lastModified().secsTo(fb.lastModified()); | 227 | return fa.lastModified().secsTo(fb.lastModified()); |
228 | } | 228 | } |
229 | case Type: | 229 | case Type: |
230 | return a->type().compare(b->type()); | 230 | return a->type().compare(b->type()); |
231 | } | 231 | } |
232 | return 0; | 232 | return 0; |
233 | } | 233 | } |
234 | 234 | ||
235 | protected: | 235 | protected: |
236 | 236 | ||
237 | void styleChange( QStyle &old ) | 237 | void styleChange( QStyle &old ) |
238 | { | 238 | { |
239 | QIconView::styleChange( old ); | 239 | QIconView::styleChange( old ); |
240 | //### duplicated code from LauncherView constructor | 240 | //### duplicated code from LauncherView constructor |
241 | int dw = QApplication::desktop()->width(); | 241 | int dw = QApplication::desktop()->width(); |
242 | setGridX( (dw-13-style().scrollBarExtent().width())/3 ); // tweaked for 8pt+dw=176 and 10pt+dw=240 | 242 | setGridX( (dw-13-style().scrollBarExtent().width())/3 ); // tweaked for 8pt+dw=176 and 10pt+dw=240 |
243 | } | 243 | } |
244 | 244 | ||
245 | private: | 245 | private: |
246 | QList<AppLnk> hidden; | 246 | QList<AppLnk> hidden; |
247 | QDict<void> mimes; | 247 | QDict<void> mimes; |
248 | QDict<void> cats; | 248 | QDict<void> cats; |
@@ -265,51 +265,51 @@ void LauncherView::setBusy(bool on) | |||
265 | class LauncherItem : public QIconViewItem | 265 | class LauncherItem : public QIconViewItem |
266 | { | 266 | { |
267 | public: | 267 | public: |
268 | LauncherItem( QIconView *parent, AppLnk* applnk ); | 268 | LauncherItem( QIconView *parent, AppLnk* applnk ); |
269 | ~LauncherItem() | 269 | ~LauncherItem() |
270 | { | 270 | { |
271 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 271 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
272 | if ( liv->busyItem() == this ) | 272 | if ( liv->busyItem() == this ) |
273 | liv->setBusy(FALSE); | 273 | liv->setBusy(FALSE); |
274 | delete app; | 274 | delete app; |
275 | } | 275 | } |
276 | 276 | ||
277 | AppLnk* appLnk() const { return app; } | 277 | AppLnk* appLnk() const { return app; } |
278 | AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; } | 278 | AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; } |
279 | 279 | ||
280 | virtual int compare ( QIconViewItem * i ) const; | 280 | virtual int compare ( QIconViewItem * i ) const; |
281 | 281 | ||
282 | void paintItem( QPainter *p, const QColorGroup &cg ) | 282 | void paintItem( QPainter *p, const QColorGroup &cg ) |
283 | { | 283 | { |
284 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 284 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
285 | QBrush oldBrush( liv->itemTextBackground() ); | 285 | QBrush oldBrush( liv->itemTextBackground() ); |
286 | QColorGroup mycg( cg ); | 286 | QColorGroup mycg( cg ); |
287 | if ( liv->currentItem() == this ) { | 287 | if ( liv->currentItem() == this ) { |
288 | liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); | 288 | liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); |
289 | mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); | 289 | mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); |
290 | } | 290 | } |
291 | QIconViewItem::paintItem(p,mycg); | 291 | QIconViewItem::paintItem(p,mycg); |
292 | if ( liv->currentItem() == this ) | 292 | if ( liv->currentItem() == this ) |
293 | liv->setItemTextBackground( oldBrush ); | 293 | liv->setItemTextBackground( oldBrush ); |
294 | if ( liv->busyItem() == this ) { | 294 | if ( liv->busyItem() == this ) { |
295 | static QPixmap* busypm=0; | 295 | static QPixmap* busypm=0; |
296 | if ( !busypm ) | 296 | if ( !busypm ) |
297 | busypm = new QPixmap(Resource::loadPixmap("launching")); | 297 | busypm = new QPixmap(Resource::loadPixmap("launching")); |
298 | p->drawPixmap(x()+(width()-busypm->width())/2, y(),*busypm); | 298 | p->drawPixmap(x()+(width()-busypm->width())/2, y(),*busypm); |
299 | } | 299 | } |
300 | } | 300 | } |
301 | 301 | ||
302 | protected: | 302 | protected: |
303 | AppLnk* app; | 303 | AppLnk* app; |
304 | }; | 304 | }; |
305 | 305 | ||
306 | 306 | ||
307 | LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk ) | 307 | LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk ) |
308 | : QIconViewItem( parent, applnk->name(), applnk->bigPixmap() ), | 308 | : QIconViewItem( parent, applnk->name(), applnk->bigPixmap() ), |
309 | app(applnk) // Takes ownership | 309 | app(applnk) // Takes ownership |
310 | { | 310 | { |
311 | } | 311 | } |
312 | 312 | ||
313 | int LauncherItem::compare ( QIconViewItem * i ) const | 313 | int LauncherItem::compare ( QIconViewItem * i ) const |
314 | { | 314 | { |
315 | LauncherIconView* view = (LauncherIconView*)iconView(); | 315 | LauncherIconView* view = (LauncherIconView*)iconView(); |
@@ -318,99 +318,96 @@ int LauncherItem::compare ( QIconViewItem * i ) const | |||
318 | 318 | ||
319 | QStringList LauncherIconView::mimeTypes() const | 319 | QStringList LauncherIconView::mimeTypes() const |
320 | { | 320 | { |
321 | QStringList r; | 321 | QStringList r; |
322 | QDictIterator<void> it(mimes); | 322 | QDictIterator<void> it(mimes); |
323 | while (it.current()) { | 323 | while (it.current()) { |
324 | r.append(it.currentKey()); | 324 | r.append(it.currentKey()); |
325 | ++it; | 325 | ++it; |
326 | } | 326 | } |
327 | r.sort(); | 327 | r.sort(); |
328 | return r; | 328 | return r; |
329 | } | 329 | } |
330 | 330 | ||
331 | void LauncherIconView::addItem(AppLnk* app, bool resort) | 331 | void LauncherIconView::addItem(AppLnk* app, bool resort) |
332 | { | 332 | { |
333 | addCatsAndMimes(app); | 333 | addCatsAndMimes(app); |
334 | 334 | ||
335 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) | 335 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) |
336 | && (cf == 0 || app->categories().contains(cf) | 336 | && (cf == 0 || app->categories().contains(cf) |
337 | || cf == -1 && app->categories().count() == 0 ) ) | 337 | || cf == -1 && app->categories().count() == 0 ) ) |
338 | (void) new LauncherItem( this, app ); | 338 | (void) new LauncherItem( this, app ); |
339 | else | 339 | else |
340 | hidden.append(app); | 340 | hidden.append(app); |
341 | if ( resort ) | 341 | if ( resort ) |
342 | sort(); | 342 | sort(); |
343 | } | 343 | } |
344 | 344 | ||
345 | void LauncherIconView::updateCategoriesAndMimeTypes() | 345 | void LauncherIconView::updateCategoriesAndMimeTypes() |
346 | { | 346 | { |
347 | mimes.clear(); | 347 | mimes.clear(); |
348 | cats.clear(); | 348 | cats.clear(); |
349 | LauncherItem* item = (LauncherItem*)firstItem(); | 349 | LauncherItem* item = (LauncherItem*)firstItem(); |
350 | while (item) { | 350 | while (item) { |
351 | addCatsAndMimes(item->appLnk()); | 351 | addCatsAndMimes(item->appLnk()); |
352 | item = (LauncherItem*)item->nextItem(); | 352 | item = (LauncherItem*)item->nextItem(); |
353 | } | 353 | } |
354 | QListIterator<AppLnk> it(hidden); | 354 | QListIterator<AppLnk> it(hidden); |
355 | AppLnk* l; | 355 | AppLnk* l; |
356 | while ((l=it.current())) { | 356 | while ((l=it.current())) { |
357 | addCatsAndMimes(l); | 357 | addCatsAndMimes(l); |
358 | ++it; | 358 | ++it; |
359 | } | 359 | } |
360 | } | 360 | } |
361 | 361 | ||
362 | void LauncherIconView::hideOrShowItems(bool resort) | 362 | void LauncherIconView::hideOrShowItems(bool resort) |
363 | { | 363 | { |
364 | hidden.setAutoDelete(FALSE); | 364 | hidden.setAutoDelete(FALSE); |
365 | QList<AppLnk> links=hidden; | 365 | QList<AppLnk> links=hidden; |
366 | hidden.clear(); | 366 | hidden.clear(); |
367 | hidden.setAutoDelete(TRUE); | 367 | hidden.setAutoDelete(TRUE); |
368 | LauncherItem* item = (LauncherItem*)firstItem(); | 368 | LauncherItem* item = (LauncherItem*)firstItem(); |
369 | while (item) { | 369 | while (item) { |
370 | links.append(item->takeAppLnk()); | 370 | links.append(item->takeAppLnk()); |
371 | item = (LauncherItem*)item->nextItem(); | 371 | item = (LauncherItem*)item->nextItem(); |
372 | } | 372 | } |
373 | bool oldAutoArrange = autoArrange(); | 373 | bool oldAutoArrange = autoArrange(); |
374 | setAutoArrange( FALSE ); | 374 | setAutoArrange( FALSE ); |
375 | clear(); | 375 | clear(); |
376 | QListIterator<AppLnk> it(links); | 376 | QListIterator<AppLnk> it(links); |
377 | AppLnk* l; | 377 | AppLnk* l; |
378 | while ((l=it.current())) { | 378 | while ((l=it.current())) { |
379 | addItem(l,FALSE); | 379 | addItem(l,FALSE); |
380 | ++it; | 380 | ++it; |
381 | } | 381 | } |
382 | if ( resort ) | 382 | if ( resort ) |
383 | sort(); | 383 | sort(); |
384 | setAutoArrange( oldAutoArrange ); | 384 | setAutoArrange( oldAutoArrange ); |
385 | } | 385 | } |
386 | 386 | ||
387 | bool LauncherIconView::removeLink(const QString& linkfile) | 387 | bool LauncherIconView::removeLink(const QString& linkfile) |
388 | { | 388 | { |
389 | LauncherItem* item = (LauncherItem*)firstItem(); | 389 | LauncherItem* item = (LauncherItem*)firstItem(); |
390 | AppLnk* l; | 390 | AppLnk* l; |
391 | bool did = FALSE; | 391 | bool did = FALSE; |
392 | DocLnk dl(linkfile); | 392 | DocLnk dl(linkfile); |
393 | while (item) { | 393 | while (item) { |
394 | l = item->appLnk(); | 394 | l = item->appLnk(); |
395 | if ( l->linkFileKnown() && l->linkFile() == linkfile || l->file() == linkfile | 395 | if ( l->linkFileKnown() && l->linkFile() == linkfile/* || l->file() == linkfile || dl.isValid() && dl.file() == l->file()*/ ) { |
396 | || dl.isValid() && dl.file() == l->file() ) { | 396 | delete item; |
397 | delete item; | 397 | did = TRUE; |
398 | did = TRUE; | 398 | } |
399 | } | 399 | item = (LauncherItem*)item->nextItem(); |
400 | item = (LauncherItem*)item->nextItem(); | ||
401 | } | 400 | } |
402 | QListIterator<AppLnk> it(hidden); | 401 | QListIterator<AppLnk> it(hidden); |
403 | while ((l=it.current())) { | 402 | while ((l=it.current())) { |
404 | ++it; | 403 | ++it; |
405 | if ( l->linkFileKnown() && l->linkFile() == linkfile | 404 | if ( l->linkFileKnown() && l->linkFile() == linkfile/* || l->file() == linkfile || dl.isValid() && dl.file() == l->file()*/ ) { |
406 | || l->file() == linkfile | 405 | hidden.removeRef(l); |
407 | || dl.isValid() && dl.file() == l->file() ) { | 406 | did = TRUE; |
408 | hidden.removeRef(l); | 407 | } |
409 | did = TRUE; | ||
410 | } | ||
411 | } | 408 | } |
412 | return did; | 409 | return did; |
413 | } | 410 | } |
414 | 411 | ||
415 | LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) | 412 | LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) |
416 | : QVBox( parent, name, fl ) | 413 | : QVBox( parent, name, fl ) |
@@ -429,57 +426,57 @@ LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) | |||
429 | icons->setSpacing( 4 ); | 426 | icons->setSpacing( 4 ); |
430 | icons->setMargin( 0 ); | 427 | icons->setMargin( 0 ); |
431 | icons->setSelectionMode( QIconView::Multi ); | 428 | icons->setSelectionMode( QIconView::Multi ); |
432 | icons->setBackgroundMode( PaletteBase ); | 429 | icons->setBackgroundMode( PaletteBase ); |
433 | 430 | ||
434 | connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)), | 431 | connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)), |
435 | SLOT(itemClicked(int, QIconViewItem *)) ); | 432 | SLOT(itemClicked(int, QIconViewItem *)) ); |
436 | connect( icons, SIGNAL(selectionChanged()), | 433 | connect( icons, SIGNAL(selectionChanged()), |
437 | SLOT(selectionChanged()) ); | 434 | SLOT(selectionChanged()) ); |
438 | connect( icons, SIGNAL(returnPressed(QIconViewItem *)), | 435 | connect( icons, SIGNAL(returnPressed(QIconViewItem *)), |
439 | SLOT(returnPressed(QIconViewItem *)) ); | 436 | SLOT(returnPressed(QIconViewItem *)) ); |
440 | connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)), | 437 | connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)), |
441 | SLOT(itemPressed(int, QIconViewItem *)) ); | 438 | SLOT(itemPressed(int, QIconViewItem *)) ); |
442 | 439 | ||
443 | tools = 0; | 440 | tools = 0; |
444 | } | 441 | } |
445 | 442 | ||
446 | LauncherView::~LauncherView() | 443 | LauncherView::~LauncherView() |
447 | { | 444 | { |
448 | } | 445 | } |
449 | 446 | ||
450 | void LauncherView::setToolsEnabled(bool y) | 447 | void LauncherView::setToolsEnabled(bool y) |
451 | { | 448 | { |
452 | if ( !y != !tools ) { | 449 | if ( !y != !tools ) { |
453 | if ( y ) { | 450 | if ( y ) { |
454 | tools = new QHBox(this); | 451 | tools = new QHBox(this); |
455 | 452 | ||
456 | // Type filter | 453 | // Type filter |
457 | typemb = new MenuButton(tools); | 454 | typemb = new MenuButton(tools); |
458 | typemb->setLabel(tr("Type: %1")); | 455 | typemb->setLabel(tr("Type: %1")); |
459 | typemb->setFixedHeight ( 20 ); | 456 | typemb->setFixedHeight ( 20 ); |
460 | 457 | ||
461 | // Category filter | 458 | // Category filter |
462 | catmb = new CategorySelect(tools); | 459 | catmb = new CategorySelect(tools); |
463 | catmb->setFixedHeight ( 20 ); | 460 | catmb->setFixedHeight ( 20 ); |
464 | 461 | ||
465 | updateTools(); | 462 | updateTools(); |
466 | tools->show(); | 463 | tools->show(); |
467 | } else { | 464 | } else { |
468 | delete tools; | 465 | delete tools; |
469 | tools = 0; | 466 | tools = 0; |
470 | } | 467 | } |
471 | } | 468 | } |
472 | } | 469 | } |
473 | 470 | ||
474 | void LauncherView::updateTools() | 471 | void LauncherView::updateTools() |
475 | { | 472 | { |
476 | disconnect( typemb, SIGNAL(selected(const QString&)), | 473 | disconnect( typemb, SIGNAL(selected(const QString&)), |
477 | this, SLOT(showType(const QString&)) ); | 474 | this, SLOT(showType(const QString&)) ); |
478 | disconnect( catmb, SIGNAL(signalSelected(int)), | 475 | disconnect( catmb, SIGNAL(signalSelected(int)), |
479 | this, SLOT(showCategory(int)) ); | 476 | this, SLOT(showCategory(int)) ); |
480 | 477 | ||
481 | icons->updateCategoriesAndMimeTypes(); | 478 | icons->updateCategoriesAndMimeTypes(); |
482 | 479 | ||
483 | QString prev; | 480 | QString prev; |
484 | 481 | ||
485 | // Type filter | 482 | // Type filter |
@@ -508,99 +505,99 @@ void LauncherView::sortBy(int s) | |||
508 | icons->setSortMethod((LauncherIconView::SortMethod)s); | 505 | icons->setSortMethod((LauncherIconView::SortMethod)s); |
509 | } | 506 | } |
510 | 507 | ||
511 | void LauncherView::showType(const QString& t) | 508 | void LauncherView::showType(const QString& t) |
512 | { | 509 | { |
513 | if ( t == tr("All") ) { | 510 | if ( t == tr("All") ) { |
514 | icons->setTypeFilter("",TRUE); | 511 | icons->setTypeFilter("",TRUE); |
515 | } else { | 512 | } else { |
516 | icons->setTypeFilter(t+"/*",TRUE); | 513 | icons->setTypeFilter(t+"/*",TRUE); |
517 | } | 514 | } |
518 | } | 515 | } |
519 | 516 | ||
520 | void LauncherView::showCategory( int c ) | 517 | void LauncherView::showCategory( int c ) |
521 | { | 518 | { |
522 | icons->setCategoryFilter( c, TRUE ); | 519 | icons->setCategoryFilter( c, TRUE ); |
523 | } | 520 | } |
524 | 521 | ||
525 | void LauncherView::resizeEvent(QResizeEvent *e) | 522 | void LauncherView::resizeEvent(QResizeEvent *e) |
526 | { | 523 | { |
527 | QVBox::resizeEvent( e ); | 524 | QVBox::resizeEvent( e ); |
528 | if ( e->size().width() != e->oldSize().width() ) | 525 | if ( e->size().width() != e->oldSize().width() ) |
529 | sort(); | 526 | sort(); |
530 | } | 527 | } |
531 | 528 | ||
532 | void LauncherView::populate( AppLnkSet *folder, const QString& typefilter ) | 529 | void LauncherView::populate( AppLnkSet *folder, const QString& typefilter ) |
533 | { | 530 | { |
534 | icons->clear(); | 531 | icons->clear(); |
535 | internalPopulate( folder, typefilter ); | 532 | internalPopulate( folder, typefilter ); |
536 | } | 533 | } |
537 | 534 | ||
538 | void LauncherView::selectionChanged() | 535 | void LauncherView::selectionChanged() |
539 | { | 536 | { |
540 | QIconViewItem* item = icons->currentItem(); | 537 | QIconViewItem* item = icons->currentItem(); |
541 | if ( item && item->isSelected() ) { | 538 | if ( item && item->isSelected() ) { |
542 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 539 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
543 | if ( icons->inKeyEvent() ) // not for mouse press | 540 | if ( icons->inKeyEvent() ) // not for mouse press |
544 | emit clicked( appLnk ); | 541 | emit clicked( appLnk ); |
545 | item->setSelected(FALSE); | 542 | item->setSelected(FALSE); |
546 | } | 543 | } |
547 | } | 544 | } |
548 | 545 | ||
549 | void LauncherView::returnPressed( QIconViewItem *item ) | 546 | void LauncherView::returnPressed( QIconViewItem *item ) |
550 | { | 547 | { |
551 | if ( item ) { | 548 | if ( item ) { |
552 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 549 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
553 | emit clicked( appLnk ); | 550 | emit clicked( appLnk ); |
554 | } | 551 | } |
555 | } | 552 | } |
556 | 553 | ||
557 | void LauncherView::itemClicked( int btn, QIconViewItem *item ) | 554 | void LauncherView::itemClicked( int btn, QIconViewItem *item ) |
558 | { | 555 | { |
559 | if ( item ) { | 556 | if ( item ) { |
560 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 557 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
561 | if ( btn == LeftButton ) { | 558 | if ( btn == LeftButton ) { |
562 | // Make sure it's the item we execute that gets highlighted | 559 | // Make sure it's the item we execute that gets highlighted |
563 | icons->setCurrentItem( item ); | 560 | icons->setCurrentItem( item ); |
564 | emit clicked( appLnk ); | 561 | emit clicked( appLnk ); |
565 | } | 562 | } |
566 | item->setSelected(FALSE); | 563 | item->setSelected(FALSE); |
567 | } | 564 | } |
568 | } | 565 | } |
569 | 566 | ||
570 | void LauncherView::itemPressed( int btn, QIconViewItem *item ) | 567 | void LauncherView::itemPressed( int btn, QIconViewItem *item ) |
571 | { | 568 | { |
572 | if ( item ) { | 569 | if ( item ) { |
573 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 570 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
574 | if ( btn == RightButton ) | 571 | if ( btn == RightButton ) |
575 | emit rightPressed( appLnk ); | 572 | emit rightPressed( appLnk ); |
576 | /* | 573 | /* |
577 | else if ( btn == LeftButton ) | 574 | else if ( btn == LeftButton ) |
578 | emit clicked( appLnk ); | 575 | emit clicked( appLnk ); |
579 | */ | 576 | */ |
580 | item->setSelected(FALSE); | 577 | item->setSelected(FALSE); |
581 | } | 578 | } |
582 | } | 579 | } |
583 | 580 | ||
584 | void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter ) | 581 | void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter ) |
585 | { | 582 | { |
586 | QListIterator<AppLnk> it( folder->children() ); | 583 | QListIterator<AppLnk> it( folder->children() ); |
587 | icons->setTypeFilter(typefilter,FALSE); | 584 | icons->setTypeFilter(typefilter,FALSE); |
588 | 585 | ||
589 | while ( it.current() ) { | 586 | while ( it.current() ) { |
590 | // show only the icons for existing files | 587 | // show only the icons for existing files |
591 | if (!QFile(it.current()->file()).exists() ) | 588 | if (!QFile(it.current()->file()).exists() ) |
592 | { | 589 | { |
593 | //maybe insert some .desktop file deletion code later | 590 | //maybe insert some .desktop file deletion code later |
594 | //maybe dir specific | 591 | //maybe dir specific |
595 | } | 592 | } |
596 | else | 593 | else |
597 | { | 594 | { |
598 | icons->addItem(*it,FALSE); | 595 | icons->addItem(*it,FALSE); |
599 | } | 596 | } |
600 | ++it; | 597 | ++it; |
601 | } | 598 | } |
602 | 599 | ||
603 | icons->sort(); | 600 | icons->sort(); |
604 | } | 601 | } |
605 | 602 | ||
606 | bool LauncherView::removeLink(const QString& linkfile) | 603 | bool LauncherView::removeLink(const QString& linkfile) |