void MainWindow::reset() { QRect geom = geometry(); geom.setHeight(defaultHeight); geom.setWidth(defaultWidth); QSettings settings; int borderType=settings.value("/Settings/BorderType",GameBoard::borderCycled).toInt(); switch (borderType) { case GameBoard::borderCycled: ui->cycledBorderButton->setChecked(true); break; case GameBoard::borderDead: ui->deadBorderButton->setChecked(true); break; case GameBoard::borderMobius: ui->mobiusBorderButton->setChecked(true); break; } setGeometry(geom); update(); updateGeometry(); setGeometry(geom); update(); updateGeometry(); }
void XmlEdit::performCompletion(const QString &completionPrefix) { populateModel(completionPrefix); if (completionPrefix != completer->completionPrefix()) { completer->setCompletionPrefix(completionPrefix); completer->popup()->setCurrentIndex( completer->completionModel()->index(0, 0)); } if (completer->completionCount() == 1) insertCompletion(completer->currentCompletion(), true); else { QRect rect = cursorRect(); rect.setWidth(completer->popup()->sizeHintForColumn(0) + completer->popup()->verticalScrollBar()-> sizeHint().width()); completer->complete(rect); } }
void TikzEditor::paintEvent(QPaintEvent *event) { QPainter painter(viewport()); if( m_highlightCurrentLine ) { // highlight current line QRect rect = cursorRect(); rect.setX(0); rect.setWidth(viewport()->width()); painter.fillRect(rect, QBrush(m_highlightCurrentLineColor)); } // show white spaces and tabulators if (m_showWhiteSpaces || m_showTabulators) printWhiteSpaces(painter); painter.end(); QPlainTextEdit::paintEvent(event); }
void KstViewBox::paintSelf(KstPainter& p, const QRegion& bounds) { p.save(); if (p.type() != KstPainter::P_PRINT && p.type() != KstPainter::P_EXPORT) { if (p.makingMask()) { p.setRasterOp(Qt::SetROP); } else { const QRegion clip(clipRegion()); KstViewObject::paintSelf(p, bounds - clip); p.setClipRegion(bounds & clip); } } // restrict the border width so we do not draw outside of the rectangle itself int bw(borderWidth() * p.lineWidthAdjustmentFactor()); if (bw > _geom.width() / 2) { bw = _geom.width() / 2; } if (bw > _geom.height()) { bw = _geom.height() / 2; } QPen pen(borderColor(), bw); pen.setJoinStyle(_cornerStyle); if (bw == 0) { pen.setStyle(Qt::NoPen); } p.setPen(pen); if (_transparentFill) { p.setBrush(Qt::NoBrush); } else { p.setBrush(_foregroundColor); } QRect r; r.setX(_geom.left() + bw / 2); r.setY(_geom.top() + bw / 2); r.setWidth(_geom.width() - bw); r.setHeight(_geom.height() - bw); p.drawRoundRect(r, _xRound, _yRound); p.restore(); }
void IconDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { painter->save(); if (option.state & QStyle::State_Selected) { painter->fillRect(option.rect, option.palette.highlight()); painter->setPen(option.palette.color(QPalette::HighlightedText)); } QRect iconRect = option.rect; iconRect.setWidth(32); iconRect.setHeight(32); int fontHeight = painter->fontMetrics().height(); QRect shortRect = option.rect; shortRect.setLeft(shortRect.left() + 38); shortRect.setBottom(shortRect.top() + fontHeight); QRect longRect = option.rect; longRect.setLeft(longRect.left() + 50); longRect.setTop(longRect.top() + fontHeight); QString text = Catalog::decorateText(index.data(ROLE_SHORT).toString(), g_searchText); painter->drawText(shortRect, Qt::AlignTop | Qt::TextShowMnemonic, text); if (option.state & QStyle::State_Selected) painter->setPen(alternativesPath->palette().color(QPalette::HighlightedText)); else painter->setPen(alternativesPath->palette().color(QPalette::WindowText)); painter->setFont(alternativesPath->font()); QString full = index.data(ROLE_FULL).toString(); full = painter->fontMetrics().elidedText(full, option.textElideMode, longRect.width()); painter->drawText(longRect, Qt::AlignTop, full); QIcon p = index.data(ROLE_ICON).value<QIcon>(); p.paint(painter, iconRect); painter->restore(); }
void QwtLegendItem::paintEvent(QPaintEvent *e) { const QRect cr = contentsRect(); QPainter painter(this); painter.setClipRegion(e->region()); if ( d_data->isDown ) { qDrawWinButton(&painter, 0, 0, width(), height(), #if QT_VERSION < 0x040000 colorGroup(), #else palette(), #endif true); } painter.save(); if ( d_data->isDown ) { const QSize shiftSize = buttonShift(this); painter.translate(shiftSize.width(), shiftSize.height()); } painter.setClipRect(cr); drawContents(&painter); QRect rect = cr; rect.setX(rect.x() + margin()); if ( d_data->itemMode != QwtLegend::ReadOnlyItem ) rect.setX(rect.x() + ButtonFrame); rect.setWidth(d_data->identifierWidth); drawIdentifier(&painter, rect); painter.restore(); }
void EditorSpashScreen::drawContents(QPainter *painter) { painter->setOpacity(1); painter->fillRect(rect(), QBrush(Qt::transparent)); painter->setOpacity(opacity); painter->drawPixmap(rect(), buffer, buffer.rect()); painter->setPen(Qt::black); painter->setBrush(Qt::white); painter->setRenderHint(QPainter::TextAntialiasing); painter->setRenderHint(QPainter::Antialiasing); for(int i=0; i<animations.size(); i++) { QPixmap &frame = animations[i].second->wholeImage(); QRect frameRect = animations[i].second->frameRect(); QRect x; x.setX(animations[i].first.x() RatioWidth); x.setY(animations[i].first.y() RatioHeight); x.setWidth(frameRect.width() RatioWidth); x.setHeight(frameRect.height() RatioHeight); painter->drawPixmap(x, frame, frameRect); } painter->setBrush(QBrush(Qt::black)); QPen progressLine_bar( QBrush(Qt::black), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); painter->setPen(progressLine_bar); painter->drawRect(0, rect().height()-5, rect().width(), 4); painter->setBrush(QBrush(Qt::green)); painter->setPen(Qt::transparent); painter->drawRect(0, rect().height()-4, Maths::iRound(double(rect().width()) *( (double)_percents/100.0)), 2); painter->setPen(Qt::white); painter->setFont(QFont("Lucida Grande", 8, -1, true)); QPainterPath path; path.addText(rect().x()+20, rect().bottom()-20, painter->font(), _label); painter->strokePath(path, QPen(QColor(Qt::black), 4)); painter->drawText(rect().x()+20, rect().bottom()-20, _label); }
void YocDialog::paintEvent(QPaintEvent *event) { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, true); QPen pen(QColor(Qt::black ),1,Qt::SolidLine,Qt::RoundCap,Qt::RoundJoin); QBrush brush(QColor(Qt::white),Qt::SolidPattern); painter.setPen(pen); painter.setBrush(brush); painter.drawRect(this->rect()); brush.setColor(QColor(Qt::lightGray)); painter.setBrush(brush); QRect textRect; textRect.setX(this->rect().x() + SIDEW); textRect.setY(this->rect().y() + SIDEW); textRect.setWidth(this->rect().width() - 2*SIDEW); textRect.setHeight(this->rect().height() - 2*SIDEW); painter.drawRect(textRect); QDialog::paintEvent(event); }
void GraphQtInteractiveRenderer::clipRegionAddRect(Rectangle *rect) { GraphQtRenderer *renderer = m_data->renderer; QRegion *clip = renderer->clipRegion(); QRect clipRect; clipRect.setX(rect->x()); clipRect.setY(rect->y()); clipRect.setWidth(rect->width()); clipRect.setHeight(rect->height()); *clip = clip->united(clipRect); QPainterPath path; path.addRegion(*clip); QPainter *painter = m_data->renderer->painter(); painter->setClipping(true); painter->setClipPath(path); }
void SnippetCompleter::performCompletion(const QString &textUnderCursor, const QStringList &words, const QRect &popupRect) { const QString completionPrefix = textUnderCursor; // TODO: find more elegant solution qobject_cast<CompletionListModel*>(completer->model())->setWords(words); if (completionPrefix != completer->completionPrefix()) { completer->setCompletionPrefix(completionPrefix); completer->popup()->setCurrentIndex(completer->completionModel()->index(0, 0)); } if (completer->completionCount() == 1) { insertSnippet(completer->currentCompletion()); } else { QRect rect = popupRect; rect.setWidth(completer->popup()->sizeHintForColumn(0) + completer->popup()->verticalScrollBar()->sizeHint().width()); completer->complete(rect); } }
chatDialog::chatDialog(QWidget *parent): QDialog(parent, Qt::Window), ui(new Ui::chatDialogClass), m_view(0), m_scene(0), m_pushButtonSend(0), m_client(0) { ui->setupUi(this); m_view = new chatGraphicsView(this); m_scene = new chatGraphicsScene(this); m_view->setChatGraphicsScene(m_scene); m_pushButtonSend = new QPushButton("Send", this); // m_pushButtonSend->setFixedHeight(); // m_pushButtonSend->setFixedWidth(); QRect rect = ui->lineEdit->geometry(); rect.setLeft(rect.right()); rect.setWidth(60); m_pushButtonSend->setGeometry(rect); ui->lineEdit->setFocus(); ui->verticalLayout->insertWidget(0, m_view); bool check = connect(m_pushButtonSend, SIGNAL(clicked(bool)), SLOT(sendMessage())); Q_ASSERT(check); Q_UNUSED(check); updateSendButtonGeomerty(); }
void BalloonTip::createRects() { QFont font = this->font(); font.setBold( true ); font.setPixelSize( 12 ); QFontMetrics metrics( font ); QRect rect = metrics.boundingRect( QRect( 10, 10, 500, 500 ), Qt::TextSingleLine, my_title ); if ( rect.width() < 100 ) { rect.setWidth( 100 ); } font.setPixelSize( 12 ); font.setBold( false ); setFont( font ); metrics = QFontMetrics( font ); my_textRect = metrics.boundingRect( QRect( 10, 30, rect.width() + 90, 500), Qt::TextWordWrap, my_text ); if ( my_textRect.width() < rect.width() ) { my_textRect.setWidth( rect.width() + 90 ); } my_popupRect = QRect( 0, 0, my_textRect.width() + 20, my_textRect.height() + 40 ); }
QRect QToolBarAreaLayoutInfo::itemRect(const QList<int> &path) const { Q_ASSERT(path.count() == 2); int j = path.at(0); int k = path.at(1); const QToolBarAreaLayoutLine &line = lines.at(j); const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k); QRect result = line.rect; if (o == Qt::Horizontal) { result.setLeft(item.pos + line.rect.left()); result.setWidth(item.size); } else { result.setTop(item.pos + line.rect.top()); result.setHeight(item.size); } return result; }
QPushButton* LabCanvas::makeButton(QString title) { // Why don't we need to delete this QPushButton? We are setting the // "parent" of the button to "this" - hence, when "this" is deleted, // Qt will delete the button for us. How convenient! // // http://doc.trolltech.com/4.5/objecttrees.html QPushButton *push = new QPushButton(title, this); QRect dr; dr.setLeft(m_menuOffset); dr.setTop(LABCANVAS_BUTTON_SPACING); dr.setWidth(LABCANVAS_BUTTON_WIDTH); dr.setHeight(LABCANVAS_BUTTON_HEIGHT); push->setGeometry(dr); m_menuOffset += dr.width(); m_menuOffset += LABCANVAS_BUTTON_SPACING; return push; }
void Widget::load(VXml xml) { { VXml coordXml = xml.findChild("coord"); if (!coordXml.isNull()) { QRect rect = geometry(); rect.setLeft ((coordXml.getInt("left", 0))); rect.setTop ((coordXml.getInt("top", 0))); rect.setWidth ((coordXml.getInt("width", 640))); rect.setHeight((coordXml.getInt("height", 480))); setGeometry(rect); } } ui->chkShowHexa->setCheckState((Qt::CheckState)xml.getInt("showHexa", (int)ui->chkShowHexa->checkState())); ui->chkSendHexa->setCheckState((Qt::CheckState)xml.getInt("sendHexa", (int)ui->chkSendHexa->checkState())); ui->chkEcho->setCheckState((Qt::CheckState)xml.getInt("echo", (int)ui->chkEcho->checkState())); ui->chkEchoBroadcast->setCheckState((Qt::CheckState)xml.getInt("echoBroadcast", (int)ui->chkEchoBroadcast->checkState())); ui->tabOption->setCurrentIndex(xml.getInt("currentIndex", 0)); ui->leTcpPort->setText(xml.getStr("tcpPort", ui->leTcpPort->text())); ui->leUdpPort->setText(xml.getStr("udpPort", ui->leUdpPort->text())); ui->leSslPort->setText(xml.getStr("sslPort", ui->leSslPort->text())); ui->pteSend->insertPlainText(xml.getStr("sendText", ui->pteSend->toPlainText())); { VXml sizesXml = xml.findChild("sizes"); QList<int> sizes; if (!sizesXml.isNull()) { QStringList strList = sizesXml.getStr("splitter").split(","); foreach (QString s, strList) sizes << s.toInt(); ui->splitter->setSizes(sizes); } } tcpServer.load(xml.gotoChilds("netClient/tcpServer")); udpServer.load(xml.gotoChilds("netClient/udpServer")); sslServer.load(xml.gotoChilds("netClient/sslServer")); }
void QStyleRangeSlider::paintFilling(QPainter& p, const QRect& bbox, const QPair<int, int>& range, const QPair<int, int>& cutoffRange) const { QRect paintBox; int x = getPosMin(bbox, range.first, cutoffRange); int width = getPosMax(bbox, range.second, cutoffRange) - x; paintBox.setX(x); paintBox.setY(getGrooveY(bbox)); paintBox.setWidth(width); paintBox.setHeight(getGrooveHeight(bbox)); QPolygon paintArea = QPolygon(paintBox, true); QRectF pbbox = paintArea.boundingRect(); QPointF p1 = pbbox.topLeft(); QPointF p2 = pbbox.bottomRight(); p2.setX(p1.x()); QLinearGradient grad(p1, p2); grad.setColorAt(0, Qt::black); grad.setColorAt(0.15, Qt::red); grad.setColorAt(0.85, Qt::red); grad.setColorAt(1.0, Qt::white); p.save(); //p.setRenderHint(QPainter::Antialiasing, true); p.setRenderHint(QPainter::HighQualityAntialiasing, true); p.setPen(Qt::NoPen); //p.drawPoints(paintArea); p.setBrush(QBrush(grad)); p.drawPolygon(paintArea); p.restore(); }
/*! \return Bounding rectangle of the pipe ( without borders ) in widget coordinates */ QRect QwtThermo::pipeRect() const { int mbd = 0; if ( d_data->scalePosition != QwtThermo::NoScale ) { int d1, d2; scaleDraw()->getBorderDistHint( font(), d1, d2 ); mbd = qMax( d1, d2 ); } const int bw = d_data->borderWidth; const int scaleOff = bw + mbd; const QRect cr = contentsRect(); QRect pipeRect = cr; if ( d_data->orientation == Qt::Horizontal ) { pipeRect.adjust( scaleOff, 0, -scaleOff, 0 ); if ( d_data->scalePosition == QwtThermo::TrailingScale ) pipeRect.setTop( cr.top() + cr.height() - bw - d_data->pipeWidth ); else pipeRect.setTop( bw ); pipeRect.setHeight( d_data->pipeWidth ); } else // Qt::Vertical { pipeRect.adjust( 0, scaleOff, 0, -scaleOff ); if ( d_data->scalePosition == QwtThermo::LeadingScale ) pipeRect.setLeft( bw ); else pipeRect.setLeft( cr.left() + cr.width() - bw - d_data->pipeWidth ); pipeRect.setWidth( d_data->pipeWidth ); } return pipeRect; }
void ImageDisplay::paintEvent(QPaintEvent *e) { QFrame::paintEvent(e); if (!m_image.isNull()) { QPainter p(this); QImage subImg; if (m_aScaling->isChecked()) { // Scale to frame size subImg = m_image.scaled(contentsRect().size(), Qt::KeepAspectRatio); m_scaledImageSize = subImg.size(); } else { // User-defined scaling subImg = m_image.copy(std::floor(m_imageOffset.x()), std::floor(m_imageOffset.y()), std::ceil(contentsRect().width()/m_scale+1), std::ceil(contentsRect().height()/m_scale+1)); subImg = subImg.scaled(m_scale*subImg.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); subImg = subImg.copy(m_scale*(m_imageOffset.x()-floor(m_imageOffset.x())), m_scale*(m_imageOffset.y()-floor(m_imageOffset.y())), contentsRect().width(), contentsRect().height()); } p.drawImage(contentsRect().topLeft(), subImg); if (m_states.countsAsMove() && !QApplication::mouseButtons().testFlag(Qt::NoButton)) { QRect r; QPoint origin = convertImageToCanvas(m_states.mouseInitialImagePos); r.setTopLeft(min(m_states.mousePrevPos, origin)); r.setWidth(abs(m_states.mousePrevPos.x()-origin.x())); r.setHeight(abs(m_states.mousePrevPos.y()-origin.y())); p.drawRect(r); } } }
void MainWindow::resizeEvent(QResizeEvent* event) { if (isMaximized()) { get_gui_settings()->set_value(settings_window_maximized, true); } else { QRect rc = Ui::get_gui_settings()->get_value(settings_main_window_rect, QRect()); rc.setWidth(event->size().width()); rc.setHeight(event->size().height()); get_gui_settings()->set_value(settings_main_window_rect, rc); get_gui_settings()->set_value(settings_window_maximized, false); } // TODO : limit call this stats // GetDispatcher()->post_stats_to_core(core::stats::stats_event_names::main_window_resize); #ifdef __APPLE__ mac_support_->updateMainMenu(); #endif }
void GfxCanvasClip::paint(GfxPainter &g) { QRect ucr = g.userClipRect(); QRect cr = clip(); if(!(_type & Height) && !g.clipRect().isEmpty()) { cr.setY(g.clipRect().y()); cr.setHeight(g.clipRect().height()); } if(!(_type & Width) && !g.clipRect().isEmpty()) { cr.setX(g.clipRect().x()); cr.setWidth(g.clipRect().width()); } if(!ucr.isEmpty()) cr &= ucr; if(!cr.isEmpty()) { g.setUserClipRect(cr); GfxCanvasItem::paint(g); g.setUserClipRect(ucr); } }
void CallgrindTextMark::paint(QPainter *painter, const QRect &paintRect) const { if (!m_modelIndex.isValid()) return; bool ok; qreal costs = m_modelIndex.data(RelativeTotalCostRole).toReal(&ok); QTC_ASSERT(ok, return) QTC_ASSERT(costs >= 0.0 && costs <= 100.0, return) painter->save(); // set up painter->setPen(Qt::black); // draw bar QRect fillRect = paintRect; fillRect.setWidth(paintRect.width() * costs); painter->fillRect(paintRect, Qt::white); painter->fillRect(fillRect, CallgrindHelper::colorForCostRatio(costs)); painter->drawRect(paintRect); // draw text const QTextOption flags = Qt::AlignHCenter | Qt::AlignVCenter; const QString text = CallgrindHelper::toPercent(costs * 100.0f); // decrease font size if paint rect is too small (very unlikely, but may happen) QFont font = painter->font(); QFontMetrics fm = font; while (fm.boundingRect(text).width() > paintRect.width()) { font.setPointSize(font.pointSize() - 1); fm = font; } painter->setFont(font); painter->drawText(paintRect, text, flags); painter->restore(); }
void PixmapDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QStyledItemDelegate::paint(painter, option, index); QPixmap pixmap = index.data(Qt::DisplayRole).value<QPixmap>(); QRect rect = option.rect; unsigned int originalWidth = rect.width(); unsigned int originalHeight = rect.height(); int minSize = std::min(rect.width(), rect.height()) - Padding*2; // We have to double the padding because we want it taken off from both sides. // These setLeft and setTop calls must come before setHeight and setWidth rect.setLeft(originalWidth/2 - minSize/2 + Padding); rect.setTop(rect.top() + originalHeight/2 - minSize/2 + Padding); rect.setHeight(minSize); rect.setWidth(minSize); painter->drawPixmap(rect, pixmap, pixmap.rect()); }
void SketchArea::resizeEvent(QResizeEvent *event) { // if (width() > image.width() || height() > image.height()) { // int newWidth = qMax(width() + 128, image.width()); // int newHeight = qMax(height() + 128, image.height()); // resizeImage(&image, QSize(newWidth, newHeight)); // update(); // } QSize newSize(width(), height()); QImage newImage(newSize, QImage::Format_RGB32); newImage.fill(qRgb(255, 255, 255)); QPainter painter(&newImage); QRect rect; rect.setWidth(qMin(width(), image.width())); rect.setHeight(qMin(height(), image.height())); painter.drawImage(rect, image.copy(rect)); image = newImage; update(); QWidget::resizeEvent(event); }
//____________________________________________________________________________________ void SunkenFrameShadow::updateGeometry() { QWidget *widget = parentWidget(); if( !widget ) return; QRect cr = widget->contentsRect(); switch (shadowArea()) { case Top: cr.setHeight( SHADOW_SIZE_TOP ); cr.adjust( -1, -1, 1, 0 ); break; case Left: cr.setWidth(SHADOW_SIZE_LEFT); cr.adjust(-1, SHADOW_SIZE_TOP, 0, -SHADOW_SIZE_BOTTOM); break; case Bottom: cr.setTop(cr.bottom() - SHADOW_SIZE_BOTTOM + 1); cr.adjust( -1, 0, 1, 1 ); if( hasContrast() ) cr.adjust( 0, 0, 0, 1 ); break; case Right: cr.setLeft(cr.right() - SHADOW_SIZE_RIGHT + 1); cr.adjust(0, SHADOW_SIZE_TOP, 1, -SHADOW_SIZE_BOTTOM); break; case Unknown: default: return; } setGeometry(cr); }
void QLabelPrivate::_q_movieUpdated(const QRect& rect) { Q_Q(QLabel); if (movie && movie->isValid()) { QRect r; if (scaledcontents) { QRect cr = q->contentsRect(); QRect pixmapRect(cr.topLeft(), movie->currentPixmap().size()); if (pixmapRect.isEmpty()) return; r.setRect(cr.left(), cr.top(), (rect.width() * cr.width()) / pixmapRect.width(), (rect.height() * cr.height()) / pixmapRect.height()); } else { r = q->style()->itemPixmapRect(q->contentsRect(), align, movie->currentPixmap()); r.translate(rect.x(), rect.y()); r.setWidth(qMin(r.width(), rect.width())); r.setHeight(qMin(r.height(), rect.height())); } q->update(r); } }
QGraphicsItem* Dial::graphicsItem() { if (m_pDial == nullptr) { m_pDial = new QDial(); QObject::connect(m_pDial, &QDial::valueChanged, [this](int pos) { onDialValueChanged(pos); }); QRect r = m_pDial->geometry(); r.setWidth(cDefaultSize); r.setHeight(cDefaultSize); m_pDial->setGeometry(r); m_pDial->setNotchesVisible(true); m_pDial->setWrapping(false); updateDialValues(); } QGraphicsProxyWidget *pWidgetItem = new QGraphicsProxyWidget(); pWidgetItem->setWidget(m_pDial); return pWidgetItem; }
QList<QRect> FatherBlock::GetEnableBlockRects(int theStatusIndex,bool theRealBlocksFlag) { QList<QRect>theBlockRects; if(theStatusIndex == -1) { theStatusIndex = m_current_status_index; } if(theStatusIndex < m_status_list.count()) { QBitArray theStatus = m_status_list[theStatusIndex]; int count = theStatus.count()-1; while(count >= 0) { if(theStatus.testBit(count) == true) { QRect ChildBlockRect = QRect(m_blocks_list[count]->geometry()); ChildBlockRect.setX(ChildBlockRect.x() + this->x()); ChildBlockRect.setY(ChildBlockRect.y() + this->y()); ChildBlockRect.setWidth(m_blocks_list[count]->width()); ChildBlockRect.setHeight(m_blocks_list[count]->height()); if(!hasBottomBlock(count) && !theRealBlocksFlag) { QRect tempBlock(ChildBlockRect); tempBlock.setY(ChildBlockRect.y()+m_blocks_list[count]->height()); theBlockRects.append(tempBlock); } if(!hasRightBlock(count) && !theRealBlocksFlag) { QRect tempBlock(ChildBlockRect); tempBlock.setX(ChildBlockRect.x() + m_blocks_list[count]->width()); theBlockRects.append(tempBlock); } theBlockRects.append(ChildBlockRect); } count--; } } return theBlockRects; }
/* * \brief Determines PIP Window size and Position. */ QRect VideoOutWindow::GetPIPRect( PIPLocation location, MythPlayer *pipplayer, bool do_pixel_adj) const { QRect position; float pipVideoAspect = pipplayer ? (float) pipplayer->GetVideoAspect() : (4.0f / 3.0f); int tmph = (display_visible_rect.height() * db_pip_size) / 100; float pixel_adj = 1; if (do_pixel_adj) { pixel_adj = ((float) display_visible_rect.width() / (float) display_visible_rect.height()) / display_aspect; } position.setHeight(tmph); position.setWidth((int) (tmph * pipVideoAspect * pixel_adj)); int xoff = (int) (display_visible_rect.width() * 0.06); int yoff = (int) (display_visible_rect.height() * 0.06); switch (location) { case kPIP_END: case kPIPTopLeft: break; case kPIPBottomLeft: yoff = display_visible_rect.height() - position.height() - yoff; break; case kPIPTopRight: xoff = display_visible_rect.width() - position.width() - xoff; break; case kPIPBottomRight: xoff = display_visible_rect.width() - position.width() - xoff; yoff = display_visible_rect.height() - position.height() - yoff; break; } position.translate(xoff, yoff); return position; }
void AttributeWidget::onItemValuedChanged(QTreeWidgetItem *item, int column) { QVariant v = item->data(0, Qt::UserRole); int type = v.toInt(); int index = m_hashElement[item]; if (column == 0) { if (type != name_item) { return; } m_pCollector->updateFrameName(index, item->text(column)); } else { int value = item->text(column).toInt(); QRect rect = m_pCollector->getFrameByIndex(index)->rect; switch (type) { case x_item: rect.moveTo(value, rect.y()); break; case y_item: rect.moveTo(rect.x(), value); break; case width_item: rect.setWidth(value); break; case height_item: rect.setHeight(value); break; default: return; } m_pCollector->updateFrameRect(index, rect); } }
/*! \brief Overlay the given text on top of the given pixmap. Used by buttons and toolButtons. \param[in] pixmap The pixmap to overlay with text \param[in] overlayText The text to overlay \param[in] backgroundColor The color of the shadow behind the text \param[in] textColor The text color */ void KxQtHelper::overlayTextOnPixmap(QPixmap* pixmap, const QString& overlayText, const QColor& backgroundColor, const QColor& textColor) { if (pixmap == NULL) return; QPainter p(pixmap); QFont f = p.font(); f.setBold(true); p.setFont(f); // get bounding rect for text QRect textRect = p.boundingRect(pixmap->rect(), Qt::AlignVCenter | Qt::AlignHCenter, overlayText); // Left-align the text if it is wider than the pixmap // so that we can see the start of the text int alignmentFlags = Qt::AlignVCenter | Qt::AlignHCenter; if(textRect.width() > pixmap->rect().width()) { alignmentFlags = Qt::AlignVCenter | Qt::AlignLeft; } // Add 1 pixel above and under the text, center it. const int margin = 1; int height = textRect.height(); textRect.setTop(pixmap->rect().bottom() - height - margin); textRect.setLeft(margin); textRect.setHeight(height); textRect.setWidth(pixmap->rect().width() - margin*2); // Draw a transparent rounded area (20%) const int radius = 2; QPainterPath path; path.addRoundedRect(textRect, radius, radius); p.fillPath(path, backgroundColor); // Draw the text p.setPen(textColor); p.drawText(textRect, alignmentFlags, overlayText); }