diff options
author | Thomas Hartmann <Thomas.Hartmann@nokia.com> | 2011-10-19 16:52:30 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@nokia.com> | 2011-10-25 10:53:26 +0200 |
commit | bf9782e30788fe34d5213a2c7ad8c24379b2e3f6 (patch) | |
tree | f59d66ae2134aba1275d26831e1e40b03e1d9098 /src/plugins/qmldesigner | |
parent | 44928237af12ec16eeb13b5eb86c6da2c483a6c1 (diff) | |
download | qt-creator-bf9782e30788fe34d5213a2c7ad8c24379b2e3f6.tar.gz |
QmlDesigner.formeditor: fix captions
To avoid confusion we rotate item captions and place them
on the upper right.
Change-Id: I97ba7ef93a8b0a6aa678af6a9ee5f76e649e5baa
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
Diffstat (limited to 'src/plugins/qmldesigner')
-rw-r--r-- | src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp b/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp index 946b96c089..1214cd7e1b 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp @@ -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(); } |