forked from qt-creator/qt-creator
Core: Introduce a IContext::attach() version taking a help provider
... and use it to dissolve the DesignerContext as example. Change-Id: I0b67989050390fd9017203ec48068c144e0b8ac9 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -41,6 +41,15 @@ void IContext::attach(QWidget *widget, const Context &context, const HelpItem &h
|
|||||||
ICore::addContextObject(icontext);
|
ICore::addContextObject(icontext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IContext::attach(QWidget *widget, const Context &context, const HelpProvider &helpProvider)
|
||||||
|
{
|
||||||
|
auto icontext = new IContext(widget); // As QObject parent.
|
||||||
|
icontext->setContext(context);
|
||||||
|
icontext->setWidget(widget);
|
||||||
|
icontext->setContextHelpProvider(helpProvider);
|
||||||
|
ICore::addContextObject(icontext);
|
||||||
|
}
|
||||||
|
|
||||||
QDebug operator<<(QDebug debug, const Core::Context &context)
|
QDebug operator<<(QDebug debug, const Core::Context &context)
|
||||||
{
|
{
|
||||||
debug.nospace() << "Context(";
|
debug.nospace() << "Context(";
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ public:
|
|||||||
static void attach(QWidget *widget,
|
static void attach(QWidget *widget,
|
||||||
const Context &context,
|
const Context &context,
|
||||||
const HelpItem &contextHelp = {});
|
const HelpItem &contextHelp = {});
|
||||||
|
static void attach(QWidget *widget,
|
||||||
|
const Context &context,
|
||||||
|
const HelpProvider &helpProvider);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Context m_context;
|
Context m_context;
|
||||||
|
|||||||
@@ -92,21 +92,6 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace Designer::Internal {
|
namespace Designer::Internal {
|
||||||
|
|
||||||
class DesignerContext final : public IContext
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DesignerContext(const Context &context, QWidget *widget, QObject *parent)
|
|
||||||
: IContext(parent)
|
|
||||||
{
|
|
||||||
setContext(context);
|
|
||||||
setWidget(widget);
|
|
||||||
setContextHelpProvider([](const HelpCallback &callback) {
|
|
||||||
const QDesignerFormEditorInterface *core = designerEditor();
|
|
||||||
callback(core->integration()->contextHelpId());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* A stub-like, read-only text editor which displays UI files as text. Could be used as a
|
/* A stub-like, read-only text editor which displays UI files as text. Could be used as a
|
||||||
* read/write editor too, but due to lack of XML editor, highlighting and other such
|
* read/write editor too, but due to lack of XML editor, highlighting and other such
|
||||||
* functionality, editing is disabled.
|
* functionality, editing is disabled.
|
||||||
@@ -443,7 +428,11 @@ void FormEditorData::fullInit()
|
|||||||
|
|
||||||
Context designerContexts = m_contexts;
|
Context designerContexts = m_contexts;
|
||||||
designerContexts.add(Core::Constants::C_EDITORMANAGER);
|
designerContexts.add(Core::Constants::C_EDITORMANAGER);
|
||||||
ICore::addContextObject(new DesignerContext(designerContexts, m_modeWidget, this));
|
|
||||||
|
IContext::attach(m_modeWidget, designerContexts, [](const IContext::HelpCallback &callback) {
|
||||||
|
const QDesignerFormEditorInterface *core = designerEditor();
|
||||||
|
callback(core->integration()->contextHelpId());
|
||||||
|
});
|
||||||
|
|
||||||
DesignMode::registerDesignWidget(m_modeWidget,
|
DesignMode::registerDesignWidget(m_modeWidget,
|
||||||
QStringList(Utils::Constants::FORM_MIMETYPE),
|
QStringList(Utils::Constants::FORM_MIMETYPE),
|
||||||
|
|||||||
Reference in New Issue
Block a user