2022-10-26 19:57:41 +03:00
|
|
|
// 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
|
2022-09-01 15:03:01 +03:00
|
|
|
|
|
|
|
|
import QtQuick 2.15
|
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
|
import QtQuickDesignerTheme 1.0
|
|
|
|
|
import HelperWidgets 2.0
|
2022-10-12 20:46:17 +03:00
|
|
|
import QtQuick.Controls
|
|
|
|
|
|
2022-09-01 15:03:01 +03:00
|
|
|
import StudioTheme 1.0 as StudioTheme
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: root
|
|
|
|
|
|
|
|
|
|
signal showContextMenu()
|
|
|
|
|
|
|
|
|
|
visible: modelData.bundleMaterialVisible
|
|
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
|
id: mouseArea
|
|
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
|
|
|
|
|
|
onPressed: (mouse) => {
|
2022-10-26 19:57:41 +03:00
|
|
|
if (mouse.button === Qt.LeftButton && !materialsModel.importerRunning)
|
|
|
|
|
rootView.startDragMaterial(modelData, mapToGlobal(mouse.x, mouse.y))
|
2022-09-01 15:03:01 +03:00
|
|
|
else if (mouse.button === Qt.RightButton)
|
|
|
|
|
root.showContextMenu()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
spacing: 1
|
|
|
|
|
|
|
|
|
|
Item { width: 1; height: 5 } // spacer
|
|
|
|
|
|
|
|
|
|
Image {
|
|
|
|
|
id: img
|
|
|
|
|
|
|
|
|
|
width: root.width - 10
|
|
|
|
|
height: img.width
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
source: modelData.bundleMaterialIcon
|
|
|
|
|
cache: false
|
2022-10-12 20:46:17 +03:00
|
|
|
|
|
|
|
|
Rectangle { // circular indicator for imported bundle materials
|
|
|
|
|
width: 10
|
|
|
|
|
height: 10
|
|
|
|
|
radius: 5
|
|
|
|
|
anchors.right: img.right
|
|
|
|
|
anchors.top: img.top
|
|
|
|
|
anchors.margins: 5
|
|
|
|
|
color: "#00ff00"
|
|
|
|
|
border.color: "#555555"
|
|
|
|
|
border.width: 1
|
|
|
|
|
visible: modelData.bundleMaterialImported
|
|
|
|
|
|
|
|
|
|
ToolTip {
|
|
|
|
|
visible: indicatorMouseArea.containsMouse
|
|
|
|
|
text: qsTr("Material is imported to project")
|
|
|
|
|
delay: 1000
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
|
id: indicatorMouseArea
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
hoverEnabled: true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IconButton {
|
|
|
|
|
icon: StudioTheme.Constants.plus
|
|
|
|
|
tooltip: qsTr("Add an instance to project")
|
|
|
|
|
buttonSize: 22
|
|
|
|
|
property color c: StudioTheme.Values.themeIconColor
|
|
|
|
|
normalColor: Qt.hsla(c.hslHue, c.hslSaturation, c.hslLightness, .2)
|
|
|
|
|
hoverColor: Qt.hsla(c.hslHue, c.hslSaturation, c.hslLightness, .3)
|
|
|
|
|
pressColor: Qt.hsla(c.hslHue, c.hslSaturation, c.hslLightness, .4)
|
|
|
|
|
anchors.right: img.right
|
|
|
|
|
anchors.bottom: img.bottom
|
2022-10-26 19:57:41 +03:00
|
|
|
enabled: !materialsModel.importerRunning
|
2022-10-12 20:46:17 +03:00
|
|
|
|
|
|
|
|
onClicked: {
|
2022-10-26 19:57:41 +03:00
|
|
|
materialsModel.addToProject(modelData)
|
2022-10-12 20:46:17 +03:00
|
|
|
}
|
|
|
|
|
}
|
2022-09-01 15:03:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextInput {
|
|
|
|
|
id: matName
|
|
|
|
|
|
|
|
|
|
text: modelData.bundleMaterialName
|
|
|
|
|
|
|
|
|
|
width: img.width
|
|
|
|
|
clip: true
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
horizontalAlignment: TextInput.AlignHCenter
|
|
|
|
|
|
|
|
|
|
font.pixelSize: StudioTheme.Values.myFontSize
|
|
|
|
|
|
|
|
|
|
readOnly: true
|
|
|
|
|
selectByMouse: !matName.readOnly
|
|
|
|
|
|
|
|
|
|
color: StudioTheme.Values.themeTextColor
|
|
|
|
|
selectionColor: StudioTheme.Values.themeTextSelectionColor
|
|
|
|
|
selectedTextColor: StudioTheme.Values.themeTextSelectedTextColor
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|