forked from qt-creator/qt-creator
QmlDesigner: Fix textures added as image or dragged using the icons
Instead of using the paths to the real, downloaded textures, the paths of the icons (thumbnails) were being used. Task-number: QDS-9228 Change-Id: I828b765c4f86502403b84fdf18532d1353d3a62c Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -39,7 +39,7 @@ QUrl ContentLibraryTexture::icon() const
|
|||||||
return m_icon;
|
return m_icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ContentLibraryTexture::path() const
|
QString ContentLibraryTexture::iconPath() const
|
||||||
{
|
{
|
||||||
return m_iconPath;
|
return m_iconPath;
|
||||||
}
|
}
|
||||||
@@ -86,10 +86,15 @@ bool ContentLibraryTexture::isDownloaded() const
|
|||||||
if (m_fileExt.isEmpty())
|
if (m_fileExt.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QString fullPath = m_downloadPath + "/" + m_baseName + m_fileExt;
|
QString fullPath = realTexturePath();
|
||||||
return QFileInfo(fullPath).isFile();
|
return QFileInfo(fullPath).isFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ContentLibraryTexture::realTexturePath() const
|
||||||
|
{
|
||||||
|
return m_downloadPath + "/" + m_baseName + m_fileExt;
|
||||||
|
}
|
||||||
|
|
||||||
void ContentLibraryTexture::setDownloaded()
|
void ContentLibraryTexture::setDownloaded()
|
||||||
{
|
{
|
||||||
m_fileExt = resolveFileExt();
|
m_fileExt = resolveFileExt();
|
||||||
|
@@ -30,7 +30,8 @@ public:
|
|||||||
bool filter(const QString &searchText);
|
bool filter(const QString &searchText);
|
||||||
|
|
||||||
QUrl icon() const;
|
QUrl icon() const;
|
||||||
QString path() const;
|
QString iconPath() const;
|
||||||
|
QString realTexturePath() const;
|
||||||
QString parentDirPath() const;
|
QString parentDirPath() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@@ -65,12 +65,13 @@ bool ContentLibraryWidget::eventFilter(QObject *obj, QEvent *event)
|
|||||||
}
|
}
|
||||||
} else if (m_textureToDrag) {
|
} else if (m_textureToDrag) {
|
||||||
QMouseEvent *me = static_cast<QMouseEvent *>(event);
|
QMouseEvent *me = static_cast<QMouseEvent *>(event);
|
||||||
if ((me->globalPos() - m_dragStartPoint).manhattanLength() > 20) {
|
if ((me->globalPos() - m_dragStartPoint).manhattanLength() > 20
|
||||||
|
&& m_textureToDrag->isDownloaded()) {
|
||||||
QMimeData *mimeData = new QMimeData;
|
QMimeData *mimeData = new QMimeData;
|
||||||
mimeData->setData(Constants::MIME_TYPE_BUNDLE_TEXTURE, {m_textureToDrag->path().toUtf8()});
|
mimeData->setData(Constants::MIME_TYPE_BUNDLE_TEXTURE, {m_textureToDrag->iconPath().toUtf8()});
|
||||||
|
|
||||||
// Allows standard file drag-n-drop. As of now needed to drop on Assets view
|
// Allows standard file drag-n-drop. As of now needed to drop on Assets view
|
||||||
mimeData->setUrls({QUrl::fromLocalFile(m_textureToDrag->path())});
|
mimeData->setUrls({QUrl::fromLocalFile(m_textureToDrag->realTexturePath())});
|
||||||
|
|
||||||
emit bundleTextureDragStarted(m_textureToDrag);
|
emit bundleTextureDragStarted(m_textureToDrag);
|
||||||
model->startDrag(mimeData, m_textureToDrag->icon().toLocalFile());
|
model->startDrag(mimeData, m_textureToDrag->icon().toLocalFile());
|
||||||
@@ -261,17 +262,26 @@ void ContentLibraryWidget::startDragTexture(QmlDesigner::ContentLibraryTexture *
|
|||||||
|
|
||||||
void ContentLibraryWidget::addImage(ContentLibraryTexture *tex)
|
void ContentLibraryWidget::addImage(ContentLibraryTexture *tex)
|
||||||
{
|
{
|
||||||
emit addTextureRequested(tex->path(), AddTextureMode::Image);
|
if (!tex->isDownloaded())
|
||||||
|
return;
|
||||||
|
|
||||||
|
emit addTextureRequested(tex->realTexturePath(), AddTextureMode::Image);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLibraryWidget::addTexture(ContentLibraryTexture *tex)
|
void ContentLibraryWidget::addTexture(ContentLibraryTexture *tex)
|
||||||
{
|
{
|
||||||
emit addTextureRequested(tex->path(), AddTextureMode::Texture);
|
if (!tex->isDownloaded())
|
||||||
|
return;
|
||||||
|
|
||||||
|
emit addTextureRequested(tex->realTexturePath(), AddTextureMode::Texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLibraryWidget::addLightProbe(ContentLibraryTexture *tex)
|
void ContentLibraryWidget::addLightProbe(ContentLibraryTexture *tex)
|
||||||
{
|
{
|
||||||
emit addTextureRequested(tex->path(), AddTextureMode::LightProbe);
|
if (!tex->isDownloaded())
|
||||||
|
return;
|
||||||
|
|
||||||
|
emit addTextureRequested(tex->realTexturePath(), AddTextureMode::LightProbe);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLibraryWidget::updateSceneEnvState()
|
void ContentLibraryWidget::updateSceneEnvState()
|
||||||
|
Reference in New Issue
Block a user