forked from qt-creator/qt-creator
QmlDesigner: If the scene looses focus change to selection tool
* We forward the focusOut event to the tools * The text tool now commits the data if the focus is lost * Adding override Task-number: QTCREATORBUG-16085 Change-Id: Ibdf6f60fc53e3c6c03222741c16cd8dd665618e1 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
committed by
Thomas Hartmann
parent
f175d0c589
commit
9ad8ec385e
@@ -39,5 +39,9 @@ void AbstractCustomTool::selectedItemsChanged(const QList<FormEditorItem *> & /*
|
|||||||
view()->changeToSelectionTool();
|
view()->changeToSelectionTool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AbstractCustomTool::focusLost()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ public:
|
|||||||
virtual QString name() const = 0;
|
virtual QString name() const = 0;
|
||||||
|
|
||||||
virtual int wantHandleItem(const ModelNode &modelNode) const = 0;
|
virtual int wantHandleItem(const ModelNode &modelNode) const = 0;
|
||||||
|
|
||||||
|
void focusLost() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ public:
|
|||||||
virtual void instancesParentChanged(const QList<FormEditorItem*> &itemList) = 0;
|
virtual void instancesParentChanged(const QList<FormEditorItem*> &itemList) = 0;
|
||||||
virtual void instancePropertyChange(const QList<QPair<ModelNode, PropertyName> > &propertyList) = 0;
|
virtual void instancePropertyChange(const QList<QPair<ModelNode, PropertyName> > &propertyList) = 0;
|
||||||
|
|
||||||
|
virtual void focusLost() = 0;
|
||||||
|
|
||||||
void setItems(const QList<FormEditorItem*> &itemList);
|
void setItems(const QList<FormEditorItem*> &itemList);
|
||||||
QList<FormEditorItem*> items() const;
|
QList<FormEditorItem*> items() const;
|
||||||
|
|
||||||
|
|||||||
@@ -196,6 +196,10 @@ void DragTool::clearMoveDelay()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DragTool::focusLost()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void DragTool::abort()
|
void DragTool::abort()
|
||||||
{
|
{
|
||||||
if (!m_isAborted) {
|
if (!m_isAborted) {
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ public:
|
|||||||
|
|
||||||
void clearMoveDelay();
|
void clearMoveDelay();
|
||||||
|
|
||||||
|
void focusLost() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void abort();
|
void abort();
|
||||||
void createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry, const QmlItemNode &parentNode, const QPointF &scenePos);
|
void createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry, const QmlItemNode &parentNode, const QPointF &scenePos);
|
||||||
|
|||||||
@@ -326,6 +326,12 @@ void FormEditorScene::keyReleaseEvent(QKeyEvent *keyEvent)
|
|||||||
currentTool()->keyReleaseEvent(keyEvent);
|
currentTool()->keyReleaseEvent(keyEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FormEditorScene::focusOutEvent(QFocusEvent *)
|
||||||
|
{
|
||||||
|
if (currentTool())
|
||||||
|
currentTool()->focusLost();
|
||||||
|
}
|
||||||
|
|
||||||
FormEditorView *FormEditorScene::editorView() const
|
FormEditorView *FormEditorScene::editorView() const
|
||||||
{
|
{
|
||||||
return m_editorView;
|
return m_editorView;
|
||||||
|
|||||||
@@ -92,22 +92,24 @@ public slots:
|
|||||||
bool showBoundingRects() const;
|
bool showBoundingRects() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent *event);
|
bool event(QEvent *event) override;
|
||||||
void dropEvent(QGraphicsSceneDragDropEvent * event);
|
void dropEvent(QGraphicsSceneDragDropEvent * event) override;
|
||||||
void dragEnterEvent(QGraphicsSceneDragDropEvent * event);
|
void dragEnterEvent(QGraphicsSceneDragDropEvent * event) override;
|
||||||
void dragLeaveEvent(QGraphicsSceneDragDropEvent * event);
|
void dragLeaveEvent(QGraphicsSceneDragDropEvent * event) override;
|
||||||
void dragMoveEvent(QGraphicsSceneDragDropEvent * event);
|
void dragMoveEvent(QGraphicsSceneDragDropEvent * event) override;
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
|
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||||
void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
|
void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
|
||||||
void keyPressEvent(QKeyEvent *keyEvent);
|
void keyPressEvent(QKeyEvent *keyEvent) override;
|
||||||
void keyReleaseEvent(QKeyEvent *keyEvent);
|
void keyReleaseEvent(QKeyEvent *keyEvent) override;
|
||||||
|
|
||||||
|
void focusOutEvent(QFocusEvent *focusEvent) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QGraphicsItem *> removeLayerItems(const QList<QGraphicsItem *> &itemList);
|
QList<QGraphicsItem *> removeLayerItems(const QList<QGraphicsItem *> &itemList);
|
||||||
|
|||||||
@@ -370,4 +370,8 @@ void MoveTool::formEditorItemsChanged(const QList<FormEditorItem*> &itemList)
|
|||||||
m_contentNotEditableIndicator.updateItems(selectedItemList);
|
m_contentNotEditableIndicator.updateItems(selectedItemList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MoveTool::focusLost()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ public:
|
|||||||
|
|
||||||
void formEditorItemsChanged(const QList<FormEditorItem*> &itemList) override;
|
void formEditorItemsChanged(const QList<FormEditorItem*> &itemList) override;
|
||||||
|
|
||||||
|
void focusLost() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static bool haveSameParent(const QList<FormEditorItem*> &itemList);
|
static bool haveSameParent(const QList<FormEditorItem*> &itemList);
|
||||||
|
|
||||||
|
|||||||
@@ -203,6 +203,10 @@ void ResizeTool::instancePropertyChange(const QList<QPair<ModelNode, PropertyNam
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResizeTool::focusLost()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ResizeTool::instancesParentChanged(const QList<FormEditorItem *> &/*itemList*/)
|
void ResizeTool::instancesParentChanged(const QList<FormEditorItem *> &/*itemList*/)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ public:
|
|||||||
void instancesCompleted(const QList<FormEditorItem*> &itemList) override;
|
void instancesCompleted(const QList<FormEditorItem*> &itemList) override;
|
||||||
void instancePropertyChange(const QList<QPair<ModelNode, PropertyName> > &propertyList) override;
|
void instancePropertyChange(const QList<QPair<ModelNode, PropertyName> > &propertyList) override;
|
||||||
|
|
||||||
|
void focusLost() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SelectionIndicator m_selectionIndicator;
|
SelectionIndicator m_selectionIndicator;
|
||||||
ResizeIndicator m_resizeIndicator;
|
ResizeIndicator m_resizeIndicator;
|
||||||
|
|||||||
@@ -294,4 +294,8 @@ void SelectionTool::selectUnderPoint(QGraphicsSceneMouseEvent *event)
|
|||||||
m_singleSelectionManipulator.end(event->scenePos());
|
m_singleSelectionManipulator.end(event->scenePos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SelectionTool::focusLost()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ public:
|
|||||||
|
|
||||||
void setCursor(const QCursor &cursor);
|
void setCursor(const QCursor &cursor);
|
||||||
|
|
||||||
|
void focusLost() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RubberBandSelectionManipulator m_rubberbandSelectionManipulator;
|
RubberBandSelectionManipulator m_rubberbandSelectionManipulator;
|
||||||
SingleSelectionManipulator m_singleSelectionManipulator;
|
SingleSelectionManipulator m_singleSelectionManipulator;
|
||||||
|
|||||||
@@ -257,6 +257,14 @@ QString TextTool::name() const
|
|||||||
return QCoreApplication::translate("TextTool", "Text Tool");
|
return QCoreApplication::translate("TextTool", "Text Tool");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextTool::focusLost()
|
||||||
|
{
|
||||||
|
if (textItem()) {
|
||||||
|
textItem()->writeTextToProperty();
|
||||||
|
view()->changeToSelectionTool();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TextEditItem *TextTool::textItem() const
|
TextEditItem *TextTool::textItem() const
|
||||||
{
|
{
|
||||||
return m_textItem.data();
|
return m_textItem.data();
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ public:
|
|||||||
|
|
||||||
QString name() const override;
|
QString name() const override;
|
||||||
|
|
||||||
|
void focusLost() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TextEditItem *textItem() const;
|
TextEditItem *textItem() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user