-rw-r--r-- | core/launcher/launcher.cpp | 1 | ||||
-rw-r--r-- | core/launcher/launcher.h | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 222592b..b26bd8b 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -142,734 +142,735 @@ void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, | |||
142 | 142 | ||
143 | ids.clear(); | 143 | ids.clear(); |
144 | 144 | ||
145 | QStringList types = rootFolder->types(); | 145 | QStringList types = rootFolder->types(); |
146 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 146 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
147 | if ( !(*it).isEmpty() ) { | 147 | if ( !(*it).isEmpty() ) { |
148 | newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); | 148 | newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); |
149 | } | 149 | } |
150 | } | 150 | } |
151 | QListIterator<AppLnk> it( rootFolder->children() ); | 151 | QListIterator<AppLnk> it( rootFolder->children() ); |
152 | AppLnk* l; | 152 | AppLnk* l; |
153 | while ( (l=it.current()) ) { | 153 | while ( (l=it.current()) ) { |
154 | if ( l->type() == "Separator" ) { | 154 | if ( l->type() == "Separator" ) { |
155 | rootFolder->remove(l); | 155 | rootFolder->remove(l); |
156 | delete l; | 156 | delete l; |
157 | } else { | 157 | } else { |
158 | int i=0; | 158 | int i=0; |
159 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 159 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
160 | if ( *it == l->type() ) | 160 | if ( *it == l->type() ) |
161 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); | 161 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); |
162 | i++; | 162 | i++; |
163 | } | 163 | } |
164 | } | 164 | } |
165 | ++it; | 165 | ++it; |
166 | } | 166 | } |
167 | rootFolder->detachChildren(); | 167 | rootFolder->detachChildren(); |
168 | for (int i=0; i<tabs; i++) | 168 | for (int i=0; i<tabs; i++) |
169 | ((LauncherView*)stack->widget(i))->sort(); | 169 | ((LauncherView*)stack->widget(i))->sort(); |
170 | 170 | ||
171 | // all documents | 171 | // all documents |
172 | docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents")); | 172 | docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents")); |
173 | docview->populate( docFolder, QString::null ); | 173 | docview->populate( docFolder, QString::null ); |
174 | docFolder->detachChildren(); | 174 | docFolder->detachChildren(); |
175 | docview->setFileSystems(fs); | 175 | docview->setFileSystems(fs); |
176 | docview->setToolsEnabled(TRUE); | 176 | docview->setToolsEnabled(TRUE); |
177 | 177 | ||
178 | connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); | 178 | connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); |
179 | 179 | ||
180 | ((LauncherView*)stack->widget(0))->setFocus(); | 180 | ((LauncherView*)stack->widget(0))->setFocus(); |
181 | 181 | ||
182 | categoryBar->show(); | 182 | categoryBar->show(); |
183 | stack->show(); | 183 | stack->show(); |
184 | } | 184 | } |
185 | 185 | ||
186 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) | 186 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) |
187 | { | 187 | { |
188 | docview->populate( docFolder, QString::null ); | 188 | docview->populate( docFolder, QString::null ); |
189 | docFolder->detachChildren(); | 189 | docFolder->detachChildren(); |
190 | docview->setFileSystems(fs); | 190 | docview->setFileSystems(fs); |
191 | docview->updateTools(); | 191 | docview->updateTools(); |
192 | } | 192 | } |
193 | 193 | ||
194 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) | 194 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) |
195 | { | 195 | { |
196 | LauncherView* view = new LauncherView( stack ); | 196 | LauncherView* view = new LauncherView( stack ); |
197 | connect( view, SIGNAL(clicked(const AppLnk*)), | 197 | connect( view, SIGNAL(clicked(const AppLnk*)), |
198 | this, SIGNAL(clicked(const AppLnk*))); | 198 | this, SIGNAL(clicked(const AppLnk*))); |
199 | connect( view, SIGNAL(rightPressed(AppLnk*)), | 199 | connect( view, SIGNAL(rightPressed(AppLnk*)), |
200 | this, SIGNAL(rightPressed(AppLnk*))); | 200 | this, SIGNAL(rightPressed(AppLnk*))); |
201 | ids.append(id); | 201 | ids.append(id); |
202 | categoryBar->addTab( new QTab( pm, label ) ); | 202 | categoryBar->addTab( new QTab( pm, label ) ); |
203 | stack->addWidget( view, tabs++ ); | 203 | stack->addWidget( view, tabs++ ); |
204 | return view; | 204 | return view; |
205 | } | 205 | } |
206 | 206 | ||
207 | void CategoryTabWidget::updateLink(const QString& linkfile) | 207 | void CategoryTabWidget::updateLink(const QString& linkfile) |
208 | { | 208 | { |
209 | int i=0; | 209 | int i=0; |
210 | LauncherView* view; | 210 | LauncherView* view; |
211 | while ((view = (LauncherView*)stack->widget(i++))) { | 211 | while ((view = (LauncherView*)stack->widget(i++))) { |
212 | if ( view->removeLink(linkfile) ) | 212 | if ( view->removeLink(linkfile) ) |
213 | break; | 213 | break; |
214 | } | 214 | } |
215 | addItem(linkfile); | 215 | addItem(linkfile); |
216 | docview->updateTools(); | 216 | docview->updateTools(); |
217 | } | 217 | } |
218 | 218 | ||
219 | void CategoryTabWidget::paletteChange( const QPalette &p ) | 219 | void CategoryTabWidget::paletteChange( const QPalette &p ) |
220 | { | 220 | { |
221 | QVBox::paletteChange( p ); | 221 | QVBox::paletteChange( p ); |
222 | QPalette pal = palette(); | 222 | QPalette pal = palette(); |
223 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 223 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
224 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 224 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
225 | categoryBar->setPalette( pal ); | 225 | categoryBar->setPalette( pal ); |
226 | categoryBar->update(); | 226 | categoryBar->update(); |
227 | } | 227 | } |
228 | 228 | ||
229 | void CategoryTabWidget::setBusy(bool on) | 229 | void CategoryTabWidget::setBusy(bool on) |
230 | { | 230 | { |
231 | if ( on ) | 231 | if ( on ) |
232 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); | 232 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); |
233 | else | 233 | else |
234 | for (int i=0; i<tabs; i++) | 234 | for (int i=0; i<tabs; i++) |
235 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); | 235 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); |
236 | } | 236 | } |
237 | 237 | ||
238 | 238 | ||
239 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) | 239 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) |
240 | : QTabBar( parent, name ) | 240 | : QTabBar( parent, name ) |
241 | { | 241 | { |
242 | setFocusPolicy( NoFocus ); | 242 | setFocusPolicy( NoFocus ); |
243 | connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); | 243 | connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); |
244 | } | 244 | } |
245 | 245 | ||
246 | CategoryTabBar::~CategoryTabBar() | 246 | CategoryTabBar::~CategoryTabBar() |
247 | { | 247 | { |
248 | } | 248 | } |
249 | 249 | ||
250 | void CategoryTabBar::layoutTabs() | 250 | void CategoryTabBar::layoutTabs() |
251 | { | 251 | { |
252 | if ( !count() ) | 252 | if ( !count() ) |
253 | return; | 253 | return; |
254 | 254 | ||
255 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; | 255 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; |
256 | int hiddenTabWidth = -12; | 256 | int hiddenTabWidth = -12; |
257 | int middleTab = currentTab(); | 257 | int middleTab = currentTab(); |
258 | int hframe, vframe, overlap; | 258 | int hframe, vframe, overlap; |
259 | style().tabbarMetrics( this, hframe, vframe, overlap ); | 259 | style().tabbarMetrics( this, hframe, vframe, overlap ); |
260 | QFontMetrics fm = fontMetrics(); | 260 | QFontMetrics fm = fontMetrics(); |
261 | int x = 0; | 261 | int x = 0; |
262 | QRect r; | 262 | QRect r; |
263 | QTab *t; | 263 | QTab *t; |
264 | int available = width()-1; | 264 | int available = width()-1; |
265 | int required = 0; | 265 | int required = 0; |
266 | for ( int i = 0; i < count(); i++ ) { | 266 | for ( int i = 0; i < count(); i++ ) { |
267 | t = tab(i); | 267 | t = tab(i); |
268 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { | 268 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { |
269 | if ( i != middleTab ) { | 269 | if ( i != middleTab ) { |
270 | // required += hiddenTabWidth + hframe - overlap; | 270 | // required += hiddenTabWidth + hframe - overlap; |
271 | available -= hiddenTabWidth + hframe - overlap; | 271 | available -= hiddenTabWidth + hframe - overlap; |
272 | if ( t->iconSet() != 0 ) | 272 | if ( t->iconSet() != 0 ) |
273 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 273 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
274 | } else { | 274 | } else { |
275 | required += fm.width( t->text() ) + hframe - overlap; | 275 | required += fm.width( t->text() ) + hframe - overlap; |
276 | if ( t->iconSet() != 0 ) | 276 | if ( t->iconSet() != 0 ) |
277 | required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 277 | required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | for ( int i = 0; i < count(); i++ ) { | 280 | for ( int i = 0; i < count(); i++ ) { |
281 | t = tab(i); | 281 | t = tab(i); |
282 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { | 282 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { |
283 | if ( i != middleTab ) { | 283 | if ( i != middleTab ) { |
284 | int w = hiddenTabWidth; | 284 | int w = hiddenTabWidth; |
285 | int ih = 0; | 285 | int ih = 0; |
286 | if ( t->iconSet() != 0 ) { | 286 | if ( t->iconSet() != 0 ) { |
287 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 287 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
288 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 288 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
289 | } | 289 | } |
290 | int h = QMAX( fm.height(), ih ); | 290 | int h = QMAX( fm.height(), ih ); |
291 | h = QMAX( h, QApplication::globalStrut().height() ); | 291 | h = QMAX( h, QApplication::globalStrut().height() ); |
292 | 292 | ||
293 | h += vframe; | 293 | h += vframe; |
294 | w += hframe; | 294 | w += hframe; |
295 | 295 | ||
296 | t->setRect( QRect(x, 0, w, h) ); | 296 | t->setRect( QRect(x, 0, w, h) ); |
297 | x += t->rect().width() - overlap; | 297 | x += t->rect().width() - overlap; |
298 | r = r.unite( t->rect() ); | 298 | r = r.unite( t->rect() ); |
299 | } else { | 299 | } else { |
300 | int w = fm.width( t->text() ); | 300 | int w = fm.width( t->text() ); |
301 | int ih = 0; | 301 | int ih = 0; |
302 | if ( t->iconSet() != 0 ) { | 302 | if ( t->iconSet() != 0 ) { |
303 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 303 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
304 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 304 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
305 | } | 305 | } |
306 | int h = QMAX( fm.height(), ih ); | 306 | int h = QMAX( fm.height(), ih ); |
307 | h = QMAX( h, QApplication::globalStrut().height() ); | 307 | h = QMAX( h, QApplication::globalStrut().height() ); |
308 | 308 | ||
309 | h += vframe; | 309 | h += vframe; |
310 | w += hframe; | 310 | w += hframe; |
311 | 311 | ||
312 | // t->setRect( QRect(x, 0, w * available/required, h) ); | 312 | // t->setRect( QRect(x, 0, w * available/required, h) ); |
313 | t->setRect( QRect(x, 0, available, h) ); | 313 | t->setRect( QRect(x, 0, available, h) ); |
314 | x += t->rect().width() - overlap; | 314 | x += t->rect().width() - overlap; |
315 | r = r.unite( t->rect() ); | 315 | r = r.unite( t->rect() ); |
316 | } | 316 | } |
317 | } | 317 | } |
318 | 318 | ||
319 | QRect rr = tab(count()-1)->rect(); | 319 | QRect rr = tab(count()-1)->rect(); |
320 | rr.setRight(width()-1); | 320 | rr.setRight(width()-1); |
321 | tab(count()-1)->setRect( rr ); | 321 | tab(count()-1)->setRect( rr ); |
322 | 322 | ||
323 | for ( t = tabList()->first(); t; t = tabList()->next() ) { | 323 | for ( t = tabList()->first(); t; t = tabList()->next() ) { |
324 | QRect tr = t->rect(); | 324 | QRect tr = t->rect(); |
325 | tr.setHeight( r.height() ); | 325 | tr.setHeight( r.height() ); |
326 | t->setRect( tr ); | 326 | t->setRect( tr ); |
327 | } | 327 | } |
328 | 328 | ||
329 | update(); | 329 | update(); |
330 | } | 330 | } |
331 | 331 | ||
332 | 332 | ||
333 | void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const | 333 | void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const |
334 | { | 334 | { |
335 | #if QT_VERSION >= 300 | 335 | #if QT_VERSION >= 300 |
336 | QStyle::SFlags flags = QStyle::Style_Default; | 336 | QStyle::SFlags flags = QStyle::Style_Default; |
337 | if ( selected ) | 337 | if ( selected ) |
338 | flags |= QStyle::Style_Selected; | 338 | flags |= QStyle::Style_Selected; |
339 | style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), | 339 | style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), |
340 | colorGroup(), flags, QStyleOption(t) ); | 340 | colorGroup(), flags, QStyleOption(t) ); |
341 | #else | 341 | #else |
342 | style().drawTab( p, this, t, selected ); | 342 | style().drawTab( p, this, t, selected ); |
343 | #endif | 343 | #endif |
344 | 344 | ||
345 | QRect r( t->rect() ); | 345 | QRect r( t->rect() ); |
346 | QFont f( font() ); | 346 | QFont f( font() ); |
347 | if ( selected ) | 347 | if ( selected ) |
348 | f.setBold( TRUE ); | 348 | f.setBold( TRUE ); |
349 | p->setFont( f ); | 349 | p->setFont( f ); |
350 | 350 | ||
351 | int iw = 0; | 351 | int iw = 0; |
352 | int ih = 0; | 352 | int ih = 0; |
353 | if ( t->iconSet() != 0 ) { | 353 | if ( t->iconSet() != 0 ) { |
354 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; | 354 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; |
355 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 355 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
356 | } | 356 | } |
357 | int w = iw + p->fontMetrics().width( t->text() ) + 4; | 357 | int w = iw + p->fontMetrics().width( t->text() ) + 4; |
358 | int h = QMAX(p->fontMetrics().height() + 4, ih ); | 358 | int h = QMAX(p->fontMetrics().height() + 4, ih ); |
359 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, | 359 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, |
360 | r.top() + (r.height()-h)/2, w, h ), t, | 360 | r.top() + (r.height()-h)/2, w, h ), t, |
361 | #if QT_VERSION >= 300 | 361 | #if QT_VERSION >= 300 |
362 | t->identifier() == keyboardFocusTab() | 362 | t->identifier() == keyboardFocusTab() |
363 | #else | 363 | #else |
364 | t->identitifer() == keyboardFocusTab() | 364 | t->identitifer() == keyboardFocusTab() |
365 | #endif | 365 | #endif |
366 | ); | 366 | ); |
367 | } | 367 | } |
368 | 368 | ||
369 | 369 | ||
370 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, | 370 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, |
371 | QTab* t, bool has_focus ) const | 371 | QTab* t, bool has_focus ) const |
372 | { | 372 | { |
373 | QRect r = t->rect(); | 373 | QRect r = t->rect(); |
374 | // if ( t->id != currentTab() ) | 374 | // if ( t->id != currentTab() ) |
375 | //r.moveBy( 1, 1 ); | 375 | //r.moveBy( 1, 1 ); |
376 | // | 376 | // |
377 | if ( t->iconSet() ) { | 377 | if ( t->iconSet() ) { |
378 | // the tab has an iconset, draw it in the right mode | 378 | // the tab has an iconset, draw it in the right mode |
379 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; | 379 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; |
380 | if ( mode == QIconSet::Normal && has_focus ) | 380 | if ( mode == QIconSet::Normal && has_focus ) |
381 | mode = QIconSet::Active; | 381 | mode = QIconSet::Active; |
382 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); | 382 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); |
383 | int pixw = pixmap.width(); | 383 | int pixw = pixmap.width(); |
384 | int pixh = pixmap.height(); | 384 | int pixh = pixmap.height(); |
385 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); | 385 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); |
386 | r.setLeft( r.left() + pixw + 5 ); | 386 | r.setLeft( r.left() + pixw + 5 ); |
387 | } | 387 | } |
388 | 388 | ||
389 | QRect tr = r; | 389 | QRect tr = r; |
390 | 390 | ||
391 | if ( r.width() < 20 ) | 391 | if ( r.width() < 20 ) |
392 | return; | 392 | return; |
393 | 393 | ||
394 | if ( t->isEnabled() && isEnabled() ) { | 394 | if ( t->isEnabled() && isEnabled() ) { |
395 | #if defined(_WS_WIN32_) | 395 | #if defined(_WS_WIN32_) |
396 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) | 396 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) |
397 | p->setPen( colorGroup().buttonText() ); | 397 | p->setPen( colorGroup().buttonText() ); |
398 | else | 398 | else |
399 | p->setPen( colorGroup().foreground() ); | 399 | p->setPen( colorGroup().foreground() ); |
400 | #else | 400 | #else |
401 | p->setPen( colorGroup().foreground() ); | 401 | p->setPen( colorGroup().foreground() ); |
402 | #endif | 402 | #endif |
403 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 403 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
404 | } else { | 404 | } else { |
405 | p->setPen( palette().disabled().foreground() ); | 405 | p->setPen( palette().disabled().foreground() ); |
406 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 406 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
407 | } | 407 | } |
408 | } | 408 | } |
409 | 409 | ||
410 | //--------------------------------------------------------------------------- | 410 | //--------------------------------------------------------------------------- |
411 | 411 | ||
412 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) | 412 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) |
413 | : QMainWindow( parent, name, fl ) | 413 | : QMainWindow( parent, name, fl ) |
414 | { | 414 | { |
415 | setCaption( tr("Launcher") ); | 415 | setCaption( tr("Launcher") ); |
416 | 416 | ||
417 | syncDialog = 0; | 417 | syncDialog = 0; |
418 | 418 | ||
419 | // we have a pretty good idea how big we'll be | 419 | // we have a pretty good idea how big we'll be |
420 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); | 420 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); |
421 | 421 | ||
422 | tabs = 0; | 422 | tabs = 0; |
423 | rootFolder = 0; | 423 | rootFolder = 0; |
424 | docsFolder = 0; | 424 | docsFolder = 0; |
425 | m_timeStamp = QDateTime::currentDateTime().toString(); | 425 | m_timeStamp = QDateTime::currentDateTime().toString(); |
426 | 426 | ||
427 | tabs = new CategoryTabWidget( this ); | 427 | tabs = new CategoryTabWidget( this ); |
428 | tabs->setMaximumWidth( qApp->desktop()->width() ); | 428 | tabs->setMaximumWidth( qApp->desktop()->width() ); |
429 | setCentralWidget( tabs ); | 429 | setCentralWidget( tabs ); |
430 | 430 | ||
431 | connect( tabs, SIGNAL(selected(const QString&)), | 431 | connect( tabs, SIGNAL(selected(const QString&)), |
432 | this, SLOT(viewSelected(const QString&)) ); | 432 | this, SLOT(viewSelected(const QString&)) ); |
433 | connect( tabs, SIGNAL(clicked(const AppLnk*)), | 433 | connect( tabs, SIGNAL(clicked(const AppLnk*)), |
434 | this, SLOT(select(const AppLnk*))); | 434 | this, SLOT(select(const AppLnk*))); |
435 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), | 435 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), |
436 | this, SLOT(properties(AppLnk*))); | 436 | this, SLOT(properties(AppLnk*))); |
437 | 437 | ||
438 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 438 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
439 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 439 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
440 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 440 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
441 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); | 441 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); |
442 | #endif | 442 | #endif |
443 | 443 | ||
444 | storage = new StorageInfo( this ); | 444 | storage = new StorageInfo( this ); |
445 | connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); | 445 | connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); |
446 | 446 | ||
447 | updateTabs(); | 447 | updateTabs(); |
448 | 448 | ||
449 | preloadApps(); | 449 | preloadApps(); |
450 | 450 | ||
451 | in_lnk_props = FALSE; | 451 | in_lnk_props = FALSE; |
452 | got_lnk_change = FALSE; | 452 | got_lnk_change = FALSE; |
453 | } | 453 | } |
454 | 454 | ||
455 | Launcher::~Launcher() | 455 | Launcher::~Launcher() |
456 | { | 456 | { |
457 | } | 457 | } |
458 | 458 | ||
459 | static bool isVisibleWindow(int wid) | 459 | static bool isVisibleWindow(int wid) |
460 | { | 460 | { |
461 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 461 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
462 | QWSWindow* w; | 462 | QWSWindow* w; |
463 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 463 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
464 | if ( w->winId() == wid ) | 464 | if ( w->winId() == wid ) |
465 | return !w->isFullyObscured(); | 465 | return !w->isFullyObscured(); |
466 | } | 466 | } |
467 | return FALSE; | 467 | return FALSE; |
468 | } | 468 | } |
469 | 469 | ||
470 | void Launcher::showMaximized() | 470 | void Launcher::showMaximized() |
471 | { | 471 | { |
472 | if ( isVisibleWindow( winId() ) ) | 472 | if ( isVisibleWindow( winId() ) ) |
473 | doMaximize(); | 473 | doMaximize(); |
474 | else | 474 | else |
475 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); | 475 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); |
476 | } | 476 | } |
477 | 477 | ||
478 | void Launcher::doMaximize() | 478 | void Launcher::doMaximize() |
479 | { | 479 | { |
480 | QMainWindow::showMaximized(); | 480 | QMainWindow::showMaximized(); |
481 | } | 481 | } |
482 | 482 | ||
483 | void Launcher::updateMimeTypes() | 483 | void Launcher::updateMimeTypes() |
484 | { | 484 | { |
485 | MimeType::clear(); | 485 | MimeType::clear(); |
486 | updateMimeTypes(rootFolder); | 486 | updateMimeTypes(rootFolder); |
487 | } | 487 | } |
488 | 488 | ||
489 | void Launcher::updateMimeTypes(AppLnkSet* folder) | 489 | void Launcher::updateMimeTypes(AppLnkSet* folder) |
490 | { | 490 | { |
491 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { | 491 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { |
492 | AppLnk *app = it.current(); | 492 | AppLnk *app = it.current(); |
493 | if ( app->type() == "Folder" ) | 493 | if ( app->type() == "Folder" ) |
494 | updateMimeTypes((AppLnkSet *)app); | 494 | updateMimeTypes((AppLnkSet *)app); |
495 | else { | 495 | else { |
496 | MimeType::registerApp(*app); | 496 | MimeType::registerApp(*app); |
497 | } | 497 | } |
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: | 501 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: |
502 | { | 502 | { |
503 | delete docsFolder; | 503 | delete docsFolder; |
504 | docsFolder = new DocLnkSet; | 504 | docsFolder = new DocLnkSet; |
505 | // find out wich filesystems are new in this round | 505 | // find out wich filesystems are new in this round |
506 | // We will do this by having a timestamp inside each mountpoint | 506 | // We will do this by having a timestamp inside each mountpoint |
507 | // if the current timestamp doesn't match this is a new file system and | 507 | // if the current timestamp doesn't match this is a new file system and |
508 | // come up with our MediumMountGui :) let the hacking begin | 508 | // come up with our MediumMountGui :) let the hacking begin |
509 | QString newStamp = QDateTime::currentDateTime().toString(); | 509 | QString newStamp = QDateTime::currentDateTime().toString(); |
510 | StorageInfo storage; | 510 | StorageInfo storage; |
511 | const QList<FileSystem> &fileSystems = storage.fileSystems(); | 511 | const QList<FileSystem> &fileSystems = storage.fileSystems(); |
512 | QListIterator<FileSystem> it ( fileSystems ); | 512 | QListIterator<FileSystem> it ( fileSystems ); |
513 | for ( ; it.current(); ++it ) { | 513 | for ( ; it.current(); ++it ) { |
514 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it | 514 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it |
515 | OConfig cfg( (*it)->path() + "/.opiestorage.cf"); | 515 | OConfig cfg( (*it)->path() + "/.opiestorage.cf"); |
516 | cfg.setGroup("main"); | 516 | cfg.setGroup("main"); |
517 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); | 517 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); |
518 | if( stamp == m_timeStamp ){ // ok we know this card | 518 | if( stamp == m_timeStamp ){ // ok we know this card |
519 | cfg.writeEntry("timestamp", newStamp ); | 519 | cfg.writeEntry("timestamp", newStamp ); |
520 | // we need to scan the list now. Hopefully the cache will be there | 520 | // we need to scan the list now. Hopefully the cache will be there |
521 | }else{ // come up with the gui | 521 | }else{ // come up with the gui |
522 | MediumMountGui medium((*it)->path() + "/.opiestorage.cf" ); | 522 | MediumMountGui medium((*it)->path() + "/.opiestorage.cf" ); |
523 | if( medium.check() ){ | 523 | if( medium.check() ){ |
524 | if( medium.exec() ){ //ok | 524 | if( medium.exec() ){ //ok |
525 | // speicher | 525 | // speicher |
526 | cfg.writeEntry("timestamp", newStamp ); | ||
526 | } | 527 | } |
527 | }else{ | 528 | }else{ |
528 | // do something different see what we need to do | 529 | // do something different see what we need to do |
529 | } | 530 | } |
530 | } | 531 | } |
531 | } | 532 | } |
532 | } | 533 | } |
533 | Global::findDocuments(docsFolder); // get rid of this call later | 534 | Global::findDocuments(docsFolder); // get rid of this call later |
534 | m_timeStamp = newStamp; | 535 | m_timeStamp = newStamp; |
535 | } | 536 | } |
536 | 537 | ||
537 | void Launcher::updateTabs() | 538 | void Launcher::updateTabs() |
538 | { | 539 | { |
539 | MimeType::updateApplications(); // ### reads all applnks twice | 540 | MimeType::updateApplications(); // ### reads all applnks twice |
540 | 541 | ||
541 | delete rootFolder; | 542 | delete rootFolder; |
542 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); | 543 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); |
543 | 544 | ||
544 | loadDocs(); | 545 | loadDocs(); |
545 | 546 | ||
546 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); | 547 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); |
547 | } | 548 | } |
548 | 549 | ||
549 | void Launcher::updateDocs() | 550 | void Launcher::updateDocs() |
550 | { | 551 | { |
551 | loadDocs(); | 552 | loadDocs(); |
552 | tabs->updateDocs(docsFolder,storage->fileSystems()); | 553 | tabs->updateDocs(docsFolder,storage->fileSystems()); |
553 | } | 554 | } |
554 | 555 | ||
555 | void Launcher::viewSelected(const QString& s) | 556 | void Launcher::viewSelected(const QString& s) |
556 | { | 557 | { |
557 | setCaption( s + tr(" - Launcher") ); | 558 | setCaption( s + tr(" - Launcher") ); |
558 | } | 559 | } |
559 | 560 | ||
560 | void Launcher::nextView() | 561 | void Launcher::nextView() |
561 | { | 562 | { |
562 | tabs->nextTab(); | 563 | tabs->nextTab(); |
563 | } | 564 | } |
564 | 565 | ||
565 | 566 | ||
566 | void Launcher::select( const AppLnk *appLnk ) | 567 | void Launcher::select( const AppLnk *appLnk ) |
567 | { | 568 | { |
568 | if ( appLnk->type() == "Folder" ) { | 569 | if ( appLnk->type() == "Folder" ) { |
569 | // Not supported: flat is simpler for the user | 570 | // Not supported: flat is simpler for the user |
570 | } else { | 571 | } else { |
571 | if ( appLnk->exec().isNull() ) { | 572 | if ( appLnk->exec().isNull() ) { |
572 | QMessageBox::information(this,tr("No application"), | 573 | QMessageBox::information(this,tr("No application"), |
573 | tr("<p>No application is defined for this document." | 574 | tr("<p>No application is defined for this document." |
574 | "<p>Type is %1.").arg(appLnk->type())); | 575 | "<p>Type is %1.").arg(appLnk->type())); |
575 | return; | 576 | return; |
576 | } | 577 | } |
577 | tabs->setBusy(TRUE); | 578 | tabs->setBusy(TRUE); |
578 | emit executing( appLnk ); | 579 | emit executing( appLnk ); |
579 | appLnk->execute(); | 580 | appLnk->execute(); |
580 | } | 581 | } |
581 | } | 582 | } |
582 | 583 | ||
583 | void Launcher::externalSelected(const AppLnk *appLnk) | 584 | void Launcher::externalSelected(const AppLnk *appLnk) |
584 | { | 585 | { |
585 | tabs->setBusy(TRUE); | 586 | tabs->setBusy(TRUE); |
586 | emit executing( appLnk ); | 587 | emit executing( appLnk ); |
587 | } | 588 | } |
588 | 589 | ||
589 | void Launcher::properties( AppLnk *appLnk ) | 590 | void Launcher::properties( AppLnk *appLnk ) |
590 | { | 591 | { |
591 | if ( appLnk->type() == "Folder" ) { | 592 | if ( appLnk->type() == "Folder" ) { |
592 | // Not supported: flat is simpler for the user | 593 | // Not supported: flat is simpler for the user |
593 | } else { | 594 | } else { |
594 | in_lnk_props = TRUE; | 595 | in_lnk_props = TRUE; |
595 | got_lnk_change = FALSE; | 596 | got_lnk_change = FALSE; |
596 | LnkProperties prop(appLnk); | 597 | LnkProperties prop(appLnk); |
597 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 598 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
598 | prop.showMaximized(); | 599 | prop.showMaximized(); |
599 | prop.exec(); | 600 | prop.exec(); |
600 | in_lnk_props = FALSE; | 601 | in_lnk_props = FALSE; |
601 | if ( got_lnk_change ) { | 602 | if ( got_lnk_change ) { |
602 | updateLink(lnk_change); | 603 | updateLink(lnk_change); |
603 | } | 604 | } |
604 | } | 605 | } |
605 | } | 606 | } |
606 | 607 | ||
607 | void Launcher::updateLink(const QString& link) | 608 | void Launcher::updateLink(const QString& link) |
608 | { | 609 | { |
609 | if (link.isNull()) | 610 | if (link.isNull()) |
610 | updateTabs(); | 611 | updateTabs(); |
611 | else if (link.isEmpty()) | 612 | else if (link.isEmpty()) |
612 | updateDocs(); | 613 | updateDocs(); |
613 | else | 614 | else |
614 | tabs->updateLink(link); | 615 | tabs->updateLink(link); |
615 | } | 616 | } |
616 | 617 | ||
617 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | 618 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) |
618 | { | 619 | { |
619 | QDataStream stream( data, IO_ReadOnly ); | 620 | QDataStream stream( data, IO_ReadOnly ); |
620 | if ( msg == "linkChanged(QString)" ) { | 621 | if ( msg == "linkChanged(QString)" ) { |
621 | QString link; | 622 | QString link; |
622 | stream >> link; | 623 | stream >> link; |
623 | if ( in_lnk_props ) { | 624 | if ( in_lnk_props ) { |
624 | got_lnk_change = TRUE; | 625 | got_lnk_change = TRUE; |
625 | lnk_change = link; | 626 | lnk_change = link; |
626 | } else { | 627 | } else { |
627 | updateLink(link); | 628 | updateLink(link); |
628 | } | 629 | } |
629 | } else if ( msg == "busy()" ) { | 630 | } else if ( msg == "busy()" ) { |
630 | emit busy(); | 631 | emit busy(); |
631 | } else if ( msg == "notBusy(QString)" ) { | 632 | } else if ( msg == "notBusy(QString)" ) { |
632 | QString app; | 633 | QString app; |
633 | stream >> app; | 634 | stream >> app; |
634 | tabs->setBusy(FALSE); | 635 | tabs->setBusy(FALSE); |
635 | emit notBusy(app); | 636 | emit notBusy(app); |
636 | } else if ( msg == "mkdir(QString)" ) { | 637 | } else if ( msg == "mkdir(QString)" ) { |
637 | QString dir; | 638 | QString dir; |
638 | stream >> dir; | 639 | stream >> dir; |
639 | if ( !dir.isEmpty() ) | 640 | if ( !dir.isEmpty() ) |
640 | mkdir( dir ); | 641 | mkdir( dir ); |
641 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { | 642 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
642 | QString baseFile, sigFile; | 643 | QString baseFile, sigFile; |
643 | stream >> baseFile >> sigFile; | 644 | stream >> baseFile >> sigFile; |
644 | QRsync::generateSignature( baseFile, sigFile ); | 645 | QRsync::generateSignature( baseFile, sigFile ); |
645 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | 646 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
646 | QString baseFile, sigFile, deltaFile; | 647 | QString baseFile, sigFile, deltaFile; |
647 | stream >> baseFile >> sigFile >> deltaFile; | 648 | stream >> baseFile >> sigFile >> deltaFile; |
648 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 649 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
649 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { | 650 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
650 | QString baseFile, deltaFile; | 651 | QString baseFile, deltaFile; |
651 | stream >> baseFile >> deltaFile; | 652 | stream >> baseFile >> deltaFile; |
652 | if ( !QFile::exists( baseFile ) ) { | 653 | if ( !QFile::exists( baseFile ) ) { |
653 | QFile f( baseFile ); | 654 | QFile f( baseFile ); |
654 | f.open( IO_WriteOnly ); | 655 | f.open( IO_WriteOnly ); |
655 | f.close(); | 656 | f.close(); |
656 | } | 657 | } |
657 | QRsync::applyDiff( baseFile, deltaFile ); | 658 | QRsync::applyDiff( baseFile, deltaFile ); |
658 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 659 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
659 | e << baseFile; | 660 | e << baseFile; |
660 | } else if ( msg == "rdiffCleanup()" ) { | 661 | } else if ( msg == "rdiffCleanup()" ) { |
661 | mkdir( "/tmp/rdiff" ); | 662 | mkdir( "/tmp/rdiff" ); |
662 | QDir dir; | 663 | QDir dir; |
663 | dir.setPath( "/tmp/rdiff" ); | 664 | dir.setPath( "/tmp/rdiff" ); |
664 | QStringList entries = dir.entryList(); | 665 | QStringList entries = dir.entryList(); |
665 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 666 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
666 | dir.remove( *it ); | 667 | dir.remove( *it ); |
667 | } else if ( msg == "sendHandshakeInfo()" ) { | 668 | } else if ( msg == "sendHandshakeInfo()" ) { |
668 | QString home = getenv( "HOME" ); | 669 | QString home = getenv( "HOME" ); |
669 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 670 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
670 | e << home; | 671 | e << home; |
671 | int locked = (int) Desktop::screenLocked(); | 672 | int locked = (int) Desktop::screenLocked(); |
672 | e << locked; | 673 | e << locked; |
673 | // register an app for autostart | 674 | // register an app for autostart |
674 | // if clear is send the list is cleared. | 675 | // if clear is send the list is cleared. |
675 | } else if ( msg == "autoStart(QString)" ) { | 676 | } else if ( msg == "autoStart(QString)" ) { |
676 | QString appName; | 677 | QString appName; |
677 | stream >> appName; | 678 | stream >> appName; |
678 | Config cfg( "autostart" ); | 679 | Config cfg( "autostart" ); |
679 | cfg.setGroup( "AutoStart" ); | 680 | cfg.setGroup( "AutoStart" ); |
680 | if ( appName.compare("clear") == 0){ | 681 | if ( appName.compare("clear") == 0){ |
681 | cfg.writeEntry("Apps", ""); | 682 | cfg.writeEntry("Apps", ""); |
682 | } | 683 | } |
683 | } else if ( msg == "autoStart(QString,QString)" ) { | 684 | } else if ( msg == "autoStart(QString,QString)" ) { |
684 | QString modifier, appName; | 685 | QString modifier, appName; |
685 | stream >> modifier >> appName; | 686 | stream >> modifier >> appName; |
686 | Config cfg( "autostart" ); | 687 | Config cfg( "autostart" ); |
687 | cfg.setGroup( "AutoStart" ); | 688 | cfg.setGroup( "AutoStart" ); |
688 | if ( modifier.compare("add") == 0 ){ | 689 | if ( modifier.compare("add") == 0 ){ |
689 | // only add it appname is entered | 690 | // only add it appname is entered |
690 | if (!appName.isEmpty()) { | 691 | if (!appName.isEmpty()) { |
691 | cfg.writeEntry("Apps", appName); | 692 | cfg.writeEntry("Apps", appName); |
692 | } | 693 | } |
693 | } else if (modifier.compare("remove") == 0 ) { | 694 | } else if (modifier.compare("remove") == 0 ) { |
694 | // need to change for multiple entries | 695 | // need to change for multiple entries |
695 | // actually remove is right now simular to clear, but in future there | 696 | // actually remove is right now simular to clear, but in future there |
696 | // should be multiple apps in autostart possible. | 697 | // should be multiple apps in autostart possible. |
697 | QString checkName; | 698 | QString checkName; |
698 | checkName = cfg.readEntry("Apps", ""); | 699 | checkName = cfg.readEntry("Apps", ""); |
699 | if (checkName == appName) { | 700 | if (checkName == appName) { |
700 | cfg.writeEntry("Apps", ""); | 701 | cfg.writeEntry("Apps", ""); |
701 | } | 702 | } |
702 | } | 703 | } |
703 | } else if ( msg == "sendCardInfo()" ) { | 704 | } else if ( msg == "sendCardInfo()" ) { |
704 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 705 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
705 | const QList<FileSystem> &fs = storage->fileSystems(); | 706 | const QList<FileSystem> &fs = storage->fileSystems(); |
706 | QListIterator<FileSystem> it ( fs ); | 707 | QListIterator<FileSystem> it ( fs ); |
707 | QString s; | 708 | QString s; |
708 | QString homeDir = getenv("HOME"); | 709 | QString homeDir = getenv("HOME"); |
709 | QString hardDiskHome; | 710 | QString hardDiskHome; |
710 | for ( ; it.current(); ++it ) { | 711 | for ( ; it.current(); ++it ) { |
711 | if ( (*it)->isRemovable() ) | 712 | if ( (*it)->isRemovable() ) |
712 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " | 713 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " |
713 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 714 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
714 | + " " + (*it)->options() + ";"; | 715 | + " " + (*it)->options() + ";"; |
715 | else if ( (*it)->disk() == "/dev/mtdblock1" || | 716 | else if ( (*it)->disk() == "/dev/mtdblock1" || |
716 | (*it)->disk() == "/dev/mtdblock/1" ) | 717 | (*it)->disk() == "/dev/mtdblock/1" ) |
717 | s += (*it)->name() + "=" + homeDir + "/Documents " | 718 | s += (*it)->name() + "=" + homeDir + "/Documents " |
718 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 719 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
719 | + " " + (*it)->options() + ";"; | 720 | + " " + (*it)->options() + ";"; |
720 | else if ( (*it)->name().contains( "Hard Disk") && | 721 | else if ( (*it)->name().contains( "Hard Disk") && |
721 | homeDir.contains( (*it)->path() ) && | 722 | homeDir.contains( (*it)->path() ) && |
722 | (*it)->path().length() > hardDiskHome.length() ) | 723 | (*it)->path().length() > hardDiskHome.length() ) |
723 | hardDiskHome = | 724 | hardDiskHome = |
724 | (*it)->name() + "=" + homeDir + "/Documents " | 725 | (*it)->name() + "=" + homeDir + "/Documents " |
725 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 726 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
726 | + " " + (*it)->options() + ";"; | 727 | + " " + (*it)->options() + ";"; |
727 | } | 728 | } |
728 | if ( !hardDiskHome.isEmpty() ) | 729 | if ( !hardDiskHome.isEmpty() ) |
729 | s += hardDiskHome; | 730 | s += hardDiskHome; |
730 | 731 | ||
731 | e << s; | 732 | e << s; |
732 | } else if ( msg == "sendSyncDate(QString)" ) { | 733 | } else if ( msg == "sendSyncDate(QString)" ) { |
733 | QString app; | 734 | QString app; |
734 | stream >> app; | 735 | stream >> app; |
735 | Config cfg( "qpe" ); | 736 | Config cfg( "qpe" ); |
736 | cfg.setGroup("SyncDate"); | 737 | cfg.setGroup("SyncDate"); |
737 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); | 738 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); |
738 | e << app << cfg.readEntry( app ); | 739 | e << app << cfg.readEntry( app ); |
739 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), | 740 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), |
740 | //cfg.readEntry( app ).latin1() ); | 741 | //cfg.readEntry( app ).latin1() ); |
741 | } else if ( msg == "setSyncDate(QString,QString)" ) { | 742 | } else if ( msg == "setSyncDate(QString,QString)" ) { |
742 | QString app, date; | 743 | QString app, date; |
743 | stream >> app >> date; | 744 | stream >> app >> date; |
744 | Config cfg( "qpe" ); | 745 | Config cfg( "qpe" ); |
745 | cfg.setGroup("SyncDate"); | 746 | cfg.setGroup("SyncDate"); |
746 | cfg.writeEntry( app, date ); | 747 | cfg.writeEntry( app, date ); |
747 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); | 748 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); |
748 | } else if ( msg == "startSync(QString)" ) { | 749 | } else if ( msg == "startSync(QString)" ) { |
749 | QString what; | 750 | QString what; |
750 | stream >> what; | 751 | stream >> what; |
751 | delete syncDialog; syncDialog = 0; | 752 | delete syncDialog; syncDialog = 0; |
752 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, | 753 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, |
753 | WStyle_Tool | WStyle_Customize | | 754 | WStyle_Tool | WStyle_Customize | |
754 | Qt::WStyle_StaysOnTop ); | 755 | Qt::WStyle_StaysOnTop ); |
755 | syncDialog->showMaximized(); | 756 | syncDialog->showMaximized(); |
756 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); | 757 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); |
757 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), | 758 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), |
758 | SLOT( cancelSync() ) ); | 759 | SLOT( cancelSync() ) ); |
759 | } | 760 | } |
760 | else if ( msg == "stopSync()") { | 761 | else if ( msg == "stopSync()") { |
761 | delete syncDialog; syncDialog = 0; | 762 | delete syncDialog; syncDialog = 0; |
762 | } else if ( msg == "getAllDocLinks()" ) { | 763 | } else if ( msg == "getAllDocLinks()" ) { |
763 | loadDocs(); | 764 | loadDocs(); |
764 | 765 | ||
765 | QString contents; | 766 | QString contents; |
766 | 767 | ||
767 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { | 768 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { |
768 | DocLnk *doc = it.current(); | 769 | DocLnk *doc = it.current(); |
769 | QFileInfo fi( doc->file() ); | 770 | QFileInfo fi( doc->file() ); |
770 | if ( !fi.exists() ) | 771 | if ( !fi.exists() ) |
771 | continue; | 772 | continue; |
772 | 773 | ||
773 | bool fake = !doc->linkFileKnown(); | 774 | bool fake = !doc->linkFileKnown(); |
774 | if ( !fake ) { | 775 | if ( !fake ) { |
775 | QFile f( doc->linkFile() ); | 776 | QFile f( doc->linkFile() ); |
776 | if ( f.open( IO_ReadOnly ) ) { | 777 | if ( f.open( IO_ReadOnly ) ) { |
777 | QTextStream ts( &f ); | 778 | QTextStream ts( &f ); |
778 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 779 | ts.setEncoding( QTextStream::UnicodeUTF8 ); |
779 | contents += ts.read(); | 780 | contents += ts.read(); |
780 | f.close(); | 781 | f.close(); |
781 | } else | 782 | } else |
782 | fake = TRUE; | 783 | fake = TRUE; |
783 | } | 784 | } |
784 | if (fake) { | 785 | if (fake) { |
785 | contents += "[Desktop Entry]\n"; | 786 | contents += "[Desktop Entry]\n"; |
786 | contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; | 787 | contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; |
787 | contents += "File = "+doc->file()+"\n"; | 788 | contents += "File = "+doc->file()+"\n"; |
788 | contents += "Name = "+doc->name()+"\n"; | 789 | contents += "Name = "+doc->name()+"\n"; |
789 | contents += "Type = "+doc->type()+"\n"; | 790 | contents += "Type = "+doc->type()+"\n"; |
790 | } | 791 | } |
791 | contents += QString("Size = %1\n").arg( fi.size() ); | 792 | contents += QString("Size = %1\n").arg( fi.size() ); |
792 | } | 793 | } |
793 | 794 | ||
794 | //qDebug( "sending length %d", contents.length() ); | 795 | //qDebug( "sending length %d", contents.length() ); |
795 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); | 796 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); |
796 | e << contents; | 797 | e << contents; |
797 | 798 | ||
798 | qDebug( "================ \n\n%s\n\n===============", | 799 | qDebug( "================ \n\n%s\n\n===============", |
799 | contents.latin1() ); | 800 | contents.latin1() ); |
800 | 801 | ||
801 | delete docsFolder; | 802 | delete docsFolder; |
802 | docsFolder = 0; | 803 | docsFolder = 0; |
803 | } | 804 | } |
804 | } | 805 | } |
805 | 806 | ||
806 | void Launcher::cancelSync() | 807 | void Launcher::cancelSync() |
807 | { | 808 | { |
808 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); | 809 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); |
809 | } | 810 | } |
810 | 811 | ||
811 | void Launcher::storageChanged() | 812 | void Launcher::storageChanged() |
812 | { | 813 | { |
813 | if ( in_lnk_props ) { | 814 | if ( in_lnk_props ) { |
814 | got_lnk_change = TRUE; | 815 | got_lnk_change = TRUE; |
815 | lnk_change = ""; | 816 | lnk_change = ""; |
816 | } else { | 817 | } else { |
817 | updateDocs(); | 818 | updateDocs(); |
818 | } | 819 | } |
819 | } | 820 | } |
820 | 821 | ||
821 | 822 | ||
822 | bool Launcher::mkdir(const QString &localPath) | 823 | bool Launcher::mkdir(const QString &localPath) |
823 | { | 824 | { |
824 | QDir fullDir(localPath); | 825 | QDir fullDir(localPath); |
825 | if (fullDir.exists()) | 826 | if (fullDir.exists()) |
826 | return true; | 827 | return true; |
827 | 828 | ||
828 | // at this point the directory doesn't exist | 829 | // at this point the directory doesn't exist |
829 | // go through the directory tree and start creating the direcotories | 830 | // go through the directory tree and start creating the direcotories |
830 | // that don't exist; if we can't create the directories, return false | 831 | // that don't exist; if we can't create the directories, return false |
831 | 832 | ||
832 | QString dirSeps = "/"; | 833 | QString dirSeps = "/"; |
833 | int dirIndex = localPath.find(dirSeps); | 834 | int dirIndex = localPath.find(dirSeps); |
834 | QString checkedPath; | 835 | QString checkedPath; |
835 | 836 | ||
836 | // didn't find any seps; weird, use the cur dir instead | 837 | // didn't find any seps; weird, use the cur dir instead |
837 | if (dirIndex == -1) { | 838 | if (dirIndex == -1) { |
838 | //qDebug("No seperators found in path %s", localPath.latin1()); | 839 | //qDebug("No seperators found in path %s", localPath.latin1()); |
839 | checkedPath = QDir::currentDirPath(); | 840 | checkedPath = QDir::currentDirPath(); |
840 | } | 841 | } |
841 | 842 | ||
842 | while (checkedPath != localPath) { | 843 | while (checkedPath != localPath) { |
843 | // no more seperators found, use the local path | 844 | // no more seperators found, use the local path |
844 | if (dirIndex == -1) | 845 | if (dirIndex == -1) |
845 | checkedPath = localPath; | 846 | checkedPath = localPath; |
846 | else { | 847 | else { |
847 | // the next directory to check | 848 | // the next directory to check |
848 | checkedPath = localPath.left(dirIndex) + "/"; | 849 | checkedPath = localPath.left(dirIndex) + "/"; |
849 | // advance the iterator; the next dir seperator | 850 | // advance the iterator; the next dir seperator |
850 | dirIndex = localPath.find(dirSeps, dirIndex+1); | 851 | dirIndex = localPath.find(dirSeps, dirIndex+1); |
851 | } | 852 | } |
852 | 853 | ||
853 | QDir checkDir(checkedPath); | 854 | QDir checkDir(checkedPath); |
854 | if (!checkDir.exists()) { | 855 | if (!checkDir.exists()) { |
855 | //qDebug("mkdir making dir %s", checkedPath.latin1()); | 856 | //qDebug("mkdir making dir %s", checkedPath.latin1()); |
856 | 857 | ||
857 | if (!checkDir.mkdir(checkedPath)) { | 858 | if (!checkDir.mkdir(checkedPath)) { |
858 | qDebug("Unable to make directory %s", checkedPath.latin1()); | 859 | qDebug("Unable to make directory %s", checkedPath.latin1()); |
859 | return FALSE; | 860 | return FALSE; |
860 | } | 861 | } |
861 | } | 862 | } |
862 | 863 | ||
863 | } | 864 | } |
864 | return TRUE; | 865 | return TRUE; |
865 | } | 866 | } |
866 | 867 | ||
867 | void Launcher::preloadApps() | 868 | void Launcher::preloadApps() |
868 | { | 869 | { |
869 | Config cfg("Launcher"); | 870 | Config cfg("Launcher"); |
870 | cfg.setGroup("Preload"); | 871 | cfg.setGroup("Preload"); |
871 | QStringList apps = cfg.readListEntry("Apps",','); | 872 | QStringList apps = cfg.readListEntry("Apps",','); |
872 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { | 873 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { |
873 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | 874 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); |
874 | } | 875 | } |
875 | } | 876 | } |
diff --git a/core/launcher/launcher.h b/core/launcher/launcher.h index 00ae980..197bd19 100644 --- a/core/launcher/launcher.h +++ b/core/launcher/launcher.h | |||
@@ -1,136 +1,138 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LAUNCHER_H | 20 | #ifndef LAUNCHER_H |
21 | #define LAUNCHER_H | 21 | #define LAUNCHER_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qtabbar.h> | 24 | #include <qtabbar.h> |
25 | #include <qstringlist.h> | 25 | #include <qstringlist.h> |
26 | #include <qvbox.h> | 26 | #include <qvbox.h> |
27 | #include <qlist.h> | 27 | #include <qlist.h> |
28 | #include "launcherview.h" | 28 | #include "launcherview.h" |
29 | 29 | ||
30 | class AppLnk; | 30 | class AppLnk; |
31 | class AppLnkSet; | 31 | class AppLnkSet; |
32 | class DocLnkSet; | 32 | class DocLnkSet; |
33 | class QWidgetStack; | 33 | class QWidgetStack; |
34 | class StorageInfo; | 34 | class StorageInfo; |
35 | class SyncDialog; | 35 | class SyncDialog; |
36 | 36 | ||
37 | class CategoryTabBar : public QTabBar | 37 | class CategoryTabBar : public QTabBar |
38 | { | 38 | { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | public: | 40 | public: |
41 | CategoryTabBar( QWidget *parent=0, const char *name=0 ); | 41 | CategoryTabBar( QWidget *parent=0, const char *name=0 ); |
42 | ~CategoryTabBar(); | 42 | ~CategoryTabBar(); |
43 | 43 | ||
44 | protected slots: | 44 | protected slots: |
45 | virtual void layoutTabs(); | 45 | virtual void layoutTabs(); |
46 | 46 | ||
47 | protected: | 47 | protected: |
48 | void paint ( QPainter *p, QTab *t, bool f ) const; | 48 | void paint ( QPainter *p, QTab *t, bool f ) const; |
49 | void paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const; | 49 | void paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | class CategoryTabWidget : public QVBox { | 52 | class CategoryTabWidget : public QVBox { |
53 | // can't use a QTabWidget, since it won't let us set the frame style. | 53 | // can't use a QTabWidget, since it won't let us set the frame style. |
54 | Q_OBJECT | 54 | Q_OBJECT |
55 | public: | 55 | public: |
56 | CategoryTabWidget( QWidget* parent ); | 56 | CategoryTabWidget( QWidget* parent ); |
57 | void initializeCategories(AppLnkSet* rootFolder, AppLnkSet* docFolder, | 57 | void initializeCategories(AppLnkSet* rootFolder, AppLnkSet* docFolder, |
58 | const QList<FileSystem> &); | 58 | const QList<FileSystem> &); |
59 | void updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs); | 59 | void updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs); |
60 | void updateLink(const QString& linkfile); | 60 | void updateLink(const QString& linkfile); |
61 | void setBusy(bool on); | 61 | void setBusy(bool on); |
62 | 62 | ||
63 | signals: | 63 | signals: |
64 | void selected(const QString&); | 64 | void selected(const QString&); |
65 | void clicked(const AppLnk*); | 65 | void clicked(const AppLnk*); |
66 | void rightPressed(AppLnk*); | 66 | void rightPressed(AppLnk*); |
67 | 67 | ||
68 | public slots: | 68 | public slots: |
69 | void nextTab(); | 69 | void nextTab(); |
70 | void prevTab(); | 70 | void prevTab(); |
71 | 71 | ||
72 | protected: | 72 | protected: |
73 | void paletteChange( const QPalette &p ); | 73 | void paletteChange( const QPalette &p ); |
74 | 74 | ||
75 | private: | 75 | private: |
76 | CategoryTabBar* categoryBar; | 76 | CategoryTabBar* categoryBar; |
77 | QWidgetStack* stack; | 77 | QWidgetStack* stack; |
78 | LauncherView* docview; | 78 | LauncherView* docview; |
79 | QStringList ids; | 79 | QStringList ids; |
80 | int tabs; | 80 | int tabs; |
81 | LauncherView* newView( const QString&, const QPixmap& pm, const QString& label ); | 81 | LauncherView* newView( const QString&, const QPixmap& pm, const QString& label ); |
82 | void addItem( const QString& ); | 82 | void addItem( const QString& ); |
83 | }; | 83 | }; |
84 | 84 | ||
85 | class Launcher : public QMainWindow | 85 | class Launcher : public QMainWindow |
86 | { | 86 | { |
87 | Q_OBJECT | 87 | Q_OBJECT |
88 | friend class LauncherPrivate; | 88 | friend class LauncherPrivate; |
89 | public: | 89 | public: |
90 | Launcher( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 90 | Launcher( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
91 | ~Launcher(); | 91 | ~Launcher(); |
92 | 92 | ||
93 | static QString appsFolderName(); | 93 | static QString appsFolderName(); |
94 | 94 | ||
95 | virtual void showMaximized(); | 95 | virtual void showMaximized(); |
96 | static bool mkdir(const QString &path); | 96 | static bool mkdir(const QString &path); |
97 | 97 | ||
98 | public slots: | 98 | public slots: |
99 | void viewSelected(const QString&); | 99 | void viewSelected(const QString&); |
100 | void select( const AppLnk * ); | 100 | void select( const AppLnk * ); |
101 | void externalSelected( const AppLnk *); | 101 | void externalSelected( const AppLnk *); |
102 | void properties( AppLnk * ); | 102 | void properties( AppLnk * ); |
103 | void nextView(); | 103 | void nextView(); |
104 | 104 | ||
105 | signals: | 105 | signals: |
106 | void executing( const AppLnk * ); | 106 | void executing( const AppLnk * ); |
107 | void busy(); | 107 | void busy(); |
108 | void notBusy(const QString&); | 108 | void notBusy(const QString&); |
109 | 109 | ||
110 | private slots: | 110 | private slots: |
111 | void doMaximize(); | 111 | void doMaximize(); |
112 | void systemMessage( const QCString &, const QByteArray &); | 112 | void systemMessage( const QCString &, const QByteArray &); |
113 | void storageChanged(); | 113 | void storageChanged(); |
114 | void cancelSync(); | 114 | void cancelSync(); |
115 | 115 | ||
116 | private: | 116 | private: |
117 | void updateApps(); | 117 | void updateApps(); |
118 | void loadDocs(); | 118 | void loadDocs(); |
119 | void updateDocs(); | 119 | void updateDocs(); |
120 | void updateTabs(); | 120 | void updateTabs(); |
121 | void updateMimeTypes(); | 121 | void updateMimeTypes(); |
122 | void updateMimeTypes(AppLnkSet*); | 122 | void updateMimeTypes(AppLnkSet*); |
123 | void preloadApps(); | 123 | void preloadApps(); |
124 | AppLnkSet *rootFolder; | 124 | AppLnkSet *rootFolder; |
125 | DocLnkSet *docsFolder; | 125 | DocLnkSet *docsFolder; |
126 | CategoryTabWidget *tabs; | 126 | CategoryTabWidget *tabs; |
127 | StorageInfo *storage; | 127 | StorageInfo *storage; |
128 | SyncDialog *syncDialog; | 128 | SyncDialog *syncDialog; |
129 | 129 | ||
130 | void updateLink(const QString& link); | 130 | void updateLink(const QString& link); |
131 | bool in_lnk_props; | 131 | bool in_lnk_props; |
132 | bool got_lnk_change; | 132 | bool got_lnk_change; |
133 | QString lnk_change; | 133 | QString lnk_change; |
134 | QString m_timeStamp; | ||
134 | }; | 135 | }; |
135 | 136 | ||
136 | #endif // LAUNCHERVIEW_H | 137 | #endif // LAUNCHERVIEW_H |
138 | |||