Commit 53b7f17f authored by Marco Bubke's avatar Marco Bubke Committed by Thomas Hartmann

QmlDesigner.FormEditor: Disable feedback pane

Task-number: QTCREATORBUG-4598

Change-Id: I5b776348c75bbf0f927138d90d5414ca1344e435
Reviewed-on: http://codereview.qt.nokia.com/1460Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent fc2a27d7
......@@ -83,24 +83,26 @@ void FormEditorGraphicsView::wheelEvent(QWheelEvent *event)
void FormEditorGraphicsView::mouseMoveEvent(QMouseEvent *event)
{
if (rect().contains(event->pos())) {
QGraphicsView::mouseMoveEvent(event);
} else {
QPoint position = event->pos();
QPoint topLeft = rect().topLeft();
QPoint bottomRight = rect().bottomRight();
position.rx() = qMax(topLeft.x(), qMin(position.x(), bottomRight.x()));
position.ry() = qMax(topLeft.y(), qMin(position.y(), bottomRight.y()));
QMouseEvent *mouseEvent = QMouseEvent::createExtendedMouseEvent(event->type(), position, mapToGlobal(position), event->button(), event->buttons(), event->modifiers());
QGraphicsView::mouseMoveEvent(mouseEvent);
delete mouseEvent;
}
// Keeps the feedback bubble within screen boundraries
int tx = qMin(width() - 114, qMax(16, event->pos().x() + 50));
int ty = qMin(height() - 45, qMax(10, event->pos().y() - 70));
m_feedbackOriginPoint = QPoint(tx, ty);
QGraphicsView::mouseMoveEvent(event);
// if (rect().contains(event->pos())) {
// QGraphicsView::mouseMoveEvent(event);
// } else {
// QPoint position = event->pos();
// QPoint topLeft = rect().topLeft();
// QPoint bottomRight = rect().bottomRight();
// position.rx() = qMax(topLeft.x(), qMin(position.x(), bottomRight.x()));
// position.ry() = qMax(topLeft.y(), qMin(position.y(), bottomRight.y()));
// QMouseEvent *mouseEvent = QMouseEvent::createExtendedMouseEvent(event->type(), position, mapToGlobal(position), event->button(), event->buttons(), event->modifiers());
// QGraphicsView::mouseMoveEvent(mouseEvent);
// delete mouseEvent;
// }
// // Keeps the feedback bubble within screen boundraries
// int tx = qMin(width() - 114, qMax(16, event->pos().x() + 50));
// int ty = qMin(height() - 45, qMax(10, event->pos().y() - 70));
// m_feedbackOriginPoint = QPoint(tx, ty);
}
void FormEditorGraphicsView::keyPressEvent(QKeyEvent *event)
......@@ -127,21 +129,22 @@ void FormEditorGraphicsView::mousePressEvent(QMouseEvent *mouseEvent)
void FormEditorGraphicsView::mouseReleaseEvent(QMouseEvent *event)
{
if (rect().contains(event->pos())) {
QGraphicsView::mouseReleaseEvent(event);
} else {
QPoint position = event->pos();
QPoint topLeft = rect().topLeft();
QPoint bottomRight = rect().bottomRight();
position.rx() = qMax(topLeft.x(), qMin(position.x(), bottomRight.x()));
position.ry() = qMax(topLeft.y(), qMin(position.y(), bottomRight.y()));
QMouseEvent *mouseEvent = QMouseEvent::createExtendedMouseEvent(event->type(), position, mapToGlobal(position), event->button(), event->buttons(), event->modifiers());
QGraphicsView::mouseReleaseEvent(mouseEvent);
delete mouseEvent;
}
m_feedbackOriginPoint = QPoint();
QGraphicsView::mouseReleaseEvent(event);
// if (rect().contains(event->pos())) {
// QGraphicsView::mouseReleaseEvent(event);
// } else {
// QPoint position = event->pos();
// QPoint topLeft = rect().topLeft();
// QPoint bottomRight = rect().bottomRight();
// position.rx() = qMax(topLeft.x(), qMin(position.x(), bottomRight.x()));
// position.ry() = qMax(topLeft.y(), qMin(position.y(), bottomRight.y()));
// QMouseEvent *mouseEvent = QMouseEvent::createExtendedMouseEvent(event->type(), position, mapToGlobal(position), event->button(), event->buttons(), event->modifiers());
// QGraphicsView::mouseReleaseEvent(mouseEvent);
// delete mouseEvent;
// }
// m_feedbackOriginPoint = QPoint();
}
void FormEditorGraphicsView::leaveEvent(QEvent *event)
......@@ -176,136 +179,136 @@ static QPixmap createBubblePixmap()
void FormEditorGraphicsView::drawForeground(QPainter *painter, const QRectF &/*rect*/ )
{
if (!m_feedbackNode.isValid())
return;
if (m_feedbackOriginPoint.isNull())
return;
painter->save();
painter->resetTransform();
painter->translate(m_feedbackOriginPoint);
QColor defaultColor(Qt::white);
QColor changeColor("#9999ff");
QFont font;
font.setFamily("Helvetica");
font.setPixelSize(12);
painter->setFont(font);
if (m_bubblePixmap.isNull())
m_bubblePixmap = createBubblePixmap();
painter->drawPixmap(-13, -7, m_bubblePixmap);
if (m_beginXHasExpression) {
if(m_feedbackNode.hasBindingProperty("x"))
painter->setPen(defaultColor);
else
painter->setPen(Qt::red);
} else {
if (m_beginX != m_feedbackNode.instanceValue("x"))
painter->setPen(changeColor);
else
painter->setPen(defaultColor);
}
painter->drawText(QPoint(8.0, 13.0), QString("x:"));
painter->drawText(QPoint(22.0, 13.0), m_feedbackNode.instanceValue("x").toString());
if (m_beginYHasExpression) {
if(m_feedbackNode.hasBindingProperty("y"))
painter->setPen(defaultColor);
else
painter->setPen(Qt::red);
} else {
if (m_beginY != m_feedbackNode.instanceValue("y"))
painter->setPen(changeColor);
else
painter->setPen(defaultColor);
}
painter->drawText(QPoint(60.0, 13.0), QString("y:"));
painter->drawText(QPoint(72.0, 13.0), m_feedbackNode.instanceValue("y").toString());
if (m_beginWidthHasExpression) {
if(m_feedbackNode.hasBindingProperty("width"))
painter->setPen(defaultColor);
else
painter->setPen(Qt::red);
} else {
if (m_beginWidth != m_feedbackNode.instanceValue("width"))
painter->setPen(changeColor);
else
painter->setPen(defaultColor);
}
painter->drawText(QPoint(8.0, 29.0), QString("w:"));
painter->drawText(QPoint(22.0, 29.0), m_feedbackNode.instanceValue("width").toString());
if (m_beginHeightHasExpression) {
if(m_feedbackNode.hasBindingProperty("height"))
painter->setPen(defaultColor);
else
painter->setPen(Qt::red);
} else {
if (m_beginHeight != m_feedbackNode.instanceValue("height"))
painter->setPen(changeColor);
else
painter->setPen(defaultColor);
}
painter->drawText(QPoint(60.0, 29.0), QString("h:"));
painter->drawText(QPoint(72.0, 29.0), m_feedbackNode.instanceValue("height").toString());
if (m_parentNode != m_feedbackNode.instanceParent()) {
painter->setPen(changeColor);
painter->drawText(QPoint(2.0, 39.0), QString("Parent changed"));
}
painter->restore();
// if (!m_feedbackNode.isValid())
// return;
// if (m_feedbackOriginPoint.isNull())
// return;
// painter->save();
// painter->resetTransform();
// painter->translate(m_feedbackOriginPoint);
// QColor defaultColor(Qt::white);
// QColor changeColor("#9999ff");
// QFont font;
// font.setFamily("Helvetica");
// font.setPixelSize(12);
// painter->setFont(font);
// if (m_bubblePixmap.isNull())
// m_bubblePixmap = createBubblePixmap();
// painter->drawPixmap(-13, -7, m_bubblePixmap);
// if (m_beginXHasExpression) {
// if(m_feedbackNode.hasBindingProperty("x"))
// painter->setPen(defaultColor);
// else
// painter->setPen(Qt::red);
// } else {
// if (m_beginX != m_feedbackNode.instanceValue("x"))
// painter->setPen(changeColor);
// else
// painter->setPen(defaultColor);
// }
// painter->drawText(QPoint(8.0, 13.0), QString("x:"));
// painter->drawText(QPoint(22.0, 13.0), m_feedbackNode.instanceValue("x").toString());
// if (m_beginYHasExpression) {
// if(m_feedbackNode.hasBindingProperty("y"))
// painter->setPen(defaultColor);
// else
// painter->setPen(Qt::red);
// } else {
// if (m_beginY != m_feedbackNode.instanceValue("y"))
// painter->setPen(changeColor);
// else
// painter->setPen(defaultColor);
// }
// painter->drawText(QPoint(60.0, 13.0), QString("y:"));
// painter->drawText(QPoint(72.0, 13.0), m_feedbackNode.instanceValue("y").toString());
// if (m_beginWidthHasExpression) {
// if(m_feedbackNode.hasBindingProperty("width"))
// painter->setPen(defaultColor);
// else
// painter->setPen(Qt::red);
// } else {
// if (m_beginWidth != m_feedbackNode.instanceValue("width"))
// painter->setPen(changeColor);
// else
// painter->setPen(defaultColor);
// }
// painter->drawText(QPoint(8.0, 29.0), QString("w:"));
// painter->drawText(QPoint(22.0, 29.0), m_feedbackNode.instanceValue("width").toString());
// if (m_beginHeightHasExpression) {
// if(m_feedbackNode.hasBindingProperty("height"))
// painter->setPen(defaultColor);
// else
// painter->setPen(Qt::red);
// } else {
// if (m_beginHeight != m_feedbackNode.instanceValue("height"))
// painter->setPen(changeColor);
// else
// painter->setPen(defaultColor);
// }
// painter->drawText(QPoint(60.0, 29.0), QString("h:"));
// painter->drawText(QPoint(72.0, 29.0), m_feedbackNode.instanceValue("height").toString());
// if (m_parentNode != m_feedbackNode.instanceParent()) {
// painter->setPen(changeColor);
// painter->drawText(QPoint(2.0, 39.0), QString("Parent changed"));
// }
// painter->restore();
}
void FormEditorGraphicsView::setFeedbackNode(const QmlItemNode &node)
{
if (node == m_feedbackNode)
return;
m_feedbackNode = node;
if (m_feedbackNode.isValid()) {
m_beginX = m_feedbackNode.instanceValue("x");
m_beginY = m_feedbackNode.instanceValue("y");
m_beginWidth = m_feedbackNode.instanceValue("width");
m_beginHeight = m_feedbackNode.instanceValue("height");
m_parentNode = m_feedbackNode.instanceParent();
m_beginLeftMargin = m_feedbackNode.instanceValue("anchors.leftMargin");
m_beginRightMargin = m_feedbackNode.instanceValue("anchors.rightMargin");
m_beginTopMargin = m_feedbackNode.instanceValue("anchors.topMargin");
m_beginBottomMargin = m_feedbackNode.instanceValue("anchors.bottomMargin");
m_beginXHasExpression = m_feedbackNode.hasBindingProperty("x");
m_beginYHasExpression = m_feedbackNode.hasBindingProperty("y");
m_beginWidthHasExpression = m_feedbackNode.hasBindingProperty("width");
m_beginHeightHasExpression = m_feedbackNode.hasBindingProperty("height");
} else {
m_beginX = QVariant();
m_beginY = QVariant();
m_beginWidth = QVariant();
m_beginHeight = QVariant();
m_parentNode = QmlObjectNode();
m_beginLeftMargin = QVariant();
m_beginRightMargin = QVariant();
m_beginTopMargin = QVariant();
m_beginBottomMargin = QVariant();
m_beginXHasExpression = false;
m_beginYHasExpression = false;
m_beginWidthHasExpression = false;
m_beginHeightHasExpression = false;
}
// if (node == m_feedbackNode)
// return;
// m_feedbackNode = node;
// if (m_feedbackNode.isValid()) {
// m_beginX = m_feedbackNode.instanceValue("x");
// m_beginY = m_feedbackNode.instanceValue("y");
// m_beginWidth = m_feedbackNode.instanceValue("width");
// m_beginHeight = m_feedbackNode.instanceValue("height");
// m_parentNode = m_feedbackNode.instanceParent();
// m_beginLeftMargin = m_feedbackNode.instanceValue("anchors.leftMargin");
// m_beginRightMargin = m_feedbackNode.instanceValue("anchors.rightMargin");
// m_beginTopMargin = m_feedbackNode.instanceValue("anchors.topMargin");
// m_beginBottomMargin = m_feedbackNode.instanceValue("anchors.bottomMargin");
// m_beginXHasExpression = m_feedbackNode.hasBindingProperty("x");
// m_beginYHasExpression = m_feedbackNode.hasBindingProperty("y");
// m_beginWidthHasExpression = m_feedbackNode.hasBindingProperty("width");
// m_beginHeightHasExpression = m_feedbackNode.hasBindingProperty("height");
// } else {
// m_beginX = QVariant();
// m_beginY = QVariant();
// m_beginWidth = QVariant();
// m_beginHeight = QVariant();
// m_parentNode = QmlObjectNode();
// m_beginLeftMargin = QVariant();
// m_beginRightMargin = QVariant();
// m_beginTopMargin = QVariant();
// m_beginBottomMargin = QVariant();
// m_beginXHasExpression = false;
// m_beginYHasExpression = false;
// m_beginWidthHasExpression = false;
// m_beginHeightHasExpression = false;
// }
}
void FormEditorGraphicsView::drawBackground(QPainter *painter, const QRectF &rectangle)
......
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