Exemplo n.º 1
0
bool QChildWidget::eventFilter(QObject *o, QEvent *e)
{
    if (e->type() == QEvent::Paint){
        QWidget *w = static_cast<QWidget*>(o);
        for (QWidget *p = parentWidget(); p; p = p->parentWidget()){
            const QPixmap *bg = p->backgroundPixmap();
            if (bg){
                QPoint pos = w->mapToGlobal(QPoint(0, 0));
                pos = p->mapFromGlobal(pos);
                QRect rc(pos.x(), pos.y(), w->width(), w->height());
                if (rc != rcChild){
                    rcChild = rc;
                    QPixmap new_bg(w->width(), w->height());
                    QPainter pp(&new_bg);
                    pp.drawTiledPixmap(0, 0, w->width(), w->height(), *bg, pos.x(), pos.y());
                    pp.end();
                    w->setBackgroundPixmap(new_bg);
                }
                if (w->backgroundPixmap()){
                    QPainter pp(w);
                    pp.drawPixmap(0, 0, *w->backgroundPixmap());
                }
                return true;
            }
        }
    }
    return false;
}
Exemplo n.º 2
0
void ProxyConfig::paintEvent(QPaintEvent*)
{
    for (QWidget *p = parentWidget(); p; p = p->parentWidget()){
        const QPixmap *bg = p->backgroundPixmap();
        if (bg){
            QPoint pos = mapToGlobal(QPoint(0, 0));
            pos = p->mapFromGlobal(pos);
            QPainter pp(this);
            pp.drawTiledPixmap(0, 0, width(), height(), *bg, pos.x(), pos.y());
            return;
        }
    }
    QPainter pp(this);
    pp.eraseRect(0, 0, width(), height());
}
Exemplo n.º 3
0
QPixmap TransparentTop::background(const QColor &c)
{
#if COMPAT_QT_VERSION < 0x030000
    QWidget *w = (QWidget*)parent();
    const QPixmap *bg = w->backgroundPixmap();
    if (bg == NULL || bg->isNull())
        return QPixmap();
    KPixmap pix(*bg);
#else
    if (bg.isNull())
        return QPixmap();
    KPixmap pix(bg);
#endif
    return KPixmapEffect::fade(pix, m_transparent, c);
}
Exemplo n.º 4
0
QPixmap TransparentTop::background(const QColor &c)
{
#if COMPAT_QT_VERSION < 0x030000
    QWidget *w = (QWidget*)parent();
    const QPixmap *bg = w->backgroundPixmap();
    if (bg == NULL)
        return QPixmap();
    QImage img = bg->toImage();
#else
    if (bg.isNull())
        return QPixmap();
    QImage img = bg.toImage();
#endif
    img = KImageEffect::fade(img, m_transparent, c);
    QPixmap res;
    res.fromImage(img);
    return res;
}