forked from qt-creator/qt-creator
QmlDesigner: Fix downloading textures no longer working after some clicks
A "locking" mechanism was implemented to prevent multiple textures from being downloaded at the same time. However, there was a mistake made, which made it so that when a texture that had already been downloaded was clicked again, this locking would be enforced and not released. Also, fixed minor issues: * The download button now has a black outline, so as to better distinguish it inside black-and-white textures * Canceling the download of a texture no longer marks the download as failed -- it should show it as if the download was never attempted. * Fixed tooltips not showing the texture size for downloaded textures - and now we also update the tooltip text after the real texture has been downloaded. * Always creating the "target path" in the FileExtractor, if it does not exist -- this is different from the "target folder" name, which is an folder that can optionally be created inside this "target path" Task-number: QDS-8664 Change-Id: Ieac0e81a5595a8bff3d1aa7ff6252e16c2509c2e Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -121,6 +121,8 @@ Item {
|
||||
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
style: Text.Outline
|
||||
styleColor: "black"
|
||||
|
||||
visible: root.downloadState !== "downloaded"
|
||||
}
|
||||
@@ -164,10 +166,10 @@ Item {
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
if (!rootView.markTextureDownloading())
|
||||
if (root.downloadState !== "" && root.downloadState !== "failed")
|
||||
return
|
||||
|
||||
if (root.downloadState !== "" && root.downloadState !== "failed")
|
||||
if (!rootView.markTextureDownloading())
|
||||
return
|
||||
|
||||
progressBar.visible = true
|
||||
@@ -205,7 +207,7 @@ Item {
|
||||
root.progressText = ""
|
||||
root.progressValue = 0
|
||||
|
||||
root.downloadState = "failed"
|
||||
root.downloadState = ""
|
||||
root.downloadStateChanged()
|
||||
mouseArea.enabled = true
|
||||
|
||||
|
@@ -20,20 +20,8 @@ ContentLibraryTexture::ContentLibraryTexture(QObject *parent, const QFileInfo &i
|
||||
, m_baseName{iconFileInfo.baseName()}
|
||||
, m_icon(icon)
|
||||
{
|
||||
m_fileExt = computeFileExt();
|
||||
|
||||
QString fileName;
|
||||
QString imageInfo;
|
||||
if (m_fileExt.isEmpty()) {
|
||||
imageInfo = ImageUtils::imageInfo(m_iconPath, false);
|
||||
fileName = m_baseName + m_defaultExt;
|
||||
} else {
|
||||
fileName = m_baseName + m_fileExt;
|
||||
QString fullDownloadPath = m_downloadPath + "/" + fileName;
|
||||
imageInfo = ImageUtils::imageInfo(fullDownloadPath, false);
|
||||
}
|
||||
|
||||
m_toolTip = QLatin1String("%1\n%2").arg(fileName, imageInfo);
|
||||
m_fileExt = resolveFileExt();
|
||||
m_toolTip = resolveToolTipText();
|
||||
}
|
||||
|
||||
bool ContentLibraryTexture::filter(const QString &searchText)
|
||||
@@ -56,7 +44,7 @@ QString ContentLibraryTexture::path() const
|
||||
return m_iconPath;
|
||||
}
|
||||
|
||||
QString ContentLibraryTexture::computeFileExt()
|
||||
QString ContentLibraryTexture::resolveFileExt()
|
||||
{
|
||||
const QFileInfoList files = QDir(m_downloadPath).entryInfoList(QDir::Files);
|
||||
const QFileInfoList textureFiles = Utils::filtered(files, [this](const QFileInfo &fi) {
|
||||
@@ -76,6 +64,23 @@ QString ContentLibraryTexture::computeFileExt()
|
||||
return QString{"."} + textureFiles.at(0).completeSuffix();
|
||||
}
|
||||
|
||||
QString ContentLibraryTexture::resolveToolTipText()
|
||||
{
|
||||
QString fileName;
|
||||
QString imageInfo;
|
||||
|
||||
if (m_fileExt.isEmpty()) {
|
||||
imageInfo = ImageUtils::imageInfo(m_iconPath, false);
|
||||
fileName = m_baseName + m_defaultExt;
|
||||
} else {
|
||||
fileName = m_baseName + m_fileExt;
|
||||
QString fullDownloadPath = m_downloadPath + "/" + fileName;
|
||||
imageInfo = ImageUtils::imageInfo(fullDownloadPath, true);
|
||||
}
|
||||
|
||||
return QLatin1String("%1\n%2").arg(fileName, imageInfo);
|
||||
}
|
||||
|
||||
bool ContentLibraryTexture::isDownloaded() const
|
||||
{
|
||||
if (m_fileExt.isEmpty())
|
||||
@@ -87,7 +92,13 @@ bool ContentLibraryTexture::isDownloaded() const
|
||||
|
||||
void ContentLibraryTexture::setDownloaded()
|
||||
{
|
||||
m_fileExt = computeFileExt();
|
||||
m_fileExt = resolveFileExt();
|
||||
QString toolTip = resolveToolTipText();
|
||||
|
||||
if (toolTip != m_toolTip) {
|
||||
m_toolTip = toolTip;
|
||||
emit textureToolTipChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString ContentLibraryTexture::parentDirPath() const
|
||||
|
@@ -15,7 +15,7 @@ class ContentLibraryTexture : public QObject
|
||||
|
||||
Q_PROPERTY(QString textureIconPath MEMBER m_iconPath CONSTANT)
|
||||
Q_PROPERTY(QString textureParentPath READ parentDirPath CONSTANT)
|
||||
Q_PROPERTY(QString textureToolTip MEMBER m_toolTip CONSTANT)
|
||||
Q_PROPERTY(QString textureToolTip MEMBER m_toolTip NOTIFY textureToolTipChanged)
|
||||
Q_PROPERTY(QUrl textureIcon MEMBER m_icon CONSTANT)
|
||||
Q_PROPERTY(bool textureVisible MEMBER m_visible NOTIFY textureVisibleChanged)
|
||||
Q_PROPERTY(QString textureWebUrl MEMBER m_webUrl CONSTANT)
|
||||
@@ -35,10 +35,12 @@ public:
|
||||
|
||||
signals:
|
||||
void textureVisibleChanged();
|
||||
void textureToolTipChanged();
|
||||
|
||||
private:
|
||||
inline static const QString m_defaultExt = ".png";
|
||||
QString computeFileExt();
|
||||
QString resolveFileExt();
|
||||
QString resolveToolTipText();
|
||||
|
||||
QString m_iconPath;
|
||||
QString m_downloadPath;
|
||||
|
@@ -82,6 +82,14 @@ QString FileExtractor::targetPath() const
|
||||
void FileExtractor::setTargetPath(const QString &path)
|
||||
{
|
||||
m_targetPath = Utils::FilePath::fromString(path);
|
||||
|
||||
QDir dir(m_targetPath.toString());
|
||||
|
||||
if (!path.isEmpty() && !dir.exists()) {
|
||||
// Even though m_targetPath will be created eventually, we need to make sure the path exists
|
||||
// before m_bytesBefore is being calculated.
|
||||
dir.mkpath(m_targetPath.toString());
|
||||
}
|
||||
}
|
||||
|
||||
void FileExtractor::browse()
|
||||
|
Reference in New Issue
Block a user