forked from qt-creator/qt-creator
QmlDesigner: Allow dropping image assets to User Assets
Also fixes a corner case where a "Content Library is disabled inside a non-visual component." message is displayed under Textures if the materials model is empty. Fixes: QDS-14443 Fixes: QDS-12825 Change-Id: I9fa37b843534a1a54f08652f7a66915ac30d024d Reviewed-by: Ali Kianian <ali.kianian@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -104,6 +104,7 @@ Item {
|
|||||||
bottomPadding: StudioTheme.Values.sectionPadding
|
bottomPadding: StudioTheme.Values.sectionPadding
|
||||||
|
|
||||||
caption: categoryTitle
|
caption: categoryTitle
|
||||||
|
dropEnabled: true
|
||||||
category: "ContentLib_User"
|
category: "ContentLib_User"
|
||||||
|
|
||||||
function expandSection() {
|
function expandSection() {
|
||||||
@@ -114,6 +115,24 @@ Item {
|
|||||||
|
|
||||||
onCountChanged: root.assignMaxCount()
|
onCountChanged: root.assignMaxCount()
|
||||||
|
|
||||||
|
onDropEnter: (drag) => {
|
||||||
|
drag.accepted = categoryTitle === "Textures"
|
||||||
|
&& drag.formats[0] === "application/vnd.qtdesignstudio.assets"
|
||||||
|
|
||||||
|
section.highlight = drag.accepted
|
||||||
|
}
|
||||||
|
|
||||||
|
onDropExit: {
|
||||||
|
section.highlight = false
|
||||||
|
}
|
||||||
|
|
||||||
|
onDrop: (drag) => {
|
||||||
|
section.highlight = false
|
||||||
|
ContentLibraryBackend.rootView.acceptTexturesDrop(drag.urls)
|
||||||
|
drag.accept()
|
||||||
|
section.expandSection()
|
||||||
|
}
|
||||||
|
|
||||||
Grid {
|
Grid {
|
||||||
width: section.width - section.leftPadding - section.rightPadding
|
width: section.width - section.leftPadding - section.rightPadding
|
||||||
spacing: StudioTheme.Values.sectionGridSpacing
|
spacing: StudioTheme.Values.sectionGridSpacing
|
||||||
@@ -182,7 +201,7 @@ Item {
|
|||||||
qsTr("<b>Content Library</b> is not supported in Qt5 projects.")
|
qsTr("<b>Content Library</b> is not supported in Qt5 projects.")
|
||||||
else if (!ContentLibraryBackend.rootView.hasQuick3DImport && categoryTitle !== "Textures")
|
else if (!ContentLibraryBackend.rootView.hasQuick3DImport && categoryTitle !== "Textures")
|
||||||
qsTr("To use " + categoryName + ", first add the QtQuick3D module in the <b>Components</b> view.")
|
qsTr("To use " + categoryName + ", first add the QtQuick3D module in the <b>Components</b> view.")
|
||||||
else if (!ContentLibraryBackend.rootView.hasMaterialLibrary)
|
else if (!ContentLibraryBackend.rootView.hasMaterialLibrary && categoryTitle !== "Textures")
|
||||||
qsTr("<b>Content Library</b> is disabled inside a non-visual component.")
|
qsTr("<b>Content Library</b> is disabled inside a non-visual component.")
|
||||||
else if (categoryEmpty)
|
else if (categoryEmpty)
|
||||||
qsTr("There are no "+ categoryName + " in the <b>User Assets</b>.")
|
qsTr("There are no "+ categoryName + " in the <b>User Assets</b>.")
|
||||||
|
@@ -87,6 +87,19 @@ WidgetInfo ContentLibraryView::widgetInfo()
|
|||||||
m_draggedBundleItem = item;
|
m_draggedBundleItem = item;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(m_widget, &ContentLibraryWidget::acceptTexturesDrop, this,
|
||||||
|
[this](const QList<QUrl> &urls) {
|
||||||
|
QStringList paths;
|
||||||
|
|
||||||
|
for (const QUrl &url : urls) {
|
||||||
|
QString path = url.toLocalFile();
|
||||||
|
|
||||||
|
if (Asset(path).isImage())
|
||||||
|
paths.append(path);
|
||||||
|
}
|
||||||
|
addLibAssets(paths);
|
||||||
|
});
|
||||||
|
|
||||||
connect(m_widget,
|
connect(m_widget,
|
||||||
&ContentLibraryWidget::addTextureRequested,
|
&ContentLibraryWidget::addTextureRequested,
|
||||||
this,
|
this,
|
||||||
|
@@ -124,6 +124,7 @@ signals:
|
|||||||
void hasModelSelectionChanged();
|
void hasModelSelectionChanged();
|
||||||
void importBundle();
|
void importBundle();
|
||||||
void requestTab(int tabIndex);
|
void requestTab(int tabIndex);
|
||||||
|
void acceptTexturesDrop(const QList<QUrl> &urls);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
|
Reference in New Issue
Block a user