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();
|
||||
}
|
||||
|
||||
void AbstractCustomTool::focusLost()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
@@ -38,6 +38,8 @@ public:
|
||||
virtual QString name() const = 0;
|
||||
|
||||
virtual int wantHandleItem(const ModelNode &modelNode) const = 0;
|
||||
|
||||
void focusLost() override;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
@@ -74,6 +74,8 @@ public:
|
||||
virtual void instancesParentChanged(const QList<FormEditorItem*> &itemList) = 0;
|
||||
virtual void instancePropertyChange(const QList<QPair<ModelNode, PropertyName> > &propertyList) = 0;
|
||||
|
||||
virtual void focusLost() = 0;
|
||||
|
||||
void setItems(const QList<FormEditorItem*> &itemList);
|
||||
QList<FormEditorItem*> items() const;
|
||||
|
||||
|
||||
@@ -196,6 +196,10 @@ void DragTool::clearMoveDelay()
|
||||
}
|
||||
}
|
||||
|
||||
void DragTool::focusLost()
|
||||
{
|
||||
}
|
||||
|
||||
void DragTool::abort()
|
||||
{
|
||||
if (!m_isAborted) {
|
||||
|
||||
@@ -75,6 +75,8 @@ public:
|
||||
|
||||
void clearMoveDelay();
|
||||
|
||||
void focusLost() override;
|
||||
|
||||
protected:
|
||||
void abort();
|
||||
void createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry, const QmlItemNode &parentNode, const QPointF &scenePos);
|
||||
|
||||
@@ -326,6 +326,12 @@ void FormEditorScene::keyReleaseEvent(QKeyEvent *keyEvent)
|
||||
currentTool()->keyReleaseEvent(keyEvent);
|
||||
}
|
||||
|
||||
void FormEditorScene::focusOutEvent(QFocusEvent *)
|
||||
{
|
||||
if (currentTool())
|
||||
currentTool()->focusLost();
|
||||
}
|
||||
|
||||
FormEditorView *FormEditorScene::editorView() const
|
||||
{
|
||||
return m_editorView;
|
||||
|
||||
@@ -92,22 +92,24 @@ public slots:
|
||||
bool showBoundingRects() const;
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event);
|
||||
void dropEvent(QGraphicsSceneDragDropEvent * event);
|
||||
void dragEnterEvent(QGraphicsSceneDragDropEvent * event);
|
||||
void dragLeaveEvent(QGraphicsSceneDragDropEvent * event);
|
||||
void dragMoveEvent(QGraphicsSceneDragDropEvent * event);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
||||
bool event(QEvent *event) override;
|
||||
void dropEvent(QGraphicsSceneDragDropEvent * event) override;
|
||||
void dragEnterEvent(QGraphicsSceneDragDropEvent * event) override;
|
||||
void dragLeaveEvent(QGraphicsSceneDragDropEvent * event) override;
|
||||
void dragMoveEvent(QGraphicsSceneDragDropEvent * event) override;
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
|
||||
void keyPressEvent(QKeyEvent *keyEvent);
|
||||
void keyReleaseEvent(QKeyEvent *keyEvent);
|
||||
void keyPressEvent(QKeyEvent *keyEvent) override;
|
||||
void keyReleaseEvent(QKeyEvent *keyEvent) override;
|
||||
|
||||
void focusOutEvent(QFocusEvent *focusEvent) override;
|
||||
|
||||
private:
|
||||
QList<QGraphicsItem *> removeLayerItems(const QList<QGraphicsItem *> &itemList);
|
||||
|
||||
@@ -370,4 +370,8 @@ void MoveTool::formEditorItemsChanged(const QList<FormEditorItem*> &itemList)
|
||||
m_contentNotEditableIndicator.updateItems(selectedItemList);
|
||||
}
|
||||
|
||||
void MoveTool::focusLost()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -67,6 +67,8 @@ public:
|
||||
|
||||
void formEditorItemsChanged(const QList<FormEditorItem*> &itemList) override;
|
||||
|
||||
void focusLost() override;
|
||||
|
||||
protected:
|
||||
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*/)
|
||||
{
|
||||
|
||||
@@ -63,6 +63,8 @@ public:
|
||||
void instancesCompleted(const QList<FormEditorItem*> &itemList) override;
|
||||
void instancePropertyChange(const QList<QPair<ModelNode, PropertyName> > &propertyList) override;
|
||||
|
||||
void focusLost() override;
|
||||
|
||||
private:
|
||||
SelectionIndicator m_selectionIndicator;
|
||||
ResizeIndicator m_resizeIndicator;
|
||||
|
||||
@@ -294,4 +294,8 @@ void SelectionTool::selectUnderPoint(QGraphicsSceneMouseEvent *event)
|
||||
m_singleSelectionManipulator.end(event->scenePos());
|
||||
}
|
||||
|
||||
void SelectionTool::focusLost()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -77,6 +77,8 @@ public:
|
||||
|
||||
void setCursor(const QCursor &cursor);
|
||||
|
||||
void focusLost() override;
|
||||
|
||||
private:
|
||||
RubberBandSelectionManipulator m_rubberbandSelectionManipulator;
|
||||
SingleSelectionManipulator m_singleSelectionManipulator;
|
||||
|
||||
@@ -257,6 +257,14 @@ QString TextTool::name() const
|
||||
return QCoreApplication::translate("TextTool", "Text Tool");
|
||||
}
|
||||
|
||||
void TextTool::focusLost()
|
||||
{
|
||||
if (textItem()) {
|
||||
textItem()->writeTextToProperty();
|
||||
view()->changeToSelectionTool();
|
||||
}
|
||||
}
|
||||
|
||||
TextEditItem *TextTool::textItem() const
|
||||
{
|
||||
return m_textItem.data();
|
||||
|
||||
@@ -77,6 +77,8 @@ public:
|
||||
|
||||
QString name() const override;
|
||||
|
||||
void focusLost() override;
|
||||
|
||||
protected:
|
||||
TextEditItem *textItem() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user