QmlDesigner: Move new item lib qmls to the share folder

...so that theming and hot reloading can be applied. Theming isn't part
of this commit. Also used icon font instead of pngs.

Change-Id: I7df149fe9c07fb4c2e3deca6bcf3b0346025e3d6
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Miina Puuronen <miina.puuronen@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Mahmoud Badri
2021-03-05 19:47:53 +02:00
parent a6f944e472
commit af41cca569
13 changed files with 58 additions and 56 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 339 B

View File

@@ -29,17 +29,7 @@
<file>images/asset_sound_192.png</file>
<file>images/asset_sound_256.png</file>
<file>images/asset_sound_384.png</file>
<file>images/tab_icon.png</file>
<file>images/tab_icon@2x.png</file>
<file>images/x.png</file>
<file>images/x@2x.png</file>
<file>images/add.png</file>
<file>images/add@2x.png</file>
<file>images/add_unselected.png</file>
<file>images/add_unselected@2x.png</file>
<file>images/down.png</file>
<file>images/down@2x.png</file>
<file>qml/libraryheader.qml</file>
<file>qml/addimport.qml</file>
</qresource>
</RCC>

View File

@@ -141,27 +141,19 @@ ItemLibraryWidget::ItemLibraryWidget(AsynchronousImageCache &imageCache,
// create header widget
m_headerWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
m_headerWidget->setClearColor(Theme::getColor(Theme::Color::QmlDesigner_BackgroundColorDarkAlternate));
Theme::setupTheme(m_headerWidget->engine());
m_headerWidget->setSource(QUrl("qrc:/ItemLibrary/qml/libraryheader.qml"));
QObject::connect(m_headerWidget->rootObject(), SIGNAL(tabChanged(int)), this,
SLOT(handleTabChanged(int)));
QObject::connect(m_headerWidget->rootObject(), SIGNAL(filterChanged(QString)), this,
SLOT(handleFilterChanged(QString)));
QObject::connect(m_headerWidget->rootObject(), SIGNAL(addModuleClicked()), this,
SLOT(handleAddModule()));
QObject::connect(m_headerWidget->rootObject(), SIGNAL(addAssetClicked()), this,
SLOT(handleAddAsset()));
m_headerWidget->engine()->addImportPath(propertyEditorResourcesPath() + "/imports");
m_headerWidget->setClearColor(Theme::getColor(Theme::Color::QmlDesigner_BackgroundColorDarkAlternate));
m_headerWidget->rootContext()->setContextProperty("rootView", QVariant::fromValue(this));
// create add imports widget
m_addImportWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
m_addImportWidget->setClearColor(Theme::getColor(Theme::Color::QmlDesigner_BackgroundColorDarkAlternate));
Theme::setupTheme(m_addImportWidget->engine());
m_addImportWidget->setSource(QUrl("qrc:/ItemLibrary/qml/addimport.qml"));
m_addImportWidget->rootContext()->setContextProperty(
"addImportModel", QVariant::fromValue(m_itemLibraryAddImportModel.data()));
QObject::connect(m_addImportWidget->rootObject(), SIGNAL(addImport(int)), this,
SLOT(handleAddImport(int)));
m_addImportWidget->rootContext()->setContextProperties({
{"addImportModel", QVariant::fromValue(m_itemLibraryAddImportModel.data())},
{"rootView", QVariant::fromValue(this)},
});
// set up Item Library view and model
m_itemViewQuickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
@@ -270,7 +262,7 @@ QList<QToolButton *> ItemLibraryWidget::createToolBarWidgets()
return buttons;
}
void ItemLibraryWidget::handleFilterChanged(const QString &filterText)
void ItemLibraryWidget::handleSearchfilterChanged(const QString &filterText)
{
m_filterText = filterText;
@@ -339,11 +331,20 @@ void ItemLibraryWidget::clearSearchFilter()
void ItemLibraryWidget::reloadQmlSource()
{
QString itemLibraryQmlFilePath = qmlSourcesPath() + QStringLiteral("/ItemsView.qml");
const QString libraryHeaderQmlPath = qmlSourcesPath() + "/LibraryHeader.qml";
QTC_ASSERT(QFileInfo::exists(libraryHeaderQmlPath), return);
m_headerWidget->engine()->clearComponentCache();
m_headerWidget->setSource(QUrl::fromLocalFile(libraryHeaderQmlPath));
QTC_ASSERT(QFileInfo::exists(itemLibraryQmlFilePath), return);
const QString addImportQmlPath = qmlSourcesPath() + "/AddImport.qml";
QTC_ASSERT(QFileInfo::exists(addImportQmlPath), return);
m_addImportWidget->engine()->clearComponentCache();
m_addImportWidget->setSource(QUrl::fromLocalFile(addImportQmlPath));
const QString itemLibraryQmlPath = qmlSourcesPath() + "/ItemsView.qml";
QTC_ASSERT(QFileInfo::exists(itemLibraryQmlPath), return);
m_itemViewQuickWidget->engine()->clearComponentCache();
m_itemViewQuickWidget->setSource(QUrl::fromLocalFile(itemLibraryQmlFilePath));
m_itemViewQuickWidget->setSource(QUrl::fromLocalFile(itemLibraryQmlPath));
}
void ItemLibraryWidget::updateModel()

View File

@@ -91,6 +91,11 @@ public:
Q_INVOKABLE void startDragAndDrop(const QVariant &itemLibEntry, const QPointF &mousePos);
Q_INVOKABLE void removeImport(const QString &importUrl);
Q_INVOKABLE void addImportForItem(const QVariant &entry);
Q_INVOKABLE void handleTabChanged(int index);
Q_INVOKABLE void handleAddModule();
Q_INVOKABLE void handleAddAsset();
Q_INVOKABLE void handleSearchfilterChanged(const QString &filterText);
Q_INVOKABLE void handleAddImport(int index);
signals:
void itemActivated(const QString& itemName);
@@ -130,13 +135,6 @@ private:
bool m_updateRetry = false;
QString m_filterText;
QPoint m_dragStartPoint;
private slots:
void handleTabChanged(int index);
void handleFilterChanged(const QString &filterText);
void handleAddModule();
void handleAddAsset();
void handleAddImport(int index);
};
}
} // namespace QmlDesigner

