void UBGraphicsTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { QColor color = UBSettings::settings()->isDarkBackground() ? mColorOnDarkBackground : mColorOnLightBackground; setDefaultTextColor(color); // Never draw the rubber band, we draw our custom selection with the DelegateFrame QStyleOptionGraphicsItem styleOption = QStyleOptionGraphicsItem(*option); styleOption.state &= ~QStyle::State_Selected; styleOption.state &= ~QStyle::State_HasFocus; QGraphicsTextItem::paint(painter, &styleOption, widget); if (widget == UBApplication::boardController->controlView()->viewport() && !isSelected() && toPlainText().isEmpty()) { QFontMetrics fm(font()); setTextWidth(fm.width(mTypeTextHereLabel)); painter->setFont(font()); painter->setPen(UBSettings::paletteColor); painter->drawText(boundingRect(), Qt::AlignCenter, mTypeTextHereLabel); setTextInteractionFlags(Qt::NoTextInteraction); } Delegate()->postpaint(painter, option, widget); }
void UBGraphicsStrokesGroup::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { // Never draw the rubber band, we draw our custom selection with the DelegateFrame QStyleOptionGraphicsItem styleOption = QStyleOptionGraphicsItem(*option); styleOption.state &= ~QStyle::State_Selected; QGraphicsItemGroup::paint(painter, &styleOption, widget); }
void UBGraphicsCurtainItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { QColor color = drawColor(); if(widget == UBApplication::boardController->controlView()->viewport()) { color = UBSettings::paletteColor; if(!UBApplication::applicationController->displayManager()->hasDisplay()) { color = opaqueControlColor(); } } // Never draw the rubber band, we draw our custom selection with the DelegateFrame QStyleOptionGraphicsItem styleOption = QStyleOptionGraphicsItem(*option); styleOption.state &= ~QStyle::State_Selected; painter->fillRect(rect(), color); }
void UBGraphicsPathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(widget) // Never draw the rubber band, we draw our custom selection with the DelegateFrame QStyleOptionGraphicsItem styleOption = QStyleOptionGraphicsItem(*option); styleOption.state &= ~QStyle::State_Selected; styleOption.state &= ~QStyle::State_HasFocus; if(this->isClosed()) painter->setBrush(*fillingProperty()); painter->setPen(*strokeProperty()); if (isClosed()) { painter->fillPath(path(), painter->brush()); } //QGraphicsPathItem::paint(painter, &styleOption, widget); painter->drawPath(path()); if (!isClosed()) { QPen penHandles; penHandles.setWidth(1); penHandles.setColor(Qt::black); penHandles.setStyle(Qt::SolidLine); painter->setPen(penHandles); int hsize = HANDLE_SIZE/2; if (mIsInCreationMode) { painter->drawEllipse(mStartEndPoint[0].x() - hsize, mStartEndPoint[0].y() - hsize, HANDLE_SIZE, HANDLE_SIZE); if(path().elementCount() >= 2) painter->drawEllipse(mStartEndPoint[1].x() - hsize, mStartEndPoint[1].y() - hsize, HANDLE_SIZE, HANDLE_SIZE); } } }