Files
qt-creator/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryTexture.qml
Mahmoud Badri e4af787ff6 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>
2022-12-20 11:29:30 +00:00

52 lines
1.3 KiB
QML

// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuickDesignerTheme 1.0
import HelperWidgets 2.0
import QtQuick.Controls
import StudioTheme 1.0 as StudioTheme
Image {
id: root
source: modelData.textureIcon
visible: modelData.textureVisible
cache: false
signal showContextMenu()
MouseArea {
id: mouseArea
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
hoverEnabled: true
onPressed: (mouse) => {
if (mouse.button === Qt.LeftButton)
rootView.startDragTexture(modelData, mapToGlobal(mouse.x, mouse.y))
else if (mouse.button === Qt.RightButton)
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
}
}
}