1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

use QPainter::setClipRect

This commit is contained in:
krepa098 2015-02-03 16:17:37 +01:00
parent 0af05929f7
commit e4c52e6118
4 changed files with 8 additions and 0 deletions

View File

@ -37,6 +37,8 @@ qreal Image::getAscent() const
void Image::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) void Image::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{ {
painter->setClipRect(boundingRect());
painter->setRenderHint(QPainter::SmoothPixmapTransform); painter->setRenderHint(QPainter::SmoothPixmapTransform);
painter->translate(-size.width() / 2.0, -size.height() / 2.0); painter->translate(-size.width() / 2.0, -size.height() / 2.0);
painter->drawPixmap(0, 0, pmap); painter->drawPixmap(0, 0, pmap);

View File

@ -42,6 +42,8 @@ QRectF NotificationIcon::boundingRect() const
void NotificationIcon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void NotificationIcon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
painter->setClipRect(boundingRect());
painter->setRenderHint(QPainter::SmoothPixmapTransform); painter->setRenderHint(QPainter::SmoothPixmapTransform);
painter->translate(-size.width() / 2.0, -size.height() / 2.0); painter->translate(-size.width() / 2.0, -size.height() / 2.0);

View File

@ -40,6 +40,8 @@ QRectF Spinner::boundingRect() const
void Spinner::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) void Spinner::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{ {
painter->setClipRect(boundingRect());
QTransform rotMat; QTransform rotMat;
rotMat.translate(size.width() / 2.0, size.height() / 2.0); rotMat.translate(size.width() / 2.0, size.height() / 2.0);
rotMat.rotate(rot); rotMat.rotate(rot);

View File

@ -155,6 +155,8 @@ void Text::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWid
{ {
if(doc) if(doc)
{ {
painter->setClipRect(boundingRect());
// draw selection // draw selection
QAbstractTextDocumentLayout::PaintContext ctx; QAbstractTextDocumentLayout::PaintContext ctx;
QAbstractTextDocumentLayout::Selection sel; QAbstractTextDocumentLayout::Selection sel;