summaryrefslogtreecommitdiff
path: root/core
authorzecke <zecke>2002-03-25 20:17:29 (UTC)
committer zecke <zecke>2002-03-25 20:17:29 (UTC)
commitb001d834cd1259ea17fd1faf82111a1efdf607db (patch) (unidiff)
tree35da1df30a27e18837d317d949db234015cfdf32 /core
parent56f2a47633046a7b08fe59acfe646a648c006230 (diff)
downloadopie-b001d834cd1259ea17fd1faf82111a1efdf607db.zip
opie-b001d834cd1259ea17fd1faf82111a1efdf607db.tar.gz
opie-b001d834cd1259ea17fd1faf82111a1efdf607db.tar.bz2
- remove old Icons from the taskbar (only when you start a new app )
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp2
-rw-r--r--core/launcher/mrulist.cpp42
2 files changed, 38 insertions, 6 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index cf1a3c8..17a30e6 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -547,97 +547,97 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global::
547 tmp = new DocLnkSet( home , QString::null); 547 tmp = new DocLnkSet( home , QString::null);
548 docsFolder->appendFrom( *tmp ); 548 docsFolder->appendFrom( *tmp );
549 delete tmp; 549 delete tmp;
550 // find out wich filesystems are new in this round 550 // find out wich filesystems are new in this round
551 // We will do this by having a timestamp inside each mountpoint 551 // We will do this by having a timestamp inside each mountpoint
552 // if the current timestamp doesn't match this is a new file system and 552 // if the current timestamp doesn't match this is a new file system and
553 // come up with our MediumMountGui :) let the hacking begin 553 // come up with our MediumMountGui :) let the hacking begin
554 int stamp = uidgen.generate(); 554 int stamp = uidgen.generate();
555 555
556 QString newStamp = QString::number( stamp ); // generates newtime Stamp 556 QString newStamp = QString::number( stamp ); // generates newtime Stamp
557 StorageInfo storage; 557 StorageInfo storage;
558 const QList<FileSystem> &fileSystems = storage.fileSystems(); 558 const QList<FileSystem> &fileSystems = storage.fileSystems();
559 QListIterator<FileSystem> it ( fileSystems ); 559 QListIterator<FileSystem> it ( fileSystems );
560 for ( ; it.current(); ++it ) { 560 for ( ; it.current(); ++it ) {
561 if ( (*it)->isRemovable() ) { // let's find out if we should search on it 561 if ( (*it)->isRemovable() ) { // let's find out if we should search on it
562 qWarning("%s is removeable", (*it)->path().latin1() ); 562 qWarning("%s is removeable", (*it)->path().latin1() );
563 OConfig cfg( (*it)->path() + "/.opiestorage.cf"); 563 OConfig cfg( (*it)->path() + "/.opiestorage.cf");
564 cfg.setGroup("main"); 564 cfg.setGroup("main");
565 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); 565 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() );
566 if( stamp == m_timeStamp ){ // ok we know this card 566 if( stamp == m_timeStamp ){ // ok we know this card
567 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp 567 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp
568 // we need to scan the list now. Hopefully the cache will be there 568 // we need to scan the list now. Hopefully the cache will be there
569 // read the mimetypes from the config and search for documents 569 // read the mimetypes from the config and search for documents
570 QStringList mimetypes = configToMime( &cfg); 570 QStringList mimetypes = configToMime( &cfg);
571 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); 571 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") );
572 docsFolder->appendFrom( *tmp ); 572 docsFolder->appendFrom( *tmp );
573 delete tmp; 573 delete tmp;
574 574
575 }else{ // come up with the gui cause this a new card 575 }else{ // come up with the gui cause this a new card
576 MediumMountGui medium((*it)->path() ); 576 MediumMountGui medium((*it)->path() );
577 if( medium.check() ){ // we did not ask before or ask again is off 577 if( medium.check() ){ // we did not ask before or ask again is off
578 if( medium.exec() ){ // he clicked yes so search it 578 if( medium.exec() ){ // he clicked yes so search it
579 // speicher 579 // speicher
580 cfg.read(); // cause of a race we need to reread 580 cfg.read(); // cause of a race we need to reread
581 cfg.writeEntry("timestamp", newStamp ); 581 cfg.writeEntry("timestamp", newStamp );
582 }// no else 582 }// no else
583 }else{ // we checked 583 }else{ // we checked
584 // do something different see what we need to do 584 // do something different see what we need to do
585 // let's see if we should check the device 585 // let's see if we should check the device
586 cfg.setGroup("main" ); 586 cfg.setGroup("main" );
587 bool check = cfg.readBoolEntry("autocheck", true ); 587 bool check = cfg.readBoolEntry("autocheck", true );
588 if( check ){ // find the documents 588 if( check ){ // find the documents
589 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); 589 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") );
590 docsFolder->appendFrom( *tmp ); 590 docsFolder->appendFrom( *tmp );
591 delete tmp; 591 delete tmp;
592 } 592 }
593 } 593 }
594 } 594 }
595 } 595 }
596 } 596 }
597 m_timeStamp = newStamp; 597 m_timeStamp = newStamp;
598} 598}
599 599
600void Launcher::updateTabs() 600void Launcher::updateTabs()
601{ 601{
602 MimeType::updateApplications(); // ### reads all applnks twice 602 MimeType::updateApplications(); // ### reads all applnks twice
603 603
604 delete rootFolder; 604 delete rootFolder;
605 rootFolder = new AppLnkSet( MimeType::appsFolderName() ); 605 rootFolder = new AppLnkSet( MimeType::appsFolderName() );
606 606
607 loadDocs(); 607 loadDocs();
608 608
609 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); 609 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems());
610} 610}
611 611
612void Launcher::updateDocs() 612void Launcher::updateDocs()
613{ 613{
614 loadDocs(); 614 loadDocs();
615 tabs->updateDocs(docsFolder,storage->fileSystems()); 615 tabs->updateDocs(docsFolder,storage->fileSystems());
616} 616}
617 617
618void Launcher::viewSelected(const QString& s) 618void Launcher::viewSelected(const QString& s)
619{ 619{
620 setCaption( s + tr(" - Launcher") ); 620 setCaption( s + tr(" - Launcher") );
621} 621}
622 622
623void Launcher::nextView() 623void Launcher::nextView()
624{ 624{
625 tabs->nextTab(); 625 tabs->nextTab();
626} 626}
627 627
628 628
629void Launcher::select( const AppLnk *appLnk ) 629void Launcher::select( const AppLnk *appLnk )
630{ 630{
631 if ( appLnk->type() == "Folder" ) { 631 if ( appLnk->type() == "Folder" ) {
632 // Not supported: flat is simpler for the user 632 // Not supported: flat is simpler for the user
633 } else { 633 } else {
634 if ( appLnk->exec().isNull() ) { 634 if ( appLnk->exec().isNull() ) {
635 QMessageBox::information(this,tr("No application"), 635 QMessageBox::information(this,tr("No application"),
636 tr("<p>No application is defined for this document." 636 tr("<p>No application is defined for this document."
637 "<p>Type is %1.").arg(appLnk->type())); 637 "<p>Type is %1.").arg(appLnk->type()));
638 return; 638 return;
639 } 639 }
640 tabs->setBusy(TRUE); 640 tabs->setBusy(TRUE);
641 emit executing( appLnk ); 641 emit executing( appLnk );
642 appLnk->execute(); 642 appLnk->execute();
643 } 643 }
diff --git a/core/launcher/mrulist.cpp b/core/launcher/mrulist.cpp
index 4daf7d2..6066dac 100644
--- a/core/launcher/mrulist.cpp
+++ b/core/launcher/mrulist.cpp
@@ -1,176 +1,208 @@
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#include "mrulist.h" 22#include "mrulist.h"
22 23
23#include <qpe/global.h> 24#include <qpe/global.h>
24#include <qpe/applnk.h> 25#include <qpe/applnk.h>
25#include <qpe/resource.h> 26#include <qpe/resource.h>
26 27
27#include <qframe.h> 28#include <qframe.h>
28#include <qpushbutton.h> 29#include <qpushbutton.h>
29#include <qtoolbutton.h> 30#include <qtoolbutton.h>
30#include <qpopupmenu.h> 31#include <qpopupmenu.h>
31#include <qpainter.h> 32#include <qpainter.h>
32#include <qwindowsystem_qws.h> 33#include <qwindowsystem_qws.h>
33 34
34 35
35 QList<MRUList>*MRUList::MRUListWidgets = NULL; 36 QList<MRUList>*MRUList::MRUListWidgets = NULL;
36 QList<AppLnk>*MRUList::task = NULL; 37 QList<AppLnk>*MRUList::task = NULL;
37 38
38 39
39MRUList::MRUList( QWidget *parent ) 40MRUList::MRUList( QWidget *parent )
40 : QFrame( parent ), selected(-1), oldsel(-1) 41 : QFrame( parent ), selected(-1), oldsel(-1)
41{ 42{
42 setBackgroundMode( PaletteButton ); 43 setBackgroundMode( PaletteButton );
43 if (!MRUListWidgets) 44 if (!MRUListWidgets)
44 MRUListWidgets = new QList<MRUList>; 45 MRUListWidgets = new QList<MRUList>;
45 if (!task) 46 if (!task)
46 task = new QList<AppLnk>; 47 task = new QList<AppLnk>;
47 MRUListWidgets->append( this ); 48 MRUListWidgets->append( this );
48} 49}
49 50
50 51
51MRUList::~MRUList() 52MRUList::~MRUList()
52{ 53{
53 if (MRUListWidgets) 54 if (MRUListWidgets)
54 MRUListWidgets->remove( this ); 55 MRUListWidgets->remove( this );
55 if (task) 56 if (task)
56 task->setAutoDelete( TRUE ); 57 task->setAutoDelete( TRUE );
57} 58}
58 59
59 60
60QSize MRUList::sizeHint() const 61QSize MRUList::sizeHint() const
61{ 62{
62 return QSize( frameWidth(), 16 ); 63 return QSize( frameWidth(), 16 );
63} 64}
64 65
65 66
66void MRUList::addTask( const AppLnk *appLnk ) 67void MRUList::addTask( const AppLnk *appLnk )
67{ 68{
68 if ( !appLnk ) 69 if ( !appLnk )
69 return; 70 return;
70 unsigned int i = 0; 71 unsigned int i = 0;
71 72
72 if ( !task ) 73 if ( !task )
73 return; 74 return;
74 75 // ok we wan't to delete old icons from the taskbar
76 // get the window list and see which windows aren't there any more
77 QList<AppLnk> cleanUp;
78 cleanUp.setAutoDelete( TRUE );
79 const QList<QWSWindow> &list = qwsServer->clientWindows();
80 QWSWindow* w;
81 bool running = false; // to see what we should do
82 for ( ; i < task->count(); i++ ) {
83 AppLnk *t = task->at(i);
84 running = false;
85 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
86 QString app = w->client()->identity();
87 if( app == t->exec( ) ){
88 running = true;
89 break;
90 }
91 }
92 if(!running ) { // gues what we do now
93 cleanUp.append( t);
94 }
95 }
96 // no do a clean up of these old icons
97 AppLnk *lnk;
98 for( lnk = cleanUp.first(); lnk != 0; lnk = cleanUp.next() ){
99 task->remove( lnk );
100 }
101 cleanUp.clear(); // should be deleted too
102
103 i = 0;
75 for ( ; i < task->count(); i++ ) { 104 for ( ; i < task->count(); i++ ) {
76 AppLnk *t = task->at(i); 105 AppLnk *t = task->at(i);
77 if ( t->exec() == appLnk->exec() ) { 106 if ( t->exec() == appLnk->exec() ) {
78 if (i != 0) { 107 if (i != 0) {
79 task->remove(); 108 task->remove();
80 task->prepend( t ); 109 task->prepend( t );
81 } 110 }
82 for (unsigned i = 0; i < MRUListWidgets->count(); i++ ) 111 for (unsigned i = 0; i < MRUListWidgets->count(); i++ )
83 MRUListWidgets->at(i)->update(); 112 MRUListWidgets->at(i)->update();
84 return; 113 return;
85 } 114 }
86 } 115 }
87 116 // check which tasks are running and delete them from the list
88 AppLnk *t = new AppLnk( *appLnk ); 117 AppLnk *t = new AppLnk( *appLnk );
89 // DocLnks have an overloaded virtual function exec() 118 // DocLnks have an overloaded virtual function exec()
90 t->setExec( appLnk->exec() ); 119 t->setExec( appLnk->exec() );
91 task->prepend( t ); 120 task->prepend( t );
92 121
93 if ( task->count() > 6 ) { 122 if ( task->count() > 6 ) {
94 t = task->last(); 123 t = task->last();
95 task->remove(); 124 task->remove();
96 Global::terminate(t); 125 Global::terminate(t);
97 delete t; 126 delete t;
98 } 127 }
99 128
100 for (unsigned i = 0; i < MRUListWidgets->count(); i++ ) 129 for (unsigned i = 0; i < MRUListWidgets->count(); i++ )
101 MRUListWidgets->at(i)->update(); 130 MRUListWidgets->at(i)->update();
102} 131}
103 132
104bool MRUList::quitOldApps() 133bool MRUList::quitOldApps()
105{ 134{
106 QStringList appsstarted; 135 QStringList appsstarted;
107 QStringList appsrunning; 136 QStringList appsrunning;
108 for ( int i=task->count()-1; i>=0; --i ) { 137 for ( int i=task->count()-1; i>=0; --i ) {
109 AppLnk *t = task->at(i); 138 AppLnk *t = task->at(i);
110 appsstarted.append(t->exec()); 139 appsstarted.append(t->exec());
111 } 140 }
112 141
113 const QList<QWSWindow> &list = qwsServer->clientWindows(); 142 const QList<QWSWindow> &list = qwsServer->clientWindows();
114 QWSWindow* w; 143 QWSWindow* w;
115 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 144 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
116 QString app = w->client()->identity(); 145 QString app = w->client()->identity();
117 if ( appsstarted.contains(app) && !appsrunning.contains(app) ) 146 if ( appsstarted.contains(app) && !appsrunning.contains(app) )
118 appsrunning.append(app); 147 appsrunning.append(app);
119 } 148 }
120 149
121 if ( appsrunning.count() > 1 ) { 150 if ( appsrunning.count() > 1 ) {
122 QStringList::ConstIterator it = appsrunning.begin(); 151 QStringList::ConstIterator it = appsrunning.begin();
123 ++it; // top stays running! 152 ++it; // top stays running!
124 for (; it != appsrunning.end(); it++) { 153 for (; it != appsrunning.end(); it++) {
125 for ( int i=task->count()-1; i>=0; --i ) { 154 for ( int i=task->count()-1; i>=0; --i ) {
126 AppLnk *t = task->at(i); 155 AppLnk *t = task->at(i);
127 if ( t->exec() == *it ) 156 if ( t->exec() == *it ){
128 Global::terminate(t); 157 task->remove(i );
158 delete t;
159 Global::terminate(t);
160 }
129 } 161 }
130 } 162 }
131 return TRUE; 163 return TRUE;
132 } else { 164 } else {
133 return FALSE; 165 return FALSE;
134 } 166 }
135} 167}
136 168
137 169
138void MRUList::mousePressEvent(QMouseEvent *e) 170void MRUList::mousePressEvent(QMouseEvent *e)
139{ 171{
140 selected = 0; 172 selected = 0;
141 int x=0; 173 int x=0;
142 QListIterator<AppLnk> it( *task ); 174 QListIterator<AppLnk> it( *task );
143 for ( ; it.current(); ++it,++selected,x+=15 ) { 175 for ( ; it.current(); ++it,++selected,x+=15 ) {
144 if ( x + 15 <= width() ) { 176 if ( x + 15 <= width() ) {
145 if ( e->x() >= x && e->x() < x+15 ) { 177 if ( e->x() >= x && e->x() < x+15 ) {
146 if ( selected < (int)task->count() ) { 178 if ( selected < (int)task->count() ) {
147 repaint(FALSE); 179 repaint(FALSE);
148 return; 180 return;
149 } 181 }
150 } 182 }
151 } else { 183 } else {
152 break; 184 break;
153 } 185 }
154 } 186 }
155 selected = -1; 187 selected = -1;
156 repaint( FALSE ); 188 repaint( FALSE );
157} 189}
158 190
159 191
160void MRUList::mouseReleaseEvent(QMouseEvent *) 192void MRUList::mouseReleaseEvent(QMouseEvent *)
161{ 193{
162 if ( selected >= 0 ) { 194 if ( selected >= 0 ) {
163 if ( parentWidget() ) 195 if ( parentWidget() )
164 if ( parentWidget()->isA( "QPopupMenu" ) ) 196 if ( parentWidget()->isA( "QPopupMenu" ) )
165 parentWidget()->hide(); 197 parentWidget()->hide();
166 Global::execute( task->at(selected)->exec() ); 198 Global::execute( task->at(selected)->exec() );
167 selected = -1; 199 selected = -1;
168 oldsel = -1; 200 oldsel = -1;
169 update(); 201 update();
170 } 202 }
171} 203}
172 204
173 205
174void MRUList::paintEvent( QPaintEvent * ) 206void MRUList::paintEvent( QPaintEvent * )
175{ 207{
176 QPainter p( this ); 208 QPainter p( this );