summaryrefslogtreecommitdiff
authorzecke <zecke>2002-03-22 16:59:27 (UTC)
committer zecke <zecke>2002-03-22 16:59:27 (UTC)
commit966b7c4d3a691c59b428ffba34e6e3a0149e4698 (patch) (unidiff)
tree88854ce123cd1a7c7e3bb7241d4702f24518a62c
parentf6f0cd02ceec72a971616de253d736a94a730397 (diff)
downloadopie-966b7c4d3a691c59b428ffba34e6e3a0149e4698.zip
opie-966b7c4d3a691c59b428ffba34e6e3a0149e4698.tar.gz
opie-966b7c4d3a691c59b428ffba34e6e3a0149e4698.tar.bz2
make something kewl possible
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp39
1 files changed, 37 insertions, 2 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 8fe41f7..222592b 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -1,116 +1,121 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (c) 2002 Holger zecke Freyther
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 3** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 4**
4** This file is part of Qtopia Environment. 5** This file is part of Qtopia Environment.
5** 6**
6** This file may be distributed and/or modified under the terms of the 7** 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 8** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 10** packaging of this file.
10** 11**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12** 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. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 14**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 16**
16** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 18** not clear to you.
18** 19**
19**********************************************************************/ 20**********************************************************************/
20 21
21// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT 22// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT
22// have this class. 23// have this class.
23#define QTOPIA_INTERNAL_FSLP 24#define QTOPIA_INTERNAL_FSLP
24 25
26#include <opie/oconfig.h>
25#include <qpe/qcopenvelope_qws.h> 27#include <qpe/qcopenvelope_qws.h>
26#include <qpe/resource.h> 28#include <qpe/resource.h>
27#include <qpe/applnk.h> 29#include <qpe/applnk.h>
28#include <qpe/config.h> 30#include <qpe/config.h>
29#include <qpe/global.h> 31#include <qpe/global.h>
30#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
31#include <qpe/mimetype.h> 33#include <qpe/mimetype.h>
32#include <qpe/storage.h> 34#include <qpe/storage.h>
33#include <qpe/palmtoprecord.h> 35#include <qpe/palmtoprecord.h>
34 36
37#include <qdatetime.h>
35#include <qdir.h> 38#include <qdir.h>
36#include <qwindowsystem_qws.h> 39#include <qwindowsystem_qws.h>
37#include <qtimer.h> 40#include <qtimer.h>
38#include <qcombobox.h> 41#include <qcombobox.h>
39#include <qvbox.h> 42#include <qvbox.h>
40#include <qlayout.h> 43#include <qlayout.h>
41#include <qstyle.h> 44#include <qstyle.h>
42#include <qpushbutton.h> 45#include <qpushbutton.h>
43#include <qtabbar.h> 46#include <qtabbar.h>
44#include <qwidgetstack.h> 47#include <qwidgetstack.h>
45#include <qlayout.h> 48#include <qlayout.h>
46#include <qregexp.h> 49#include <qregexp.h>
47#include <qmessagebox.h> 50#include <qmessagebox.h>
48#include <qframe.h> 51#include <qframe.h>
49#include <qpainter.h> 52#include <qpainter.h>
50#include <qlabel.h> 53#include <qlabel.h>
51#include <qtextstream.h> 54#include <qtextstream.h>
52 55
53#include "launcherview.h" 56#include "launcherview.h"
54#include "launcher.h" 57#include "launcher.h"
55#include "syncdialog.h" 58#include "syncdialog.h"
56#include "desktop.h" 59#include "desktop.h"
57#include <qpe/lnkproperties.h> 60#include <qpe/lnkproperties.h>
58#include "mrulist.h" 61#include "mrulist.h"
59#include "qrsync.h" 62#include "qrsync.h"
60#include <stdlib.h> 63#include <stdlib.h>
61#include <unistd.h> 64#include <unistd.h>
62 65
63#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 66#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
64#include <stdio.h> 67#include <stdio.h>
65#include <sys/vfs.h> 68#include <sys/vfs.h>
66#include <mntent.h> 69#include <mntent.h>
67#endif 70#endif
68 71
72#include <qpe/storage.h>
73#include "mediummountgui.h"
69//#define SHOW_ALL 74//#define SHOW_ALL
70 75
71CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : 76CategoryTabWidget::CategoryTabWidget( QWidget* parent ) :
72 QVBox( parent ) 77 QVBox( parent )
73{ 78{
74 categoryBar = 0; 79 categoryBar = 0;
75 stack = 0; 80 stack = 0;
76} 81}
77 82
78void CategoryTabWidget::prevTab() 83void CategoryTabWidget::prevTab()
79{ 84{
80 if ( categoryBar ) { 85 if ( categoryBar ) {
81 int n = categoryBar->count(); 86 int n = categoryBar->count();
82 int tab = categoryBar->currentTab(); 87 int tab = categoryBar->currentTab();
83 if ( tab >= 0 ) 88 if ( tab >= 0 )
84 categoryBar->setCurrentTab( (tab - 1 + n)%n ); 89 categoryBar->setCurrentTab( (tab - 1 + n)%n );
85 } 90 }
86} 91}
87 92
88void CategoryTabWidget::nextTab() 93void CategoryTabWidget::nextTab()
89{ 94{
90 if ( categoryBar ) { 95 if ( categoryBar ) {
91 int n = categoryBar->count(); 96 int n = categoryBar->count();
92 int tab = categoryBar->currentTab(); 97 int tab = categoryBar->currentTab();
93 categoryBar->setCurrentTab( (tab + 1)%n ); 98 categoryBar->setCurrentTab( (tab + 1)%n );
94 } 99 }
95} 100}
96 101
97void CategoryTabWidget::addItem( const QString& linkfile ) 102void CategoryTabWidget::addItem( const QString& linkfile )
98{ 103{
99 int i=0; 104 int i=0;
100 AppLnk *app = new AppLnk(linkfile); 105 AppLnk *app = new AppLnk(linkfile);
101 if ( !app->isValid() ) { 106 if ( !app->isValid() ) {
102 delete app; 107 delete app;
103 return; 108 return;
104 } 109 }
105 if ( !app->file().isEmpty() ) { 110 if ( !app->file().isEmpty() ) {
106 // A document 111 // A document
107 delete app; 112 delete app;
108 app = new DocLnk(linkfile); 113 app = new DocLnk(linkfile);
109 ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); 114 ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app);
110 return; 115 return;
111 } 116 }
112 for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { 117 for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) {
113 if ( !(*it).isEmpty() ) { 118 if ( !(*it).isEmpty() ) {
114 QRegExp tf(*it,FALSE,TRUE); 119 QRegExp tf(*it,FALSE,TRUE);
115 if ( tf.match(app->type()) >= 0 ) { 120 if ( tf.match(app->type()) >= 0 ) {
116 ((LauncherView*)stack->widget(i))->addItem(app); 121 ((LauncherView*)stack->widget(i))->addItem(app);
@@ -372,176 +377,206 @@ void CategoryTabBar::paintLabel( QPainter* p, const QRect&,
372 if ( t->iconSet() ) { 377 if ( t->iconSet() ) {
373 // the tab has an iconset, draw it in the right mode 378 // the tab has an iconset, draw it in the right mode
374 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; 379 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled;
375 if ( mode == QIconSet::Normal && has_focus ) 380 if ( mode == QIconSet::Normal && has_focus )
376 mode = QIconSet::Active; 381 mode = QIconSet::Active;
377 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); 382 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode );
378 int pixw = pixmap.width(); 383 int pixw = pixmap.width();
379 int pixh = pixmap.height(); 384 int pixh = pixmap.height();
380 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 );
381 r.setLeft( r.left() + pixw + 5 ); 386 r.setLeft( r.left() + pixw + 5 );
382 } 387 }
383 388
384 QRect tr = r; 389 QRect tr = r;
385 390
386 if ( r.width() < 20 ) 391 if ( r.width() < 20 )
387 return; 392 return;
388 393
389 if ( t->isEnabled() && isEnabled() ) { 394 if ( t->isEnabled() && isEnabled() ) {
390#if defined(_WS_WIN32_) 395#if defined(_WS_WIN32_)
391 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) 396 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) )
392 p->setPen( colorGroup().buttonText() ); 397 p->setPen( colorGroup().buttonText() );
393 else 398 else
394 p->setPen( colorGroup().foreground() ); 399 p->setPen( colorGroup().foreground() );
395#else 400#else
396 p->setPen( colorGroup().foreground() ); 401 p->setPen( colorGroup().foreground() );
397#endif 402#endif
398 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 403 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
399 } else { 404 } else {
400 p->setPen( palette().disabled().foreground() ); 405 p->setPen( palette().disabled().foreground() );
401 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 406 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
402 } 407 }
403} 408}
404 409
405//--------------------------------------------------------------------------- 410//---------------------------------------------------------------------------
406 411
407Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) 412Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
408 : QMainWindow( parent, name, fl ) 413 : QMainWindow( parent, name, fl )
409{ 414{
410 setCaption( tr("Launcher") ); 415 setCaption( tr("Launcher") );
411 416
412 syncDialog = 0; 417 syncDialog = 0;
413 418
414 // we have a pretty good idea how big we'll be 419 // we have a pretty good idea how big we'll be
415 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); 420 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
416 421
417 tabs = 0; 422 tabs = 0;
418 rootFolder = 0; 423 rootFolder = 0;
419 docsFolder = 0; 424 docsFolder = 0;
425 m_timeStamp = QDateTime::currentDateTime().toString();
420 426
421 tabs = new CategoryTabWidget( this ); 427 tabs = new CategoryTabWidget( this );
422 tabs->setMaximumWidth( qApp->desktop()->width() ); 428 tabs->setMaximumWidth( qApp->desktop()->width() );
423 setCentralWidget( tabs ); 429 setCentralWidget( tabs );
424 430
425 connect( tabs, SIGNAL(selected(const QString&)), 431 connect( tabs, SIGNAL(selected(const QString&)),
426 this, SLOT(viewSelected(const QString&)) ); 432 this, SLOT(viewSelected(const QString&)) );
427 connect( tabs, SIGNAL(clicked(const AppLnk*)), 433 connect( tabs, SIGNAL(clicked(const AppLnk*)),
428 this, SLOT(select(const AppLnk*))); 434 this, SLOT(select(const AppLnk*)));
429 connect( tabs, SIGNAL(rightPressed(AppLnk*)), 435 connect( tabs, SIGNAL(rightPressed(AppLnk*)),
430 this, SLOT(properties(AppLnk*))); 436 this, SLOT(properties(AppLnk*)));
431 437
432#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 438#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
433 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 439 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
434 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 440 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
435 this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); 441 this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
436#endif 442#endif
437 443
438 storage = new StorageInfo( this ); 444 storage = new StorageInfo( this );
439 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); 445 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) );
440 446
441 updateTabs(); 447 updateTabs();
442 448
443 preloadApps(); 449 preloadApps();
444 450
445 in_lnk_props = FALSE; 451 in_lnk_props = FALSE;
446 got_lnk_change = FALSE; 452 got_lnk_change = FALSE;
447} 453}
448 454
449Launcher::~Launcher() 455Launcher::~Launcher()
450{ 456{
451} 457}
452 458
453static bool isVisibleWindow(int wid) 459static bool isVisibleWindow(int wid)
454{ 460{
455 const QList<QWSWindow> &list = qwsServer->clientWindows(); 461 const QList<QWSWindow> &list = qwsServer->clientWindows();
456 QWSWindow* w; 462 QWSWindow* w;
457 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 463 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
458 if ( w->winId() == wid ) 464 if ( w->winId() == wid )
459 return !w->isFullyObscured(); 465 return !w->isFullyObscured();
460 } 466 }
461 return FALSE; 467 return FALSE;
462} 468}
463 469
464void Launcher::showMaximized() 470void Launcher::showMaximized()
465{ 471{
466 if ( isVisibleWindow( winId() ) ) 472 if ( isVisibleWindow( winId() ) )
467 doMaximize(); 473 doMaximize();
468 else 474 else
469 QTimer::singleShot( 20, this, SLOT(doMaximize()) ); 475 QTimer::singleShot( 20, this, SLOT(doMaximize()) );
470} 476}
471 477
472void Launcher::doMaximize() 478void Launcher::doMaximize()
473{ 479{
474 QMainWindow::showMaximized(); 480 QMainWindow::showMaximized();
475} 481}
476 482
477void Launcher::updateMimeTypes() 483void Launcher::updateMimeTypes()
478{ 484{
479 MimeType::clear(); 485 MimeType::clear();
480 updateMimeTypes(rootFolder); 486 updateMimeTypes(rootFolder);
481} 487}
482 488
483void Launcher::updateMimeTypes(AppLnkSet* folder) 489void Launcher::updateMimeTypes(AppLnkSet* folder)
484{ 490{
485 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { 491 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) {
486 AppLnk *app = it.current(); 492 AppLnk *app = it.current();
487 if ( app->type() == "Folder" ) 493 if ( app->type() == "Folder" )
488 updateMimeTypes((AppLnkSet *)app); 494 updateMimeTypes((AppLnkSet *)app);
489 else { 495 else {
490 MimeType::registerApp(*app); 496 MimeType::registerApp(*app);
491 } 497 }
492 } 498 }
493} 499}
494 500
495void Launcher::loadDocs() 501void Launcher::loadDocs() // ok here comes a hack belonging to Global::
496{ 502{
497 delete docsFolder; 503 delete docsFolder;
498 docsFolder = new DocLnkSet; 504 docsFolder = new DocLnkSet;
499 Global::findDocuments(docsFolder); 505 // find out wich filesystems are new in this round
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
508 // come up with our MediumMountGui :) let the hacking begin
509 QString newStamp = QDateTime::currentDateTime().toString();
510 StorageInfo storage;
511 const QList<FileSystem> &fileSystems = storage.fileSystems();
512 QListIterator<FileSystem> it ( fileSystems );
513 for ( ; it.current(); ++it ) {
514 if ( (*it)->isRemovable() ) { // let's find out if we should search on it
515 OConfig cfg( (*it)->path() + "/.opiestorage.cf");
516 cfg.setGroup("main");
517 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() );
518 if( stamp == m_timeStamp ){ // ok we know this card
519 cfg.writeEntry("timestamp", newStamp );
520 // we need to scan the list now. Hopefully the cache will be there
521 }else{ // come up with the gui
522 MediumMountGui medium((*it)->path() + "/.opiestorage.cf" );
523 if( medium.check() ){
524 if( medium.exec() ){ //ok
525 // speicher
526 }
527 }else{
528 // do something different see what we need to do
529 }
530 }
531 }
532 }
533 Global::findDocuments(docsFolder); // get rid of this call later
534 m_timeStamp = newStamp;
500} 535}
501 536
502void Launcher::updateTabs() 537void Launcher::updateTabs()
503{ 538{
504 MimeType::updateApplications(); // ### reads all applnks twice 539 MimeType::updateApplications(); // ### reads all applnks twice
505 540
506 delete rootFolder; 541 delete rootFolder;
507 rootFolder = new AppLnkSet( MimeType::appsFolderName() ); 542 rootFolder = new AppLnkSet( MimeType::appsFolderName() );
508 543
509 loadDocs(); 544 loadDocs();
510 545
511 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); 546 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems());
512} 547}
513 548
514void Launcher::updateDocs() 549void Launcher::updateDocs()
515{ 550{
516 loadDocs(); 551 loadDocs();
517 tabs->updateDocs(docsFolder,storage->fileSystems()); 552 tabs->updateDocs(docsFolder,storage->fileSystems());
518} 553}
519 554
520void Launcher::viewSelected(const QString& s) 555void Launcher::viewSelected(const QString& s)
521{ 556{
522 setCaption( s + tr(" - Launcher") ); 557 setCaption( s + tr(" - Launcher") );
523} 558}
524 559
525void Launcher::nextView() 560void Launcher::nextView()
526{ 561{
527 tabs->nextTab(); 562 tabs->nextTab();
528} 563}
529 564
530 565
531void Launcher::select( const AppLnk *appLnk ) 566void Launcher::select( const AppLnk *appLnk )
532{ 567{
533 if ( appLnk->type() == "Folder" ) { 568 if ( appLnk->type() == "Folder" ) {
534 // Not supported: flat is simpler for the user 569 // Not supported: flat is simpler for the user
535 } else { 570 } else {
536 if ( appLnk->exec().isNull() ) { 571 if ( appLnk->exec().isNull() ) {
537 QMessageBox::information(this,tr("No application"), 572 QMessageBox::information(this,tr("No application"),
538 tr("<p>No application is defined for this document." 573 tr("<p>No application is defined for this document."
539 "<p>Type is %1.").arg(appLnk->type())); 574 "<p>Type is %1.").arg(appLnk->type()));
540 return; 575 return;
541 } 576 }
542 tabs->setBusy(TRUE); 577 tabs->setBusy(TRUE);
543 emit executing( appLnk ); 578 emit executing( appLnk );
544 appLnk->execute(); 579 appLnk->execute();
545 } 580 }
546} 581}
547 582