diff --git a/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryTexture.qml b/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryTexture.qml index a749d8d52db..ac98bb40faa 100644 --- a/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryTexture.qml +++ b/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryTexture.qml @@ -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 diff --git a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexture.cpp b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexture.cpp index 600d84368ea..e0227203ba8 100644 --- a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexture.cpp +++ b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexture.cpp @@ -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 diff --git a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexture.h b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexture.h index 5921bb27965..54b90ba6d88 100644 --- a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexture.h +++ b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexture.h @@ -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; diff --git a/src/plugins/qmldesigner/utils/fileextractor.cpp b/src/plugins/qmldesigner/utils/fileextractor.cpp index 79aa4974e5c..a7e32b6bc1d 100644 --- a/src/plugins/qmldesigner/utils/fileextractor.cpp +++ b/src/plugins/qmldesigner/utils/fileextractor.cpp @@ -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()