void TalkablePainter::paint(QPainter *painter) { ItemRect = Option.rect; ItemRect.adjust(HFrameMargin, VFrameMargin, -HFrameMargin, -VFrameMargin); computeLayout(); fixColors(); // some bit of broken logic if (drawSelected() || drawDisabled() || !Configuration->useConfigurationColors()) painter->setPen(textColor()); else { Buddy buddy = Index.data(BuddyRole).value<Buddy>(); Contact contact = Index.data(ContactRole).value<Contact>(); if (buddy.isBlocked() || contact.isBlocking()) painter->setPen(QColor(255, 0, 0)); else painter->setPen(Configuration->fontColor()); } paintCheckbox(painter); paintIcon(painter); paintAvatar(painter); paintIdentityName(painter); paintName(painter); paintDescription(painter); /* paintDebugRect(painter, ItemRect, QColor(255, 0, 0)); paintDebugRect(painter, CheckboxRect, QColor(255, 255, 0)); paintDebugRect(painter, IconRect, QColor(0, 255, 0)); paintDebugRect(painter, AvatarRect, QColor(0, 0, 255)); paintDebugRect(painter, IdentityNameRect, QColor(255, 0, 255)); paintDebugRect(painter, NameRect, QColor(0, 255, 255)); paintDebugRect(painter, DescriptionRect, QColor(0, 0, 0)); */ }
void ArthurFrame::paintEvent(QPaintEvent *e) { #ifdef Q_WS_QWS static QPixmap *static_image = 0; #else static QImage *static_image = 0; #endif QPainter painter; if (preferImage() #ifdef QT_OPENGL_SUPPORT && !m_use_opengl #endif ) { if (!static_image || static_image->size() != size()) { delete static_image; #ifdef Q_WS_QWS static_image = new QPixmap(size()); #else static_image = new QImage(size(), QImage::Format_RGB32); #endif } painter.begin(static_image); int o = 10; QBrush bg = palette().brush(QPalette::Background); painter.fillRect(0, 0, o, o, bg); painter.fillRect(width() - o, 0, o, o, bg); painter.fillRect(0, height() - o, o, o, bg); painter.fillRect(width() - o, height() - o, o, o, bg); } else { #ifdef QT_OPENGL_SUPPORT if (m_use_opengl) { painter.begin(glw); painter.fillRect(QRectF(0, 0, glw->width(), glw->height()), palette().color(backgroundRole())); } else { painter.begin(this); } #else painter.begin(this); #endif } painter.setClipRect(e->rect()); painter.setRenderHint(QPainter::Antialiasing); QPainterPath clipPath; QRect r = rect(); qreal left = r.x() + 1; qreal top = r.y() + 1; qreal right = r.right(); qreal bottom = r.bottom(); qreal radius2 = 8 * 2; clipPath.moveTo(right - radius2, top); clipPath.arcTo(right - radius2, top, radius2, radius2, 90, -90); clipPath.arcTo(right - radius2, bottom - radius2, radius2, radius2, 0, -90); clipPath.arcTo(left, bottom - radius2, radius2, radius2, 270, -90); clipPath.arcTo(left, top, radius2, radius2, 180, -90); clipPath.closeSubpath(); painter.save(); painter.setClipPath(clipPath, Qt::IntersectClip); painter.drawTiledPixmap(rect(), m_tile); // client painting paint(&painter); painter.restore(); painter.save(); if (m_show_doc) paintDescription(&painter); painter.restore(); int level = 180; painter.setPen(QPen(QColor(level, level, level), 2)); painter.setBrush(Qt::NoBrush); painter.drawPath(clipPath); if (preferImage() #ifdef QT_OPENGL_SUPPORT && !m_use_opengl #endif ) { painter.end(); painter.begin(this); #ifdef Q_WS_QWS painter.drawPixmap(e->rect(), *static_image, e->rect()); #else painter.drawImage(e->rect(), *static_image, e->rect()); #endif } #ifdef QT_OPENGL_SUPPORT if (m_use_opengl && (inherits("PathDeformRenderer") || inherits("PathStrokeRenderer") || inherits("CompositionRenderer") || m_show_doc)) glw->swapBuffers(); #endif }
void ArthurFrame::paintEvent(QPaintEvent *e) { static QImage *static_image = 0; QPainter painter; if (preferImage()) { if (!static_image) { static_image = new QImage(size(), QImage::Format_RGB32); } else if (static_image->size() != size()) { delete static_image; static_image = new QImage(size(), QImage::Format_RGB32); } painter.begin(static_image); int o = 10; QBrush bg = palette().brush(QPalette::Background); painter.fillRect(0, 0, o, o, bg); painter.fillRect(width() - o, 0, o, o, bg); painter.fillRect(0, height() - o, o, o, bg); painter.fillRect(width() - o, height() - o, o, o, bg); } else { painter.begin(this); } painter.setClipRect(e->rect()); painter.setRenderHint(QPainter::Antialiasing); QPainterPath clipPath; QRect r = rect(); double left = r.x() + 1; double top = r.y() + 1; double right = r.right(); double bottom = r.bottom(); double radius2 = 8 * 2; clipPath.moveTo(right - radius2, top); clipPath.arcTo(right - radius2, top, radius2, radius2, 90, -90); clipPath.arcTo(right - radius2, bottom - radius2, radius2, radius2, 0, -90); clipPath.arcTo(left, bottom - radius2, radius2, radius2, 270, -90); clipPath.arcTo(left, top, radius2, radius2, 180, -90); clipPath.closeSubpath(); painter.save(); painter.setClipPath(clipPath, Qt::IntersectClip); painter.drawTiledPixmap(rect(), m_tile); // client painting paint(&painter); painter.restore(); painter.save(); if (m_show_doc) paintDescription(&painter); painter.restore(); int level = 180; painter.setPen(QPen(QColor(level, level, level), 2)); painter.setBrush(Qt::NoBrush); painter.drawPath(clipPath); if (preferImage()) { painter.end(); painter.begin(this); painter.drawImage(e->rect(), *static_image, e->rect()); } }