2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2023-01-04 08:52:22 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2010-02-16 19:07:59 +02:00
|
|
|
|
2024-01-16 12:30:29 +01:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import HelperWidgets
|
|
|
|
|
import StudioTheme as StudioTheme
|
2023-03-02 13:10:47 +01:00
|
|
|
import ItemLibraryBackend
|
2024-01-16 12:12:52 +01:00
|
|
|
import QtQuickDesignerTheme
|
2010-03-10 12:45:49 +02:00
|
|
|
|
2016-07-28 13:17:54 +02:00
|
|
|
Item {
|
2021-03-02 17:15:59 +02:00
|
|
|
id: delegateRoot
|
2021-03-16 00:08:36 +02:00
|
|
|
|
|
|
|
|
property alias textColor: text.color
|
|
|
|
|
|
2021-03-02 17:15:59 +02:00
|
|
|
signal showContextMenu()
|
|
|
|
|
|
2016-07-28 13:17:54 +02:00
|
|
|
Rectangle {
|
|
|
|
|
anchors.rightMargin: 1
|
|
|
|
|
anchors.topMargin: 1
|
|
|
|
|
anchors.fill: parent
|
2010-03-10 12:45:49 +02:00
|
|
|
|
2021-08-24 12:43:51 +03:00
|
|
|
color: mouseRegion.containsMouse ? StudioTheme.Values.themeControlBackgroundHover : StudioTheme.Values.themePanelBackground
|
2021-12-02 16:33:07 +02:00
|
|
|
Behavior on color {
|
|
|
|
|
ColorAnimation {
|
|
|
|
|
duration: StudioTheme.Values.hoverDuration
|
|
|
|
|
easing.type: StudioTheme.Values.hoverEasing
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-16 17:24:18 +02:00
|
|
|
|
2016-07-28 13:17:54 +02:00
|
|
|
Image {
|
|
|
|
|
id: itemIcon // to be set by model
|
2010-02-16 17:24:18 +02:00
|
|
|
|
2016-07-28 13:17:54 +02:00
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: styleConstants.cellVerticalMargin
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2010-02-16 17:24:18 +02:00
|
|
|
|
2023-03-02 13:10:47 +01:00
|
|
|
width: ItemLibraryBackend.itemLibraryIconWidth // to be set in Qml context
|
|
|
|
|
height: ItemLibraryBackend.itemLibraryIconHeight // to be set in Qml context
|
2016-07-28 13:17:54 +02:00
|
|
|
source: itemLibraryIconPath // to be set by model
|
2022-06-28 15:47:59 +03:00
|
|
|
|
|
|
|
|
// Icons generated for components can change if the component is edited,
|
|
|
|
|
// so don't cache them locally at Image level.
|
|
|
|
|
cache: itemComponentSource === ""
|
2016-07-28 13:17:54 +02:00
|
|
|
}
|
2010-02-16 17:24:18 +02:00
|
|
|
|
2016-07-28 13:17:54 +02:00
|
|
|
Text {
|
|
|
|
|
id: text
|
2018-04-09 16:26:25 +02:00
|
|
|
font.pixelSize: Theme.smallFontPixelSize()
|
2016-07-28 13:17:54 +02:00
|
|
|
elide: Text.ElideMiddle
|
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
|
anchors.top: itemIcon.bottom
|
|
|
|
|
anchors.topMargin: styleConstants.cellVerticalSpacing
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: styleConstants.cellHorizontalMargin
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: styleConstants.cellHorizontalMargin
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.bottomMargin: styleConstants.cellHorizontalMargin
|
2010-02-16 17:24:18 +02:00
|
|
|
|
2016-07-28 13:17:54 +02:00
|
|
|
verticalAlignment: Qt.AlignVCenter
|
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
|
|
|
|
text: itemName // to be set by model
|
2021-03-02 13:35:07 +01:00
|
|
|
color: StudioTheme.Values.themeTextColor
|
2016-07-28 13:17:54 +02:00
|
|
|
renderType: Text.NativeRendering
|
|
|
|
|
}
|
2010-02-16 17:24:18 +02:00
|
|
|
|
2020-09-16 13:44:43 +02:00
|
|
|
ImagePreviewTooltipArea {
|
2016-07-28 13:17:54 +02:00
|
|
|
id: mouseRegion
|
|
|
|
|
anchors.fill: parent
|
2020-09-16 13:44:43 +02:00
|
|
|
|
2022-11-25 16:55:26 +01:00
|
|
|
tooltip: toolTip
|
|
|
|
|
|
2021-03-02 17:15:59 +02:00
|
|
|
onShowContextMenu: delegateRoot.showContextMenu()
|
2021-08-17 11:24:55 +02:00
|
|
|
onPressed: (mouse)=> {
|
2022-03-18 15:14:15 +02:00
|
|
|
allowTooltip = false
|
|
|
|
|
hide()
|
2021-03-02 17:15:59 +02:00
|
|
|
if (mouse.button === Qt.LeftButton)
|
2023-03-02 13:10:47 +01:00
|
|
|
ItemLibraryBackend.rootView.startDragAndDrop(itemLibraryEntry, mapToGlobal(mouse.x, mouse.y))
|
2016-07-28 13:17:54 +02:00
|
|
|
}
|
2022-02-11 13:41:22 +02:00
|
|
|
onDoubleClicked: (mouse)=> {
|
|
|
|
|
if (mouse.button === Qt.LeftButton && itemComponentSource) {
|
|
|
|
|
hide()
|
2023-03-02 13:10:47 +01:00
|
|
|
ItemLibraryBackend.rootView.goIntoComponent(itemComponentSource)
|
2022-02-11 13:41:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
2010-02-16 17:24:18 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|