forked from qt-creator/qt-creator
Core: Return context help id by callback
...to support asynchronous providers. Change-Id: I483489c74e7886d5bc2bf00b65540c3d2c7afee0 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -61,7 +61,7 @@ namespace Internal {
|
|||||||
// CMakeEditor
|
// CMakeEditor
|
||||||
//
|
//
|
||||||
|
|
||||||
QString CMakeEditor::contextHelpId() const
|
void CMakeEditor::contextHelpId(const HelpIdCallback &callback) const
|
||||||
{
|
{
|
||||||
int pos = position();
|
int pos = position();
|
||||||
|
|
||||||
@@ -71,8 +71,10 @@ QString CMakeEditor::contextHelpId() const
|
|||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
break;
|
break;
|
||||||
chr = characterAt(pos);
|
chr = characterAt(pos);
|
||||||
if (chr == QLatin1Char('('))
|
if (chr == QLatin1Char('(')) {
|
||||||
return QString();
|
callback(QString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
} while (chr.unicode() != QChar::ParagraphSeparator);
|
} while (chr.unicode() != QChar::ParagraphSeparator);
|
||||||
|
|
||||||
++pos;
|
++pos;
|
||||||
@@ -95,11 +97,13 @@ QString CMakeEditor::contextHelpId() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Not a command
|
// Not a command
|
||||||
if (chr != QLatin1Char('('))
|
if (chr != QLatin1Char('(')) {
|
||||||
return QString();
|
callback(QString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QString command = textAt(begin, end - begin).toLower();
|
QString command = textAt(begin, end - begin).toLower();
|
||||||
return QLatin1String("command/") + command;
|
callback(QLatin1String("command/") + command);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@@ -38,7 +38,7 @@ class CMakeEditor : public TextEditor::BaseTextEditor
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString contextHelpId() const override;
|
void contextHelpId(const HelpIdCallback &callback) const override;
|
||||||
|
|
||||||
friend class CMakeEditorWidget;
|
friend class CMakeEditorWidget;
|
||||||
};
|
};
|
||||||
|
@@ -33,6 +33,8 @@
|
|||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class CORE_EXPORT Context
|
class CORE_EXPORT Context
|
||||||
@@ -71,7 +73,8 @@ public:
|
|||||||
|
|
||||||
virtual Context context() const { return m_context; }
|
virtual Context context() const { return m_context; }
|
||||||
virtual QWidget *widget() const { return m_widget; }
|
virtual QWidget *widget() const { return m_widget; }
|
||||||
virtual QString contextHelpId() const { return m_contextHelpId; }
|
using HelpIdCallback = std::function<void(const QString &id)>;
|
||||||
|
virtual void contextHelpId(const HelpIdCallback &callback) const { callback(m_contextHelpId); }
|
||||||
|
|
||||||
virtual void setContext(const Context &context) { m_context = context; }
|
virtual void setContext(const Context &context) { m_context = context; }
|
||||||
virtual void setWidget(QWidget *widget) { m_widget = widget; }
|
virtual void setWidget(QWidget *widget) { m_widget = widget; }
|
||||||
|
@@ -45,10 +45,10 @@ DesignerContext::DesignerContext(const Core::Context &context,
|
|||||||
setWidget(widget);
|
setWidget(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DesignerContext::contextHelpId() const
|
void DesignerContext::contextHelpId(const HelpIdCallback &callback) const
|
||||||
{
|
{
|
||||||
const QDesignerFormEditorInterface *core = FormEditorW::designerEditor();
|
const QDesignerFormEditorInterface *core = FormEditorW::designerEditor();
|
||||||
return core->integration()->contextHelpId();
|
callback(core->integration()->contextHelpId());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -37,7 +37,7 @@ public:
|
|||||||
QWidget *widget,
|
QWidget *widget,
|
||||||
QObject *parent = nullptr);
|
QObject *parent = nullptr);
|
||||||
|
|
||||||
QString contextHelpId() const override;
|
void contextHelpId(const HelpIdCallback &callback) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -194,7 +194,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
|||||||
Context(kToolTipHelpContext, Core::Constants::C_GLOBAL));
|
Context(kToolTipHelpContext, Core::Constants::C_GLOBAL));
|
||||||
ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F1));
|
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F1));
|
||||||
connect(action, &QAction::triggered, this, &HelpPlugin::showContextHelp);
|
connect(action, &QAction::triggered, this, &HelpPlugin::requestContextHelp);
|
||||||
|
|
||||||
action = new QAction(tr("Technical Support"), this);
|
action = new QAction(tr("Technical Support"), this);
|
||||||
cmd = ActionManager::registerAction(action, "Help.TechSupport");
|
cmd = ActionManager::registerAction(action, "Help.TechSupport");
|
||||||
@@ -573,14 +573,19 @@ static QUrl findBestLink(const QMap<QString, QUrl> &links, QString *highlightId)
|
|||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpPlugin::showContextHelp()
|
void HelpPlugin::requestContextHelp()
|
||||||
{
|
{
|
||||||
// Find out what to show
|
// Find out what to show
|
||||||
QString contextHelpId = Utils::ToolTip::contextHelpId();
|
QString contextHelpId = Utils::ToolTip::contextHelpId();
|
||||||
IContext *context = ICore::currentContextObject();
|
IContext *context = ICore::currentContextObject();
|
||||||
if (contextHelpId.isEmpty() && context)
|
if (contextHelpId.isEmpty() && context)
|
||||||
contextHelpId = context->contextHelpId();
|
context->contextHelpId([this](const QString &id) { showContextHelp(id); });
|
||||||
|
else
|
||||||
|
showContextHelp(contextHelpId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpPlugin::showContextHelp(const QString &contextHelpId)
|
||||||
|
{
|
||||||
// get the viewer after getting the help id,
|
// get the viewer after getting the help id,
|
||||||
// because a new window might be opened and therefore focus be moved
|
// because a new window might be opened and therefore focus be moved
|
||||||
HelpViewer *viewer = viewerForContextHelp();
|
HelpViewer *viewer = viewerForContextHelp();
|
||||||
|
@@ -76,7 +76,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
void modeChanged(Core::Id mode, Core::Id old);
|
void modeChanged(Core::Id mode, Core::Id old);
|
||||||
|
|
||||||
void showContextHelp();
|
void requestContextHelp();
|
||||||
|
void showContextHelp(const QString &contextHelpId);
|
||||||
void activateIndex();
|
void activateIndex();
|
||||||
void activateContents();
|
void activateContents();
|
||||||
|
|
||||||
|
@@ -334,12 +334,12 @@ double FormEditorWidget::containerPadding() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString FormEditorWidget::contextHelpId() const
|
void FormEditorWidget::contextHelpId(const Core::IContext::HelpIdCallback &callback) const
|
||||||
{
|
{
|
||||||
if (m_formEditorView)
|
if (m_formEditorView)
|
||||||
return m_formEditorView->contextHelpId();
|
m_formEditorView->contextHelpId(callback);
|
||||||
|
else
|
||||||
return QString();
|
callback(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormEditorWidget::setRootItemRect(const QRectF &rect)
|
void FormEditorWidget::setRootItemRect(const QRectF &rect)
|
||||||
|
@@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#include <documentwarningwidget.h>
|
#include <documentwarningwidget.h>
|
||||||
|
|
||||||
|
#include <coreplugin/icontext.h>
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
@@ -62,7 +64,7 @@ public:
|
|||||||
double spacing() const;
|
double spacing() const;
|
||||||
double containerPadding() const;
|
double containerPadding() const;
|
||||||
|
|
||||||
QString contextHelpId() const;
|
void contextHelpId(const Core::IContext::HelpIdCallback &callback) const;
|
||||||
|
|
||||||
void setRootItemRect(const QRectF &rect);
|
void setRootItemRect(const QRectF &rect);
|
||||||
QRectF rootItemRect() const;
|
QRectF rootItemRect() const;
|
||||||
|
@@ -651,12 +651,12 @@ void DesignDocument::updateCurrentProject()
|
|||||||
viewManager().setNodeInstanceViewProject(currentProject);
|
viewManager().setNodeInstanceViewProject(currentProject);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DesignDocument::contextHelpId() const
|
void DesignDocument::contextHelpId(const Core::IContext::HelpIdCallback &callback) const
|
||||||
{
|
{
|
||||||
if (view())
|
if (view())
|
||||||
return view()->contextHelpId();
|
view()->contextHelpId(callback);
|
||||||
|
else
|
||||||
return QString();
|
callback(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -31,6 +31,8 @@
|
|||||||
#include <componenttextmodifier.h>
|
#include <componenttextmodifier.h>
|
||||||
#include <subcomponentmanager.h>
|
#include <subcomponentmanager.h>
|
||||||
|
|
||||||
|
#include <coreplugin/icontext.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
@@ -75,7 +77,7 @@ public:
|
|||||||
Model *currentModel() const;
|
Model *currentModel() const;
|
||||||
Model *documentModel() const;
|
Model *documentModel() const;
|
||||||
|
|
||||||
QString contextHelpId() const;
|
void contextHelpId(const Core::IContext::HelpIdCallback &callback) const;
|
||||||
QList<DocumentMessage> qmlParseWarnings() const;
|
QList<DocumentMessage> qmlParseWarnings() const;
|
||||||
bool hasQmlParseWarnings() const;
|
bool hasQmlParseWarnings() const;
|
||||||
QList<DocumentMessage> qmlParseErrors() const;
|
QList<DocumentMessage> qmlParseErrors() const;
|
||||||
|
@@ -130,12 +130,12 @@ QList<QToolButton *> NavigatorWidget::createToolBarWidgets()
|
|||||||
return buttons;
|
return buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NavigatorWidget::contextHelpId() const
|
void NavigatorWidget::contextHelpId(const Core::IContext::HelpIdCallback &callback) const
|
||||||
{
|
{
|
||||||
if (navigatorView())
|
if (navigatorView())
|
||||||
return navigatorView()->contextHelpId();
|
navigatorView()->contextHelpId(callback);
|
||||||
|
else
|
||||||
return QString();
|
callback(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigatorView *NavigatorWidget::navigatorView() const
|
NavigatorView *NavigatorWidget::navigatorView() const
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <coreplugin/icontext.h>
|
||||||
|
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
@@ -46,7 +48,7 @@ public:
|
|||||||
void setTreeModel(QAbstractItemModel *model);
|
void setTreeModel(QAbstractItemModel *model);
|
||||||
QTreeView *treeView() const;
|
QTreeView *treeView() const;
|
||||||
QList<QToolButton *> createToolBarWidgets();
|
QList<QToolButton *> createToolBarWidgets();
|
||||||
QString contextHelpId() const;
|
void contextHelpId(const Core::IContext::HelpIdCallback &callback) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void leftButtonClicked();
|
void leftButtonClicked();
|
||||||
|
@@ -150,19 +150,17 @@ WidgetInfo TextEditorView::widgetInfo()
|
|||||||
return createWidgetInfo(m_widget.get(), 0, "TextEditor", WidgetInfo::CentralPane, 0, tr("Text Editor"), DesignerWidgetFlags::IgnoreErrors);
|
return createWidgetInfo(m_widget.get(), 0, "TextEditor", WidgetInfo::CentralPane, 0, tr("Text Editor"), DesignerWidgetFlags::IgnoreErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TextEditorView::contextHelpId() const
|
void TextEditorView::contextHelpId(const Core::IContext::HelpIdCallback &callback) const
|
||||||
{
|
{
|
||||||
return AbstractView::contextHelpId();
|
AbstractView::contextHelpId(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TextEditorView::qmlJSEditorHelpId() const
|
void TextEditorView::qmlJSEditorHelpId(const Core::IContext::HelpIdCallback &callback) const
|
||||||
{
|
{
|
||||||
if (m_widget->textEditor()) {
|
if (m_widget->textEditor())
|
||||||
QString contextHelpId = m_widget->textEditor()->contextHelpId();
|
m_widget->textEditor()->contextHelpId(callback);
|
||||||
if (!contextHelpId.isEmpty())
|
else
|
||||||
return m_widget->textEditor()->contextHelpId();
|
callback(QString());
|
||||||
}
|
|
||||||
return QString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorView::nodeIdChanged(const ModelNode& /*node*/, const QString &/*newId*/, const QString &/*oldId*/)
|
void TextEditorView::nodeIdChanged(const ModelNode& /*node*/, const QString &/*newId*/, const QString &/*oldId*/)
|
||||||
|
@@ -24,6 +24,8 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <coreplugin/icontext.h>
|
||||||
|
|
||||||
#include <abstractview.h>
|
#include <abstractview.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -67,9 +69,9 @@ public:
|
|||||||
|
|
||||||
// TextEditorView
|
// TextEditorView
|
||||||
WidgetInfo widgetInfo() override;
|
WidgetInfo widgetInfo() override;
|
||||||
QString contextHelpId() const override;
|
void contextHelpId(const Core::IContext::HelpIdCallback &callback) const override;
|
||||||
|
|
||||||
QString qmlJSEditorHelpId() const;
|
void qmlJSEditorHelpId(const Core::IContext::HelpIdCallback &callback) const;
|
||||||
|
|
||||||
TextEditor::BaseTextEditor *textEditor();
|
TextEditor::BaseTextEditor *textEditor();
|
||||||
|
|
||||||
|
@@ -94,9 +94,9 @@ void TextEditorWidget::setTextEditor(TextEditor::BaseTextEditor *textEditor)
|
|||||||
oldEditor->deleteLater();
|
oldEditor->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TextEditorWidget::contextHelpId() const
|
void TextEditorWidget::contextHelpId(const Core::IContext::HelpIdCallback &callback) const
|
||||||
{
|
{
|
||||||
return m_textEditorView->contextHelpId();
|
m_textEditorView->contextHelpId(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorWidget::updateSelectionByCursorPosition()
|
void TextEditorWidget::updateSelectionByCursorPosition()
|
||||||
|
@@ -50,7 +50,7 @@ public:
|
|||||||
return m_textEditor.get();
|
return m_textEditor.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString contextHelpId() const;
|
void contextHelpId(const Core::IContext::HelpIdCallback &callback) const;
|
||||||
void jumpTextCursorToSelectedModelNode();
|
void jumpTextCursorToSelectedModelNode();
|
||||||
void gotoCursorPosition(int line, int column);
|
void gotoCursorPosition(int line, int column);
|
||||||
|
|
||||||
|
@@ -34,6 +34,8 @@
|
|||||||
#include <rewritertransaction.h>
|
#include <rewritertransaction.h>
|
||||||
#include <commondefines.h>
|
#include <commondefines.h>
|
||||||
|
|
||||||
|
#include <coreplugin/icontext.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
@@ -255,7 +257,7 @@ public:
|
|||||||
virtual bool hasWidget() const;
|
virtual bool hasWidget() const;
|
||||||
virtual WidgetInfo widgetInfo();
|
virtual WidgetInfo widgetInfo();
|
||||||
|
|
||||||
virtual QString contextHelpId() const;
|
virtual void contextHelpId(const Core::IContext::HelpIdCallback &callback) const;
|
||||||
|
|
||||||
void activateTimelineRecording(const ModelNode &mutator);
|
void activateTimelineRecording(const ModelNode &mutator);
|
||||||
void deactivateTimelineRecording();
|
void deactivateTimelineRecording();
|
||||||
|
@@ -95,7 +95,7 @@ public:
|
|||||||
|
|
||||||
void toggleStatesViewExpanded();
|
void toggleStatesViewExpanded();
|
||||||
|
|
||||||
QString qmlJSEditorHelpId() const;
|
void qmlJSEditorHelpId(const Core::IContext::HelpIdCallback &callback) const;
|
||||||
DesignDocument *currentDesignDocument() const;
|
DesignDocument *currentDesignDocument() const;
|
||||||
|
|
||||||
private: // functions
|
private: // functions
|
||||||
|
@@ -561,14 +561,13 @@ WidgetInfo AbstractView::widgetInfo()
|
|||||||
return createWidgetInfo();
|
return createWidgetInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AbstractView::contextHelpId() const
|
void AbstractView::contextHelpId(const Core::IContext::HelpIdCallback &callback) const
|
||||||
{
|
{
|
||||||
QString helpId;
|
|
||||||
|
|
||||||
#ifndef QMLDESIGNER_TEST
|
#ifndef QMLDESIGNER_TEST
|
||||||
helpId = QmlDesignerPlugin::instance()->viewManager().qmlJSEditorHelpId();
|
QmlDesignerPlugin::instance()->viewManager().qmlJSEditorHelpId(callback);
|
||||||
|
#else
|
||||||
|
callback(QString());
|
||||||
#endif
|
#endif
|
||||||
return helpId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractView::activateTimelineRecording(const ModelNode &mutator)
|
void AbstractView::activateTimelineRecording(const ModelNode &mutator)
|
||||||
|
@@ -411,9 +411,9 @@ void ViewManager::toggleStatesViewExpanded()
|
|||||||
d->statesEditorView.toggleStatesViewExpanded();
|
d->statesEditorView.toggleStatesViewExpanded();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ViewManager::qmlJSEditorHelpId() const
|
void ViewManager::qmlJSEditorHelpId(const Core::IContext::HelpIdCallback &callback) const
|
||||||
{
|
{
|
||||||
return d->textEditorView.qmlJSEditorHelpId();
|
d->textEditorView.qmlJSEditorHelpId(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
Model *ViewManager::currentModel() const
|
Model *ViewManager::currentModel() const
|
||||||
|
@@ -40,9 +40,9 @@ DesignModeContext::DesignModeContext(QWidget *widget)
|
|||||||
setContext(Core::Context(Constants::C_QMLDESIGNER, Constants::C_QT_QUICK_TOOLS_MENU));
|
setContext(Core::Context(Constants::C_QMLDESIGNER, Constants::C_QT_QUICK_TOOLS_MENU));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DesignModeContext::contextHelpId() const
|
void DesignModeContext::contextHelpId(const HelpIdCallback &callback) const
|
||||||
{
|
{
|
||||||
return qobject_cast<DesignModeWidget *>(m_widget)->contextHelpId();
|
qobject_cast<DesignModeWidget *>(m_widget)->contextHelpId(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
FormEditorContext::FormEditorContext(QWidget *widget)
|
FormEditorContext::FormEditorContext(QWidget *widget)
|
||||||
@@ -52,9 +52,9 @@ FormEditorContext::FormEditorContext(QWidget *widget)
|
|||||||
setContext(Core::Context(Constants::C_QMLFORMEDITOR, Constants::C_QT_QUICK_TOOLS_MENU));
|
setContext(Core::Context(Constants::C_QMLFORMEDITOR, Constants::C_QT_QUICK_TOOLS_MENU));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FormEditorContext::contextHelpId() const
|
void FormEditorContext::contextHelpId(const HelpIdCallback &callback) const
|
||||||
{
|
{
|
||||||
return qobject_cast<FormEditorWidget *>(m_widget)->contextHelpId();
|
qobject_cast<FormEditorWidget *>(m_widget)->contextHelpId(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigatorContext::NavigatorContext(QWidget *widget)
|
NavigatorContext::NavigatorContext(QWidget *widget)
|
||||||
@@ -64,9 +64,9 @@ NavigatorContext::NavigatorContext(QWidget *widget)
|
|||||||
setContext(Core::Context(Constants::C_QMLNAVIGATOR, Constants::C_QT_QUICK_TOOLS_MENU));
|
setContext(Core::Context(Constants::C_QMLNAVIGATOR, Constants::C_QT_QUICK_TOOLS_MENU));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NavigatorContext::contextHelpId() const
|
void NavigatorContext::contextHelpId(const HelpIdCallback &callback) const
|
||||||
{
|
{
|
||||||
return qobject_cast<NavigatorWidget *>(m_widget)->contextHelpId();
|
qobject_cast<NavigatorWidget *>(m_widget)->contextHelpId(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEditorContext::TextEditorContext(QWidget *widget)
|
TextEditorContext::TextEditorContext(QWidget *widget)
|
||||||
@@ -76,9 +76,9 @@ TextEditorContext::TextEditorContext(QWidget *widget)
|
|||||||
setContext(Core::Context(Constants::C_QMLTEXTEDITOR, Constants::C_QT_QUICK_TOOLS_MENU));
|
setContext(Core::Context(Constants::C_QMLTEXTEDITOR, Constants::C_QT_QUICK_TOOLS_MENU));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TextEditorContext::contextHelpId() const
|
void TextEditorContext::contextHelpId(const HelpIdCallback &callback) const
|
||||||
{
|
{
|
||||||
return qobject_cast<TextEditorWidget *>(m_widget)->contextHelpId();
|
qobject_cast<TextEditorWidget *>(m_widget)->contextHelpId(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -39,7 +39,7 @@ class DesignModeContext : public Core::IContext
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
DesignModeContext(QWidget *widget);
|
DesignModeContext(QWidget *widget);
|
||||||
QString contextHelpId() const;
|
void contextHelpId(const Core::IContext::HelpIdCallback &callback) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FormEditorContext : public Core::IContext
|
class FormEditorContext : public Core::IContext
|
||||||
@@ -48,7 +48,7 @@ class FormEditorContext : public Core::IContext
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
FormEditorContext(QWidget *widget);
|
FormEditorContext(QWidget *widget);
|
||||||
QString contextHelpId() const;
|
void contextHelpId(const Core::IContext::HelpIdCallback &callback) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NavigatorContext : public Core::IContext
|
class NavigatorContext : public Core::IContext
|
||||||
@@ -57,7 +57,7 @@ class NavigatorContext : public Core::IContext
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
NavigatorContext(QWidget *widget);
|
NavigatorContext(QWidget *widget);
|
||||||
QString contextHelpId() const;
|
void contextHelpId(const Core::IContext::HelpIdCallback &callback) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextEditorContext : public Core::IContext
|
class TextEditorContext : public Core::IContext
|
||||||
@@ -66,7 +66,7 @@ class TextEditorContext : public Core::IContext
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
TextEditorContext(QWidget *widget);
|
TextEditorContext(QWidget *widget);
|
||||||
QString contextHelpId() const;
|
void contextHelpId(const Core::IContext::HelpIdCallback &callback) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -531,11 +531,12 @@ void DesignModeWidget::showInternalTextEditor()
|
|||||||
m_centralTabWidget->switchTo(viewManager().widget("TextEditor"));
|
m_centralTabWidget->switchTo(viewManager().widget("TextEditor"));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DesignModeWidget::contextHelpId() const
|
void DesignModeWidget::contextHelpId(const Core::IContext::HelpIdCallback &callback) const
|
||||||
{
|
{
|
||||||
if (currentDesignDocument())
|
if (currentDesignDocument())
|
||||||
return currentDesignDocument()->contextHelpId();
|
currentDesignDocument()->contextHelpId(callback);
|
||||||
return QString();
|
else
|
||||||
|
callback(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesignModeWidget::initialize()
|
void DesignModeWidget::initialize()
|
||||||
|
@@ -62,7 +62,7 @@ public:
|
|||||||
explicit DesignModeWidget(QWidget *parent = 0);
|
explicit DesignModeWidget(QWidget *parent = 0);
|
||||||
|
|
||||||
~DesignModeWidget();
|
~DesignModeWidget();
|
||||||
QString contextHelpId() const;
|
void contextHelpId(const Core::IContext::HelpIdCallback &callback) const;
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
||||||
|
@@ -7913,9 +7913,9 @@ void TextEditorWidgetPrivate::updateCursorPosition()
|
|||||||
q->ensureCursorVisible();
|
q->ensureCursorVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BaseTextEditor::contextHelpId() const
|
void BaseTextEditor::contextHelpId(const HelpIdCallback &callback) const
|
||||||
{
|
{
|
||||||
return editorWidget()->contextHelpId();
|
editorWidget()->contextHelpId(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextEditor::setContextHelpId(const QString &id)
|
void BaseTextEditor::setContextHelpId(const QString &id)
|
||||||
@@ -7924,11 +7924,11 @@ void BaseTextEditor::setContextHelpId(const QString &id)
|
|||||||
editorWidget()->setContextHelpId(id);
|
editorWidget()->setContextHelpId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TextEditorWidget::contextHelpId()
|
void TextEditorWidget::contextHelpId(const IContext::HelpIdCallback &callback)
|
||||||
{
|
{
|
||||||
if (d->m_contextHelpId.isEmpty() && !d->m_hoverHandlers.isEmpty())
|
if (d->m_contextHelpId.isEmpty() && !d->m_hoverHandlers.isEmpty())
|
||||||
d->m_contextHelpId = d->m_hoverHandlers.first()->contextHelpId(this, textCursor().position());
|
d->m_contextHelpId = d->m_hoverHandlers.first()->contextHelpId(this, textCursor().position());
|
||||||
return d->m_contextHelpId;
|
callback(d->m_contextHelpId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorWidget::setContextHelpId(const QString &id)
|
void TextEditorWidget::setContextHelpId(const QString &id)
|
||||||
|
@@ -129,7 +129,7 @@ public:
|
|||||||
bool restoreState(const QByteArray &state) override;
|
bool restoreState(const QByteArray &state) override;
|
||||||
QWidget *toolBar() override;
|
QWidget *toolBar() override;
|
||||||
|
|
||||||
QString contextHelpId() const override; // from IContext
|
void contextHelpId(const HelpIdCallback &callback) const override; // from IContext
|
||||||
void setContextHelpId(const QString &id) override;
|
void setContextHelpId(const QString &id) override;
|
||||||
|
|
||||||
int currentLine() const override;
|
int currentLine() const override;
|
||||||
@@ -533,7 +533,7 @@ public:
|
|||||||
QChar characterAt(int pos) const;
|
QChar characterAt(int pos) const;
|
||||||
QString textAt(int from, int to) const;
|
QString textAt(int from, int to) const;
|
||||||
|
|
||||||
QString contextHelpId();
|
void contextHelpId(const Core::IContext::HelpIdCallback &callback);
|
||||||
void setContextHelpId(const QString &id);
|
void setContextHelpId(const QString &id);
|
||||||
|
|
||||||
static TextEditorWidget *currentTextEditorWidget();
|
static TextEditorWidget *currentTextEditorWidget();
|
||||||
|
Reference in New Issue
Block a user