fixed preview event painting, to use pixmap as intermediate painting device, in order to proper account for event clip rect, and avoid decorations appearing out of the widget rect
svn path=/trunk/KDE/kdebase/workspace/; revision=1018742
This commit is contained in:
parent
b0769ebdb8
commit
76104a522a
1 changed files with 16 additions and 12 deletions
|
@ -109,19 +109,23 @@ void KDecorationPreview::disablePreview()
|
|||
|
||||
void KDecorationPreview::paintEvent( QPaintEvent* e )
|
||||
{
|
||||
|
||||
QWidget::paintEvent(e);
|
||||
|
||||
// render existing decorations into a pixmap
|
||||
// there is some translations involved to make use of event.rect()
|
||||
// and optimize painting
|
||||
QRect rect( KDecorationPreview::rect().intersected( e->rect() ) );
|
||||
QPixmap pixmap( rect.size() );
|
||||
pixmap.fill( Qt::transparent );
|
||||
if( deco[Inactive] ) deco[Inactive]->widget()->render( &pixmap, deco[Inactive]->widget()->mapToParent( -rect.topLeft() ) );
|
||||
if( deco[Active] ) deco[Active]->widget()->render( &pixmap, deco[Active]->widget()->mapToParent( -rect.topLeft() ) );
|
||||
|
||||
// draw pixmap on widget
|
||||
QPainter painter( this );
|
||||
QPoint delta = mapTo( window(), QPoint(0, 0) );
|
||||
|
||||
if ( deco[Inactive] )
|
||||
{
|
||||
QWidget *w = deco[Inactive]->widget();
|
||||
w->render( &painter, delta + w->mapToParent( QPoint(0, 0) ) );
|
||||
}
|
||||
if ( deco[Active] )
|
||||
{
|
||||
QWidget *w = deco[Active]->widget();
|
||||
w->render( &painter, delta + w->mapToParent( QPoint(0, 0) ) );
|
||||
}
|
||||
painter.setClipRect( e->rect() );
|
||||
painter.drawPixmap( rect.topLeft(), pixmap );
|
||||
|
||||
}
|
||||
|
||||
void KDecorationPreview::resizeEvent( QResizeEvent* e )
|
||||
|
|
Loading…
Reference in a new issue