summaryrefslogtreecommitdiff
path: root/core/launcher/launcherview.cpp
Side-by-side diff
Diffstat (limited to 'core/launcher/launcherview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp28
1 files changed, 27 insertions, 1 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
@@ -250,48 +250,49 @@ 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()
{
#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());
}
@@ -434,54 +435,65 @@ void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,in
}
void LauncherIconView::checkCallback()
{
if (m_EyeCallBack) {
return;
}
m_EyeCallBack = new LauncherThumbReceiver();
connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)),
this,SLOT(setEyePixmap(const QPixmap&,const QString&,int)));
}
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();
}
}
void LauncherIconView::updateCategoriesAndMimeTypes()
{
mimes.clear();
cats.clear();
LauncherItem* item = (LauncherItem*)firstItem();
while (item) {
addCatsAndMimes(item->appLnk());
item = (LauncherItem*)item->nextItem();
}
@@ -580,48 +592,63 @@ void LauncherIconView::calculateGrid( ItemTextPos pos )
if ( viewerWidth <= 200 )
cols = 2;
else if ( viewerWidth >= 400 )
cols = viewerWidth/96;
setSpacing( 4 );
setGridX( (viewerWidth-(cols+1)*spacing())/cols );
setGridY( fontMetrics().height()*2+24 );
} else {
int cols = 2;
if ( viewerWidth < 150 )
cols = 1;
else if ( viewerWidth >= 400 )
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);
QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold );
icons->setItemsMovable( FALSE );
icons->setAutoArrange( TRUE );
icons->setSorting( TRUE );
icons->setFrameStyle( QFrame::NoFrame );
icons->setMargin( 0 );
icons->setSelectionMode( QIconView::NoSelection );
icons->setBackgroundMode( PaletteBase );
icons->setResizeMode( QIconView::Fixed );
vmode = (ViewMode)-1;
setViewMode( Icon );
@@ -1102,47 +1129,46 @@ LauncherThumbReceiver::LauncherThumbReceiver()
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 ) {
- 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()));
}
void LauncherThumbReceiver::sendRequest()
{
if (m_inThumbNail.count()>0) {
QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" );
env << m_inThumbNail;
m_inThumbNail.clear();
}
}