summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp43
-rw-r--r--core/launcher/launcher.h4
-rw-r--r--core/launcher/launcherview.cpp109
-rw-r--r--core/launcher/launcherview.h7
4 files changed, 113 insertions, 50 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 5ec1cf8..ccc2114 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -72,17 +72,17 @@
#include <mntent.h>
#endif
static bool isVisibleWindow( int );
//===========================================================================
LauncherTabWidget::LauncherTabWidget( Launcher* parent ) :
- QVBox( parent ), docview( 0 )
+ QVBox( parent ), docview( 0 ),docTabEnabled(true),m_DocumentTabId(0)
{
docLoadingWidgetEnabled = false;
docLoadingWidget = 0;
docLoadingWidgetProgress = 0;
launcher = parent;
categoryBar = new LauncherTabBar( this );
QPalette pal = categoryBar->palette();
pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
@@ -123,17 +123,17 @@ void LauncherTabWidget::createDocLoadingWidget()
QLabel *waitPixmap = new QLabel( docLoadingVBox );
waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) );
waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) );
waitPixmap->setAlignment( int( QLabel::AlignCenter ) );
Config cfg( "Launcher" );
cfg.setGroup( "DocTab" );
- bool docTabEnabled = cfg.readBoolEntry( "Enable", true );
+ docTabEnabled = cfg.readBoolEntry( "Enable", true );
QLabel *textLabel = new QLabel( docLoadingVBox );
textLabel->setAlignment( int( QLabel::AlignCenter ) );
docLoadingWidgetProgress = new QProgressBar( docLoadingVBox );
docLoadingWidgetProgress->setProgress( 0 );
docLoadingWidgetProgress->setCenterIndicator( TRUE );
docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker
setProgressStyle();
@@ -164,101 +164,104 @@ void LauncherTabWidget::initLayout()
layout()->activate();
docView()->setFocus();
categoryBar->showTab("Documents");
}
void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&)
{
if ( message == "nextView()" )
- categoryBar->nextTab();
+ categoryBar->nextTab();
}
void LauncherTabWidget::raiseTabWidget()
{
if ( categoryBar->currentView() == docView()
- && docLoadingWidgetEnabled ) {
- stack->raiseWidget( docLoadingWidget );
- docLoadingWidget->updateGeometry();
+ && docLoadingWidgetEnabled ) {
+ stack->raiseWidget( docLoadingWidget );
+ docLoadingWidget->updateGeometry();
} else {
- stack->raiseWidget( categoryBar->currentView() );
+ stack->raiseWidget( categoryBar->currentView() );
}
}
void LauncherTabWidget::tabProperties()
{
LauncherView *view = categoryBar->currentView();
QPopupMenu *m = new QPopupMenu( this );
m->insertItem( tr("Icon View"), LauncherView::Icon );
m->insertItem( tr("List View"), LauncherView::List );
m->setItemChecked( (int)view->viewMode(), TRUE );
int rv = m->exec( QCursor::pos() );
if ( rv >= 0 && rv != view->viewMode() ) {
- view->setViewMode( (LauncherView::ViewMode)rv );
+ view->setViewMode( (LauncherView::ViewMode)rv );
}
delete m;
}
void LauncherTabWidget::deleteView( const QString& id )
{
LauncherTab *t = categoryBar->launcherTab(id);
if ( t ) {
- stack->removeWidget( t->view );
- delete t->view;
- categoryBar->removeTab( t );
+ stack->removeWidget( t->view );
+ delete t->view;
+ categoryBar->removeTab( t );
}
}
LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label )
{
LauncherView* view = new LauncherView( stack );
connect( view, SIGNAL(clicked(const AppLnk*)),
this, SIGNAL(clicked(const AppLnk*)));
connect( view, SIGNAL(rightPressed(AppLnk*)),
this, SIGNAL(rightPressed(AppLnk*)));
+
int n = categoryBar->count();
+
stack->addWidget( view, n );
LauncherTab *tab = new LauncherTab( id, view, pm, label );
categoryBar->insertTab( tab, n-1 );
-
- if ( id == "Documents" )
- docview = view;
+ if ( id == "Documents" ) {
+ docview = view;
+ m_DocumentTabId = n;
+ }
odebug << "inserting " << id << " at " << n-1 << "" << oendl;
Config cfg("Launcher");
setTabAppearance( tab, cfg );
cfg.setGroup( "GUI" );
view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) );
return view;
}
LauncherView *LauncherTabWidget::view( const QString &id )
{
LauncherTab *t = categoryBar->launcherTab(id);
if ( !t )
- return 0;
+ return 0;
return t->view;
}
LauncherView *LauncherTabWidget::docView()
{
return docview;
}
void LauncherTabWidget::setLoadingWidgetEnabled( bool v )
{
if ( v != docLoadingWidgetEnabled && docLoadingWidget ) {
- docLoadingWidgetEnabled = v;
- raiseTabWidget();
+ docLoadingWidgetEnabled = v;
+ raiseTabWidget();
}
}
void LauncherTabWidget::setLoadingProgress( int percent )
{
docLoadingWidgetProgress->setProgress( (percent / 4) * 4 );
}
@@ -599,17 +602,16 @@ 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 );
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
}
@@ -716,18 +718,23 @@ void Launcher::showDocTab()
void Launcher::documentRemoved( const DocLnk& doc )
{
tabs->docView()->removeLink( doc.linkFile() );
}
void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc )
{
+#if 0
documentRemoved( oldDoc );
documentAdded( newDoc );
+// tabs->docView()->updateTools();
+#else
+ tabs->docView()->changeItem(oldDoc,new DocLnk(newDoc));
+#endif
}
void Launcher::allDocumentsRemoved()
{
tabs->docView()->removeAllItems();
}
void Launcher::applicationStateChanged( const QString& name, ApplicationState state )
diff --git a/core/launcher/launcher.h b/core/launcher/launcher.h
index 2eaf77c..db6ac54 100644
--- a/core/launcher/launcher.h
+++ b/core/launcher/launcher.h
@@ -85,16 +85,18 @@ protected:
private:
Launcher *launcher;
LauncherView *docview;
QWidgetStack *stack;
LauncherView *docLoadingWidget;
QProgressBar *docLoadingWidgetProgress;
bool docLoadingWidgetEnabled;
+ bool docTabEnabled;
+ int m_DocumentTabId;
};
class Launcher : public QMainWindow, public ServerInterface
{
Q_OBJECT
public:
Launcher();
~Launcher();
@@ -130,17 +132,17 @@ public slots:
void select( const AppLnk * );
void properties( AppLnk * );
void makeVisible();
signals:
void executing( const AppLnk * );
private slots:
- void systemMessage( const QCString &, const QByteArray &);
+ void systemMessage( const QCString &, const QByteArray &);
protected:
bool eventFilter( QObject *o, QEvent *ev );
private:
void updateApps();
void loadDocs();
void updateDocs();
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index ff26133..c9efacb 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -39,16 +39,17 @@ using namespace Opie::Core;
// 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
+typedef QMap<QString,QPixmap>::Iterator pixiter;
class BgPixmap
{
public:
BgPixmap( const QPixmap &p ) : pm(p), ref(1) {}
QPixmap pm;
int ref;
};
@@ -100,35 +101,37 @@ 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());
+ QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(applnk->file());
+ if (it != LauncherIconView::sm_EyeCache->end()) {
+ m_EyeImageSet = EYE_ICON;
+ setPixmap(*it);
+ }
}
}
LauncherItem::~LauncherItem()
{
LauncherIconView* liv = (LauncherIconView*)iconView();
if ( liv->busyItem() == this )
liv->setBusy(FALSE);
@@ -208,17 +211,23 @@ void LauncherItem::animateIcon()
{
LauncherIconView* liv = (LauncherIconView*)iconView();
if ( liv->busyItem() != this || !app )
return;
// Highlight the icon
if ( iteration == 0 ) {
- QPixmap src = (isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()));
+ QPixmap src;
+ pixiter it;
+ if (isEyeImage() && (it=LauncherIconView::sm_EyeCache->find(appLnk()->file()))!=LauncherIconView::sm_EyeCache->end()) {
+ src = (*it);
+ } else {
+ 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();
} else {
rgb = img.colorTable();
@@ -244,34 +253,44 @@ void LauncherItem::animateIcon()
// Paint animation overlay
QPainter p( liv->viewport() );
paintAnimatedIcon( &p );
}
void LauncherItem::resetIcon()
{
iteration = 0;
- setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap())));
+ if (isEyeImage()) {
+ QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(appLnk()->file());
+ if (it != LauncherIconView::sm_EyeCache->end()) {
+ setPixmap(*it);
+ return;
+ }
+ }
+ setPixmap(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
//===========================================================================
+
+QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0;
+
LauncherIconView::LauncherIconView( QWidget* parent, const char* name )
: QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white)
{
m_EyeCallBack = 0;
+ if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>();
sortmeth = Name;
hidden.setAutoDelete(TRUE);
ike = FALSE;
calculateGrid( Bottom );
connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer()));
}
LauncherIconView::~LauncherIconView()
@@ -427,27 +446,28 @@ LauncherItem*LauncherIconView::findDocItem(const QString&fname)
}
void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width)
{
int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
if (s!=width) return;
LauncherItem*item = findDocItem(aFile);
if (!item||!item->isEyeImage()) return;
+ (*sm_EyeCache)[aFile]=aPixmap;
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);
}
+ m_eyeTimer.changeInterval(600000);
}
void LauncherIconView::addCheckItem(AppLnk* app)
{
LauncherItem*item = new LauncherItem( this, app, bigIcns );
if (item->isEyeImage()) {
checkCallback();
}
@@ -461,37 +481,24 @@ void LauncherIconView::requestEyePix(const LauncherItem*item)
int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s);
}
}
void LauncherIconView::stopEyeTimer()
{
if (m_EyeCallBack) {
+ disconnect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)),
+ this,SLOT(setEyePixmap(const QPixmap&,const QString&,int)));
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();
@@ -523,27 +530,28 @@ void LauncherIconView::hideOrShowItems(bool resort)
addItem(l,FALSE);
++it;
}
if ( resort && !autoArrange() )
sort();
viewport()->setUpdatesEnabled( TRUE );
}
-bool LauncherIconView::removeLink(const QString& linkfile)
+bool LauncherIconView::removeLink(const QString& linkfile,bool removeCache)
{
LauncherItem* item = (LauncherItem*)firstItem();
AppLnk* l;
bool did = FALSE;
DocLnk dl(linkfile);
while (item) {
l = item->appLnk();
LauncherItem *nextItem = (LauncherItem *)item->nextItem();
if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() &&
( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) {
+ if (removeCache) sm_EyeCache->remove(l->file());
delete item;
did = TRUE;
}
item = nextItem;
}
QListIterator<AppLnk> it(hidden);
while ((l=it.current())) {
++it;
@@ -552,28 +560,61 @@ bool LauncherIconView::removeLink(const QString& linkfile)
|| dl.isValid() && dl.file() == l->file() ) {
hidden.removeRef(l);
did = TRUE;
}
}
return did;
}
+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::changeItem(const AppLnk&old,AppLnk*nlink)
+{
+ QString oldfile = old.file();
+ QString newfile = nlink->file();
+
+ if (newfile != oldfile) {
+ QMap<QString,QPixmap>::Iterator it = sm_EyeCache->find(oldfile);
+ if (it != sm_EyeCache->end()) {
+ (*sm_EyeCache)[newfile]=(*it);
+ }
+ removeLink(old.linkFile());
+ } else {
+ removeLink(old.linkFile(),false);
+ }
+ addItem(nlink,false);
+}
+
void LauncherIconView::timerEvent( QTimerEvent *te )
{
if ( te->timerId() == busyTimer ) {
if ( bsy )
bsy->animateIcon();
} else {
QIconView::timerEvent( te );
}
}
void LauncherIconView::setBigIcons( bool bi )
{
+ sm_EyeCache->clear();
bigIcns = bi;
#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
busyPix.resize(0,0);
#endif
}
QIconViewItem* LauncherIconView::busyItem() const
{
@@ -751,18 +792,21 @@ void LauncherView::updateTools()
break;
}
}
if ( prev.isNull() ) {
typemb->setCurrentItem(typemb->count()-1);
}
int pcat = catmb ? catmb->currentCategory() : -2;
- if ( !catmb )
+ if ( !catmb ) {
catmb = new CategorySelect(tools);
+ } else if (pcat!=-2) {
+
+ }
Categories cats( 0 );
cats.load( categoryFileName() );
QArray<int> vl( 0 );
catmb->setCategories( vl, "Document View", // No tr
tr("Document View") );
catmb->setRemoveCategoryEdit( TRUE );
catmb->setAllCategories( TRUE );
catmb->setCurrentCategory(pcat);
@@ -1015,17 +1059,17 @@ 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);
+ item->setSelected(FALSE);
}
}
void LauncherView::itemPressed( int btn, QIconViewItem *item )
{
if ( item ) {
AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
if ( btn == RightButton )
@@ -1042,16 +1086,26 @@ void LauncherView::removeAllItems()
icons->clear();
}
bool LauncherView::removeLink(const QString& linkfile)
{
return icons->removeLink(linkfile);
}
+void LauncherView::addItem(AppLnk* app, bool resort)
+{
+ icons->addItem(app,resort);
+}
+
+void LauncherView::changeItem(const AppLnk&old,AppLnk*nlink)
+{
+ icons->changeItem(old,nlink);
+}
+
void LauncherView::setSortEnabled( bool v )
{
icons->setSorting( v );
if ( v )
sort();
}
void LauncherView::setUpdatesEnabled( bool u )
@@ -1059,21 +1113,16 @@ 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 );
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h
index 6d94539..05073ab 100644
--- a/core/launcher/launcherview.h
+++ b/core/launcher/launcherview.h
@@ -51,16 +51,18 @@ class LauncherView : public QVBox
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 changeItem(const AppLnk&old,AppLnk*nlink);
+
void removeAllItems();
void setSortEnabled(bool);
void setUpdatesEnabled(bool);
void sort();
void setToolsEnabled(bool);
void updateTools();
@@ -171,17 +173,18 @@ public:
{
// We don't want rubberbanding (yet)
}
void setBusy(bool on);
bool inKeyEvent() const { return ike; }
void addItem(AppLnk* app, bool resort=TRUE);
- bool removeLink(const QString& linkfile);
+ bool removeLink(const QString& linkfile,bool removeCache = true);
+ void changeItem(const AppLnk&old,AppLnk*nlink);
QStringList mimeTypes() const;
QStringList categories() const;
void clear();
void addCatsAndMimes(AppLnk* app);
void setBackgroundOrigin( QWidget::BackgroundOrigin ) {}
@@ -201,16 +204,18 @@ public:
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);
+ static QMap<QString,QPixmap>* sm_EyeCache;
+
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);