QmlDesigner: Add adjustable frame color

Task-number: QDS-2238
Change-Id: I6f43a7c87ae4c8daaf41c08ad2960502770fba58
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2020-07-06 12:51:22 +02:00
parent 33671897bd
commit 9bfb608986
3 changed files with 21 additions and 1 deletions

View File

@@ -283,6 +283,11 @@ bool FormEditorItem::flowHitTest(const QPointF & ) const
return false; return false;
} }
void FormEditorItem::setFrameColor(const QColor &color)
{
m_frameColor = color;
}
FormEditorItem::~FormEditorItem() FormEditorItem::~FormEditorItem()
{ {
scene()->removeItemFromHash(this); scene()->removeItemFromHash(this);
@@ -313,14 +318,21 @@ void FormEditorItem::paintBoundingRect(QPainter *painter) const
pen.setJoinStyle(Qt::MiterJoin); pen.setJoinStyle(Qt::MiterJoin);
const QColor frameColor(0xaa, 0xaa, 0xaa); const QColor frameColor(0xaa, 0xaa, 0xaa);
static const QColor selectionColor = Utils::creatorTheme()->color(Utils::Theme::QmlDesigner_FormEditorSelectionColor); static const QColor selectionColor = Utils::creatorTheme()->color(
Utils::Theme::QmlDesigner_FormEditorSelectionColor);
if (scene()->showBoundingRects()) { if (scene()->showBoundingRects()) {
pen.setColor(frameColor.darker(150)); pen.setColor(frameColor.darker(150));
pen.setStyle(Qt::DotLine); pen.setStyle(Qt::DotLine);
painter->setPen(pen); painter->setPen(pen);
painter->drawRect(m_boundingRect.adjusted(0., 0., -1., -1.)); painter->drawRect(m_boundingRect.adjusted(0., 0., -1., -1.));
}
if (m_frameColor.isValid()) {
pen.setColor(m_frameColor);
pen.setStyle(Qt::SolidLine);
painter->setPen(pen);
painter->drawRect(m_boundingRect.adjusted(0., 0., -1., -1.));
} }
if (m_highlightBoundingRect) { if (m_highlightBoundingRect) {

View File

@@ -117,6 +117,8 @@ public:
virtual bool flowHitTest(const QPointF &point) const; virtual bool flowHitTest(const QPointF &point) const;
void setFrameColor(const QColor &color);
protected: protected:
AbstractFormEditorTool* tool() const; AbstractFormEditorTool* tool() const;
void paintBoundingRect(QPainter *painter) const; void paintBoundingRect(QPainter *painter) const;
@@ -129,6 +131,7 @@ protected:
QRectF m_boundingRect; QRectF m_boundingRect;
QRectF m_paintedBoundingRect; QRectF m_paintedBoundingRect;
QRectF m_selectionBoundingRect; QRectF m_selectionBoundingRect;
QColor m_frameColor{0xaa, 0xaa, 0xaa};
private: // functions private: // functions
void setup(); void setup();

View File

@@ -624,6 +624,11 @@ void FormEditorView::auxiliaryDataChanged(const ModelNode &node, const PropertyN
editorItem->update(); editorItem->update();
} }
} }
if (name == "FrameColor@Internal") {
if (FormEditorItem *editorItem = scene()->itemForQmlItemNode(item))
editorItem->setFrameColor(data.value<QColor>());
}
} }
void FormEditorView::instancesCompleted(const QVector<ModelNode> &completedNodeList) void FormEditorView::instancesCompleted(const QVector<ModelNode> &completedNodeList)