Commit 85c85d84 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.formEditor: add reset button

Adding a button that allows reseting the view.
parent 1a7759b4
......@@ -15,4 +15,7 @@
<qresource prefix="/icon/selection">
<file>selectonlycontentitems.png</file>
</qresource>
<qresource prefix="/icon">
<file>reset.png</file>
</qresource>
</RCC>
......@@ -166,6 +166,15 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view)
addAction(m_zoomAction.data());
upperActions.append(m_zoomAction.data());
m_toolBox->addRightSideAction(m_zoomAction.data());
m_resetAction = new QAction(tr("Reset view (R)"), this);
m_resetAction->setShortcut(Qt::Key_R);
m_resetAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
m_resetAction->setIcon(QPixmap(":/icon/reset.png"));
connect(m_resetAction.data(), SIGNAL(triggered(bool)), this, SLOT(resetNodeInstanceView()));
addAction(m_resetAction.data());
upperActions.append(m_resetAction.data());
m_toolBox->addRightSideAction(m_resetAction.data());
}
void FormEditorWidget::enterEvent(QEvent *event)
......@@ -203,6 +212,12 @@ void FormEditorWidget::changeRootItemHeight(const QString &heighText)
}
}
void FormEditorWidget::resetNodeInstanceView()
{
m_formEditorView->setCurrentState(m_formEditorView->baseState());
m_formEditorView->emitCustomNotification(QLatin1String("reset QmlPuppet"));
}
void FormEditorWidget::changeAnchorTool(bool checked)
{
if (checked && m_formEditorView->currentState().isBaseState())
......
......@@ -95,6 +95,7 @@ private slots:
void setZoomLevel(double zoomLevel);
void changeRootItemWidth(const QString &widthText);
void changeRootItemHeight(const QString &heightText);
void resetNodeInstanceView();
private:
QWeakPointer<FormEditorView> m_formEditorView;
......@@ -111,6 +112,7 @@ private:
QWeakPointer<QAction> m_selectOnlyContentItemsAction;
QWeakPointer<LineEditAction> m_rootWidthAction;
QWeakPointer<LineEditAction> m_rootHeightAction;
QWeakPointer<QAction> m_resetAction;
};
......
......@@ -109,6 +109,7 @@ public:
void instancesPreviewImageChanged(const QVector<ModelNode> &nodeList);
void instancesChildrenChanged(const QVector<ModelNode> &nodeList);
void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);
void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
void rewriterBeginTransaction();
void rewriterEndTransaction();
......
......@@ -496,6 +496,12 @@ void NodeInstanceView::auxiliaryDataChanged(const ModelNode &node, const QString
}
}
void NodeInstanceView::customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &, const QList<QVariant> &)
{
if (view && identifier == QLatin1String("reset QmlPuppet"))
restartProcess();
}
void NodeInstanceView::rewriterBeginTransaction()
{
......
Supports Markdown
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