Ejemplo n.º 1
0
QPoint KasPopup::calcPosition(KasItem *item, int w, int h)
{
    KasBar *kasbar = item->kasbar();
    QPoint pos = kasbar->itemPos(item);

    if((pos.x() < 0) && (pos.y() < 0))
        return QPoint();

    pos = kasbar->mapToGlobal(pos);
    int x = pos.x();
    int y = pos.y();

    if(kasbar->orientation() == Horizontal)
    {
        if(y < (qApp->desktop()->height() / 2))
            y = y + kasbar->itemExtent();
        else
            y = y - h;

        if((x + w) > qApp->desktop()->width())
            x = x - w + kasbar->itemExtent();
    }
    else
    {
        if(x < (qApp->desktop()->width() / 2))
            x = x + kasbar->itemExtent();
        else
            x = x - w;

        if((y + h) > qApp->desktop()->height())
            y = y - h + kasbar->itemExtent();
    }

    return QPoint(x, y);
}
Ejemplo n.º 2
0
void KasAboutDialog::addDemoBar()
{
   TQHBox *box = new TQHBox( this );

   box->setLineWidth(2);
   box->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );

   box->setSpacing( spacingHint() );
   box->setMargin( marginHint() );

   KasBar *bar = new KasBar( Qt::Horizontal, box );
   bar->setItemSize( KasBar::Large );
   bar->setMasked( false );

   KasItem *ci = new KasItem( bar );
   ci->setIcon( LargeIcon( "icons" ) );
   bar->append( ci );

   KasPopup *pop = new KasPopup( ci );
   ci->setPopup( pop );
   ci->setCustomPopup( true );
   connect( ci, TQT_SIGNAL(leftButtonClicked(TQMouseEvent *)), ci, TQT_SLOT(togglePopup()) );

   KasBar *groupbar = bar->createChildBar( ( bar->orientation() == Qt::Horizontal ) ? Qt::Vertical : Qt::Horizontal, pop );
   KasItem *i = 0;

   KasClockItem *clk = new KasClockItem( groupbar );
   groupbar->append( clk );

   i = new KasLoadItem( groupbar );
   groupbar->append( i );

   groupbar->addTestItems();

   pop->resize( groupbar->size() );

   bar->setFixedSize( bar->itemExtent(), bar->itemExtent() );
   addWidgetBelowList( box );
}