示例#1
0
KasPopup *KasGroupItem::createPopup()
{
    KasPopup *pop = new KasPopup(this);
    bar = kasbar()->createChildBar((kasbar()->orientation() == Horizontal) ? Vertical : Horizontal, pop);

    connect(pop, SIGNAL(shown()), SLOT(updatePopup()));

    return pop;

    //     // Test code
    //     //
    //     // This generates cool looking fractal-like patterns if you keep unfolding the
    //     // groups!
    //     int pos = (int) this;
    //     if ( pos % 2 )
    //        bar->append( new KasItem( bar ) );
    //     if ( pos % 5 )
    //        bar->append( new KasItem( bar ) );
    //     bar->append( new KasGroupItem( bar ) );
    //     if ( pos % 3 )
    //        bar->append( new KasItem( bar ) );
    //     if ( pos % 7 )
    //        bar->append( new KasItem( bar ) );
    //     ////////////
}
示例#2
0
void KasGroupItem::showGroupMenuAt(const QPoint &p)
{
    TaskRMBMenu *tm = new TaskRMBMenu(items, true, kasbar());
    tm->insertItem(i18n("&Ungroup"), this, SLOT(ungroup()));
    tm->insertSeparator();
    tm->insertItem(i18n("&Kasbar"), kasbar()->contextMenu());

    setLockPopup(true);
    tm->exec(p);
    delete tm;
    setLockPopup(false);
}
示例#3
0
void KasTaskItem::showWindowMenuAt( QPoint p )
{
    TaskRMBMenu *tm = new TaskRMBMenu(task_, true, kasbar());
    tm->insertItem( i18n("To &Tray" ), this, SLOT( sendToTray() ) );
    tm->insertSeparator();
    tm->insertItem( i18n("&Kasbar"), kasbar()->contextMenu() );
    tm->insertSeparator();
    tm->insertItem( i18n("&Properties" ), this, SLOT( showPropertiesDialog() ) );

    mouseLeave();
    kasbar()->updateMouseOver();

    tm->exec( p );
}
示例#4
0
void KasTaskItem::startAutoThumbnail()
{
    if ( thumbTimer )
	return;
    if ( !kasbar()->thumbnailsEnabled() )
	return;

    if ( kasbar()->thumbnailUpdateDelay() > 0 ) {
	thumbTimer = new QTimer( this, "thumbTimer" );
	connect( thumbTimer, SIGNAL( timeout() ), SLOT( refreshThumbnail() ) );

	thumbTimer->start( kasbar()->thumbnailUpdateDelay() * 1000 );
    }

    QTimer::singleShot( 200, this, SLOT( refreshThumbnail() ) );
}
示例#5
0
void KasTaskItem::refreshThumbnail()
{
    if ( !kasbar()->thumbnailsEnabled() )
	return;
    if ( !task_->isActive() )
	return;

    // TODO: Check if the popup obscures the window
    KasItem *i = kasbar()->itemUnderMouse();
    if ( i && i->isShowingPopup() ) {
	QTimer::singleShot( 200, this, SLOT( refreshThumbnail() ) );
	return;
    }

    task_->setThumbnailSize( kasbar()->thumbnailSize() );
    task_->updateThumbnail();
}
示例#6
0
void KasTaskItem::updateTask(bool geometryChangeOnly)
{
    if (geometryChangeOnly)
    {
        return;
    }

    bool updates = kasbar()->isUpdatesEnabled();
    kasbar()->setUpdatesEnabled( false );

    setProgress( kasbar()->showProgress() ? 0 : -1 );
    setText( task_->visibleIconicName() );
    setModified( task_->isModified() );
    setActive( task_->isActive() );

    kasbar()->setUpdatesEnabled( updates );
    update();
}
示例#7
0
void KasLoadItem::paint( QPainter *p )
{
    double val = valuesOne.last();
    double maxValue = 1.0;
    double scaleVal = QMAX( val, valuesFive.last() );

    if ( scaleVal >= maxValue )
	maxValue = 2.0;
    if ( scaleVal >= maxValue )
	maxValue = 5.0;
    if ( scaleVal >= maxValue )
	maxValue = 10.0;
    if ( scaleVal >= maxValue )
	maxValue = 20.0;
    if ( scaleVal >= maxValue )
	maxValue = 50.0;
    if ( scaleVal >= maxValue )
	maxValue = 100.0;

    double dh = extent()-16;
    dh = dh / maxValue;

    int h = (int) floor( dh * val );
    int w = extent()-4;
    h = (h > 0) ? h : 1;
    w = (w > 0) ? w : 1;

    KasItem::paint( p );

    QColor light = kasbar()->colorGroup().highlight();
    QColor dark = light.dark();

    KPixmap pix;
    pix.resize( w, h );
    KPixmapEffect::gradient( pix, light, dark, KPixmapEffect::DiagonalGradient );
    p->drawPixmap( 2, extent()-2-h, pix );

    p->setPen( kasbar()->colorGroup().mid() );
    for ( double pos = 0.2 ; pos < 1.0 ; pos += 0.2 ) {
	int ypos = (int) floor((extent()-2) - (dh*maxValue*pos));
	p->drawLine( 2, ypos, extent()-3, ypos );
    }
}
示例#8
0
void KasLoadItem::showMenuAt( QPoint p )
{
    mouseLeave();
    kasbar()->updateMouseOver();

    KasTasker *bar = dynamic_cast<KasTasker *> (KasItem::kasbar());
    if ( !bar )
	return;

    KPopupMenu *menu = bar->contextMenu();
    menu->exec( p );
}
示例#9
0
QPixmap KasTaskItem::icon()
{
    int sizes[] = { KIcon::SizeEnormous,
		    KIcon::SizeHuge,
		    KIcon::SizeLarge,
		    KIcon::SizeMedium,
		    KIcon::SizeSmall };

    if ( kasbar()->embedThumbnails() && task_->hasThumbnail() ) {
	usedIconLoader = true;

	QPixmap thumb = task_->thumbnail();
	QSize sz = thumb.size();
	sz.scale( sizes[kasbar()->itemSize()], sizes[kasbar()->itemSize()], QSize::ScaleMin );

	QImage img = thumb.convertToImage();
	img = img.smoothScale( sz );

	bool ok = thumb.convertFromImage( img );
	if ( ok )
	    return thumb;
    }

    usedIconLoader = false;
    QPixmap p = task_->bestIcon( sizes[kasbar()->itemSize()], usedIconLoader );
    if ( !p.isNull() )
	return p;

    return task_->icon( sizes[kasbar()->itemSize()], sizes[kasbar()->itemSize()], true );
}
示例#10
0
void KasGroupItem::updateIcon()
{
    QPixmap p;
    bool usedIconLoader = false;
    Task::Ptr t = items.first();
    if(!t)
        p = KGlobal::iconLoader()->loadIcon("kicker", KIcon::NoGroup, KIcon::SizeSmall);

    int sizes[] = {KIcon::SizeEnormous, KIcon::SizeHuge, KIcon::SizeLarge, KIcon::SizeMedium, KIcon::SizeSmall};

    p = t->bestIcon(sizes[kasbar()->itemSize()], usedIconLoader);

    if(p.isNull())
        p = KGlobal::iconLoader()->loadIcon("error", KIcon::NoGroup, KIcon::SizeSmall);

    setIcon(p);
}
示例#11
0
void KasTaskItem::sendToTray()
{
    QString s;
    s.setNum( task_->window() );

    KProcess proc;
    proc << "ksystraycmd";
    proc << "--wid" << s << "--hidden";

    bool ok = proc.start( KProcess::DontCare );
    if ( !ok ) {
	kdWarning(1345) << "Unable to launch ksystraycmd" << endl;
	KPassivePopup::message( i18n("Could Not Send to Tray"),
				i18n("%1").arg(strerror(errno)),
				Icon("error"),
				kasbar() );
	return;
    }

    proc.detach();
}
示例#12
0
void KasTaskItem::showPropertiesDialog()
{
    //
    // Create Dialog
    //
    QDialog *dlg = new QDialog( /*kasbar()*/0L, "task_props", false );

    //
    // Title
    //
    KPopupTitle *title = new KPopupTitle( dlg, "title" );
    dlg->setCaption( i18n("Task Properties") );
    title->setText( i18n("Task Properties") );
    title->setIcon( icon() );

    //
    // Tabbed View
    //
    QTabWidget *tabs = new QTabWidget( dlg );
    tabs->addTab( createX11Props( tabs ), i18n("General") );
    tabs->addTab( createTaskProps( task_, tabs ), i18n("Task") );

    tabs->addTab( createTaskProps( this, tabs ), i18n("Item") );
    tabs->addTab( createTaskProps( kasbar(), tabs, false ), i18n("Bar") );

#if 0
    tabs->addTab( createNETProps( tabs ), i18n("NET") );
#endif

    //
    // Layout Dialog
    //
    QVBoxLayout *vbl = new QVBoxLayout( dlg, KDialog::marginHint(), KDialog::spacingHint() );
    vbl->addWidget( title );
    vbl->addWidget( tabs );

    dlg->resize( 470, 500 );
    dlg->show();

}
示例#13
0
void KasGroupItem::removeTask(Task::Ptr t)
{
    if(!t)
        return;

    hidePopup();

    for(Task::List::iterator it = items.begin(); it != items.end();)
    {
        if((*it) == t)
        {
            it = items.erase(it);
        }
        else
        {
            ++it;
        }
    }

    updateIcon();

    if(items.count() == 1)
        kasbar()->moveToMain(this, items.first());
}
示例#14
0
void KasGroupItem::ungroup()
{
    kasbar()->moveToMain(this);
}
示例#15
0
void KasGroupItem::paint(QPainter *p)
{
    KasItem::paint(p);

    //
    // Item summary info
    //
    int modCount = 0;
    for(Task::List::iterator it = items.begin(); it != items.end(); ++it)
    {
        if((*it)->isModified())
            modCount++;
    }

    KasResources *res = resources();

    p->setPen(isShowingPopup() ? res->activePenColor() : res->inactivePenColor());

    if(modCount)
    {
        QString modCountStr;
        modCountStr.setNum(modCount);
        p->drawText(extent() - fontMetrics().width(modCountStr) - 3, 15 + fontMetrics().ascent(), modCountStr);

        p->drawPixmap(extent() - 12, 29, res->modifiedIcon());
    }

    int microsPerCol;
    switch(kasbar()->itemSize())
    {
        default:
        case KasBar::Small:
            microsPerCol = 2;
            break;
        case KasBar::Medium:
            microsPerCol = 4;
            break;
        case KasBar::Large:
            microsPerCol = 7;
            break;
        case KasBar::Huge:
            microsPerCol = 9;
            break;
        case KasBar::Enormous:
            microsPerCol = 16;
            break;
    }

    int xpos = 3;
    int ypos = 16;

    for(int i = 0; (i < (int)items.count()) && (i < microsPerCol); i++)
    {
        Task::Ptr t = items.at(i);

        if(t->isIconified())
            p->drawPixmap(xpos, ypos, res->microMinIcon());
        else if(t->isShaded())
            p->drawPixmap(xpos, ypos, res->microShadeIcon());
        else
            p->drawPixmap(xpos, ypos, res->microMaxIcon());

        ypos += 7;
    }

    if(((int)items.count() > microsPerCol) && (kasbar()->itemSize() != KasBar::Small))
    {
        QString countStr;
        countStr.setNum(items.count());
        p->drawText(extent() - fontMetrics().width(countStr) - 3, extent() + fontMetrics().ascent() - 16, countStr);
    }
}
示例#16
0
void KasTaskItem::paint( QPainter *p )
{
    KasItem::paint( p );

    KasResources *res = resources();
    QColor c = task_->isActive() ? res->activePenColor() : res->inactivePenColor();
    p->setPen( c );

    //
    // Overlay the small icon if the icon has changed, we have space,
    // and we are using a KIconLoader icon rather than one from the NET props.
    // This only exists because we are almost always using the icon loader for
    // large icons.
    //
    KasTasker *kas = kasbar();
    bool haveSpace = ( kas->itemSize() != KasBar::Small )
	          && ( kas->itemSize() != KasBar::Medium );

    if ( usedIconLoader && iconHasChanged && haveSpace ) {
	QPixmap pix = icon();
	int x = (extent() - 4 - pix.width()) / 2;
	QPixmap overlay = task_->pixmap();
	p->drawPixmap( x-4+pix.width()-overlay.width(), 18, overlay );
    }

    //
    // Draw window state.
    //
    if( task_->isIconified() )
	paintStateIcon( p, StateIcon );
    else if ( task_->isShaded() )
	paintStateIcon( p, StateShaded );
    else
	paintStateIcon( p, StateNormal );

    //
    // Draw desktop number.
    //

    // Check if we only have one desktop
    bool oneDesktop = (TaskManager::the()->numberOfDesktops() == 1) ? true : false;

    QString deskStr;
    if ( task_->isOnAllDesktops() )
	deskStr = i18n( "All" );
    else
	deskStr.setNum( task_->desktop() );


    if ( kas->itemSize() != KasBar::Small ) {
	// Medium and Large modes
	if ( !oneDesktop )
	    p->drawText( extent()-fontMetrics().width(deskStr)-3, 15+fontMetrics().ascent(), deskStr );

	// Draw document state.
	if ( kas->showModified() )
	    paintModified( p );
    }
    else {
	// Small mode
	if ( !oneDesktop )
	    p->drawText( extent()-fontMetrics().width(deskStr)-2, 13+fontMetrics().ascent(), deskStr );
    }
}