summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-02-23 22:47:25 (UTC)
committer harlekin <harlekin>2002-02-23 22:47:25 (UTC)
commitf1c800025cf759ca0d6257a42f548216d217b16b (patch) (side-by-side diff)
tree42aa7b339aad4b6dcfc6b17d4931febbb17b591d
parent9f9006e0257e3d4c5d66331a7d6061c8a5da164b (diff)
downloadopie-f1c800025cf759ca0d6257a42f548216d217b16b.zip
opie-f1c800025cf759ca0d6257a42f548216d217b16b.tar.gz
opie-f1c800025cf759ca0d6257a42f548216d217b16b.tar.bz2
make the two bottom menus the same height (the buttons)
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 0df949e..764f088 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -267,356 +267,358 @@ class LauncherItem : public QIconViewItem
public:
LauncherItem( QIconView *parent, AppLnk* applnk );
~LauncherItem()
{
LauncherIconView* liv = (LauncherIconView*)iconView();
if ( liv->busyItem() == this )
liv->setBusy(FALSE);
delete app;
}
AppLnk* appLnk() const { return app; }
AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; }
virtual int compare ( QIconViewItem * i ) const;
void 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);
if ( liv->currentItem() == this )
liv->setItemTextBackground( oldBrush );
if ( liv->busyItem() == this ) {
static QPixmap* busypm=0;
if ( !busypm )
busypm = new QPixmap(Resource::loadPixmap("launching"));
p->drawPixmap(x()+(width()-busypm->width())/2, y(),*busypm);
}
}
protected:
AppLnk* app;
};
LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk )
: QIconViewItem( parent, applnk->name(), applnk->bigPixmap() ),
app(applnk) // Takes ownership
{
}
int LauncherItem::compare ( QIconViewItem * i ) const
{
LauncherIconView* view = (LauncherIconView*)iconView();
return view->compare(app,((LauncherItem *)i)->appLnk());
}
QStringList LauncherIconView::mimeTypes() const
{
QStringList r;
QDictIterator<void> it(mimes);
while (it.current()) {
r.append(it.currentKey());
++it;
}
r.sort();
return r;
}
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 ) )
(void) new LauncherItem( this, 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();
}
QListIterator<AppLnk> it(hidden);
AppLnk* l;
while ((l=it.current())) {
addCatsAndMimes(l);
++it;
}
}
void LauncherIconView::hideOrShowItems(bool resort)
{
hidden.setAutoDelete(FALSE);
QList<AppLnk> links=hidden;
hidden.clear();
hidden.setAutoDelete(TRUE);
LauncherItem* item = (LauncherItem*)firstItem();
while (item) {
links.append(item->takeAppLnk());
item = (LauncherItem*)item->nextItem();
}
bool oldAutoArrange = autoArrange();
setAutoArrange( FALSE );
clear();
QListIterator<AppLnk> it(links);
AppLnk* l;
while ((l=it.current())) {
addItem(l,FALSE);
++it;
}
if ( resort )
sort();
setAutoArrange( oldAutoArrange );
}
bool LauncherIconView::removeLink(const QString& linkfile)
{
LauncherItem* item = (LauncherItem*)firstItem();
AppLnk* l;
bool did = FALSE;
DocLnk dl(linkfile);
while (item) {
l = item->appLnk();
if ( l->linkFileKnown() && l->linkFile() == linkfile || l->file() == linkfile
|| dl.isValid() && dl.file() == l->file() ) {
delete item;
did = TRUE;
}
item = (LauncherItem*)item->nextItem();
}
QListIterator<AppLnk> it(hidden);
while ((l=it.current())) {
++it;
if ( l->linkFileKnown() && l->linkFile() == linkfile
|| l->file() == linkfile
|| dl.isValid() && dl.file() == l->file() ) {
hidden.removeRef(l);
did = TRUE;
}
}
return did;
}
LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
: QVBox( parent, name, fl )
{
icons = new LauncherIconView( this );
setFocusProxy(icons);
QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold );
int dw = QApplication::desktop()->width();
icons->setItemsMovable( FALSE );
icons->setAutoArrange( TRUE );
icons->setSorting( TRUE );
icons->setGridX( (dw-13-style().scrollBarExtent().width())/3 ); // tweaked for 8pt+dw=176 and 10pt+dw=240
icons->setGridY( fontMetrics().height()*2+24 );
icons->setFrameStyle( QFrame::NoFrame );
icons->setSpacing( 4 );
icons->setMargin( 0 );
icons->setSelectionMode( QIconView::Multi );
icons->setBackgroundMode( PaletteBase );
connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)),
SLOT(itemClicked(int, QIconViewItem *)) );
connect( icons, SIGNAL(selectionChanged()),
SLOT(selectionChanged()) );
connect( icons, SIGNAL(returnPressed(QIconViewItem *)),
SLOT(returnPressed(QIconViewItem *)) );
connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)),
SLOT(itemPressed(int, QIconViewItem *)) );
tools = 0;
}
LauncherView::~LauncherView()
{
}
void LauncherView::setToolsEnabled(bool y)
{
if ( !y != !tools ) {
if ( y ) {
tools = new QHBox(this);
// Type filter
typemb = new MenuButton(tools);
typemb->setLabel(tr("Type: %1"));
+ typemb->setFixedHeight ( 20 );
// Category filter
catmb = new CategorySelect(tools);
+ catmb->setFixedHeight ( 20 );
updateTools();
tools->show();
} else {
delete tools;
tools = 0;
}
}
}
void LauncherView::updateTools()
{
disconnect( typemb, SIGNAL(selected(const QString&)),
this, SLOT(showType(const QString&)) );
disconnect( catmb, SIGNAL(signalSelected(int)),
this, SLOT(showCategory(int)) );
icons->updateCategoriesAndMimeTypes();
QString prev;
// Type filter
QStringList types;
types << tr("All");
types << "--";
types += icons->mimeTypes();
prev = typemb->currentText();
typemb->clear();
typemb->insertItems(types);
typemb->select(prev);
Categories cats( 0 );
cats.load( categoryFileName() );
QArray<int> vl( 0 );
catmb->setCategories( vl, "Document View", tr("Document View") );
catmb->setRemoveCategoryEdit( TRUE );
catmb->setAllCategories( TRUE );
connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&)));
connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
}
void LauncherView::sortBy(int s)
{
icons->setSortMethod((LauncherIconView::SortMethod)s);
}
void LauncherView::showType(const QString& t)
{
if ( t == tr("All") ) {
icons->setTypeFilter("",TRUE);
} else {
icons->setTypeFilter(t+"/*",TRUE);
}
}
void LauncherView::showCategory( int c )
{
icons->setCategoryFilter( c, TRUE );
}
void LauncherView::resizeEvent(QResizeEvent *e)
{
QVBox::resizeEvent( e );
if ( e->size().width() != e->oldSize().width() )
sort();
}
void LauncherView::populate( AppLnkSet *folder, const QString& typefilter )
{
icons->clear();
internalPopulate( folder, typefilter );
}
void LauncherView::selectionChanged()
{
QIconViewItem* item = icons->currentItem();
if ( item && item->isSelected() ) {
AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
if ( icons->inKeyEvent() ) // not for mouse press
emit clicked( appLnk );
item->setSelected(FALSE);
}
}
void LauncherView::returnPressed( QIconViewItem *item )
{
if ( item ) {
AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
emit clicked( appLnk );
}
}
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);
}
}
void LauncherView::itemPressed( int btn, QIconViewItem *item )
{
if ( item ) {
AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
if ( btn == RightButton )
emit rightPressed( appLnk );
/*
else if ( btn == LeftButton )
emit clicked( appLnk );
*/
item->setSelected(FALSE);
}
}
void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter )
{
QListIterator<AppLnk> it( folder->children() );
icons->setTypeFilter(typefilter,FALSE);
while ( it.current() ) {
// show only the icons for existing files
if (!QFile(it.current()->file()).exists() )
{
//maybe insert some .desktop file deletion code later
//maybe dir specific
}
else
{
icons->addItem(*it,FALSE);
}
++it;
}
icons->sort();
}
bool LauncherView::removeLink(const QString& linkfile)
{
return icons->removeLink(linkfile);
}
void LauncherView::sort()
{
icons->sort();
}
void LauncherView::addItem(AppLnk* app, bool resort)
{
icons->addItem(app,resort);
}
void LauncherView::setFileSystems(const QList<FileSystem> &)
{
// ### does nothing now...
}