View File

@@ -1,89 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuickDesignerTheme 1.0
Column {
id: root
signal addImport(int index)
Text {
id: header
text: qsTr("Select a Module to Add")
color: "#ffffff"
font.pixelSize: 16
width: parent.width
height: 50
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
ScrollView { // ListView not used because of QTBUG-52941
id: listView
width: parent.width
height: parent.height - header.height
clip: true
Column {
spacing: 2
Repeater {
model: addImportModel
delegate: Rectangle {
width: listView.width
height: isSeparator ? 4 : 25
color: isSeparator ? Theme.color(Theme.BackgroundColorNormal)
: mouseArea.containsMouse
? Qt.lighter(Theme.qmlDesignerButtonColor(), 1.3)
: Theme.qmlDesignerButtonColor()
visible: importVisible
Text {
text: importUrl
color: Theme.color(Theme.PanelTextColorLight)
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 10
anchors.rightMargin: 10
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: addImport(index)
enabled: !isSeparator
}
}
}
}
}
}

View File

@@ -1,157 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuickDesignerTheme 1.0
Item {
id: root
width: 200
height: 75
signal tabChanged(int index)
signal filterChanged(string filterText)
signal addModuleClicked()
signal addAssetClicked()
function setTab(index)
{
tabBar.setCurrentIndex(index);
}
function clearSearchFilter()
{
searchFilterText.text = "";
}
Column {
anchors.left: parent.left
anchors.right: parent.right
spacing: 10
TabBar {
id: tabBar
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 5
anchors.rightMargin: 5
spacing: 40
background: Rectangle {
color: Theme.color(Theme.QmlDesigner_BackgroundColorDarkAlternate)
}
Repeater {
model: [{title: qsTr("Components"), addToolTip: qsTr("Add Module")},
{title: qsTr("Assets"), addToolTip: qsTr("Add new assets to project.")}]
TabButton {
contentItem: Text { // TabButton text
text: modelData.title
font.pixelSize: 13
font.bold: true
color: tabBar.currentIndex === index ? "#0094ce" : "#dadada"
anchors.bottomMargin: 2
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignBottom
elide: Text.ElideRight
}
background: Item { // TabButton background
Rectangle { // + button
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.rightMargin: 2
anchors.bottomMargin: 2
width: img.width + 10
height: img.height + 10
color: mouseArea.containsMouse ? "#353535" : "#262626"
ToolTip.delay: 500
ToolTip.text: modelData.addToolTip
ToolTip.visible: mouseArea.containsMouse
Image {
id: img
source: tabBar.currentIndex === index ? "../images/add.png"
: "../images/add_unselected.png"
anchors.centerIn: parent
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: index == 0 ? addModuleClicked() : addAssetClicked()
}
}
Rectangle { // bottom strip
anchors.bottom: parent.bottom
width: parent.width
height: 2
color: tabBar.currentIndex === index ? "#0094ce" : "#a8a8a8"
}
}
onClicked: tabChanged(index)
}
}
}
TextField { // filter
id: searchFilterText
placeholderText: qsTr("Search")
placeholderTextColor: "#a8a8a8"
color: "#dadada"
selectedTextColor: "#0094ce"
background: Rectangle {
color: "#111111"
border.color: "#666666"
}
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 5
anchors.rightMargin: 5
selectByMouse: true
onTextChanged: filterChanged(text)
Image { // clear text button
source: "../images/x.png"
anchors.right: parent.right
anchors.rightMargin: 5
anchors.verticalCenter: parent.verticalCenter
visible: searchFilterText.text !== ""
MouseArea {
anchors.fill: parent
onClicked: searchFilterText.text = ""
}
}
}
}
}