Commit 7c91160f authored by Marco Bubke's avatar Marco Bubke
Browse files

Polish feedback in the form editor a little bit more

parent f4983380
......@@ -116,95 +116,115 @@ void FormEditorGraphicsView::drawForeground(QPainter *painter, const QRectF &/*r
return;
painter->save();
painter->translate(mapToScene(QPoint(3, 3)));
QColor changeColor(QColor(Qt::green).lighter(170));
QFont font;
font.setPixelSize(12);
painter->setFont(font);
painter->save();
painter->setOpacity(0.7);
QLinearGradient gradient(QPoint(0, 0), QPoint(100, 0));
gradient.setColorAt(0.0, Qt::darkGray);
gradient.setColorAt(1.0, Qt::gray);
painter->setBrush(gradient);
painter->setPen(Qt::black);
int height = 40;
if (m_feedbackNode.instanceHasAnchors())
height += 24;
painter->drawRoundedRect(QRect(-1, -1, 100, height), 5, 5);
painter->restore();
if (m_beginX != m_feedbackNode.instanceValue("x"))
painter->setPen(Qt::green);
painter->setPen(changeColor);
else
painter->setPen(Qt::black);
painter->drawText(mapToScene(QPoint(2.0, 12.0)), QString("x:"));
painter->drawText(mapToScene(QPoint(14.0, 12.0)), m_feedbackNode.instanceValue("x").toString());
painter->drawText(QPoint(2.0, 12.0), QString("x:"));
painter->drawText(QPoint(14.0, 12.0), m_feedbackNode.instanceValue("x").toString());
if (m_beginY != m_feedbackNode.instanceValue("y"))
painter->setPen(Qt::green);
painter->setPen(changeColor);
else
painter->setPen(Qt::black);
painter->drawText(mapToScene(QPoint(50.0, 12.0)), QString("y:"));
painter->drawText(mapToScene(QPoint(60.0, 12.0)), m_feedbackNode.instanceValue("y").toString());
painter->drawText(QPoint(50.0, 12.0), QString("y:"));
painter->drawText(QPoint(60.0, 12.0), m_feedbackNode.instanceValue("y").toString());
if (m_beginWidth != m_feedbackNode.instanceValue("width"))
painter->setPen(Qt::green);
painter->setPen(changeColor);
else
painter->setPen(Qt::black);
painter->drawText(mapToScene(QPoint(2.0, 24.0)), QString("w:"));
painter->drawText(mapToScene(QPoint(14.0, 24.0)), m_feedbackNode.instanceValue("width").toString());
painter->drawText(QPoint(2.0, 24.0), QString("w:"));
painter->drawText(QPoint(14.0, 24.0), m_feedbackNode.instanceValue("width").toString());
if (m_beginHeight != m_feedbackNode.instanceValue("height"))
painter->setPen(Qt::green);
painter->setPen(changeColor);
else
painter->setPen(Qt::black);
painter->drawText(mapToScene(QPoint(50.0, 24.0)), QString("h:"));
painter->drawText(mapToScene(QPoint(60.0, 24.0)),m_feedbackNode.instanceValue("height").toString());
painter->drawText(QPoint(50.0, 24.0), QString("h:"));
painter->drawText(QPoint(60.0, 24.0),m_feedbackNode.instanceValue("height").toString());
if (m_parentNode == m_feedbackNode.instanceParent()) {
if (!m_feedbackNode.canReparent()) {
painter->setPen(Qt::red);
painter->drawText(mapToScene(QPoint(2.0, 36.0)), QString("Cannot reparent."));
painter->drawText(QPoint(2.0, 36.0), QString("Cannot reparent."));
}
} else {
painter->setPen(Qt::yellow);
if (m_feedbackNode.instanceParent().id().isEmpty())
painter->drawText(mapToScene(QPoint(2.0, 36.0)), QString("Parent has changed."));
painter->drawText(QPoint(2.0, 36.0), QString("Parent has changed."));
else
painter->drawText(mapToScene(QPoint(2.0, 36.0)), QString("Parent has changed to %1.").arg(m_feedbackNode.instanceParent().id()));
painter->drawText(QPoint(2.0, 36.0), QString("Parent has changed to %1.").arg(m_feedbackNode.instanceParent().id()));
}
if (m_feedbackNode.instanceHasAnchors()) {
if (m_beginTopMargin != m_feedbackNode.instanceValue("anchors.leftMargin"))
painter->setPen(Qt::green);
painter->setPen(changeColor);
else
painter->setPen(Qt::black);
painter->drawText(mapToScene(QPoint(2.0, 48.0)), QString("l:"));
painter->drawText(mapToScene(QPoint(14.0, 48.0)), m_feedbackNode.instanceValue("anchors.leftMargin").toString());
painter->drawText(QPoint(2.0, 48.0), QString("l:"));
painter->drawText(QPoint(14.0, 48.0), m_feedbackNode.instanceValue("anchors.leftMargin").toString());
if (m_beginRightMargin != m_feedbackNode.instanceValue("anchors.rightMargin"))
painter->setPen(Qt::green);
painter->setPen(changeColor);
else
painter->setPen(Qt::black);
painter->drawText(mapToScene(QPoint(50.0, 48.0)), QString("r:"));
painter->drawText(mapToScene(QPoint(60.0, 48.0)), m_feedbackNode.instanceValue("anchors.rightMargin").toString());
painter->drawText(QPoint(50.0, 48.0), QString("r:"));
painter->drawText(QPoint(60.0, 48.0), m_feedbackNode.instanceValue("anchors.rightMargin").toString());
if (m_beginTopMargin != m_feedbackNode.instanceValue("anchors.topMargin"))
painter->setPen(Qt::green);
painter->setPen(changeColor);
else
painter->setPen(Qt::black);
painter->drawText(mapToScene(QPoint(2.0, 60.0)), QString("t:"));
painter->drawText(mapToScene(QPoint(14.0, 60.0)), m_feedbackNode.instanceValue("anchors.topMargin").toString());
painter->drawText(QPoint(2.0, 60.0), QString("t:"));
painter->drawText(QPoint(14.0, 60.0), m_feedbackNode.instanceValue("anchors.topMargin").toString());
if (m_beginBottomMargin != m_feedbackNode.instanceValue("anchors.bottomMargin"))
painter->setPen(Qt::green);
painter->setPen(changeColor);
else
painter->setPen(Qt::black);
painter->drawText(mapToScene(QPoint(50.0, 60.0)), QString("b:"));
painter->drawText(mapToScene(QPoint(60.0, 60.0)), m_feedbackNode.instanceValue("anchors.bottomMargin").toString());
painter->drawText(QPoint(50.0, 60.0), QString("b:"));
painter->drawText(QPoint(60.0, 60.0), m_feedbackNode.instanceValue("anchors.bottomMargin").toString());
}
painter->restore();
......
......@@ -64,7 +64,8 @@ FormEditorView::FormEditorView(QObject *parent)
m_anchorTool(new AnchorTool(this)),
m_dragTool(new DragTool(this)),
m_itemCreatorTool(new ItemCreatorTool(this)),
m_currentTool(m_selectionTool)
m_currentTool(m_selectionTool),
m_transactionCounter(0)
{
connect(widget()->zoomAction(), SIGNAL(zoomLevelChanged(double)), SLOT(updateGraphicsIndicators()));
connect(widget()->showBoundingRectAction(), SIGNAL(toggled(bool)), scene(), SLOT(setShowBoundingRects(bool)));
......@@ -251,9 +252,7 @@ void FormEditorView::selectedNodesChanged(const QList<ModelNode> &selectedNodeLi
item->update();
}
if (selectedNodeList.count() == 1)
m_formEditorWidget->setFeedbackNode(QmlItemNode(selectedNodeList.first()));
else
if (selectedNodeList.count() != 1)
m_formEditorWidget->setFeedbackNode(QmlItemNode());
m_scene->update();
......@@ -426,6 +425,24 @@ void FormEditorView::auxiliaryDataChanged(const ModelNode &node, const QString &
}
}
void FormEditorView::customNotification(const AbstractView */*view*/, const QString &identifier, const QList<ModelNode> &/*nodeList*/, const QList<QVariant> &/*data*/)
{
if (identifier == "__start rewriter transaction__") {
m_transactionCounter++;
if (m_transactionCounter == 1
&& selectedModelNodes().count() == 1)
m_formEditorWidget->setFeedbackNode(QmlItemNode(selectedModelNodes().first()));
}
if (identifier == "__end rewriter transaction__") {
m_transactionCounter--;
if (m_transactionCounter == 0)
m_formEditorWidget->setFeedbackNode(QmlItemNode());
}
}
double FormEditorView::margins() const
{
return m_formEditorWidget->margins();
......
......@@ -95,6 +95,7 @@ public:
void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex);
void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);
void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
double margins() const;
double spacing() const;
......@@ -132,7 +133,7 @@ private: //variables
DragTool *m_dragTool;
ItemCreatorTool *m_itemCreatorTool;
AbstractFormEditorTool *m_currentTool;
int m_transactionCounter;
};
}
......
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