Commit 8dfb05c8 authored by Marco Bubke's avatar Marco Bubke Committed by Tim Jenssen
Browse files

QmlDesigner: Use QQuickWidget in the item library



Change-Id: I8297b513722fb5fc51fedadfd5f93e3198800ada
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent eb5edae8
......@@ -62,7 +62,7 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
m_itemIconSize(24, 24),
m_resIconSize(24, 24),
m_iconProvider(m_resIconSize),
m_itemsView(new QQuickView()),
m_itemViewQuickWidget(new QQuickWidget),
m_resourcesView(new ItemLibraryTreeView(this)),
m_filterFlag(QtBasic)
{
......@@ -71,16 +71,16 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
setWindowTitle(tr("Library", "Title of library view"));
/* create Items view and its model */
m_itemsView->setResizeMode(QQuickView::SizeRootObjectToView);
m_itemViewQuickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
m_itemLibraryModel = new ItemLibraryModel(this);
QQmlContext *rootContext = m_itemsView->rootContext();
QQmlContext *rootContext = m_itemViewQuickWidget->rootContext();
rootContext->setContextProperty(QStringLiteral("itemLibraryModel"), m_itemLibraryModel.data());
rootContext->setContextProperty(QStringLiteral("itemLibraryIconWidth"), m_itemIconSize.width());
rootContext->setContextProperty(QStringLiteral("itemLibraryIconHeight"), m_itemIconSize.height());
rootContext->setContextProperty(QStringLiteral("rootView"), this);
m_itemsView->rootContext()->setContextProperty(QStringLiteral("highlightColor"), Utils::StyleHelper::notTooBrightHighlightColor());
m_itemViewQuickWidget->rootContext()->setContextProperty(QStringLiteral("highlightColor"), Utils::StyleHelper::notTooBrightHighlightColor());
/* create Resources view and its model */
m_resourcesFileSystemModel = new QFileSystemModel(this);
......@@ -89,7 +89,7 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
m_resourcesView->setIconSize(m_resIconSize);
/* create image provider for loading item icons */
m_itemsView->engine()->addImageProvider(QStringLiteral("qmldesigner_itemlibrary"), new Internal::ItemLibraryImageProvider);
m_itemViewQuickWidget->engine()->addImageProvider(QStringLiteral("qmldesigner_itemlibrary"), new Internal::ItemLibraryImageProvider);
/* other widgets */
QTabBar *tabBar = new QTabBar(this);
......@@ -118,9 +118,9 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
lineEditLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 2);
connect(m_filterLineEdit.data(), SIGNAL(filterChanged(QString)), this, SLOT(setSearchFilter(QString)));
QWidget *container = createWindowContainer(m_itemsView.data());
m_stackedWidget = new QStackedWidget(this);
m_stackedWidget->addWidget(container);
m_stackedWidget->addWidget(m_itemViewQuickWidget.data());
m_stackedWidget->addWidget(m_resourcesView.data());
QWidget *spacer = new QWidget(this);
......@@ -224,7 +224,7 @@ void ItemLibraryWidget::setSearchFilter(const QString &searchFilter)
{
if (m_stackedWidget->currentIndex() == 0) {
m_itemLibraryModel->setSearchText(searchFilter);
m_itemsView->update();
m_itemViewQuickWidget->update();
} else {
QStringList nameFilterList;
if (searchFilter.contains('.')) {
......@@ -295,8 +295,8 @@ void ItemLibraryWidget::reloadQmlSource()
{
QString itemLibraryQmlFilePath = qmlSourcesPath() + QStringLiteral("/ItemsView.qml");
QTC_ASSERT(QFileInfo::exists(itemLibraryQmlFilePath), return);
m_itemsView->engine()->clearComponentCache();
m_itemsView->setSource(QUrl::fromLocalFile(itemLibraryQmlFilePath));
m_itemViewQuickWidget->engine()->clearComponentCache();
m_itemViewQuickWidget->setSource(QUrl::fromLocalFile(itemLibraryQmlFilePath));
}
void ItemLibraryWidget::setImportFilter(FilterChangeFlag flag)
......
......@@ -38,7 +38,7 @@
#include <QFrame>
#include <QToolButton>
#include <QFileIconProvider>
#include <QQuickView>
#include <QQuickWidget>
QT_BEGIN_NAMESPACE
class QFileSystemModel;
......@@ -133,7 +133,7 @@ private:
QPointer<QStackedWidget> m_stackedWidget;
QPointer<Utils::FancyLineEdit> m_filterLineEdit;
QScopedPointer<QQuickView> m_itemsView;
QScopedPointer<QQuickWidget> m_itemViewQuickWidget;
QScopedPointer<ItemLibraryTreeView> m_resourcesView;
QShortcut *m_qmlSourceUpdateShortcut;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment