summaryrefslogtreecommitdiff
path: root/share/qtcreator/qmldesigner/itemLibraryQmlSources
diff options
context:
space:
mode:
authorSamuel Ghinet <samuel.ghinet@qt.io>2022-12-15 23:20:43 +0200
committerSamuel Ghinet <samuel.ghinet@qt.io>2023-01-10 19:10:02 +0000
commitff9c170053588999670df83457df5b912ea1d996 (patch)
tree7aca061f4143afa316b38115ad79d1ff82cb8f55 /share/qtcreator/qmldesigner/itemLibraryQmlSources
parentb02b60800e49ad1c67b4a21fc89c98d2047b1301 (diff)
downloadqt-creator-ff9c170053588999670df83457df5b912ea1d996.tar.gz
QmlDesigner: Show metadata of assets when being hovered on
This change does not affect font files. For all other assets, the file type is now also shown in tooltips For image assets, the image size is also displayed. Task-number: QDS-8177 Change-Id: Iceb93a0ffe1cb284a87cc93f1da2060f6f4f1529 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'share/qtcreator/qmldesigner/itemLibraryQmlSources')
-rw-r--r--share/qtcreator/qmldesigner/itemLibraryQmlSources/AssetDelegate.qml34
1 files changed, 33 insertions, 1 deletions
diff --git a/share/qtcreator/qmldesigner/itemLibraryQmlSources/AssetDelegate.qml b/share/qtcreator/qmldesigner/itemLibraryQmlSources/AssetDelegate.qml
index 2bbfff5223..3e8f346fde 100644
--- a/share/qtcreator/qmldesigner/itemLibraryQmlSources/AssetDelegate.qml
+++ b/share/qtcreator/qmldesigner/itemLibraryQmlSources/AssetDelegate.qml
@@ -182,9 +182,36 @@ TreeViewDelegate {
}
ToolTip {
+ id: assetTooltip
visible: !root.isFont && mouseArea.containsMouse && !root.assetsView.contextMenu.visible
- text: model.filePath
+ text: assetTooltip.__computeText()
delay: 1000
+
+ function __computeText()
+ {
+ let filePath = model.filePath.replace(assetsModel.contentDirPath(), "")
+ let fileSize = rootView.assetFileSize(model.filePath)
+ let fileExtMatches = model.filePath.match(/\.(.*)$/)
+ let fileExt = fileExtMatches ? "(" + fileExtMatches[1] + ")" : ""
+
+ if (rootView.assetIsImage(model.filePath)) {
+ let size = rootView.imageSize(model.filePath)
+
+ return filePath + "\n"
+ + size.width + " x " + size.height
+ + "\n" + fileSize
+ + " " + fileExt
+ } else {
+ return filePath + "\n"
+ + fileSize
+ + " " + fileExt
+ }
+ }
+
+ function refresh()
+ {
+ text = assetTooltip.__computeText()
+ }
}
Timer {
@@ -293,5 +320,10 @@ TreeViewDelegate {
: "image://qmldesigner_assets/" + model.filePath
}
+ onStatusChanged: {
+ if (thumbnailImage.status === Image.Ready)
+ assetTooltip.refresh()
+ }
+
} // Image
} // TreeViewDelegate