forked from qt-creator/qt-creator
QmlDesigner: Remove AnnotationTool
Remove AnnotationTool from FormEditor's selected item's tools. Change-Id: I797ed4002d14c04956aaeb5d779f1cf3f326f849 Fixes: QDS-2970 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Aleksei German <aleksei.german@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -2554,13 +2554,6 @@ To hide a sticky splash screen, invoke QtAndroid::hideSplashScreen().</source>
|
|||||||
<translation>Анимируемые свойства.</translation>
|
<translation>Анимируемые свойства.</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
|
||||||
<name>AnnotationToolAction</name>
|
|
||||||
<message>
|
|
||||||
<source>Edit Annotation</source>
|
|
||||||
<translation>Изменить аннотацию</translation>
|
|
||||||
</message>
|
|
||||||
</context>
|
|
||||||
<context>
|
<context>
|
||||||
<name>Application</name>
|
<name>Application</name>
|
||||||
<message>
|
<message>
|
||||||
@@ -39440,13 +39433,6 @@ Neither the path to the library nor the path to its includes is added to the .pr
|
|||||||
<translation>Аннотация</translation>
|
<translation>Аннотация</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
|
||||||
<name>QmlDesigner::AnnotationTool</name>
|
|
||||||
<message>
|
|
||||||
<source>Annotation Tool</source>
|
|
||||||
<translation>Аннотация</translation>
|
|
||||||
</message>
|
|
||||||
</context>
|
|
||||||
<context>
|
<context>
|
||||||
<name>QmlDesigner::AssetExportDialog</name>
|
<name>QmlDesigner::AssetExportDialog</name>
|
||||||
<message>
|
<message>
|
||||||
|
@@ -627,7 +627,6 @@ extend_qtc_plugin(QmlDesigner
|
|||||||
annotationeditordialog.cpp annotationeditordialog.h annotationeditordialog.ui
|
annotationeditordialog.cpp annotationeditordialog.h annotationeditordialog.ui
|
||||||
globalannotationeditordialog.cpp globalannotationeditordialog.h globalannotationeditordialog.ui
|
globalannotationeditordialog.cpp globalannotationeditordialog.h globalannotationeditordialog.ui
|
||||||
annotationeditor.cpp annotationeditor.h
|
annotationeditor.cpp annotationeditor.h
|
||||||
annotationtool.cpp annotationtool.h
|
|
||||||
globalannotationeditor.cpp globalannotationeditor.h
|
globalannotationeditor.cpp globalannotationeditor.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -1,11 +1,9 @@
|
|||||||
HEADERS += $$PWD/annotationtool.h
|
|
||||||
HEADERS += $$PWD/annotationcommenttab.h
|
HEADERS += $$PWD/annotationcommenttab.h
|
||||||
HEADERS += $$PWD/annotationeditordialog.h
|
HEADERS += $$PWD/annotationeditordialog.h
|
||||||
HEADERS += $$PWD/annotationeditor.h
|
HEADERS += $$PWD/annotationeditor.h
|
||||||
HEADERS += $$PWD/globalannotationeditor.h
|
HEADERS += $$PWD/globalannotationeditor.h
|
||||||
HEADERS += $$PWD/globalannotationeditordialog.h
|
HEADERS += $$PWD/globalannotationeditordialog.h
|
||||||
|
|
||||||
SOURCES += $$PWD/annotationtool.cpp
|
|
||||||
SOURCES += $$PWD/annotationcommenttab.cpp
|
SOURCES += $$PWD/annotationcommenttab.cpp
|
||||||
SOURCES += $$PWD/annotationeditordialog.cpp
|
SOURCES += $$PWD/annotationeditordialog.cpp
|
||||||
SOURCES += $$PWD/annotationeditor.cpp
|
SOURCES += $$PWD/annotationeditor.cpp
|
||||||
|
@@ -1,259 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "annotationtool.h"
|
|
||||||
|
|
||||||
#include "formeditorscene.h"
|
|
||||||
#include "formeditorview.h"
|
|
||||||
#include "formeditorwidget.h"
|
|
||||||
#include "itemutilfunctions.h"
|
|
||||||
#include "formeditoritem.h"
|
|
||||||
|
|
||||||
#include "nodemetainfo.h"
|
|
||||||
#include "qmlitemnode.h"
|
|
||||||
#include <qmldesignerplugin.h>
|
|
||||||
#include <abstractaction.h>
|
|
||||||
#include <designeractionmanager.h>
|
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QGraphicsSceneMouseEvent>
|
|
||||||
#include <QAction>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QPair>
|
|
||||||
#include <QUrl>
|
|
||||||
#include <QMetaType>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
|
||||||
|
|
||||||
class AnnotationToolAction : public AbstractAction
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AnnotationToolAction() : AbstractAction(QCoreApplication::translate("AnnotationToolAction","Edit Annotation"))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray category() const override
|
|
||||||
{
|
|
||||||
return QByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray menuId() const override
|
|
||||||
{
|
|
||||||
return "AnnotationTool";
|
|
||||||
}
|
|
||||||
|
|
||||||
int priority() const override
|
|
||||||
{
|
|
||||||
return CustomActionsPriority + 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
Type type() const override
|
|
||||||
{
|
|
||||||
return FormEditorAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool isVisible(const SelectionContext &selectionContext) const override
|
|
||||||
{
|
|
||||||
return selectionContext.singleNodeIsSelected();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isEnabled(const SelectionContext &selectionContext) const override
|
|
||||||
{
|
|
||||||
return isVisible(selectionContext);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AnnotationTool::AnnotationTool()
|
|
||||||
{
|
|
||||||
auto annotationToolAction = new AnnotationToolAction;
|
|
||||||
QmlDesignerPlugin::instance()->designerActionManager().addDesignerAction(annotationToolAction);
|
|
||||||
connect(annotationToolAction->action(), &QAction::triggered, [=]() {
|
|
||||||
view()->changeCurrentToolTo(this);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
AnnotationTool::~AnnotationTool() = default;
|
|
||||||
|
|
||||||
void AnnotationTool::clear()
|
|
||||||
{
|
|
||||||
if (m_annotationEditor)
|
|
||||||
m_annotationEditor->deleteLater();
|
|
||||||
|
|
||||||
AbstractFormEditorTool::clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnotationTool::mousePressEvent(const QList<QGraphicsItem*> &itemList,
|
|
||||||
QGraphicsSceneMouseEvent *event)
|
|
||||||
{
|
|
||||||
AbstractFormEditorTool::mousePressEvent(itemList, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnotationTool::mouseMoveEvent(const QList<QGraphicsItem*> & /*itemList*/,
|
|
||||||
QGraphicsSceneMouseEvent * /*event*/)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnotationTool::hoverMoveEvent(const QList<QGraphicsItem*> & /*itemList*/,
|
|
||||||
QGraphicsSceneMouseEvent * /*event*/)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnotationTool::keyPressEvent(QKeyEvent * /*keyEvent*/)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnotationTool::keyReleaseEvent(QKeyEvent * /*keyEvent*/)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnotationTool::dragLeaveEvent(const QList<QGraphicsItem*> &/*itemList*/, QGraphicsSceneDragDropEvent * /*event*/)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnotationTool::dragMoveEvent(const QList<QGraphicsItem*> &/*itemList*/, QGraphicsSceneDragDropEvent * /*event*/)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnotationTool::mouseReleaseEvent(const QList<QGraphicsItem*> &itemList,
|
|
||||||
QGraphicsSceneMouseEvent *event)
|
|
||||||
{
|
|
||||||
AbstractFormEditorTool::mouseReleaseEvent(itemList, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AnnotationTool::mouseDoubleClickEvent(const QList<QGraphicsItem*> &itemList, QGraphicsSceneMouseEvent *event)
|
|
||||||
{
|
|
||||||
AbstractFormEditorTool::mouseDoubleClickEvent(itemList, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnotationTool::itemsAboutToRemoved(const QList<FormEditorItem*> &removedItemList)
|
|
||||||
{
|
|
||||||
if (m_annotationEditor.isNull())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (removedItemList.contains(m_formEditorItem))
|
|
||||||
view()->changeToSelectionTool();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnotationTool::selectedItemsChanged(const QList<FormEditorItem*> &itemList)
|
|
||||||
{
|
|
||||||
if (!itemList.isEmpty()) {
|
|
||||||
m_formEditorItem = itemList.constFirst();
|
|
||||||
|
|
||||||
ModelNode itemModelNode = m_formEditorItem->qmlItemNode().modelNode();
|
|
||||||
m_oldCustomId = itemModelNode.customId();
|
|
||||||
m_oldAnnotation = itemModelNode.annotation();
|
|
||||||
|
|
||||||
if (m_annotationEditor.isNull()) {
|
|
||||||
m_annotationEditor = new AnnotationEditorDialog(view()->formEditorWidget()->parentWidget(),
|
|
||||||
itemModelNode.displayName(),
|
|
||||||
m_oldCustomId, m_oldAnnotation);
|
|
||||||
|
|
||||||
connect(m_annotationEditor, &AnnotationEditorDialog::accepted, this, &AnnotationTool::annotationDialogAccepted);
|
|
||||||
connect(m_annotationEditor, &QDialog::rejected, this, &AnnotationTool::annotationDialogRejected);
|
|
||||||
|
|
||||||
m_annotationEditor->show();
|
|
||||||
m_annotationEditor->raise();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
view()->changeToSelectionTool();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnotationTool::instancesCompleted(const QList<FormEditorItem*> & /*itemList*/)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnotationTool::instancesParentChanged(const QList<FormEditorItem *> & /*itemList*/)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnotationTool::instancePropertyChange(const QList<QPair<ModelNode, PropertyName> > & /*propertyList*/)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnotationTool::formEditorItemsChanged(const QList<FormEditorItem*> & /*itemList*/)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int AnnotationTool::wantHandleItem(const ModelNode & /*modelNode*/) const
|
|
||||||
{
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AnnotationTool::name() const
|
|
||||||
{
|
|
||||||
return tr("Annotation Tool");
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnotationTool::annotationDialogAccepted()
|
|
||||||
{
|
|
||||||
if (m_annotationEditor) {
|
|
||||||
saveNewCustomId(m_annotationEditor->customId());
|
|
||||||
saveNewAnnotation(m_annotationEditor->annotation());
|
|
||||||
|
|
||||||
m_annotationEditor->close();
|
|
||||||
m_annotationEditor->deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_annotationEditor = nullptr;
|
|
||||||
|
|
||||||
view()->changeToSelectionTool();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnotationTool::saveNewCustomId(const QString &customId)
|
|
||||||
{
|
|
||||||
if (m_formEditorItem) {
|
|
||||||
m_oldCustomId = customId;
|
|
||||||
m_formEditorItem->qmlItemNode().modelNode().setCustomId(customId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnotationTool::saveNewAnnotation(const Annotation &annotation)
|
|
||||||
{
|
|
||||||
if (m_formEditorItem) {
|
|
||||||
if (annotation.comments().isEmpty())
|
|
||||||
m_formEditorItem->qmlItemNode().modelNode().removeAnnotation();
|
|
||||||
else
|
|
||||||
m_formEditorItem->qmlItemNode().modelNode().setAnnotation(annotation);
|
|
||||||
|
|
||||||
m_oldAnnotation = annotation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnotationTool::annotationDialogRejected()
|
|
||||||
{
|
|
||||||
if (m_annotationEditor) {
|
|
||||||
m_annotationEditor->close();
|
|
||||||
m_annotationEditor->deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_annotationEditor = nullptr;
|
|
||||||
|
|
||||||
view()->changeToSelectionTool();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,93 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "annotation.h"
|
|
||||||
#include "annotationeditordialog.h"
|
|
||||||
#include "abstractcustomtool.h"
|
|
||||||
#include "selectionindicator.h"
|
|
||||||
|
|
||||||
#include <QHash>
|
|
||||||
#include <QPointer>
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
|
||||||
|
|
||||||
class AnnotationTool : public QObject, public AbstractCustomTool
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
AnnotationTool();
|
|
||||||
~AnnotationTool() override;
|
|
||||||
|
|
||||||
void mousePressEvent(const QList<QGraphicsItem*> &itemList,
|
|
||||||
QGraphicsSceneMouseEvent *event) override;
|
|
||||||
void mouseMoveEvent(const QList<QGraphicsItem*> &itemList,
|
|
||||||
QGraphicsSceneMouseEvent *event) override;
|
|
||||||
void mouseReleaseEvent(const QList<QGraphicsItem*> &itemList,
|
|
||||||
QGraphicsSceneMouseEvent *event) override;
|
|
||||||
void mouseDoubleClickEvent(const QList<QGraphicsItem*> &itemList,
|
|
||||||
QGraphicsSceneMouseEvent *event) override;
|
|
||||||
void hoverMoveEvent(const QList<QGraphicsItem*> &itemList,
|
|
||||||
QGraphicsSceneMouseEvent *event) override;
|
|
||||||
void keyPressEvent(QKeyEvent *event) override;
|
|
||||||
void keyReleaseEvent(QKeyEvent *keyEvent) override;
|
|
||||||
|
|
||||||
void dragLeaveEvent(const QList<QGraphicsItem*> &itemList,
|
|
||||||
QGraphicsSceneDragDropEvent * event) override;
|
|
||||||
void dragMoveEvent(const QList<QGraphicsItem*> &itemList,
|
|
||||||
QGraphicsSceneDragDropEvent * event) override;
|
|
||||||
|
|
||||||
void itemsAboutToRemoved(const QList<FormEditorItem*> &itemList) override;
|
|
||||||
|
|
||||||
void selectedItemsChanged(const QList<FormEditorItem*> &itemList) override; //impl needed
|
|
||||||
|
|
||||||
void instancesCompleted(const QList<FormEditorItem*> &itemList) override;
|
|
||||||
void instancesParentChanged(const QList<FormEditorItem *> &itemList) override;
|
|
||||||
void instancePropertyChange(const QList<QPair<ModelNode, PropertyName> > &propertyList) override;
|
|
||||||
|
|
||||||
void clear() override;
|
|
||||||
|
|
||||||
void formEditorItemsChanged(const QList<FormEditorItem*> &itemList) override;
|
|
||||||
|
|
||||||
int wantHandleItem(const ModelNode &modelNode) const override;
|
|
||||||
|
|
||||||
QString name() const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void annotationDialogAccepted();
|
|
||||||
void annotationDialogRejected();
|
|
||||||
void saveNewCustomId(const QString &customId);
|
|
||||||
void saveNewAnnotation(const Annotation &annotation);
|
|
||||||
|
|
||||||
private:
|
|
||||||
FormEditorItem *m_formEditorItem = nullptr;
|
|
||||||
QString m_oldCustomId;
|
|
||||||
Annotation m_oldAnnotation;
|
|
||||||
QPointer<AnnotationEditorDialog> m_annotationEditor;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
@@ -37,7 +37,6 @@
|
|||||||
#include <connectionview.h>
|
#include <connectionview.h>
|
||||||
#include <sourcetool/sourcetool.h>
|
#include <sourcetool/sourcetool.h>
|
||||||
#include <colortool/colortool.h>
|
#include <colortool/colortool.h>
|
||||||
#include <annotationeditor/annotationtool.h>
|
|
||||||
#include <curveeditor/curveeditorview.h>
|
#include <curveeditor/curveeditorview.h>
|
||||||
#include <formeditor/transitiontool.h>
|
#include <formeditor/transitiontool.h>
|
||||||
#include <texttool/texttool.h>
|
#include <texttool/texttool.h>
|
||||||
@@ -250,7 +249,6 @@ bool QmlDesignerPlugin::delayedInitialize()
|
|||||||
|
|
||||||
d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::SourceTool);
|
d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::SourceTool);
|
||||||
d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::ColorTool);
|
d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::ColorTool);
|
||||||
d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::AnnotationTool);
|
|
||||||
d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::TextTool);
|
d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::TextTool);
|
||||||
d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::PathTool);
|
d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::PathTool);
|
||||||
d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::TransitionTool);
|
d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::TransitionTool);
|
||||||
|
@@ -712,8 +712,6 @@ Project {
|
|||||||
"annotationeditor/globalannotationeditordialog.cpp",
|
"annotationeditor/globalannotationeditordialog.cpp",
|
||||||
"annotationeditor/globalannotationeditordialog.h",
|
"annotationeditor/globalannotationeditordialog.h",
|
||||||
"annotationeditor/globalannotationeditordialog.ui",
|
"annotationeditor/globalannotationeditordialog.ui",
|
||||||
"annotationeditor/annotationtool.cpp",
|
|
||||||
"annotationeditor/annotationtool.h",
|
|
||||||
"bindingeditor/bindingeditor.cpp",
|
"bindingeditor/bindingeditor.cpp",
|
||||||
"bindingeditor/bindingeditor.h",
|
"bindingeditor/bindingeditor.h",
|
||||||
"bindingeditor/actioneditor.cpp",
|
"bindingeditor/actioneditor.cpp",
|
||||||
|
Reference in New Issue
Block a user