2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-02-16 19:07:59 +02:00
|
|
|
**
|
2016-01-15 14:59:14 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2010-02-16 19:07:59 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-02-16 19:07:59 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:59:14 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2010-02-16 19:07:59 +02:00
|
|
|
**
|
2015-09-18 11:34:48 +02:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
2016-01-15 14:59:14 +01:00
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-02-16 19:07:59 +02:00
|
|
|
|
2020-07-03 16:17:54 +02:00
|
|
|
import QtQuick 2.15
|
|
|
|
|
import QtQuick.Controls 2.15
|
2017-03-07 16:06:02 +01:00
|
|
|
import QtQuickDesignerTheme 1.0
|
2019-08-06 13:52:32 +02:00
|
|
|
import HelperWidgets 2.0
|
2021-03-02 13:35:07 +01:00
|
|
|
import StudioTheme 1.0 as StudioTheme
|
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
|
|
|
|
2016-07-28 13:17:54 +02:00
|
|
|
width: itemLibraryIconWidth // to be set in Qml context
|
|
|
|
|
height: itemLibraryIconHeight // to be set in Qml context
|
|
|
|
|
source: itemLibraryIconPath // to be set by model
|
|
|
|
|
}
|
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
|
|
|
|
2021-03-02 17:15:59 +02:00
|
|
|
onShowContextMenu: delegateRoot.showContextMenu()
|
2021-08-17 11:24:55 +02:00
|
|
|
onPressed: (mouse)=> {
|
2021-03-02 17:15:59 +02:00
|
|
|
if (mouse.button === Qt.LeftButton)
|
|
|
|
|
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()
|
|
|
|
|
rootView.goIntoComponent(itemComponentSource)
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-16 17:24:18 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|