forked from qt-creator/qt-creator
QmlDesigner: Register AssetsLibraryContext more directly
... in the constructor of the relevant AssetsLibraryWidget. This simplifies the code and ensure the context gets set in all paths creating such an object. One was missing. Change-Id: I00daf9ef9f932a35bdc8b2b258c471a655b97fbf Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
#include "assetslibraryview.h"
|
||||
|
||||
#include "assetslibrarywidget.h"
|
||||
#include "designmodecontext.h"
|
||||
#include "qmldesignerplugin.h"
|
||||
|
||||
#include <asynchronousimagecache.h>
|
||||
@@ -62,9 +61,6 @@ WidgetInfo AssetsLibraryView::widgetInfo()
|
||||
m_widget = new AssetsLibraryWidget{imageCacheData()->asynchronousFontImageCache,
|
||||
imageCacheData()->synchronousFontImageCache,
|
||||
this};
|
||||
|
||||
auto context = new Internal::AssetsLibraryContext(m_widget.data());
|
||||
Core::ICore::addContextObject(context);
|
||||
}
|
||||
|
||||
return createWidgetInfo(m_widget.data(), "Assets", WidgetInfo::LeftPane, 0, tr("Assets"));
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
#include <QToolButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
static QString propertyEditorResourcesPath()
|
||||
@@ -158,6 +160,10 @@ AssetsLibraryWidget::AssetsLibraryWidget(AsynchronousImageCache &asynchronousFon
|
||||
reloadQmlSource();
|
||||
|
||||
setFocusProxy(m_assetsWidget->quickWidget());
|
||||
|
||||
IContext::attach(this,
|
||||
Context(Constants::C_QMLASSETSLIBRARY, Constants::C_QT_QUICK_TOOLS_MENU),
|
||||
[this](const IContext::HelpCallback &callback) { contextHelp(callback); });
|
||||
}
|
||||
|
||||
void AssetsLibraryWidget::contextHelp(const Core::IContext::HelpCallback &callback) const
|
||||
|
||||
@@ -53,16 +53,6 @@ MaterialBrowserContext::MaterialBrowserContext(QWidget *widget)
|
||||
});
|
||||
}
|
||||
|
||||
AssetsLibraryContext::AssetsLibraryContext(QWidget *widget)
|
||||
: IContext(widget)
|
||||
{
|
||||
setWidget(widget);
|
||||
setContext(Core::Context(Constants::C_QMLASSETSLIBRARY, Constants::C_QT_QUICK_TOOLS_MENU));
|
||||
setContextHelpProvider([this](const HelpCallback &callback) {
|
||||
qobject_cast<AssetsLibraryWidget *>(m_widget)->contextHelp(callback);
|
||||
});
|
||||
}
|
||||
|
||||
NavigatorContext::NavigatorContext(QWidget *widget)
|
||||
: IContext(widget)
|
||||
{
|
||||
|
||||
@@ -43,14 +43,6 @@ public:
|
||||
MaterialBrowserContext(QWidget *widget);
|
||||
};
|
||||
|
||||
class AssetsLibraryContext : public Core::IContext
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AssetsLibraryContext(QWidget *widget);
|
||||
};
|
||||
|
||||
class NavigatorContext : public Core::IContext
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Reference in New Issue
Block a user