QmlDesigner: Fix help

The designer used a over simplified lookup,
that did not distinguish between e.g. Controls 1 and Controls 2.
Instead of fixing the lookup we simply use the working lookup from
the QmlJSEditor.

Change-Id: I2d31e633eaadc67e211d44bad307b26993f21fc9
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2017-03-22 12:17:28 +01:00
parent 316ed6943c
commit 970496b24c
5 changed files with 23 additions and 16 deletions

View File

@@ -146,13 +146,18 @@ WidgetInfo TextEditorView::widgetInfo()
}
QString TextEditorView::contextHelpId() const
{
return AbstractView::contextHelpId();
}
QString TextEditorView::qmlJSEditorHelpId() const
{
if (m_widget->textEditor()) {
QString contextHelpId = m_widget->textEditor()->contextHelpId();
if (!contextHelpId.isEmpty())
return m_widget->textEditor()->contextHelpId();
}
return AbstractView::contextHelpId();
return QString();
}
void TextEditorView::nodeIdChanged(const ModelNode& /*node*/, const QString &/*newId*/, const QString &/*oldId*/)

View File

@@ -69,6 +69,8 @@ public:
WidgetInfo widgetInfo() override;
QString contextHelpId() const override;
QString qmlJSEditorHelpId() const;
TextEditor::BaseTextEditor *textEditor();
bool changeToMoveTool();

View File

@@ -95,6 +95,8 @@ public:
void toggleStatesViewExpanded();
QString qmlJSEditorHelpId() const;
private: // functions
Q_DISABLE_COPY(ViewManager)

View File

@@ -31,6 +31,11 @@
#include "nodeinstanceview.h"
#include <qmlstate.h>
#ifndef QMLDESIGNER_TEST
#include <qmldesignerplugin.h>
#include <viewmanager.h>
#endif
#include <coreplugin/helpmanager.h>
#include <utils/qtcassert.h>
@@ -554,21 +559,9 @@ QString AbstractView::contextHelpId() const
{
QString helpId;
if (hasSelectedModelNodes()) {
QString className = firstSelectedModelNode().simplifiedTypeName();
helpId = QStringLiteral("QML.") + className;
if (Core::HelpManager::linksForIdentifier(helpId).isEmpty() && firstSelectedModelNode().metaInfo().isValid()) {
foreach (className, firstSelectedModelNode().metaInfo().superClassNames()) {
helpId = QStringLiteral("QML.") + className;
if (Core::HelpManager::linksForIdentifier(helpId).isEmpty())
helpId = QString();
else
break;
}
}
}
#ifndef QMLDESIGNER_TEST
helpId = QmlDesignerPlugin::instance()->viewManager().qmlJSEditorHelpId();
#endif
return helpId;
}

View File

@@ -411,6 +411,11 @@ void ViewManager::toggleStatesViewExpanded()
d->statesEditorView.toggleStatesViewExpanded();
}
QString ViewManager::qmlJSEditorHelpId() const
{
return d->textEditorView.qmlJSEditorHelpId();
}
Model *ViewManager::currentModel() const
{
return currentDesignDocument()->currentModel();