summaryrefslogtreecommitdiff
path: root/core/launcher
authoralwin <alwin>2004-11-08 02:27:03 (UTC)
committer alwin <alwin>2004-11-08 02:27:03 (UTC)
commit18875a0d90d0425c066e6fa2cda81a6140fe8606 (patch) (side-by-side diff)
tree778844c7dd2acb9f387a3228b3d3bd9df647c1a7 /core/launcher
parent9218d2bf841e1f999475c86ba602dc1cd7e338f6 (diff)
downloadopie-18875a0d90d0425c066e6fa2cda81a6140fe8606.zip
opie-18875a0d90d0425c066e6fa2cda81a6140fe8606.tar.gz
opie-18875a0d90d0425c066e6fa2cda81a6140fe8606.tar.bz2
first try getting small imagethumbs in document-tab.
Diffstat (limited to 'core/launcher') (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp98
-rw-r--r--core/launcher/launcherview.h36
2 files changed, 131 insertions, 3 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index cd9c14b..1317bda 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -29,6 +29,8 @@
#include <qtopia/resource.h>
using namespace Opie::Core;
+#include <qpe/qcopenvelope_qws.h>
+
/* QT */
#include <qtimer.h>
#include <qfileinfo.h>
@@ -79,18 +81,25 @@ public:
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);
protected:
bool isBigIcon;
int iteration;
AppLnk* app;
+
private:
void paintAnimatedIcon( QPainter *p );
BusyIndicatorType busyType;
+ int psize;
+ QPixmap m_iPixmap;
+ bool m_EyeImage;
+ LauncherThumbReceiver*m_EyeCallback;
};
@@ -377,8 +386,17 @@ LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon )
bigIcon ? applnk->bigPixmap() :applnk->pixmap() ),
isBigIcon( bigIcon ),
iteration(0),
- app(applnk) // Takes ownership
+ app(applnk), // Takes ownership
+ psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ),
+ m_iPixmap(),
+ m_EyeImage(false)
{
+ m_EyeCallback = new LauncherThumbReceiver(this);
+ if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) {
+ m_EyeImage = true;
+ m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap());
+ m_EyeCallback->requestThumb(applnk->file(),m_iPixmap.width(),m_iPixmap.height());
+ }
}
LauncherItem::~LauncherItem()
@@ -387,6 +405,7 @@ LauncherItem::~LauncherItem()
if ( liv->busyItem() == this )
liv->setBusy(FALSE);
delete app;
+ if (m_EyeCallback) delete m_EyeCallback;
}
int LauncherItem::compare ( QIconViewItem * i ) const
@@ -460,7 +479,7 @@ void LauncherItem::animateIcon()
// Highlight the icon
if ( iteration == 0 ) {
- QPixmap src = isBigIcon ? app->bigPixmap() : app->pixmap();
+ QPixmap src = (isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()));
QImage img = src.convertToImage();
QRgb *rgb;
int count;
@@ -496,7 +515,14 @@ void LauncherItem::animateIcon()
void LauncherItem::resetIcon()
{
iteration = 0;
- setPixmap( isBigIcon ? app->bigPixmap() : app->pixmap() );
+ setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap())));
+}
+
+void LauncherItem::setEyePixmap(const QPixmap&aIcon)
+{
+ if (!isEyeImage()) return;
+ m_iPixmap = aIcon;
+ setPixmap(aIcon);
}
//===========================================================================
@@ -1059,3 +1085,69 @@ void LauncherView::flushBgCache()
}
}
+/* special image handling - based on opie eye */
+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(LauncherItem*parent)
+ :QObject()
+{
+ m_parent = parent;
+ 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()" );
+ }
+ m_waiting = false;
+}
+
+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 );
+ if (!m_parent || !m_waiting) return;
+ /* we are just interested in thumbmails */
+ if ( str == "pixmapsHandled(PixmapList)" )
+ stream >> pixinfos;
+
+ for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) {
+ if ((*it).file==m_reqFile) {
+ m_parent->setEyePixmap((*it).pixmap);
+ m_waiting = false;
+ break;
+ }
+ }
+}
+
+void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height)
+{
+ m_reqFile = file;
+ rItem.file = file;
+ rItem.width = width;
+ rItem.height = height;
+ QTimer::singleShot(1, this, SLOT(sendRequest()));
+}
+
+void LauncherThumbReceiver::sendRequest()
+{
+ PixmapInfos m_inThumbNail;
+ m_inThumbNail.append(rItem);
+ QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" );
+ env << m_inThumbNail;
+ m_waiting = true;
+}
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h
index e40a006..a9ff9eb 100644
--- a/core/launcher/launcherview.h
+++ b/core/launcher/launcherview.h
@@ -27,6 +27,7 @@
class CategorySelect;
class LauncherIconView;
+class LauncherItem;
class QIconView;
class QIconViewItem;
class QLabel;
@@ -116,4 +117,39 @@ private:
};
+/* taken from opie-eye */
+
+struct PixmapInfo {
+ PixmapInfo() : width( -1 ), height( -1 ) {}
+ bool operator==( const PixmapInfo& r ) {
+ if ( width != r.width ) return false;
+ if ( height != r.height ) return false;
+ if ( file != r.file ) return false;
+ return true;
+ }
+ int width, height;
+ QString file;
+ QPixmap pixmap;
+};
+
+class LauncherThumbReceiver:public QObject
+{
+ Q_OBJECT
+ typedef QValueList<PixmapInfo> PixmapInfos;
+public:
+ LauncherThumbReceiver(LauncherItem*parent);
+ ~LauncherThumbReceiver();
+ void requestThumb(const QString&file,int width,int height);
+
+public slots:
+ void recieve( const QCString&, const QByteArray& );
+protected slots:
+ virtual void sendRequest();
+protected:
+ LauncherItem*m_parent;
+ QString m_reqFile;
+ PixmapInfo rItem;
+ bool m_waiting:1;
+};
+
#endif // LAUNCHERVIEW_H