Commit bf9782e3 authored by Thomas Hartmann's avatar Thomas Hartmann Committed by Eike Ziller

QmlDesigner.formeditor: fix captions

To avoid confusion we rotate item captions and place them
on the upper right.

Change-Id: I97ba7ef93a8b0a6aa678af6a9ee5f76e649e5baa
Reviewed-by: default avatarEike Ziller <eike.ziller@nokia.com>
parent 44928237
......@@ -294,32 +294,34 @@ void FormEditorItem::paintPlaceHolderForInvisbleItem(QPainter *painter) const
displayText = qmlItemNode().simplifiedTypeName();
QTextOption textOption;
textOption.setAlignment(Qt::AlignCenter);
textOption.setAlignment(Qt::AlignTop);
textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
if (boundingRect().width() > 60) {
if (boundingRect().height() > 60) {
painter->save();
QFont font;
font.setStyleHint(QFont::SansSerif);
font.setBold(true);
font.setPixelSize(14);
font.setPixelSize(12);
painter->setFont(font);
QFontMetrics fm(font);
if (fm.width(displayText) > (boundingRect().width() - 22) && displayText.length() > 4) {
painter->rotate(90);
if (fm.width(displayText) > (boundingRect().height() - 32) && displayText.length() > 4) {
displayText = fm.elidedText(displayText, Qt::ElideRight, boundingRect().width() - 22, Qt::TextShowMnemonic);
displayText = fm.elidedText(displayText, Qt::ElideRight, boundingRect().height() - 32, Qt::TextShowMnemonic);
}
painter->setPen(QColor(255, 255, 255, 128));
painter->setCompositionMode(QPainter::CompositionMode_Exclusion);
painter->drawText(boundingRect().adjusted(-2, -2, 0,0), displayText, textOption);
QRectF rotatedBoundingBox;
rotatedBoundingBox.setWidth(boundingRect().height());
rotatedBoundingBox.setHeight(12);
rotatedBoundingBox.setY(-boundingRect().width() + 12);
rotatedBoundingBox.setX(20);
painter->setFont(font);
painter->setPen(QColor(0, 0, 0, 255));
painter->drawText(boundingRect(), displayText, textOption);
painter->setPen(QColor(48, 48, 96, 255));
painter->drawText(rotatedBoundingBox, displayText, textOption);
painter->restore();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment