Files
qt-creator/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryTextureContextMenu.qml
Miikka Heikkinen 26c1747ae6 QmlDesigner: Fix issues with adding texture as light probe
Changed resolving the currently active scene environment to be done
on demand instead of trying to track it realtime, since resolving it
is relatively cheap operation, so it doesn't cause noticeable delay
at context menu opening. The alternative would be to implement multiple
different notification handlers in ContentLibraryView, which would slow
down all operations and would be much more complex to ensure all edge
cases are covered.

Fixes: QDS-8437
Change-Id: Ib33cd1ad549d836b9d780f9b0f92e70d223e2a25
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-11-29 11:06:54 +00:00

42 lines
1.1 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 HelperWidgets 2.0
import StudioControls 1.0 as StudioControls
import StudioTheme 1.0 as StudioTheme
StudioControls.Menu {
id: root
property var targetTexture: null
property bool hasSceneEnv: false
function popupMenu(targetTexture = null)
{
this.targetTexture = targetTexture
rootView.updateSceneEnvState();
popup()
}
closePolicy: StudioControls.Menu.CloseOnEscape | StudioControls.Menu.CloseOnPressOutside
StudioControls.MenuItem {
text: qsTr("Add image")
enabled: root.targetTexture
onTriggered: rootView.addImage(root.targetTexture)
}
StudioControls.MenuItem {
text: qsTr("Add texture")
enabled: root.targetTexture
onTriggered: rootView.addTexture(root.targetTexture)
}
StudioControls.MenuItem {
text: qsTr("Add light probe")
enabled: root.hasSceneEnv && root.targetTexture
onTriggered: rootView.addLightProbe(root.targetTexture)
}
}