forked from qt-creator/qt-creator
QmlDesigner: Add image info to content library texture tooltip
Fixes: QDS-8489 Change-Id: I1afbf91ad12839cc93a46f0a608ab3bda135b76b Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -23,6 +23,7 @@ Image {
|
|||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
|
hoverEnabled: true
|
||||||
|
|
||||||
onPressed: (mouse) => {
|
onPressed: (mouse) => {
|
||||||
if (mouse.button === Qt.LeftButton)
|
if (mouse.button === Qt.LeftButton)
|
||||||
@@ -31,4 +32,20 @@ Image {
|
|||||||
root.showContextMenu()
|
root.showContextMenu()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ToolTip {
|
||||||
|
visible: mouseArea.containsMouse
|
||||||
|
// contentWidth is not calculated correctly by the toolTip (resulting in a wider tooltip than
|
||||||
|
// needed). Using a helper Text to calculate the correct width
|
||||||
|
contentWidth: helperText.width
|
||||||
|
bottomInset: -2
|
||||||
|
text: modelData.textureToolTip
|
||||||
|
delay: 1000
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: helperText
|
||||||
|
text: modelData.textureToolTip
|
||||||
|
visible: false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,12 +3,17 @@
|
|||||||
|
|
||||||
#include "contentlibrarytexture.h"
|
#include "contentlibrarytexture.h"
|
||||||
|
|
||||||
|
#include "imageutils.h"
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
ContentLibraryTexture::ContentLibraryTexture(QObject *parent, const QString &path, const QUrl &icon)
|
ContentLibraryTexture::ContentLibraryTexture(QObject *parent, const QString &path, const QUrl &icon)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_path(path)
|
, m_path(path)
|
||||||
, m_icon(icon) {}
|
, m_icon(icon)
|
||||||
|
{
|
||||||
|
m_toolTip = QLatin1String("%1\n%2").arg(path.split('/').last(), ImageUtils::imageInfo(path));
|
||||||
|
}
|
||||||
|
|
||||||
bool ContentLibraryTexture::filter(const QString &searchText)
|
bool ContentLibraryTexture::filter(const QString &searchText)
|
||||||
{
|
{
|
||||||
|
@@ -13,6 +13,7 @@ class ContentLibraryTexture : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QString texturePath MEMBER m_path CONSTANT)
|
Q_PROPERTY(QString texturePath MEMBER m_path CONSTANT)
|
||||||
|
Q_PROPERTY(QString textureToolTip MEMBER m_toolTip CONSTANT)
|
||||||
Q_PROPERTY(QUrl textureIcon MEMBER m_icon CONSTANT)
|
Q_PROPERTY(QUrl textureIcon MEMBER m_icon CONSTANT)
|
||||||
Q_PROPERTY(bool textureVisible MEMBER m_visible NOTIFY textureVisibleChanged)
|
Q_PROPERTY(bool textureVisible MEMBER m_visible NOTIFY textureVisibleChanged)
|
||||||
|
|
||||||
@@ -29,6 +30,7 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_path;
|
QString m_path;
|
||||||
|
QString m_toolTip;
|
||||||
QUrl m_icon;
|
QUrl m_icon;
|
||||||
|
|
||||||
bool m_visible = true;
|
bool m_visible = true;
|
||||||
|
Reference in New Issue
Block a user