2022-10-26 19:57:41 +03:00
|
|
|
// Copyright (C) 2022 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
|
2022-10-26 19:57:41 +03:00
|
|
|
|
|
|
|
|
import QtQuick
|
2022-12-01 14:13:33 +02:00
|
|
|
import QtQuick.Controls
|
2022-10-26 19:57:41 +03:00
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import QtQuickDesignerTheme
|
|
|
|
|
import HelperWidgets
|
|
|
|
|
import StudioTheme as StudioTheme
|
2023-03-09 10:46:32 +01:00
|
|
|
import MaterialBrowserBackend
|
2022-10-26 19:57:41 +03:00
|
|
|
|
2022-11-10 15:24:26 +02:00
|
|
|
Rectangle {
|
2022-10-26 19:57:41 +03:00
|
|
|
id: root
|
|
|
|
|
|
|
|
|
|
visible: textureVisible
|
2022-11-10 15:24:26 +02:00
|
|
|
|
|
|
|
|
color: "transparent"
|
2023-03-09 10:46:32 +01:00
|
|
|
border.width: MaterialBrowserBackend.materialBrowserTexturesModel.selectedIndex === index
|
|
|
|
|
? !MaterialBrowserBackend.rootView.materialSectionFocused ? 3 : 1 : 0
|
|
|
|
|
border.color: MaterialBrowserBackend.materialBrowserTexturesModel.selectedIndex === index
|
2022-11-10 15:24:26 +02:00
|
|
|
? StudioTheme.Values.themeControlOutlineInteraction
|
|
|
|
|
: "transparent"
|
2022-10-26 19:57:41 +03:00
|
|
|
|
|
|
|
|
signal showContextMenu()
|
|
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
|
id: mouseArea
|
|
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
2022-12-01 14:13:33 +02:00
|
|
|
hoverEnabled: true
|
2022-10-26 19:57:41 +03:00
|
|
|
|
|
|
|
|
onPressed: (mouse) => {
|
2023-03-09 10:46:32 +01:00
|
|
|
MaterialBrowserBackend.materialBrowserTexturesModel.selectTexture(index)
|
|
|
|
|
MaterialBrowserBackend.rootView.focusMaterialSection(false)
|
2022-11-10 15:24:26 +02:00
|
|
|
|
2022-10-26 19:57:41 +03:00
|
|
|
if (mouse.button === Qt.LeftButton)
|
2023-03-09 10:46:32 +01:00
|
|
|
MaterialBrowserBackend.rootView.startDragTexture(index, mapToGlobal(mouse.x, mouse.y))
|
2022-10-26 19:57:41 +03:00
|
|
|
else if (mouse.button === Qt.RightButton)
|
|
|
|
|
root.showContextMenu()
|
|
|
|
|
}
|
2022-11-24 23:42:26 +02:00
|
|
|
|
2023-03-09 10:46:32 +01:00
|
|
|
onDoubleClicked: MaterialBrowserBackend.materialBrowserTexturesModel.openTextureEditor();
|
2022-10-26 19:57:41 +03:00
|
|
|
}
|
2022-11-10 15:24:26 +02:00
|
|
|
|
2022-12-01 14:13:33 +02:00
|
|
|
ToolTip {
|
|
|
|
|
visible: mouseArea.containsMouse
|
2022-12-12 16:58:04 +02:00
|
|
|
// 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: textureToolTip
|
2022-12-01 14:13:33 +02:00
|
|
|
delay: 1000
|
2022-12-12 16:58:04 +02:00
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
id: helperText
|
|
|
|
|
text: textureToolTip
|
|
|
|
|
visible: false
|
|
|
|
|
}
|
2022-12-01 14:13:33 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-10 15:24:26 +02:00
|
|
|
Image {
|
2022-11-14 16:26:42 +02:00
|
|
|
source: "image://materialBrowserTex/" + textureSource
|
2022-11-24 17:30:12 +02:00
|
|
|
asynchronous: true
|
2023-01-16 13:55:02 +02:00
|
|
|
width: root.width - 10
|
|
|
|
|
height: root.height - 10
|
2022-11-10 15:24:26 +02:00
|
|
|
anchors.centerIn: parent
|
2022-11-17 12:54:19 +02:00
|
|
|
smooth: true
|
2023-01-16 13:55:02 +02:00
|
|
|
fillMode: Image.PreserveAspectFit
|
2022-11-10 15:24:26 +02:00
|
|
|
}
|
2022-10-26 19:57:41 +03:00
|
|
|
}
|