forked from qt-creator/qt-creator
QmlDesigner: break dependency to Core::IContext
Move the dependency from the abstract view into the plugin class. The abstract view is now only returning the id. Change-Id: I4f508c907bcdc8f717817fd40ef9c933e5fe2211 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -228,8 +228,8 @@ void Edit3DWidget::onCreateAction()
|
||||
void Edit3DWidget::contextHelp(const Core::IContext::HelpCallback &callback) const
|
||||
{
|
||||
if (m_view)
|
||||
m_view->contextHelp(callback);
|
||||
|
||||
QmlDesignerPlugin::contextHelp(callback, m_view->contextHelpId());
|
||||
else
|
||||
callback({});
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include <abstractview.h>
|
||||
|
||||
#include <QPicture>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
@@ -480,7 +480,7 @@ double FormEditorWidget::containerPadding() const
|
||||
void FormEditorWidget::contextHelp(const Core::IContext::HelpCallback &callback) const
|
||||
{
|
||||
if (m_formEditorView)
|
||||
m_formEditorView->contextHelp(callback);
|
||||
QmlDesignerPlugin::contextHelp(callback, m_formEditorView->contextHelpId());
|
||||
else
|
||||
callback({});
|
||||
}
|
||||
|
||||
@@ -777,8 +777,8 @@ void DesignDocument::updateActiveTarget()
|
||||
|
||||
void DesignDocument::contextHelp(const Core::IContext::HelpCallback &callback) const
|
||||
{
|
||||
if (view())
|
||||
view()->contextHelp(callback);
|
||||
if (auto v = view())
|
||||
QmlDesignerPlugin::contextHelp(callback, v->contextHelpId());
|
||||
else
|
||||
callback({});
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ class AbstractView;
|
||||
class QMLDESIGNERCORE_EXPORT DesignDocument: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DesignDocument(ProjectStorage<Sqlite::Database> &projectStorage);
|
||||
~DesignDocument() override;
|
||||
|
||||
@@ -187,7 +187,7 @@ QList<QToolButton *> MaterialBrowserWidget::createToolBarWidgets()
|
||||
void MaterialBrowserWidget::contextHelp(const Core::IContext::HelpCallback &callback) const
|
||||
{
|
||||
if (m_materialBrowserView)
|
||||
m_materialBrowserView->contextHelp(callback);
|
||||
QmlDesignerPlugin::contextHelp(callback, m_materialBrowserView->contextHelpId());
|
||||
else
|
||||
callback({});
|
||||
}
|
||||
|
||||
@@ -150,8 +150,8 @@ QToolBar *NavigatorWidget::createToolBar()
|
||||
|
||||
void NavigatorWidget::contextHelp(const Core::IContext::HelpCallback &callback) const
|
||||
{
|
||||
if (navigatorView())
|
||||
navigatorView()->contextHelp(callback);
|
||||
if (auto view = navigatorView())
|
||||
QmlDesignerPlugin::contextHelp(callback, view->contextHelpId());
|
||||
else
|
||||
callback({});
|
||||
}
|
||||
|
||||
@@ -127,11 +127,6 @@ WidgetInfo TextEditorView::widgetInfo()
|
||||
return createWidgetInfo(m_widget, "TextEditor", WidgetInfo::CentralPane, 0, tr("Code"), DesignerWidgetFlags::IgnoreErrors);
|
||||
}
|
||||
|
||||
void TextEditorView::contextHelp(const Core::IContext::HelpCallback &callback) const
|
||||
{
|
||||
AbstractView::contextHelp(callback);
|
||||
}
|
||||
|
||||
void TextEditorView::qmlJSEditorContextHelp(const Core::IContext::HelpCallback &callback) const
|
||||
{
|
||||
if (m_widget->textEditor())
|
||||
|
||||
@@ -47,7 +47,6 @@ public:
|
||||
|
||||
// TextEditorView
|
||||
WidgetInfo widgetInfo() override;
|
||||
void contextHelp(const Core::IContext::HelpCallback &callback) const override;
|
||||
|
||||
void qmlJSEditorContextHelp(const Core::IContext::HelpCallback &callback) const;
|
||||
|
||||
|
||||
@@ -82,7 +82,10 @@ void TextEditorWidget::setTextEditor(TextEditor::BaseTextEditor *textEditor)
|
||||
|
||||
void TextEditorWidget::contextHelp(const Core::IContext::HelpCallback &callback) const
|
||||
{
|
||||
m_textEditorView->contextHelp(callback);
|
||||
if (m_textEditorView)
|
||||
QmlDesignerPlugin::contextHelp(callback, m_textEditorView->contextHelpId());
|
||||
else
|
||||
callback({});
|
||||
}
|
||||
|
||||
void TextEditorWidget::updateSelectionByCursorPosition()
|
||||
|
||||
@@ -455,8 +455,8 @@ void TimelineWidget::setTimelineRecording(bool value)
|
||||
|
||||
void TimelineWidget::contextHelp(const Core::IContext::HelpCallback &callback) const
|
||||
{
|
||||
if (timelineView())
|
||||
timelineView()->contextHelp(callback);
|
||||
if (auto view = timelineView())
|
||||
QmlDesignerPlugin::contextHelp(callback, view->contextHelpId());
|
||||
else
|
||||
callback({});
|
||||
}
|
||||
|
||||
@@ -312,8 +312,8 @@ void TransitionEditorWidget::selectionChanged()
|
||||
|
||||
void TransitionEditorWidget::contextHelp(const Core::IContext::HelpCallback &callback) const
|
||||
{
|
||||
if (transitionEditorView())
|
||||
transitionEditorView()->contextHelp(callback);
|
||||
if (auto view = transitionEditorView())
|
||||
QmlDesignerPlugin::contextHelp(callback, view->contextHelpId());
|
||||
else
|
||||
callback({});
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
#include <rewritertransaction.h>
|
||||
#include <commondefines.h>
|
||||
|
||||
#include <coreplugin/icontext.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <QVector3D>
|
||||
@@ -70,6 +68,7 @@ public:
|
||||
class QMLDESIGNERCORE_EXPORT AbstractView : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Q_FLAGS(PropertyChangeFlag PropertyChangeFlags)
|
||||
|
||||
@@ -249,7 +248,7 @@ public:
|
||||
virtual void disableWidget();
|
||||
virtual void enableWidget();
|
||||
|
||||
virtual void contextHelp(const Core::IContext::HelpCallback &callback) const;
|
||||
QString contextHelpId() const;
|
||||
|
||||
void setCurrentTimeline(const ModelNode &timeline);
|
||||
void activateTimelineRecording(const ModelNode &timeline);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <QElapsedTimer>
|
||||
#include <QHash>
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
#include <QPointer>
|
||||
#include <QRectF>
|
||||
#include <QTime>
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
|
||||
#include "abstractview.h"
|
||||
|
||||
#include <QWidgetAction>
|
||||
#include <coreplugin/icontext.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QWidgetAction>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class Target;
|
||||
}
|
||||
|
||||
@@ -587,21 +587,16 @@ void AbstractView::enableWidget()
|
||||
widgetInfo().widget->setEnabled(true);
|
||||
}
|
||||
|
||||
void AbstractView::contextHelp(const Core::IContext::HelpCallback &callback) const
|
||||
QString AbstractView::contextHelpId() const
|
||||
{
|
||||
#ifndef QMLDESIGNER_TEST
|
||||
QString id = const_cast<AbstractView *>(this)->widgetInfo().uniqueId;
|
||||
|
||||
const QString id = const_cast<AbstractView *>(this)->widgetInfo().uniqueId;
|
||||
if (!selectedModelNodes().isEmpty()) {
|
||||
const auto nodeId = selectedModelNodes().first().simplifiedTypeName();
|
||||
id += " " + nodeId;
|
||||
}
|
||||
|
||||
QString nodeId;
|
||||
if (!selectedModelNodes().isEmpty())
|
||||
nodeId = selectedModelNodes().first().simplifiedTypeName();
|
||||
QmlDesignerPlugin::instance()->emitUsageStatisticsHelpRequested(id + " " + nodeId);
|
||||
QmlDesignerPlugin::instance()->viewManager().qmlJSEditorContextHelp(callback);
|
||||
|
||||
#else
|
||||
callback(QString());
|
||||
#endif
|
||||
return id;
|
||||
}
|
||||
|
||||
void AbstractView::setCurrentTimeline(const ModelNode &timeline)
|
||||
|
||||
@@ -642,6 +642,12 @@ double QmlDesignerPlugin::formEditorDevicePixelRatio()
|
||||
return topLevelWindows.constFirst()->screen()->devicePixelRatio();
|
||||
}
|
||||
|
||||
void QmlDesignerPlugin::contextHelp(const Core::IContext::HelpCallback &callback, const QString &id)
|
||||
{
|
||||
emitUsageStatisticsHelpRequested(id);
|
||||
QmlDesignerPlugin::instance()->viewManager().qmlJSEditorContextHelp(callback);
|
||||
}
|
||||
|
||||
void QmlDesignerPlugin::emitUsageStatistics(const QString &identifier)
|
||||
{
|
||||
QTC_ASSERT(instance(), return);
|
||||
|
||||
@@ -65,6 +65,8 @@ public:
|
||||
|
||||
static double formEditorDevicePixelRatio();
|
||||
|
||||
static void contextHelp(const Core::IContext::HelpCallback &callback, const QString &id);
|
||||
|
||||
static void emitUsageStatistics(const QString &identifier);
|
||||
static void emitUsageStatisticsContextAction(const QString &identifier);
|
||||
static void emitUsageStatisticsHelpRequested(const QString &identifier);
|
||||
|
||||
Reference in New Issue
Block a user