MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / paintEvent

Method paintEvent

src/common/widget/collapsewidget.cpp:160–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160void CollapseWidget::paintEvent(QPaintEvent *event)
161{
162 DWidget::paintEvent(event);
163 QPainter painter(this);
164 QRect rect = CollapseWidget::rect();
165 painter.drawLine(rect.topLeft() + QPoint{0, d->minHeight -1},
166 rect.topRight() + QPoint{0, d->minHeight -1});
167 painter.drawLine(rect.topLeft(), rect.topRight());
168 painter.drawLine(rect.topLeft(), rect.bottomLeft());
169 painter.drawLine(rect.topRight(), rect.bottomRight());
170 painter.drawLine(rect.bottomLeft(), rect.bottomRight());
171
172 QFont font(d->title);
173 QFontMetrics fontMetrics(this->font());
174 QRect textBoundingRect = fontMetrics.boundingRect(d->title);
175 QSize fontSize = textBoundingRect.size();
176 int fontPosX = textBoundingRect.x();
177 int fontPosY = textBoundingRect.y();
178 int textPosX = 4 + ( fontPosX > 0 ? fontPosX : - fontPosX);;
179 int textPosY = (d->detailsButton->height() - fontSize.height()) / 2
180 + ( fontPosY > 0 ? fontPosY: - fontPosY);
181 painter.drawText(QPoint{textPosX, textPosY}, d->title);
182}
183
184void CollapseWidget::setChecked(bool checked)
185{

Callers

nothing calls this directly

Calls 4

fontMethod · 0.80
paintEventFunction · 0.50
sizeMethod · 0.45
drawTextMethod · 0.45

Tested by

no test coverage detected