summaryrefslogtreecommitdiff
path: root/core
authorharlekin <harlekin>2003-11-30 18:04:13 (UTC)
committer harlekin <harlekin>2003-11-30 18:04:13 (UTC)
commitf40b049e2345a9b008ea2bdc241062302bd7ca04 (patch) (side-by-side diff)
tree82ba2d954605de18ef063315b62f04f434ce43cb /core
parenta7e786be4f9545a881015de8ba8a124a62f0f891 (diff)
downloadopie-f40b049e2345a9b008ea2bdc241062302bd7ca04.zip
opie-f40b049e2345a9b008ea2bdc241062302bd7ca04.tar.gz
opie-f40b049e2345a9b008ea2bdc241062302bd7ca04.tar.bz2
make the busy indicator launcher settings also work in head
Diffstat (limited to 'core') (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp26
-rw-r--r--core/launcher/launcherview.h9
2 files changed, 26 insertions, 9 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 85163b6..62c678d 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -41,168 +41,170 @@
#include <qwidgetstack.h>
#include <qpainter.h>
#include <qregexp.h>
#include <qtoolbutton.h>
#include <qimage.h>
#include <qlabel.h>
#include <qobjectlist.h>
// These define how the busy icon is animated and highlighted
#define BRIGHTEN_BUSY_ICON
//#define ALPHA_FADE_BUSY_ICON
//#define USE_ANIMATED_BUSY_ICON_OVERLAY
#define BOUNCE_BUSY_ICON
class BgPixmap
{
public:
BgPixmap( const QPixmap &p ) : pm(p), ref(1) {}
QPixmap pm;
int ref;
};
-enum BusyIndicatorType {
- BIT_Normal = 0,
- BIT_Blinking
-};
static QMap<QString,BgPixmap*> *bgCache = 0;
static void cleanup_cache()
{
QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
while ( it != bgCache->end() ) {
QMap<QString,BgPixmap*>::Iterator curr = it;
++it;
delete (*curr);
bgCache->remove( curr );
}
delete bgCache;
bgCache = 0;
}
class LauncherItem : public QIconViewItem
{
public:
LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE );
~LauncherItem();
AppLnk *appLnk() const { return app; }
AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; }
void animateIcon();
void resetIcon();
virtual int compare ( QIconViewItem * i ) const;
void paintItem( QPainter *p, const QColorGroup &cg );
+
+ void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
protected:
bool isBigIcon;
int iteration;
AppLnk* app;
private:
void paintAnimatedIcon( QPainter *p );
+ BusyIndicatorType busyType;
};
class LauncherIconView : public QIconView {
public:
LauncherIconView( QWidget* parent, const char* name=0 ) :
QIconView(parent,name),
tf(""),
cf(0),
bsy(0),
busyTimer(0),
bigIcns(TRUE),
bgColor(white)
{
sortmeth = Name;
hidden.setAutoDelete(TRUE);
ike = FALSE;
calculateGrid( Bottom );
}
~LauncherIconView()
{
#if 0 // debuggery
QListIterator<AppLnk> it(hidden);
AppLnk* l;
while ((l=it.current())) {
++it;
//qDebug("%p: hidden (should remove)",l);
}
#endif
}
QIconViewItem* busyItem() const { return bsy; }
#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
QPixmap busyPixmap() const { return busyPix; }
#endif
void setBigIcons( bool bi ) {
bigIcns = bi;
#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
busyPix.resize(0,0);
#endif
}
void updateCategoriesAndMimeTypes();
-
+ void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
void doAutoScroll()
{
// We don't want rubberbanding (yet)
}
void setBusy(bool on)
{
#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
if ( busyPix.isNull() ) {
int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) );
}
#endif
if ( on ) {
busyTimer = startTimer( 100 );
} else {
if ( busyTimer ) {
killTimer( busyTimer );
busyTimer = 0;
}
}
LauncherItem *c = on ? (LauncherItem*)currentItem() : 0;
if ( bsy != c ) {
LauncherItem *oldBusy = bsy;
bsy = c;
- if ( oldBusy )
+ if ( oldBusy ) {
oldBusy->resetIcon();
- if ( bsy )
+ }
+ if ( bsy ) {
+ bsy->setBusyIndicatorType( busyType ) ;
bsy->animateIcon();
}
}
+ }
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()
{
@@ -342,127 +344,135 @@ protected:
setGridX( (viewerWidth-(cols+1)*spacing())/cols );
setGridY( fontMetrics().height()+2 );
}
}
void focusInEvent( QFocusEvent * ) {}
void focusOutEvent( QFocusEvent * ) {}
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;
#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
QPixmap busyPix;
#endif
+ BusyIndicatorType busyType;
};
bool LauncherView::bsy=FALSE;
void LauncherView::setBusy(bool on)
{
icons->setBusy(on);
}
void LauncherView::setBusyIndicatorType( const QString& type ) {
- /* ### FIXME */
+ if ( type. lower ( ) == "animated" )
+ icons->setBusyIndicatorType( BIT_Animated ) ;
+ else
+ icons->setBusyIndicatorType( BIT_Normal ) ;
}
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
{
}
LauncherItem::~LauncherItem()
{
LauncherIconView* liv = (LauncherIconView*)iconView();
if ( liv->busyItem() == this )
liv->setBusy(FALSE);
delete app;
}
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();
y1 = y() - liv->contentsY();
} else {
x1 = x() - liv->contentsX();
y1 = y() + (height() - h) / 2 - liv->contentsY();
}
y1 -= 2;
p2.translate(-x1,-y1);
liv->drawBackground( &p2, QRect(x1,y1,w,h+4) );
int bounceY = 2;
#ifdef BOUNCE_BUSY_ICON
+ if ( busyType == BIT_Animated ) {
bounceY = 4 - ((iteration+2)%8);
bounceY = bounceY < 0 ? -bounceY : bounceY;
+ }
#endif
p2.drawPixmap( x1, y1 + bounceY, *pixmap() );
#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h );
#endif
p->drawPixmap( x1, y1, dblBuf );
}
void LauncherItem::animateIcon()
{
LauncherIconView* liv = (LauncherIconView*)iconView();
if ( liv->busyItem() != this || !app )
return;
// Highlight the icon
if ( iteration == 0 ) {
QPixmap src = isBigIcon ? app->bigPixmap() : app->pixmap();
QImage img = src.convertToImage();
QRgb *rgb;
int count;
if ( img.depth() == 32 ) {
rgb = (QRgb*)img.bits();
count = img.bytesPerLine()/sizeof(QRgb)*img.height();
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h
index 7863d6a..e40a006 100644
--- a/core/launcher/launcherview.h
+++ b/core/launcher/launcherview.h
@@ -13,48 +13,55 @@
**
** 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.
**
**********************************************************************/
#ifndef LAUNCHERVIEW_H
#define LAUNCHERVIEW_H
#include <qtopia/storage.h>
#include <qtopia/applnk.h>
#include <qvbox.h>
class CategorySelect;
class LauncherIconView;
class QIconView;
class QIconViewItem;
class QLabel;
class QWidgetStack;
class MenuButton;
class QComboBox;
+
+
+enum BusyIndicatorType {
+ BIT_Normal = 0,
+ BIT_Animated
+};
+
class LauncherView : public QVBox
{
Q_OBJECT
public:
LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~LauncherView();
void hideIcons();
bool removeLink(const QString& linkfile);
void addItem(AppLnk* app, bool resort=TRUE);
void removeAllItems();
void setSortEnabled(bool);
void setUpdatesEnabled(bool);
void sort();
void setToolsEnabled(bool);
void updateTools();
void setBusy(bool);
void setBusyIndicatorType( const QString& );
enum ViewMode { Icon, List };
@@ -85,28 +92,28 @@ protected slots:
void sortBy(int);
void showType(int);
void showCategory( int );
void resizeEvent(QResizeEvent *);
void flushBgCache();
protected:
void paletteChange( const QPalette & );
void fontChanged(const QFont &);
private:
static bool bsy;
QWidget* tools;
LauncherIconView* icons;
QComboBox *typemb;
QStringList typelist;
CategorySelect *catmb;
ViewMode vmode;
BackgroundType bgType;
QString bgName;
QColor textCol;
QImage loadBackgroundImage(QString &fname);
- int m_busyType;
+
};
#endif // LAUNCHERVIEW_H