author | alwin <alwin> | 2004-11-09 20:19:53 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-11-09 20:19:53 (UTC) |
commit | c7b97ac140de31282dba2463a00f434c7a5bba69 (patch) (side-by-side diff) | |
tree | 3be0a497f30d2265359e99dbc0951ab0b594e865 | |
parent | 439b89dbda8afb2deeb0461dcd249a3e80131825 (diff) | |
download | opie-c7b97ac140de31282dba2463a00f434c7a5bba69.zip opie-c7b97ac140de31282dba2463a00f434c7a5bba69.tar.gz opie-c7b97ac140de31282dba2463a00f434c7a5bba69.tar.bz2 |
- removed code which let qpe crash when generating image icons
- when edit properties of an document item it will reread the table of categories
-rw-r--r-- | core/launcher/launcher.cpp | 18 | ||||
-rw-r--r-- | core/launcher/launcherview.cpp | 127 | ||||
-rw-r--r-- | core/launcher/launcherview.h | 1 |
3 files changed, 70 insertions, 76 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 010a2e9..5ec1cf8 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp @@ -312,102 +312,102 @@ void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg ) if ( tabTextCol.isEmpty() ) tab->fgColor = QColor(); else tab->fgColor = QColor(tabTextCol); } void LauncherTabWidget::paletteChange( const QPalette &p ) { QVBox::paletteChange( p ); QPalette pal = palette(); pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); categoryBar->setPalette( pal ); categoryBar->update(); } void LauncherTabWidget::styleChange( QStyle & ) { QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); } void LauncherTabWidget::setProgressStyle() { if (docLoadingWidgetProgress) { docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); docLoadingWidgetProgress->setMargin( 1 ); docLoadingWidgetProgress->setLineWidth( 1 ); } } /* * FIXME * The following NULL check is triggered by inserting, then removing a tab on the fly * as you would if you had removable media (which I do). Without this check * the first app launched after a tab removal causes qpe to Segfault. * This obviously has a more sinister cause, but this works around it with no * obvious adverse effects. Please FIXME * bkc - 17/6/2004 * */ void LauncherTabWidget::setBusy(bool on) { if ( on ) currentView()->setBusy(TRUE); else { for ( int i = 0; i < categoryBar->count(); i++ ) { - if (categoryBar->tab(i)) { - LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; - view->setBusy( FALSE ); - } else { - odebug << "Averting Disaster with tab " << i << " == NULL! " << oendl; - } + if (categoryBar->tab(i)) { + LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; + view->setBusy( FALSE ); + } else { + odebug << "Averting Disaster with tab " << i << " == NULL! " << oendl; + } } } } void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { for (int i = 0; i < categoryBar->count(); i++ ) { LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; view->setBusyIndicatorType( str ); } } LauncherView *LauncherTabWidget::currentView(void) { return (LauncherView*)stack->visibleWidget(); } void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "setTabView(QString,int)" ) { QString id; stream >> id; int mode; stream >> mode; if ( view(id) ) view(id)->setViewMode( (LauncherView::ViewMode)mode ); } else if ( msg == "setTabBackground(QString,int,QString)" ) { QString id; stream >> id; int mode; stream >> mode; QString pixmapOrColor; stream >> pixmapOrColor; if ( view(id) ) view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); if ( id == "Documents" ) docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); } else if ( msg == "setTextColor(QString,QString)" ) { QString id; stream >> id; QString color; stream >> color; if ( view(id) ) view(id)->setTextColor( QColor(color) ); if ( id == "Documents" ) docLoadingWidget->setTextColor( QColor(color) ); @@ -556,99 +556,101 @@ static bool isVisibleWindow(int wid) QWSWindow* w; for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { if ( w->winId() == wid ) return !w->isFullyObscured(); } #endif return FALSE; } void Launcher::viewSelected(const QString& s) { setCaption( s + tr(" - Launcher") ); } void Launcher::showTab(const QString& id) { tabs->categoryBar->showTab(id); raise(); } void Launcher::select( const AppLnk *appLnk ) { if ( appLnk->type() == "Folder" ) { // No tr // Not supported: flat is simpler for the user } else { if ( appLnk->exec().isNull() ) { int i = QMessageBox::information(this,tr("No application"), tr("<p>No application is defined for this document." "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); /* ### Fixme */ if ( i == 1 ) Global::execute("textedit",appLnk->file()); return; } tabs->setBusy(TRUE); emit executing( appLnk ); appLnk->execute(); } } void Launcher::properties( AppLnk *appLnk ) { if ( appLnk->type() == "Folder" ) { // No tr // Not supported: flat is simpler for the user } else { /* ### libqtopia FIXME also moving docLnks... */ - LnkProperties prop(appLnk,0 ); + LnkProperties prop(appLnk,0 ); - QPEApplication::execDialog( &prop ); + if (QPEApplication::execDialog( &prop )==QDialog::Accepted && tabs->currentView()==tabs->docView()) { + tabs->docView()->updateTools(); + } } } void Launcher::storageChanged( const QList<FileSystem> & ) { // ### update combo boxes if we had a combo box for the storage type } void Launcher::systemMessage( const QCString &msg, const QByteArray &data) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "busy()" ) { tb->startWait(); } else if ( msg == "notBusy(QString)" ) { QString app; stream >> app; tabs->setBusy(FALSE); tb->stopWait(app); } else if (msg == "applyStyle()") { tabs->currentView()->relayout(); } } // These are the update functions from the server void Launcher::typeAdded( const QString& type, const QString& name, const QPixmap& pixmap, const QPixmap& ) { tabs->newView( type, pixmap, name ); ids.append( type ); /* this will be called in applicationScanningProgress with value 100! */ // tb->refreshStartMenu(); static bool first = TRUE; if ( first ) { first = FALSE; tabs->categoryBar->showTab(type); } tabs->view( type )->setUpdatesEnabled( FALSE ); tabs->view( type )->setSortEnabled( FALSE ); } void Launcher::typeRemoved( const QString& type ) { tabs->view( type )->removeAllItems(); tabs->deleteView( type ); ids.remove( type ); /* this will be called in applicationScanningProgress with value 100! */ diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index 72313e3..ff26133 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp @@ -86,97 +86,97 @@ public: AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } void animateIcon(); void resetIcon(); bool isEyeImage()const{return m_EyeImage;} virtual int compare ( QIconViewItem * i ) const; void paintItem( QPainter *p, const QColorGroup &cg ); void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } void setEyePixmap(const QPixmap&aIcon); virtual QPixmap*pixmap()const; protected: bool isBigIcon; int iteration; AppLnk* app; private: void paintAnimatedIcon( QPainter *p ); BusyIndicatorType busyType; int psize; QPixmap m_iPixmap; bool m_EyeImage; iconstate_t m_EyeImageSet; }; LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) : QIconViewItem( parent, applnk->name(), bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), isBigIcon( bigIcon ), iteration(0), app(applnk), // Takes ownership psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), m_iPixmap(), m_EyeImage(false), m_EyeImageSet(BASE_ICON) { if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { m_EyeImage = true; m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap()); } } LauncherItem::~LauncherItem() { LauncherIconView* liv = (LauncherIconView*)iconView(); if ( liv->busyItem() == this ) - liv->setBusy(FALSE); + liv->setBusy(FALSE); delete app; } QPixmap*LauncherItem::pixmap()const { if (m_EyeImage && m_EyeImageSet == BASE_ICON) { LauncherIconView* liv = (LauncherIconView*)iconView(); liv->requestEyePix(this); } return QIconViewItem::pixmap(); } int LauncherItem::compare ( QIconViewItem * i ) const { LauncherIconView* view = (LauncherIconView*)iconView(); return view->compare(app,((LauncherItem *)i)->appLnk()); } void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) { LauncherIconView* liv = (LauncherIconView*)iconView(); QBrush oldBrush( liv->itemTextBackground() ); QColorGroup mycg( cg ); if ( liv->currentItem() == this ) { liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); } QIconViewItem::paintItem(p,mycg); // Paint animation overlay if ( liv->busyItem() == this ) paintAnimatedIcon(p); if ( liv->currentItem() == this ) liv->setItemTextBackground( oldBrush ); } void LauncherItem::paintAnimatedIcon( QPainter *p ) { LauncherIconView* liv = (LauncherIconView*)iconView(); int pic = iteration % 16; int w = pixmap()->width(), h = pixmap()->height(); QPixmap dblBuf( w, h + 4 ); QPainter p2( &dblBuf ); int x1, y1; if ( liv->itemTextPos() == QIconView::Bottom ) { x1 = x() + (width() - w) / 2 - liv->contentsX(); @@ -231,96 +231,97 @@ void LauncherItem::animateIcon() c.hsv(&h,&s,&v); c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); #elif defined(ALPHA_FADE_BUSY_ICON) *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); #endif } src.convertFromImage( img ); setPixmap( src ); } iteration++; // Paint animation overlay QPainter p( liv->viewport() ); paintAnimatedIcon( &p ); } void LauncherItem::resetIcon() { iteration = 0; setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()))); } void LauncherItem::setEyePixmap(const QPixmap&aIcon) { if (!isEyeImage()) return; m_iPixmap = aIcon; setPixmap(aIcon); m_EyeImageSet = EYE_ICON; } //=========================================================================== // Implemantation of LauncherIconview start //=========================================================================== LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white) { m_EyeCallBack = 0; sortmeth = Name; hidden.setAutoDelete(TRUE); ike = FALSE; calculateGrid( Bottom ); connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer())); } LauncherIconView::~LauncherIconView() { + odebug << "LauncherIconView::~LauncherIconView()" << oendl; #if 0 // debuggery QListIterator<AppLnk> it(hidden); AppLnk* l; while ((l=it.current())) { ++it; //odebug << "" << l << ": hidden (should remove)" << oendl; } #endif } int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) { switch (sortmeth) { case Name: return a->name().lower().compare(b->name().lower()); case Date: { QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); return fa.lastModified().secsTo(fb.lastModified()); } case Type: return a->type().compare(b->type()); } return 0; } void LauncherIconView::setSortMethod( SortMethod m ) { if ( sortmeth != m ) { sortmeth = m; sort(); } } void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) { Categories cat; cat.load( categoryFileName() ); QString str; if ( catfilter == -2 ) cf = 0; else cf = catfilter; hideOrShowItems(resort); } void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) { @@ -384,144 +385,135 @@ void LauncherIconView::setBusy(bool on) LauncherItem *oldBusy = bsy; bsy = c; if ( oldBusy ) { oldBusy->resetIcon(); } if ( bsy ) { bsy->setBusyIndicatorType( busyType ) ; bsy->animateIcon(); } } } void LauncherIconView::clear() { mimes.clear(); cats.clear(); QIconView::clear(); hidden.clear(); } QStringList LauncherIconView::mimeTypes() const { QStringList r; QDictIterator<void> it(mimes); while (it.current()) { r.append(it.currentKey()); ++it; } r.sort(); return r; } LauncherItem*LauncherIconView::findDocItem(const QString&fname) { LauncherItem* item = (LauncherItem*)firstItem(); while (item) { if (item->appLnk()->file()==fname) { break; } item = (LauncherItem*)item->nextItem(); } return item; } void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) { int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); if (s!=width) return; - LauncherItem*item = 0; - QMap<QString,LauncherItem*>::Iterator it; - if ( ( it = m_itemCache.find(aFile))!=m_itemCache.end()) { - item = it.data(); - m_itemCache.remove(it); - } else { - item = findDocItem(aFile); - } + LauncherItem*item = findDocItem(aFile); if (!item||!item->isEyeImage()) return; item->setEyePixmap(aPixmap); } void LauncherIconView::checkCallback() { if (!m_EyeCallBack) { m_EyeCallBack = new LauncherThumbReceiver(); connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); m_eyeTimer.changeInterval(600000); } } void LauncherIconView::addCheckItem(AppLnk* app) { LauncherItem*item = new LauncherItem( this, app, bigIcns ); if (item->isEyeImage()) { checkCallback(); } } void LauncherIconView::requestEyePix(const LauncherItem*item) { if (!item) return; if (item->isEyeImage()) { checkCallback(); int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); - m_itemCache[item->appLnk()->file()]=(LauncherItem*)item; m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); } } void LauncherIconView::stopEyeTimer() { if (m_EyeCallBack) { delete m_EyeCallBack; m_EyeCallBack=0; } - m_itemCache.clear(); m_eyeTimer.stop(); } void LauncherIconView::addItem(AppLnk* app, bool resort) { addCatsAndMimes(app); if ( (tf.isEmpty() || tf.match(app->type()) >= 0) && (cf == 0 || app->categories().contains(cf) || cf == -1 && app->categories().count() == 0 ) ) { addCheckItem(app); } else { hidden.append(app); } if ( resort ){ sort(); } } void LauncherIconView::updateCategoriesAndMimeTypes() { mimes.clear(); cats.clear(); LauncherItem* item = (LauncherItem*)firstItem(); while (item) { addCatsAndMimes(item->appLnk()); item = (LauncherItem*)item->nextItem(); } QListIterator<AppLnk> it(hidden); AppLnk* l; while ((l=it.current())) { addCatsAndMimes(l); ++it; } } void LauncherIconView::hideOrShowItems(bool resort) { viewport()->setUpdatesEnabled( FALSE ); hidden.setAutoDelete(FALSE); QList<AppLnk> links=hidden; hidden.clear(); hidden.setAutoDelete(TRUE); LauncherItem* item = (LauncherItem*)firstItem(); while (item) { links.append(item->takeAppLnk()); item = (LauncherItem*)item->nextItem(); } clear(); @@ -657,217 +649,217 @@ LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) icons->setSelectionMode( QIconView::NoSelection ); icons->setBackgroundMode( PaletteBase ); icons->setResizeMode( QIconView::Fixed ); vmode = (ViewMode)-1; setViewMode( Icon ); connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), SLOT(itemClicked(int,QIconViewItem*)) ); connect( icons, SIGNAL(selectionChanged()), SLOT(selectionChanged()) ); connect( icons, SIGNAL(returnPressed(QIconViewItem*)), SLOT(returnPressed(QIconViewItem*)) ); connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), SLOT(itemPressed(int,QIconViewItem*)) ); tools = 0; setBackgroundType( Ruled, QString::null ); } LauncherView::~LauncherView() { if ( bgCache && bgCache->contains( bgName ) ) (*bgCache)[bgName]->ref--; } bool LauncherView::bsy=FALSE; void LauncherView::setBusy(bool on) { icons->setBusy(on); } void LauncherView::setBusyIndicatorType( const QString& type ) { if ( type. lower ( ) == "animated" ) icons->setBusyIndicatorType( BIT_Animated ) ; else icons->setBusyIndicatorType( BIT_Normal ) ; } void LauncherView::hideIcons() { icons->hide(); } void LauncherView::setToolsEnabled(bool y) { if ( !y != !tools ) { - if ( y ) { - tools = new QHBox(this); - - // Type filter - typemb = new QComboBox(tools); - QSizePolicy p = typemb->sizePolicy(); - p.setHorData(QSizePolicy::Expanding); - typemb->setSizePolicy(p); - - // Category filter - updateTools(); - tools->show(); - - } else { - delete tools; - tools = 0; - } + if ( y ) { + tools = new QHBox(this); + // Type filter + typemb = new QComboBox(tools); + QSizePolicy p = typemb->sizePolicy(); + p.setHorData(QSizePolicy::Expanding); + typemb->setSizePolicy(p); + // Category filter + updateTools(); + tools->show(); + } else { + delete tools; + tools = 0; + } } } void LauncherView::updateTools() { disconnect( typemb, SIGNAL(activated(int)), this, SLOT(showType(int)) ); - if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)), - this, SLOT(showCategory(int)) ); + if ( catmb ) { + disconnect( catmb, SIGNAL(signalSelected(int)),this,SLOT(showCategory(int))); + } // ### I want to remove this icons->updateCategoriesAndMimeTypes(); QString prev; // Type filter QStringList types; typelist = icons->mimeTypes(); for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { - QString t = *it; - if ( t.left(12) == "application/" ) { - MimeType mt(t); - const AppLnk* app = mt.application(); - if ( app ) - t = app->name(); - else - t = t.mid(12); - } else { - t[0] = t[0].upper(); - } - types += t; + QString t = *it; + if ( t.left(12) == "application/" ) { + MimeType mt(t); + const AppLnk* app = mt.application(); + if ( app ) + t = app->name(); + else + t = t.mid(12); + } else { + t[0] = t[0].upper(); + } + types += t; } types << tr("All types"); prev = typemb->currentText(); typemb->clear(); typemb->insertStringList(types); for (int i=0; i<typemb->count(); i++) { - if ( typemb->text(i) == prev ) { - typemb->setCurrentItem(i); - break; + if ( typemb->text(i) == prev ) { + typemb->setCurrentItem(i); + break; + } } + if ( prev.isNull() ) { + typemb->setCurrentItem(typemb->count()-1); } - if ( prev.isNull() ) - typemb->setCurrentItem(typemb->count()-1); int pcat = catmb ? catmb->currentCategory() : -2; if ( !catmb ) - catmb = new CategorySelect(tools); + catmb = new CategorySelect(tools); Categories cats( 0 ); cats.load( categoryFileName() ); QArray<int> vl( 0 ); catmb->setCategories( vl, "Document View", // No tr - tr("Document View") ); + tr("Document View") ); catmb->setRemoveCategoryEdit( TRUE ); catmb->setAllCategories( TRUE ); catmb->setCurrentCategory(pcat); // if type has changed we need to redisplay if ( typemb->currentText() != prev ) - showType( typemb->currentItem() ); + showType( typemb->currentItem() ); connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); } void LauncherView::sortBy(int s) { icons->setSortMethod((LauncherIconView::SortMethod)s); } void LauncherView::showType(int t) { if ( t >= (int)typelist.count() ) { - icons->setTypeFilter("",TRUE); + icons->setTypeFilter("",TRUE); } else { - QString ty = typelist[t]; - if ( !ty.contains('/') ) - ty += "/*"; - icons->setTypeFilter(ty,TRUE); + QString ty = typelist[t]; + if ( !ty.contains('/') ) + ty += "/*"; + icons->setTypeFilter(ty,TRUE); } } void LauncherView::showCategory( int c ) { icons->setCategoryFilter( c, TRUE ); } void LauncherView::setViewMode( ViewMode m ) { + odebug << "LauncherView::setViewMode( ViewMode m )" << oendl; if ( vmode != m ) { - bool bigIcons = m == Icon; - icons->viewport()->setUpdatesEnabled( FALSE ); - icons->setBigIcons( bigIcons ); - switch ( m ) { - case List: - icons->setItemTextPos( QIconView::Right ); + bool bigIcons = m == Icon; + icons->viewport()->setUpdatesEnabled( FALSE ); + icons->setBigIcons( bigIcons ); + switch ( m ) { + case List: + icons->setItemTextPos( QIconView::Right ); break; case Icon: - icons->setItemTextPos( QIconView::Bottom ); + icons->setItemTextPos( QIconView::Bottom ); break; - } - icons->hideOrShowItems( FALSE ); - icons->viewport()->setUpdatesEnabled( TRUE ); - vmode = m; + } + icons->hideOrShowItems( FALSE ); + icons->viewport()->setUpdatesEnabled( TRUE ); + vmode = m; } } // // User images may require scaling. // QImage LauncherView::loadBackgroundImage(QString &bgName) { QImageIO imgio; QSize ds = qApp->desktop()->size(); // should be launcher, not desktop bool further_scaling = TRUE; imgio.setFileName( bgName ); imgio.setParameters("GetHeaderInformation"); if (imgio.read() == FALSE) { return imgio.image(); } if (imgio.image().width() < ds.width() && imgio.image().height() < ds.height()) { further_scaling = FALSE; } if (!imgio.image().bits()) { // // Scale and load. Note we don't scale up. // QString param( "Scale( %1, %2, ScaleMin )" ); // No tr imgio.setParameters(further_scaling ? param.arg(ds.width()).arg(ds.height()).latin1() : ""); imgio.read(); } else { if (further_scaling) { int t1 = imgio.image().width() * ds.height(); int t2 = imgio.image().height() * ds.width(); int dsth = ds.height(); int dstw = ds.width(); if (t1 > t2) { dsth = t2 / imgio.image().width(); } else { dstw = t1 / imgio.image().height(); } // // Loader didn't scale for us. Do it manually. @@ -1001,96 +993,97 @@ void LauncherView::resizeEvent(QResizeEvent *e) } void LauncherView::selectionChanged() { QIconViewItem* item = icons->currentItem(); if ( item && item->isSelected() ) { AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); if ( icons->inKeyEvent() ) // not for mouse press emit clicked( appLnk ); item->setSelected(FALSE); } } void LauncherView::returnPressed( QIconViewItem *item ) { if ( item ) { AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); emit clicked( appLnk ); } } void LauncherView::itemClicked( int btn, QIconViewItem *item ) { if ( item ) { AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); if ( btn == LeftButton ) { // Make sure it's the item we execute that gets highlighted icons->setCurrentItem( item ); emit clicked( appLnk ); } item->setSelected(FALSE); } } void LauncherView::itemPressed( int btn, QIconViewItem *item ) { if ( item ) { AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); if ( btn == RightButton ) emit rightPressed( appLnk ); else if ( btn == ShiftButton ) emit rightPressed( appLnk ); item->setSelected(FALSE); } } void LauncherView::removeAllItems() { + odebug << "LauncherView::removeAllItems()" << oendl; icons->clear(); } bool LauncherView::removeLink(const QString& linkfile) { return icons->removeLink(linkfile); } void LauncherView::setSortEnabled( bool v ) { icons->setSorting( v ); if ( v ) sort(); } void LauncherView::setUpdatesEnabled( bool u ) { icons->setUpdatesEnabled( u ); } void LauncherView::sort() { icons->sort(); } void LauncherView::addItem(AppLnk* app, bool resort) { icons->addItem(app,resort); } void LauncherView::paletteChange( const QPalette &p ) { icons->unsetPalette(); QVBox::paletteChange( p ); if ( bgType == Ruled ) setBackgroundType( Ruled, QString::null ); QColorGroup cg = icons->colorGroup(); cg.setColor( QColorGroup::Text, textCol ); icons->setPalette( QPalette(cg,cg,cg) ); } void LauncherView::fontChanged(const QFont&) { odebug << "LauncherView::fontChanged()" << oendl; icons->hideOrShowItems( FALSE ); } void LauncherView::relayout(void) @@ -1123,59 +1116,59 @@ QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { s >> inf.file >> inf.pixmap >> inf.width >> inf.height; return s; } QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { return s << inf.file << inf.width << inf.height; } LauncherThumbReceiver::LauncherThumbReceiver() :QObject() { QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(recieve(const QCString&,const QByteArray&)) ); { QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); } } LauncherThumbReceiver::~LauncherThumbReceiver() { { QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); } } void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) { PixmapInfos pixinfos; QDataStream stream( at, IO_ReadOnly ); /* we are just interested in thumbmails */ if ( str == "pixmapsHandled(PixmapList)" ) stream >> pixinfos; for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); } } void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) { PixmapInfo rItem; rItem.file = file; rItem.width = width; rItem.height = height; m_inThumbNail.append(rItem); - QTimer::singleShot(0, this, SLOT(sendRequest())); + QTimer::singleShot(2, this, SLOT(sendRequest())); } void LauncherThumbReceiver::sendRequest() { if (m_inThumbNail.count()>0) { QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); env << m_inThumbNail; m_inThumbNail.clear(); } } diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h index 94c367c..6d94539 100644 --- a/core/launcher/launcherview.h +++ b/core/launcher/launcherview.h @@ -195,52 +195,51 @@ public: void drawBackground( QPainter *p, const QRect &r ); void setItemTextPos( ItemTextPos pos ); void hideOrShowItems(bool resort); void setTypeFilter(const QString& typefilter, bool resort); void setCategoryFilter( int catfilter, bool resort ); enum SortMethod { Name, Date, Type }; void setSortMethod( SortMethod m ); int compare(const AppLnk* a, const AppLnk* b); void requestEyePix(const LauncherItem*which); protected: virtual void timerEvent( QTimerEvent *te ); void styleChange( QStyle &old ); void calculateGrid( ItemTextPos pos ); void focusInEvent( QFocusEvent * ) {} void focusOutEvent( QFocusEvent * ) {} LauncherItem*findDocItem(const QString&); void addCheckItem(AppLnk* app); void checkCallback(); virtual void keyPressEvent(QKeyEvent* e); protected slots: void setEyePixmap(const QPixmap&,const QString&,int width); void stopEyeTimer(); private: QList<AppLnk> hidden; QDict<void> mimes; QDict<void> cats; SortMethod sortmeth; QRegExp tf; int cf; LauncherItem* bsy; int busyTimer; bool ike; bool bigIcns; QPixmap bgPixmap; QColor bgColor; LauncherThumbReceiver*m_EyeCallBack; #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY QPixmap busyPix; #endif BusyIndicatorType busyType; QTimer m_eyeTimer; - QMap<QString,LauncherItem*> m_itemCache; }; #endif // LAUNCHERVIEW_H |