-rw-r--r-- | core/launcher/launcherview.cpp | 28 | ||||
-rw-r--r-- | core/launcher/launcherview.h | 22 |
2 files changed, 33 insertions, 17 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index 506c11e..42704ba 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp @@ -262,24 +262,25 @@ void LauncherItem::setEyePixmap(const QPixmap&aIcon) //=========================================================================== // 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() { #if 0 // debuggery QListIterator<AppLnk> it(hidden); AppLnk* l; while ((l=it.current())) { ++it; //odebug << "" << l << ": hidden (should remove)" << oendl; } #endif @@ -446,30 +447,41 @@ void LauncherIconView::checkCallback() 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()) { + m_eyeTimer.changeInterval(600000); checkCallback(); int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); } } +void LauncherIconView::stopEyeTimer() +{ + odebug << "Launcherview: delete opie-eye handle" << oendl; + if (m_EyeCallBack) { + delete m_EyeCallBack; + m_EyeCallBack=0; + } + 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(); @@ -592,24 +604,39 @@ void LauncherIconView::calculateGrid( ItemTextPos pos ) cols = viewerWidth/150; setSpacing( 2 ); setGridX( (viewerWidth-(cols+1)*spacing())/cols ); setGridY( fontMetrics().height()+2 ); } } void LauncherIconView::styleChange( QStyle &old ) { QIconView::styleChange( old ); calculateGrid( itemTextPos() ); } + +void LauncherIconView::keyPressEvent(QKeyEvent* e) +{ + ike = TRUE; + if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { + if ( (e->state() & ShiftButton) ) + emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); + else + returnPressed(currentItem()); + } + + QIconView::keyPressEvent(e); + ike = FALSE; +} + //=========================================================================== // Implemantation of LauncherIconview end //=========================================================================== //=========================================================================== LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) : QVBox( parent, name, fl ) { catmb = 0; icons = new LauncherIconView( this ); setFocusProxy(icons); @@ -1114,25 +1141,24 @@ LauncherThumbReceiver::~LauncherThumbReceiver() } 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 ) { - odebug << "Pixinfos: " << (*it).file << " - " << (*it).width << oendl; 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())); diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h index 0be9a1f..ebb1362 100644 --- a/core/launcher/launcherview.h +++ b/core/launcher/launcherview.h @@ -16,24 +16,25 @@ ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef LAUNCHERVIEW_H #define LAUNCHERVIEW_H #include <qtopia/storage.h> #include <qtopia/applnk.h> #include <qvbox.h> #include <qiconview.h> +#include <qtimer.h> class CategorySelect; class LauncherIconView; class LauncherItem; class QIconViewItem; class QLabel; class QWidgetStack; class MenuButton; class QComboBox; @@ -164,38 +165,24 @@ public: #endif void setBigIcons( bool bi ); void updateCategoriesAndMimeTypes(); void setBusyIndicatorType ( BusyIndicatorType t ); void doAutoScroll() { // We don't want rubberbanding (yet) } void setBusy(bool on); bool inKeyEvent() const { return ike; } - void keyPressEvent(QKeyEvent* e) - { - ike = TRUE; - if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { - if ( (e->state() & ShiftButton) ) - emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); - else - returnPressed(currentItem()); - } - - QIconView::keyPressEvent(e); - ike = FALSE; - } - void addItem(AppLnk* app, bool resort=TRUE); bool removeLink(const QString& linkfile); QStringList mimeTypes() const; QStringList categories() const; void clear(); void addCatsAndMimes(AppLnk* app); void setBackgroundOrigin( QWidget::BackgroundOrigin ) {} void setBackgroundPixmap( const QPixmap &pm ) { bgPixmap = pm; @@ -210,45 +197,48 @@ public: 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: - void timerEvent( QTimerEvent *te ); + 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; + BusyIndicatorType busyType; + QTimer m_eyeTimer; }; #endif // LAUNCHERVIEW_H |