mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-28 19:28:38 +00:00
Draw the review toolbar borders anti-aliased.
svn path=/trunk/KDE/kdegraphics/okular/; revision=756114
This commit is contained in:
parent
cb4367608b
commit
3af668a384
1 changed files with 9 additions and 22 deletions
|
@ -411,8 +411,6 @@ public:
|
||||||
PageViewToolBar::PageViewToolBar( QWidget * parent, QWidget * anchorWidget )
|
PageViewToolBar::PageViewToolBar( QWidget * parent, QWidget * anchorWidget )
|
||||||
: QWidget( parent ), d( new ToolBarPrivate( this ) )
|
: QWidget( parent ), d( new ToolBarPrivate( this ) )
|
||||||
{
|
{
|
||||||
setAttribute( Qt::WA_OpaquePaintEvent, true );
|
|
||||||
|
|
||||||
// initialize values of the private data storage structure
|
// initialize values of the private data storage structure
|
||||||
d->anchorWidget = anchorWidget;
|
d->anchorWidget = anchorWidget;
|
||||||
d->anchorSide = Left;
|
d->anchorSide = Left;
|
||||||
|
@ -539,7 +537,7 @@ void PageViewToolBar::paintEvent( QPaintEvent * e )
|
||||||
{
|
{
|
||||||
// paint the internal pixmap over the widget
|
// paint the internal pixmap over the widget
|
||||||
QPainter p( this );
|
QPainter p( this );
|
||||||
p.drawPixmap( e->rect().topLeft(), d->backgroundPixmap, e->rect() );
|
p.drawImage( e->rect().topLeft(), d->backgroundPixmap.toImage(), e->rect() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void PageViewToolBar::mousePressEvent( QMouseEvent * e )
|
void PageViewToolBar::mousePressEvent( QMouseEvent * e )
|
||||||
|
@ -630,26 +628,15 @@ void ToolBarPrivate::buildToolBar()
|
||||||
bool prevUpdates = q->updatesEnabled();
|
bool prevUpdates = q->updatesEnabled();
|
||||||
q->setUpdatesEnabled( false );
|
q->setUpdatesEnabled( false );
|
||||||
|
|
||||||
// 3. resize pixmap, mask and widget
|
// 3. resize pixmap and widget
|
||||||
QBitmap mask( myWidth + 1, myHeight + 1 );
|
|
||||||
backgroundPixmap = QPixmap( myWidth + 1, myHeight + 1 );
|
backgroundPixmap = QPixmap( myWidth + 1, myHeight + 1 );
|
||||||
|
backgroundPixmap.fill(Qt::transparent);
|
||||||
q->resize( myWidth + 1, myHeight + 1 );
|
q->resize( myWidth + 1, myHeight + 1 );
|
||||||
|
|
||||||
// 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 );
|
QPainter bufferPainter( &backgroundPixmap );
|
||||||
QPalette pal = q->palette();
|
QPalette pal = q->palette();
|
||||||
// 5.1. draw horizontal/vertical gradient
|
// 4.1. draw horizontal/vertical gradient
|
||||||
QLinearGradient grad;
|
QLinearGradient grad;
|
||||||
switch ( anchorSide )
|
switch ( anchorSide )
|
||||||
{
|
{
|
||||||
|
@ -668,15 +655,15 @@ void ToolBarPrivate::buildToolBar()
|
||||||
}
|
}
|
||||||
grad.setColorAt( 0, pal.color( QPalette::Active, QPalette::Button ) );
|
grad.setColorAt( 0, pal.color( QPalette::Active, QPalette::Button ) );
|
||||||
grad.setColorAt( 1, pal.color( QPalette::Active, QPalette::Light ) );
|
grad.setColorAt( 1, pal.color( QPalette::Active, QPalette::Light ) );
|
||||||
bufferPainter.fillRect( 0, 0, myWidth + 1, myHeight + 1, grad );
|
bufferPainter.setBrush( QBrush( grad ) );
|
||||||
// 5.2. draw rounded border
|
// 4.2. draw rounded border
|
||||||
bufferPainter.setPen( pal.color( QPalette::Active, QPalette::Dark ) );
|
bufferPainter.setPen( pal.color( QPalette::Active, QPalette::Dark ) );
|
||||||
bufferPainter.setRenderHints( QPainter::Antialiasing );
|
bufferPainter.setRenderHints( QPainter::Antialiasing );
|
||||||
if ( vertical )
|
if ( vertical )
|
||||||
bufferPainter.drawRoundRect( topLeft ? -10 : 0, 0, myWidth + 10, myHeight, 2000 / (myWidth + 10), 2000 / myHeight );
|
bufferPainter.drawRoundRect( topLeft ? -10 : 0, 0, myWidth + 10, myHeight, 2000 / (myWidth + 10), 2000 / myHeight );
|
||||||
else
|
else
|
||||||
bufferPainter.drawRoundRect( 0, topLeft ? -10 : 0, myWidth, myHeight + 10, 2000 / myWidth, 2000 / (myHeight + 10) );
|
bufferPainter.drawRoundRect( 0, topLeft ? -10 : 0, myWidth, myHeight + 10, 2000 / myWidth, 2000 / (myHeight + 10) );
|
||||||
// 5.3. draw handle
|
// 4.3. draw handle
|
||||||
bufferPainter.setPen( pal.color( QPalette::Active, QPalette::Mid ) );
|
bufferPainter.setPen( pal.color( QPalette::Active, QPalette::Mid ) );
|
||||||
if ( vertical )
|
if ( vertical )
|
||||||
{
|
{
|
||||||
|
@ -697,7 +684,7 @@ void ToolBarPrivate::buildToolBar()
|
||||||
bufferPainter.drawLine( 10, dy + 1, 10, dy + myHeight - 7 );
|
bufferPainter.drawLine( 10, dy + 1, 10, dy + myHeight - 7 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. reposition buttons (in rows/col grid)
|
// 5. reposition buttons (in rows/col grid)
|
||||||
int gridX = 0,
|
int gridX = 0,
|
||||||
gridY = 0;
|
gridY = 0;
|
||||||
QLinkedList< ToolBarButton * >::const_iterator it = buttons.begin(), end = buttons.end();
|
QLinkedList< ToolBarButton * >::const_iterator it = buttons.begin(), end = buttons.end();
|
||||||
|
|
Loading…
Reference in a new issue