forked from qt-creator/qt-creator
QmlDesigner: use changeCurrentToolTo everywhere
Change-Id: I1b30cc1e9a5b1d62441719d006aa9a9c3c991aa4 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@theqtcompany.com>
This commit is contained in:
@@ -302,15 +302,9 @@ bool FormEditorView::changeToMoveTool()
|
||||
{
|
||||
if (m_currentTool == m_moveTool)
|
||||
return true;
|
||||
|
||||
if (!isMoveToolAvailable())
|
||||
return false;
|
||||
|
||||
m_scene->updateAllFormEditorItems();
|
||||
m_currentTool->clear();
|
||||
m_currentTool = m_moveTool;
|
||||
m_currentTool->clear();
|
||||
m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedModelNodes())));
|
||||
changeCurrentToolTo(m_moveTool);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -318,12 +312,7 @@ void FormEditorView::changeToDragTool()
|
||||
{
|
||||
if (m_currentTool == m_dragTool)
|
||||
return;
|
||||
|
||||
m_scene->updateAllFormEditorItems();
|
||||
m_currentTool->clear();
|
||||
m_currentTool = m_dragTool;
|
||||
m_currentTool->clear();
|
||||
m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedModelNodes())));
|
||||
changeCurrentToolTo(m_dragTool);
|
||||
}
|
||||
|
||||
|
||||
@@ -331,15 +320,9 @@ bool FormEditorView::changeToMoveTool(const QPointF &beginPoint)
|
||||
{
|
||||
if (m_currentTool == m_moveTool)
|
||||
return true;
|
||||
|
||||
if (!isMoveToolAvailable())
|
||||
return false;
|
||||
|
||||
m_scene->updateAllFormEditorItems();
|
||||
m_currentTool->clear();
|
||||
m_currentTool = m_moveTool;
|
||||
m_currentTool->clear();
|
||||
m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedModelNodes())));
|
||||
changeCurrentToolTo(m_moveTool);
|
||||
m_moveTool->beginWithPoint(beginPoint);
|
||||
return true;
|
||||
}
|
||||
@@ -348,25 +331,14 @@ void FormEditorView::changeToSelectionTool()
|
||||
{
|
||||
if (m_currentTool == m_selectionTool)
|
||||
return;
|
||||
|
||||
m_scene->updateAllFormEditorItems();
|
||||
m_currentTool->clear();
|
||||
m_currentTool = m_selectionTool;
|
||||
m_currentTool->clear();
|
||||
m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedModelNodes())));
|
||||
changeCurrentToolTo(m_selectionTool);
|
||||
}
|
||||
|
||||
void FormEditorView::changeToSelectionTool(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (m_currentTool == m_selectionTool)
|
||||
return;
|
||||
|
||||
m_scene->updateAllFormEditorItems();
|
||||
m_currentTool->clear();
|
||||
m_currentTool = m_selectionTool;
|
||||
m_currentTool->clear();
|
||||
m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedModelNodes())));
|
||||
|
||||
changeCurrentToolTo(m_selectionTool);
|
||||
m_selectionTool->selectUnderPoint(event);
|
||||
}
|
||||
|
||||
@@ -374,12 +346,7 @@ void FormEditorView::changeToResizeTool()
|
||||
{
|
||||
if (m_currentTool == m_resizeTool)
|
||||
return;
|
||||
|
||||
m_scene->updateAllFormEditorItems();
|
||||
m_currentTool->clear();
|
||||
m_currentTool = m_resizeTool;
|
||||
m_currentTool->clear();
|
||||
m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedModelNodes())));
|
||||
changeCurrentToolTo(m_resizeTool);
|
||||
}
|
||||
|
||||
void FormEditorView::changeToTransformTools()
|
||||
@@ -388,7 +355,6 @@ void FormEditorView::changeToTransformTools()
|
||||
m_currentTool == m_resizeTool ||
|
||||
m_currentTool == m_selectionTool)
|
||||
return;
|
||||
|
||||
changeToSelectionTool();
|
||||
}
|
||||
|
||||
@@ -405,28 +371,21 @@ void FormEditorView::changeToCustomTool()
|
||||
handlingRank = customTool->wantHandleItem(selectedModelNode);
|
||||
selectedCustomTool = customTool;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (handlingRank > 0) {
|
||||
m_scene->updateAllFormEditorItems();
|
||||
m_currentTool->clear();
|
||||
if (selectedCustomTool) {
|
||||
m_currentTool = selectedCustomTool;
|
||||
m_currentTool->clear();
|
||||
m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedModelNodes())));
|
||||
}
|
||||
}
|
||||
if (handlingRank > 0 && selectedCustomTool)
|
||||
changeCurrentToolTo(selectedCustomTool);
|
||||
}
|
||||
}
|
||||
|
||||
void FormEditorView::changeToCustomTool(AbstractCustomTool *customTool)
|
||||
void FormEditorView::changeCurrentToolTo(AbstractFormEditorTool *newTool)
|
||||
{
|
||||
m_scene->updateAllFormEditorItems();
|
||||
m_currentTool->clear();
|
||||
m_currentTool = customTool;
|
||||
m_currentTool = newTool;
|
||||
m_currentTool->clear();
|
||||
m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedModelNodes())));
|
||||
m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(
|
||||
selectedModelNodes())));
|
||||
}
|
||||
|
||||
void FormEditorView::registerTool(AbstractCustomTool *tool)
|
||||
@@ -618,6 +577,5 @@ void FormEditorView::delayedReset()
|
||||
setupFormEditorItemTree(rootModelNode());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
void changeToResizeTool();
|
||||
void changeToTransformTools();
|
||||
void changeToCustomTool();
|
||||
void changeToCustomTool(AbstractCustomTool *customTool);
|
||||
void changeCurrentToolTo(AbstractFormEditorTool *customTool);
|
||||
|
||||
void registerTool(AbstractCustomTool *tool);
|
||||
|
||||
|
||||
@@ -93,10 +93,9 @@ ColorTool::ColorTool()
|
||||
{
|
||||
ColorToolAction *colorToolAction = new ColorToolAction;
|
||||
QmlDesignerPlugin::instance()->designerActionManager().addDesignerAction(colorToolAction);
|
||||
connect(colorToolAction->action(),
|
||||
SIGNAL(triggered()),
|
||||
this,
|
||||
SLOT(changeToColorTool()));
|
||||
connect(colorToolAction->action(), &QAction::triggered, [=]() {
|
||||
view()->changeCurrentToolTo(this);
|
||||
});
|
||||
}
|
||||
|
||||
ColorTool::~ColorTool()
|
||||
@@ -244,9 +243,4 @@ void ColorTool::currentColorChanged(const QColor &color)
|
||||
}
|
||||
}
|
||||
|
||||
void ColorTool::changeToColorTool()
|
||||
{
|
||||
view()->changeToCustomTool(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -80,7 +80,6 @@ private slots:
|
||||
void colorDialogAccepted();
|
||||
void colorDialogRejected();
|
||||
void currentColorChanged(const QColor &color);
|
||||
void changeToColorTool();
|
||||
|
||||
private:
|
||||
QPointer<QColorDialog> m_colorDialog;
|
||||
|
||||
@@ -146,10 +146,13 @@ PathTool::PathTool()
|
||||
{
|
||||
PathToolAction *textToolAction = new PathToolAction;
|
||||
QmlDesignerPlugin::instance()->designerActionManager().addDesignerAction(textToolAction);
|
||||
connect(textToolAction->action(),
|
||||
SIGNAL(triggered()),
|
||||
this,
|
||||
SLOT(changeToPathTool()));
|
||||
connect(textToolAction->action(), &QAction::triggered, [=]() {
|
||||
if (m_pathToolView.model())
|
||||
m_pathToolView.model()->detachView(&m_pathToolView);
|
||||
view()->changeCurrentToolTo(this);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
PathTool::~PathTool()
|
||||
@@ -313,11 +316,4 @@ void PathTool::pathChanged()
|
||||
m_pathItem->updatePath();
|
||||
}
|
||||
|
||||
void PathTool::changeToPathTool()
|
||||
{
|
||||
if (m_pathToolView.model())
|
||||
m_pathToolView.model()->detachView(&m_pathToolView);
|
||||
view()->changeToCustomTool(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -84,9 +84,6 @@ public:
|
||||
|
||||
void pathChanged();
|
||||
|
||||
private slots:
|
||||
void changeToPathTool();
|
||||
|
||||
private:
|
||||
PathToolView m_pathToolView;
|
||||
QPointer<PathItem> m_pathItem;
|
||||
|
||||
@@ -112,10 +112,9 @@ SourceTool::SourceTool()
|
||||
{
|
||||
SourceToolAction *sourceToolAction = new SourceToolAction;
|
||||
QmlDesignerPlugin::instance()->designerActionManager().addDesignerAction(sourceToolAction);
|
||||
connect(sourceToolAction->action(),
|
||||
SIGNAL(triggered()),
|
||||
this,
|
||||
SLOT(changeToSourceTool()));
|
||||
connect(sourceToolAction->action(), &QAction::triggered, [=]() {
|
||||
view()->changeCurrentToolTo(this);
|
||||
});
|
||||
}
|
||||
|
||||
SourceTool::~SourceTool()
|
||||
@@ -247,9 +246,4 @@ void SourceTool::fileSelected(const QString &fileName)
|
||||
view()->changeToSelectionTool();
|
||||
}
|
||||
|
||||
void SourceTool::changeToSourceTool()
|
||||
{
|
||||
view()->changeToCustomTool(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -78,9 +78,6 @@ public:
|
||||
|
||||
QString name() const override;
|
||||
|
||||
private slots:
|
||||
void changeToSourceTool();
|
||||
|
||||
private:
|
||||
/* private methods */
|
||||
void fileSelected(const QString &fileName);
|
||||
|
||||
@@ -97,10 +97,9 @@ TextTool::TextTool()
|
||||
{
|
||||
TextToolAction *textToolAction = new TextToolAction;
|
||||
QmlDesignerPlugin::instance()->designerActionManager().addDesignerAction(textToolAction);
|
||||
connect(textToolAction->action(),
|
||||
SIGNAL(triggered()),
|
||||
this,
|
||||
SLOT(changeToTextTool()));
|
||||
connect(textToolAction->action(), &QAction::triggered, [=]() {
|
||||
view()->changeCurrentToolTo(this);
|
||||
});
|
||||
}
|
||||
|
||||
TextTool::~TextTool()
|
||||
@@ -258,11 +257,6 @@ QString TextTool::name() const
|
||||
return QCoreApplication::translate("TextTool", "Text Tool");
|
||||
}
|
||||
|
||||
void TextTool::changeToTextTool()
|
||||
{
|
||||
view()->changeToCustomTool(this);
|
||||
}
|
||||
|
||||
TextEditItem *TextTool::textItem() const
|
||||
{
|
||||
return m_textItem.data();
|
||||
|
||||
@@ -78,9 +78,6 @@ public:
|
||||
|
||||
QString name() const override;
|
||||
|
||||
private slots:
|
||||
void changeToTextTool();
|
||||
|
||||
protected:
|
||||
TextEditItem *textItem() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user