On second thought, keep the mask - less work for Qt.

svn path=/trunk/KDE/kdegraphics/okular/; revision=756115
This commit is contained in:
Eike Hein 2008-01-02 19:48:30 +00:00
parent 3af668a384
commit 2ab6d6f842

View file

@ -628,15 +628,27 @@ void ToolBarPrivate::buildToolBar()
bool prevUpdates = q->updatesEnabled();
q->setUpdatesEnabled( false );
// 3. resize pixmap and widget
// 3. resize pixmap, mask and widget
QBitmap mask( myWidth + 1, myHeight + 1 );
backgroundPixmap = QPixmap( myWidth + 1, myHeight + 1 );
backgroundPixmap.fill(Qt::transparent);
q->resize( myWidth + 1, myHeight + 1 );
// 4. draw background
// 4. create and set transparency mask // 4. draw background
QPainter maskPainter( &mask);
mask.fill( Qt::white );
maskPainter.setBrush( Qt::black );
if ( vertical )
maskPainter.drawRoundRect( topLeft ? -10 : 0, 0, myWidth + 10, myHeight, 2000 / (myWidth + 10), 2000 / myHeight );
else
maskPainter.drawRoundRect( 0, topLeft ? -10 : 0, myWidth, myHeight + 10, 2000 / myWidth, 2000 / (myHeight + 10) );
maskPainter.end();
q->setMask( mask );
// 5. draw background
QPainter bufferPainter( &backgroundPixmap );
QPalette pal = q->palette();
// 4.1. draw horizontal/vertical gradient
// 5.1. draw horizontal/vertical gradient
QLinearGradient grad;
switch ( anchorSide )
{
@ -656,14 +668,14 @@ void ToolBarPrivate::buildToolBar()
grad.setColorAt( 0, pal.color( QPalette::Active, QPalette::Button ) );
grad.setColorAt( 1, pal.color( QPalette::Active, QPalette::Light ) );
bufferPainter.setBrush( QBrush( grad ) );
// 4.2. draw rounded border
// 5.2. draw rounded border
bufferPainter.setPen( pal.color( QPalette::Active, QPalette::Dark ) );
bufferPainter.setRenderHints( QPainter::Antialiasing );
if ( vertical )
bufferPainter.drawRoundRect( topLeft ? -10 : 0, 0, myWidth + 10, myHeight, 2000 / (myWidth + 10), 2000 / myHeight );
else
bufferPainter.drawRoundRect( 0, topLeft ? -10 : 0, myWidth, myHeight + 10, 2000 / myWidth, 2000 / (myHeight + 10) );
// 4.3. draw handle
// 5.3. draw handle
bufferPainter.setPen( pal.color( QPalette::Active, QPalette::Mid ) );
if ( vertical )
{
@ -684,7 +696,7 @@ void ToolBarPrivate::buildToolBar()
bufferPainter.drawLine( 10, dy + 1, 10, dy + myHeight - 7 );
}
// 5. reposition buttons (in rows/col grid)
// 6. reposition buttons (in rows/col grid)
int gridX = 0,
gridY = 0;
QLinkedList< ToolBarButton * >::const_iterator it = buttons.begin(), end = buttons.end();