void GraphicsScene::drawForeground(QPainter *painter, const QRectF &rect) { QRectF textRect(rect.left(), rect.bottom()-100, rect.width(), 100); painter->drawText(textRect, QString("copyright @ Wang Wei. SEU. Nanjing"), QTextOption(Qt::AlignCenter) ); QRectF titleRect(rect.left(), rect.top(), rect.width(), 50); QFont titleFont; titleFont.setPointSizeF(20); titleFont.setWeight(QFont::Bold); painter->setFont(titleFont); painter->drawText(titleRect, QString(mTitle), QTextOption(Qt::AlignCenter)); }
void GraphicsWidget::drawControlText(QPainter &painter, int top, const QString &labelText, const QString &valueText) { int labelLeft = width() - 200 + 5; int labelWidth = 40; int valueLeft = labelLeft + labelWidth + 10; int valueWidth = 150; if (!staticText.contains(labelText)) { QStaticText t(labelText); t.setPerformanceHint(QStaticText::AggressiveCaching); t.setTextFormat(Qt::PlainText); t.setTextWidth(labelWidth); t.setTextOption(QTextOption(Qt::AlignRight)); staticText.insert(labelText, t); } if (!staticText.contains(valueText)) { QStaticText t(valueText); t.setPerformanceHint(QStaticText::AggressiveCaching); t.setTextFormat(Qt::PlainText); t.setTextWidth(valueWidth); t.setTextOption(QTextOption(Qt::AlignLeft)); staticText.insert(valueText, t); } painter.drawStaticText(labelLeft, top, staticText.value(labelText)); painter.drawStaticText(valueLeft, top, staticText.value(valueText)); }
void QueueSystem::drawCountsRequests(QPainter *painter) { painter->save(); painter->setPen(getColorText()); painter->drawText(QRect(35, m_size.height() / 2, m_size.width() - 35, m_size.height() / 3), QString(tr("Число элемнтов ")) + QString::number(m_countRequests), QTextOption(Qt::AlignLeft)); painter->drawText(QRect(35, 3 * m_size.height() / 4, m_size.width() - 35, m_size.height() / 3), QString(tr("Максимум ")) + QString::number(m_maxCountRequests), QTextOption(Qt::AlignLeft)); painter->restore(); }
void IconButton::paintEvent(QPaintEvent *evt) { QPainter painter(this); painter.drawPixmap(rect(),m_cur_icon); if ( NULL == m_txt_lb ) painter.drawText(QRectF(rect()),m_txt,QTextOption(Qt::AlignHCenter | Qt::AlignVCenter)); }
void OrientationWidget::paintEvent(QPaintEvent *) { QPainter p(this); p.setPen(palette().color(QPalette::Text)); p.setBrush(palette().window()); double radius = radiusCircle(); QPointF centerCircle = this->centerCircle(); p.drawEllipse(centerCircle, radius, radius); p.translate(centerCircle); p.rotate(_value); p.drawLines(QVector<QLineF>() << QLineF(QPointF(-radius, 0), QPointF(radius, 0)) << QLineF(QPointF(0, -radius), QPointF(0, radius))); if(_value >= 90 && _value < 270) { p.rotate(180); p.drawText(QRectF(0.0, 0.0, radius-4, radius-4), tr("Droite"), QTextOption(Qt::AlignRight)); } else { p.drawText(QPointF(-radius+4, -4), tr("Droite")); } }
void IntroPwdCheck::paintEvent(QPaintEvent *e) { bool trivial = (rect() == e->rect()); QPainter p(this); if (!trivial) { p.setClipRect(e->rect()); } if (trivial || e->rect().intersects(textRect)) { p.setFont(st::introHeaderFont->f); p.drawText(textRect, lang(lng_signin_title), style::al_top); p.setFont(st::introFont->f); p.drawText(textRect, lang(_pwdField.isHidden() ? lng_signin_recover_desc : lng_signin_desc), style::al_bottom); } if (_pwdField.isHidden()) { if (!_emailPattern.isEmpty()) { p.drawText(QRect(textRect.x(), _pwdField.y() + _pwdField.height() + st::introFinishSkip, textRect.width(), st::introFont->height), _emailPattern, style::al_top); } } else if (!_hint.isEmpty()) { _hintText.drawElided(p, _pwdField.x(), _pwdField.y() + _pwdField.height() + st::introFinishSkip, _pwdField.width(), 1, style::al_top); } if (animating() || error.length()) { p.setOpacity(errorAlpha.current()); QRect errRect((width() - st::introErrWidth) / 2, (_pwdField.y() + _pwdField.height() + st::introFinishSkip + st::introFont->height + _next.y() - st::introErrHeight) / 2, st::introErrWidth, st::introErrHeight); p.setFont(st::introErrFont->f); p.setPen(st::introErrColor->p); p.drawText(errRect, error, QTextOption(style::al_center)); p.setOpacity(1); } }
void FilmstripFrames::drawFrameIcon(QPainter &p, const QRect &r, int index, const TFrameId &fid, int flags) { QPixmap pm; TXshSimpleLevel *sl = getLevel(); if (sl) { pm = IconGenerator::instance()->getIcon(sl, fid); } if (!pm.isNull()) { p.drawPixmap(r.left(), r.top(), pm); if (sl && sl->getType() == PLI_XSHLEVEL && flags & F_INBETWEEN_RANGE) { int x1 = r.right(); int x0 = x1 - 12; int y0 = r.top(); int y1 = r.bottom(); p.fillRect(x0, y0, x1 - x0 + 1, y1 - y0 + 1, QColor(180, 180, 180, 255)); p.setPen(Qt::black); p.drawLine(x0 - 1, y0, x0 - 1, y1); QPixmap inbetweenPixmap( svgToPixmap(":Resources/filmstrip_inbetween.svg")); p.drawPixmap( x0 + 2, y1 - inbetweenPixmap.height() / inbetweenPixmap.devicePixelRatio() - 3, inbetweenPixmap); } } else { // non riesco (per qualche ragione) a visualizzare l'icona p.fillRect(r, QColor(255, 200, 200)); p.setPen(Qt::black); p.drawText(r, tr("no icon"), QTextOption(Qt::AlignCenter)); } }
FadingMultilineLabel::FadingMultilineLabel(QWidget* parent) : QWidget(parent) , textLayout_(0) { textOption_ = QTextOption(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignTop); textOption_.setWrapMode(QTextOption::WordWrap); }
void FlatInput::paintEvent(QPaintEvent *e) { Painter p(this); p.fillRect(rect(), a_bgColor.current()); if (_st.borderWidth) { QBrush b(a_borderColor.current()); p.fillRect(0, 0, width() - _st.borderWidth, _st.borderWidth, b); p.fillRect(width() - _st.borderWidth, 0, _st.borderWidth, height() - _st.borderWidth, b); p.fillRect(_st.borderWidth, height() - _st.borderWidth, width() - _st.borderWidth, _st.borderWidth, b); p.fillRect(0, _st.borderWidth, _st.borderWidth, height() - _st.borderWidth, b); } if (_st.imgRect.pxWidth()) { p.drawPixmap(_st.imgPos, App::sprite(), _st.imgRect); } bool phDraw = _phVisible; if (animating()) { p.setOpacity(a_phAlpha.current()); phDraw = true; } if (phDraw) { p.save(); p.setClipRect(rect()); QRect phRect(placeholderRect()); phRect.moveLeft(phRect.left() + a_phLeft.current()); phPrepare(p); p.drawText(phRect, _ph, QTextOption(_st.phAlign)); p.restore(); } QLineEdit::paintEvent(e); }
QPixmap QDeclarativeTextPrivate::richTextImage(bool drawStyle) { QSize size = doc->size().toSize(); //paint text QPixmap img(size); img.fill(Qt::transparent); QPainter p(&img); QAbstractTextDocumentLayout::PaintContext context; if (drawStyle) { context.palette.setColor(QPalette::Text, styleColor); // ### Do we really want this? QTextOption colorOption; colorOption.setFlags(QTextOption::SuppressColors); doc->setDefaultTextOption(colorOption); } else { context.palette.setColor(QPalette::Text, color); } doc->documentLayout()->draw(&p, context); if (drawStyle) doc->setDefaultTextOption(QTextOption()); return img; }
void SourceDelegate::paintCategory( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const { painter->save(); QFont font = painter->font(); font.setPointSize( TomahawkUtils::defaultFontSize() - 1 ); painter->setFont( font ); painter->setPen( Qt::black ); painter->setOpacity( 0.5 ); painter->drawText( option.rect.adjusted( m_margin / 2, 0, -m_margin, 0 ), index.data().toString().toUpper(), QTextOption( Qt::AlignVCenter ) ); if ( option.state & QStyle::State_MouseOver ) { QString text = tr( "Show" ); if ( option.state & QStyle::State_Open ) text = tr( "Hide" ); // draw close icon painter->setPen( TomahawkStyle::GROUP_HEADER ); painter->drawText( option.rect.translated( -m_margin / 4, 0 ), text, QTextOption( Qt::AlignVCenter | Qt::AlignRight ) ); } painter->restore(); }
void EmojiBox::paintEvent(QPaintEvent *e) { QPainter p(this); if (_cache.isNull()) { if (!_hiding || a_opacity.current() > 0.01) { // fill bg p.fillRect(0, 0, _width, _height, st::boxBG->b); p.setFont(st::boxFont->f); p.setPen(st::boxGrayTitle->p); _header.draw(p, 0, st::boxPadding.top(), _width, Qt::AlignCenter); p.setFont(st::emojiTextFont->f); p.setPen(st::black->p); int32 top = st::boxPadding.top() + st::boxFont->height + (st::emojiReplaceHeight - _blockHeight) / 2; for (Blocks::const_iterator i = _blocks.cbegin(), e = _blocks.cend(); i != e; ++i) { int32 rowSize = i->size(), left = (_width - rowSize * st::emojiReplaceWidth) / 2; for (BlockRow::const_iterator j = i->cbegin(), en = i->cend(); j != en; ++j) { if (j->emoji) { QPoint pos(left + (st::emojiReplaceWidth - st::emojiSize) / 2, top + (st::emojiReplaceHeight - _blockHeight) / 2); p.drawPixmap(pos, App::emojis(), QRect(j->emoji->x, j->emoji->y, st::emojiSize, st::emojiSize)); } QRect trect(left, top + (st::emojiReplaceHeight + _blockHeight) / 2 - st::emojiTextFont->height, st::emojiReplaceWidth, st::emojiTextFont->height); p.drawText(trect, j->text, QTextOption(Qt::AlignHCenter | Qt::AlignTop)); left += st::emojiReplaceWidth; } top += st::emojiReplaceHeight; } } } else { p.setOpacity(a_opacity.current()); p.drawPixmap(0, 0, _cache); } }
void paintSection( QPainter * painter, const QRect& rect, int logicalIndex ) const override { if ( rect.isValid() ) { if ( logicalIndex > 0 ) { QStyleOptionHeader op; initStyleOption(&op); op.text = ""; op.rect = rect; op.textAlignment = Qt::AlignVCenter | Qt::AlignHCenter; // draw the section style()->drawControl( QStyle::CE_Header, &op, painter, this ); // html painting painter->save(); QRect textRect = style()->subElementRect( QStyle::SE_HeaderLabel, &op, this ); painter->translate( textRect.topLeft() ); QTextDocument doc; doc.setTextWidth( textRect.width() ); doc.setDefaultTextOption( QTextOption( Qt::AlignHCenter ) ); doc.setDocumentMargin(0); doc.setHtml( model()->headerData( logicalIndex, Qt::Horizontal ).toString() ); doc.drawContents( painter, QRect( QPoint( 0, 0 ), textRect.size() ) ); painter->restore(); } else { QHeaderView::paintSection( painter, rect, logicalIndex ); } } }
/** * Décrit le façon de dessiner l'élément sur la scène * * @brief Item_Tempo::paint(QPainter *pPainter, const QStyleOptionGraphicsItem * option, QWidget * widget) * @param pPainter le pinceau servant à dessiner sur la scène * @param option Option sur le dessin (pas utile dans notre cas) * @param widget Pointer vers le widget sur lequel l'item sera peint (pas utile dans notre cas) * @see Item */ void Item_Tempo::paint(QPainter *pPainter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/) { this->GererSelection(pPainter) ; this->sTexte = this->pInstRepresentee->toString() ; //Définition du dégradé qreal top (this->rect.top()) ; QPointF PremierPoint (0, top) ; QPointF SecondPoint (0, -top) ; QLinearGradient grad (PremierPoint, SecondPoint) ; QColor PremiereCouleur (0x5E, 0xC1, 0xFF, 0xFF) ; QColor SecondeCouleur (0x22, 0xAA, 0xFF, 0xFF) ; grad.setColorAt(0, PremiereCouleur) ; grad.setColorAt(1, SecondeCouleur) ; //Définition du brush QBrush brush(grad) ; pPainter->setBrush(brush) ; //Dessin de l'item qreal Rayon (-top) ; QPointF Centre (0, 0) ; QRectF RectTexte (top, top, -2*top, -2*top) ; pPainter->drawEllipse(Centre, Rayon, Rayon) ; pPainter->setPen(QPen()); pPainter->drawText(RectTexte, sTexte, QTextOption(Qt::AlignCenter)) ; }
void QgsMapCanvas::rendererJobFinished() { QgsDebugMsg( QString( "CANVAS finish! %1" ).arg( !mJobCancelled ) ); mMapUpdateTimer.stop(); // TODO: would be better to show the errors in message bar Q_FOREACH ( const QgsMapRendererJob::Error& error, mJob->errors() ) { QgsMessageLog::logMessage( error.layerID + " :: " + error.message, tr( "Rendering" ) ); } if ( !mJobCancelled ) { // take labeling results before emitting renderComplete, so labeling map tools // connected to signal work with correct results delete mLabelingResults; mLabelingResults = mJob->takeLabelingResults(); QImage img = mJob->renderedImage(); // emit renderComplete to get our decorations drawn QPainter p( &img ); emit renderComplete( &p ); QSettings settings; if ( settings.value( "/Map/logCanvasRefreshEvent", false ).toBool() ) { QString logMsg = tr( "Canvas refresh: %1 ms" ).arg( mJob->renderingTime() ); QgsMessageLog::logMessage( logMsg, tr( "Rendering" ) ); } if ( mDrawRenderingStats ) { int w = img.width(), h = img.height(); QFont fnt = p.font(); fnt.setBold( true ); p.setFont( fnt ); int lh = p.fontMetrics().height() * 2; QRect r( 0, h - lh, w, lh ); p.setPen( Qt::NoPen ); p.setBrush( QColor( 0, 0, 0, 110 ) ); p.drawRect( r ); p.setPen( Qt::white ); QString msg = QString( "%1 :: %2 ms" ).arg( mUseParallelRendering ? "PARALLEL" : "SEQUENTIAL" ).arg( mJob->renderingTime() ); p.drawText( r, msg, QTextOption( Qt::AlignCenter ) ); } p.end(); mMap->setContent( img, imageRect( img, mJob->mapSettings() ) ); } // now we are in a slot called from mJob - do not delete it immediately // so the class is still valid when the execution returns to the class mJob->deleteLater(); mJob = 0; emit mapCanvasRefreshed(); }
void FlatInput::paintEvent(QPaintEvent *e) { QPainter p(this); p.fillRect(rect(), a_bgColor.current()); if (_st.borderWidth) { p.setPen(a_borderColor.current()); for (uint32 i = 0; i < _st.borderWidth; ++i) { p.drawRect(i, i, width() - 2 * i - 1, height() - 2 * i - 1); } } if (_st.imgRect.pxWidth()) { p.drawPixmap(_st.imgPos, App::sprite(), _st.imgRect); } bool phDraw = _phVisible; if (animating()) { p.setOpacity(a_phAlpha.current()); phDraw = true; } if (phDraw) { p.save(); p.setClipRect(rect()); QRect phRect(_st.textMrg.left() + _st.phPos.x() + a_phLeft.current(), _st.textMrg.top() + _st.phPos.y(), width() - _st.textMrg.left() - _st.textMrg.right(), height() - _st.textMrg.top() - _st.textMrg.bottom()); p.setFont(_st.font->f); p.setPen(a_phColor.current()); p.drawText(phRect, _ph, QTextOption(_st.phAlign)); p.restore(); } QLineEdit::paintEvent(e); }
static void drawRotatedText (QPainter &p, int x, int y, int width, int height, float angle, const QString text) { p.translate(x, y); p.rotate(angle); p.drawText(QRectF(0,0,width,height),text,QTextOption(Qt::AlignHCenter)); p.rotate(-1*angle); p.translate(-1*x, -1*y); }
void FlatTextarea::paintEvent(QPaintEvent *e) { QPainter p(viewport()); QRect r(rect().intersected(e->rect())); p.fillRect(r, _st.bgColor->b); bool phDraw = _phVisible; if (_a_appearance.animating()) { p.setOpacity(a_phAlpha.current()); phDraw = true; } if (phDraw) { p.save(); p.setClipRect(r); p.setFont(_st.font); p.setPen(a_phColor.current()); if (_st.phAlign == style::al_topleft && _phAfter > 0) { p.drawText(_st.textMrg.left() - _fakeMargin + a_phLeft.current() + _st.font->width(getLastText().mid(0, _phAfter)), _st.textMrg.top() - _fakeMargin - st::lineWidth + _st.font->ascent, _ph); } else { QRect phRect(_st.textMrg.left() - _fakeMargin + _st.phPos.x() + a_phLeft.current(), _st.textMrg.top() - _fakeMargin + _st.phPos.y(), width() - _st.textMrg.left() - _st.textMrg.right(), height() - _st.textMrg.top() - _st.textMrg.bottom()); p.drawText(phRect, _ph, QTextOption(_st.phAlign)); } p.restore(); p.setOpacity(1); } QTextEdit::paintEvent(e); }
ClientPlayer::ClientPlayer(Client *client) :Player(client), handcard_num(0) { mark_doc = new QTextDocument(this); mark_doc->setTextWidth(128); mark_doc->setDefaultTextOption(QTextOption(Qt::AlignRight)); }
/** * Décrit le façon de dessiner l'élément sur la scène * * @brief Item_Ope::paint(QPainter *pPainter, const QStyleOptionGraphicsItem * option, QWidget * widget) * @param pPainter le pinceau servant à dessiner sur la scène * @param option Option sur le dessin (pas utile dans notre cas) * @param widget Pointer vers le widget sur lequel l'item sera peint (pas utile dans notre cas) * @see Item */ void Item_Ope::paint(QPainter *pPainter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/) { this->GererSelection(pPainter) ; this->sTexte = this->pInstRepresentee->toString() ; //Définition du dégradé dans l'item qreal top (this->rect.top()) ; QPointF PremierPoint (0, top) ; QPointF SecondPoint (0, -top) ; QLinearGradient grad (PremierPoint, SecondPoint) ; QColor PremiereCouleur (0x98, 0xFE, 0x98, 0xFF) ; QColor SecondeCouleur (0x62, 0xBA, 0x62, 0xFF) ; grad.setColorAt(0, PremiereCouleur) ; grad.setColorAt(1, SecondeCouleur) ; //Définition du brush pour appliquer le dégradé QBrush brush (grad) ; //Dessin de l'item pPainter->setBrush(brush); pPainter->drawRect(rect); pPainter->setPen(QPen()); pPainter->drawText(rect, sTexte, QTextOption(Qt::AlignCenter)); }
void Board::drawStone(QPainter &p, int id) { if (isDead(id)) { return; } QColor color; if (red(id)) { color = Qt::red; } else { color = Qt::black; } p.setPen(QPen(QBrush(color), 2)); if (id == _selectid) { p.setBrush(Qt::gray); } else { p.setBrush(Qt::yellow); } p.drawEllipse(cell(id)); p.setFont(QFont("system", _r * 1.2, 700)); // 设置字体大小和类型 p.drawText(cell(id), name(id), QTextOption(Qt::AlignCenter)); }
/** * Décrit le façon de dessiner l'élément sur la scène * * @brief Item_Rout::paint(QPainter *pPainter, const QStyleOptionGraphicsItem * option, QWidget * widget) * @param pPainter le pinceau servant à dessiner sur la scène * @param option Option sur le dessin (pas utile dans notre cas) * @param widget Pointer vers le widget sur lequel l'item sera peint (pas utile dans notre cas) * @see Item */ void Item_Rout::paint(QPainter *pPainter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/) { this->GererSelection(pPainter) ; this->sTexte = this->pInstRepresentee->toString() ; //Définition du dégradé qreal top (this->rect.top()) ; qreal left (this->rect.left()) ; QPointF PremierPoint (0, top) ; QPointF SecondPoint (0, -top) ; QLinearGradient grad (PremierPoint, SecondPoint) ; QColor PremiereCouleur (0xFF, 0xD5, 0x98, 0xFF) ; QColor SecondeCouleur (0xF3, 0xA6, 0x62, 0xFF) ; grad.setColorAt(0, PremiereCouleur); grad.setColorAt(1, SecondeCouleur); //Définition du brush QBrush brush(grad); pPainter->setBrush(brush); //Dessin de l'item QPointF OriginePrem (left*(7.0/8.0), top) ; QPointF FinPrem (left*(7.0/8.0), -top) ; QPointF OrigineSec (-left*(7.0/8.0), top) ; QPointF FinSec (-left*(7.0/8.0), -top) ; pPainter->drawRect(rect); pPainter->drawLine(OriginePrem, FinPrem); pPainter->drawLine(OrigineSec, FinSec); pPainter->setPen(QPen()); pPainter->drawText(rect, sTexte, QTextOption(Qt::AlignCenter)); }
void QAttribute::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { // Rettangolo if (selct)// se selezionato allora . painter->fillRect(boundingRect(),QColor(255,19,0,125)); // riempo tutto il rettangolo di rosso. QRectF Rect = boundingRect();// ottengo il rettangolo qreal bx =(Rect.width()/6)+(Rect.width()/8); qreal by =(Rect.height()*(80))/100 ; qreal ox =(Rect.left()+Rect.width()/2.8); qreal oy =Rect.topLeft().y()+Rect.height()-by ; painter->fillRect(ox+1,oy+11,bx-1,by-12,Qt::white); // Testo QRectF *typetext = new QRectF(); painter->drawText(QRectF(Rect.x(),oy-25,Rect.width(),30),Qt::AlignCenter,attribute->Caption(),typetext); qreal px = typetext->left()+this->attribute->getCaptionWidth(); qreal py = typetext->top()+this->attribute->getCaptionHeight(); typetext->translate(20,typetext->height()+1); typetext->setLeft(Rect.x()+16); painter->drawText(*typetext,attribute->GetattributeTypeStr(),QTextOption(Qt::AlignVCenter)); painter->drawRect(ox,oy+10,bx,by-11); if (this->grabRefer->GrabberItem()==this) painter->drawLine(px,py,px+5,py); // inserire tipo .... // draw right and left arrow that permit to change type. }
void TabOrderEditor::paintEvent(QPaintEvent *e) { QPainter p(this); p.setClipRegion(e->region()); int cur = m_current_index - 1; if (m_beginning == false && cur < 0) cur = m_tab_order_list.size() - 1; for (int i = 0; i < m_tab_order_list.size(); ++i) { QWidget *widget = m_tab_order_list.at(i); if (!isWidgetVisible(widget)) continue; const QRect r = indicatorRect(i); QColor c = Qt::darkGreen; if (i == cur) c = Qt::red; else if (i > cur) c = Qt::blue; p.setPen(c); c.setAlpha(BG_ALPHA); p.setBrush(c); p.drawRect(fixRect(r)); p.setPen(Qt::white); p.drawText(r, QString::number(i + 1), QTextOption(Qt::AlignCenter)); } }
void ItemComp::paint(QPainter *_painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/) { _painter->drawLine(0, 0, 0, mHeight); _painter->setBrush(Qt::white); _painter->drawRect( QRect(-50, -mFontHeight*3, 100, mFontHeight*6) ); _painter->drawText(QRect(-50, -mFontHeight*3, 100, mFontHeight*6), mText, QTextOption(Qt::AlignHCenter|Qt::AlignVCenter)); }
void PinGraphicsItem::paint(QPainter * painter, const QStyleOptionGraphicsItem*, QWidget*) { QRectF rect(0, 0, 200, 100); painter->setBrush(QBrush(QColor(128,255,128))); painter->setPen(QColor(0,0,0)); painter->drawRoundedRect(rect, 20, 20); painter->setFont(QFont("Helveteca", 40)); painter->drawText(rect, pinName(), QTextOption(Qt::AlignHCenter | Qt::AlignVCenter)); }
void SourceDelegate::paintStandardItem( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index, const QString& count ) const { QFont font = painter->font(); font.setPointSize( TomahawkUtils::defaultFontSize() ); painter->setFont( font ); SourcesModel::RowType type = static_cast< SourcesModel::RowType >( index.data( SourcesModel::SourceTreeItemTypeRole ).toInt() ); const bool upperCase = !( type == SourcesModel::StaticPlaylist || type == SourcesModel::AutomaticPlaylist || type == SourcesModel::Station || type == SourcesModel::TemporaryPage ); QStyleOptionViewItemV4 opt = option; initStyleOption( &opt, index ); opt.showDecorationSelected = false; const bool selected = ( option.state & QStyle::State_Selected ) == QStyle::State_Selected; const bool enabled = ( option.state & QStyle::State_Enabled ) == QStyle::State_Enabled; QIcon::Mode iconMode = QIcon::Normal; if ( !enabled ) iconMode = QIcon::Disabled; QRect iconRect = opt.rect.adjusted( m_margin / 2, m_margin / 6, 0, -m_margin / 6 ); iconRect.setWidth( iconRect.height() ); painter->drawPixmap( iconRect, opt.icon.pixmap( iconRect.size(), iconMode ) ); if ( selected ) { QFont f = painter->font(); f.setBold( true ); painter->setFont( f ); } int figWidth = 0; if ( !count.isEmpty() ) { figWidth = QFontMetrics( painter->font() ).width( count ); const QRect figRect = option.rect.adjusted( option.rect.width() - figWidth - m_margin / 2, 0, -m_margin / 2, 0 ); painter->drawText( figRect, count, QTextOption( Qt::AlignVCenter | Qt::AlignRight ) ); } QRect textRect = opt.rect.adjusted( iconRect.width() + m_margin / 2 + m_margin / 4, 0, -m_margin - figWidth, 0 ); const QString text = painter->fontMetrics().elidedText( upperCase ? opt.text.toUpper() : opt.text, Qt::ElideRight, textRect.width() ); { QTextOption to( Qt::AlignVCenter ); to.setWrapMode( QTextOption::NoWrap ); painter->setPen( Qt::black ); if ( !enabled && !selected ) { painter->setOpacity( 0.4 ); } painter->drawText( textRect, text, to ); } }
void QueueSystem::drawNameType(QPainter *painter) { painter->save(); painter->setPen(getColorText()); painter->drawText(QRect(35, m_size.height() / 4, m_size.width() - 35, m_size.height() / 3), m_nameTypeQueue, QTextOption(Qt::AlignLeft)); painter->restore(); }
void QueueSystem::drawName(QPainter *painter) { painter->save(); painter->setPen(getColorText()); painter->drawText(QRect(26, 0, m_size.width() - 26, m_size.height() / 3), getNameElement(), QTextOption(Qt::AlignCenter)); painter->restore(); }
void KPrTimeLineView::paintTextRow(QPainter *painter, int x, int y, int row, int column, const int RowHeight) { QRect rect(x,y,m_mainView->widthOfColumn(column), RowHeight); paintItemBackground(painter, rect, row == m_mainView->selectedRow()); painter->drawText(rect, m_mainView->model()->data(m_mainView->model()->index(row, column)).toString(), QTextOption(Qt::AlignCenter)); }