summaryrefslogtreecommitdiff
authorzecke <zecke>2002-03-25 20:17:29 (UTC)
committer zecke <zecke>2002-03-25 20:17:29 (UTC)
commitb001d834cd1259ea17fd1faf82111a1efdf607db (patch) (side-by-side diff)
tree35da1df30a27e18837d317d949db234015cfdf32
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 (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::
tmp = new DocLnkSet( home , QString::null);
docsFolder->appendFrom( *tmp );
delete tmp;
// find out wich filesystems are new in this round
// We will do this by having a timestamp inside each mountpoint
// if the current timestamp doesn't match this is a new file system and
// come up with our MediumMountGui :) let the hacking begin
int stamp = uidgen.generate();
QString newStamp = QString::number( stamp ); // generates newtime Stamp
StorageInfo storage;
const QList<FileSystem> &fileSystems = storage.fileSystems();
QListIterator<FileSystem> it ( fileSystems );
for ( ; it.current(); ++it ) {
if ( (*it)->isRemovable() ) { // let's find out if we should search on it
qWarning("%s is removeable", (*it)->path().latin1() );
OConfig cfg( (*it)->path() + "/.opiestorage.cf");
cfg.setGroup("main");
QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() );
if( stamp == m_timeStamp ){ // ok we know this card
cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp
// we need to scan the list now. Hopefully the cache will be there
// read the mimetypes from the config and search for documents
QStringList mimetypes = configToMime( &cfg);
tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") );
docsFolder->appendFrom( *tmp );
delete tmp;
}else{ // come up with the gui cause this a new card
MediumMountGui medium((*it)->path() );
if( medium.check() ){ // we did not ask before or ask again is off
if( medium.exec() ){ // he clicked yes so search it
// speicher
cfg.read(); // cause of a race we need to reread
cfg.writeEntry("timestamp", newStamp );
}// no else
}else{ // we checked
// do something different see what we need to do
// let's see if we should check the device
cfg.setGroup("main" );
bool check = cfg.readBoolEntry("autocheck", true );
if( check ){ // find the documents
tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") );
docsFolder->appendFrom( *tmp );
delete tmp;
}
}
}
- }
+ }
}
m_timeStamp = newStamp;
}
void Launcher::updateTabs()
{
MimeType::updateApplications(); // ### reads all applnks twice
delete rootFolder;
rootFolder = new AppLnkSet( MimeType::appsFolderName() );
loadDocs();
tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems());
}
void Launcher::updateDocs()
{
loadDocs();
tabs->updateDocs(docsFolder,storage->fileSystems());
}
void Launcher::viewSelected(const QString& s)
{
setCaption( s + tr(" - Launcher") );
}
void Launcher::nextView()
{
tabs->nextTab();
}
void Launcher::select( const AppLnk *appLnk )
{
if ( appLnk->type() == "Folder" ) {
// Not supported: flat is simpler for the user
} else {
if ( appLnk->exec().isNull() ) {
QMessageBox::information(this,tr("No application"),
tr("<p>No application is defined for this document."
"<p>Type is %1.").arg(appLnk->type()));
return;
}
tabs->setBusy(TRUE);
emit executing( appLnk );
appLnk->execute();
}
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 @@
/**********************************************************************
+** Copyright (C) 2002 Holger 'zecke' Freyther
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "mrulist.h"
#include <qpe/global.h>
#include <qpe/applnk.h>
#include <qpe/resource.h>
#include <qframe.h>
#include <qpushbutton.h>
#include <qtoolbutton.h>
#include <qpopupmenu.h>
#include <qpainter.h>
#include <qwindowsystem_qws.h>
QList<MRUList> *MRUList::MRUListWidgets = NULL;
QList<AppLnk> *MRUList::task = NULL;
MRUList::MRUList( QWidget *parent )
: QFrame( parent ), selected(-1), oldsel(-1)
{
setBackgroundMode( PaletteButton );
if (!MRUListWidgets)
MRUListWidgets = new QList<MRUList>;
if (!task)
task = new QList<AppLnk>;
MRUListWidgets->append( this );
}
MRUList::~MRUList()
{
if (MRUListWidgets)
MRUListWidgets->remove( this );
if (task)
task->setAutoDelete( TRUE );
}
QSize MRUList::sizeHint() const
{
return QSize( frameWidth(), 16 );
}
void MRUList::addTask( const AppLnk *appLnk )
{
if ( !appLnk )
return;
unsigned int i = 0;
if ( !task )
return;
-
+ // ok we wan't to delete old icons from the taskbar
+ // get the window list and see which windows aren't there any more
+ QList<AppLnk> cleanUp;
+ cleanUp.setAutoDelete( TRUE );
+ const QList<QWSWindow> &list = qwsServer->clientWindows();
+ QWSWindow* w;
+ bool running = false; // to see what we should do
+ for ( ; i < task->count(); i++ ) {
+ AppLnk *t = task->at(i);
+ running = false;
+ for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
+ QString app = w->client()->identity();
+ if( app == t->exec( ) ){
+ running = true;
+ break;
+ }
+ }
+ if(!running ) { // gues what we do now
+ cleanUp.append( t);
+ }
+ }
+ // no do a clean up of these old icons
+ AppLnk *lnk;
+ for( lnk = cleanUp.first(); lnk != 0; lnk = cleanUp.next() ){
+ task->remove( lnk );
+ }
+ cleanUp.clear(); // should be deleted too
+
+ i = 0;
for ( ; i < task->count(); i++ ) {
AppLnk *t = task->at(i);
if ( t->exec() == appLnk->exec() ) {
if (i != 0) {
task->remove();
task->prepend( t );
}
for (unsigned i = 0; i < MRUListWidgets->count(); i++ )
MRUListWidgets->at(i)->update();
return;
}
}
-
+ // check which tasks are running and delete them from the list
AppLnk *t = new AppLnk( *appLnk );
// DocLnks have an overloaded virtual function exec()
t->setExec( appLnk->exec() );
task->prepend( t );
if ( task->count() > 6 ) {
t = task->last();
task->remove();
Global::terminate(t);
delete t;
}
for (unsigned i = 0; i < MRUListWidgets->count(); i++ )
MRUListWidgets->at(i)->update();
}
bool MRUList::quitOldApps()
{
QStringList appsstarted;
QStringList appsrunning;
for ( int i=task->count()-1; i>=0; --i ) {
AppLnk *t = task->at(i);
appsstarted.append(t->exec());
}
const QList<QWSWindow> &list = qwsServer->clientWindows();
QWSWindow* w;
for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
- QString app = w->client()->identity();
+ QString app = w->client()->identity();
if ( appsstarted.contains(app) && !appsrunning.contains(app) )
appsrunning.append(app);
}
if ( appsrunning.count() > 1 ) {
QStringList::ConstIterator it = appsrunning.begin();
++it; // top stays running!
for (; it != appsrunning.end(); it++) {
for ( int i=task->count()-1; i>=0; --i ) {
AppLnk *t = task->at(i);
- if ( t->exec() == *it )
- Global::terminate(t);
+ if ( t->exec() == *it ){
+ task->remove(i );
+ delete t;
+ Global::terminate(t);
+ }
}
}
return TRUE;
} else {
return FALSE;
}
}
void MRUList::mousePressEvent(QMouseEvent *e)
{
selected = 0;
int x=0;
QListIterator<AppLnk> it( *task );
for ( ; it.current(); ++it,++selected,x+=15 ) {
if ( x + 15 <= width() ) {
if ( e->x() >= x && e->x() < x+15 ) {
if ( selected < (int)task->count() ) {
repaint(FALSE);
return;
}
}
} else {
break;
}
}
selected = -1;
repaint( FALSE );
}
void MRUList::mouseReleaseEvent(QMouseEvent *)
{
if ( selected >= 0 ) {
if ( parentWidget() )
if ( parentWidget()->isA( "QPopupMenu" ) )
parentWidget()->hide();
Global::execute( task->at(selected)->exec() );
selected = -1;
oldsel = -1;
update();
}
}
void MRUList::paintEvent( QPaintEvent * )
{
QPainter p( this );