2024-05-11 00:04:11 +03:00
|
|
|
// Copyright (C) 2024 The Qt Company Ltd.
|
2022-12-21 10:12:09 +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
|
|
|
|
2024-05-11 00:04:11 +03:00
|
|
|
import QtQuick
|
|
|
|
|
import StudioControls as StudioControls
|
|
|
|
|
import StudioTheme as StudioTheme
|
|
|
|
|
import ContentLibraryBackend
|
2022-10-26 19:57:41 +03:00
|
|
|
|
|
|
|
|
StudioControls.Menu {
|
|
|
|
|
id: root
|
|
|
|
|
|
2024-05-11 00:04:11 +03:00
|
|
|
property var targetItem: null
|
|
|
|
|
property bool enableRemove: false // true: adds an option to remove targetItem
|
2022-11-29 16:56:08 +02:00
|
|
|
|
2024-05-11 00:04:11 +03:00
|
|
|
readonly property bool targetAvailable: targetItem && !ContentLibraryBackend.rootView.importerRunning
|
2022-11-29 16:56:08 +02:00
|
|
|
|
2024-03-21 12:47:09 +02:00
|
|
|
signal unimport();
|
|
|
|
|
signal addToProject()
|
|
|
|
|
signal applyToSelected(bool add)
|
2024-04-25 11:59:01 +03:00
|
|
|
signal removeFromContentLib()
|
2022-10-26 19:57:41 +03:00
|
|
|
|
2024-05-11 00:04:11 +03:00
|
|
|
function popupMenu(item = null)
|
2022-10-26 19:57:41 +03:00
|
|
|
{
|
2024-05-11 00:04:11 +03:00
|
|
|
root.targetItem = item
|
|
|
|
|
|
2024-06-14 12:14:09 +03:00
|
|
|
let isMaterial = root.targetItem.bundleId === "UserMaterials"
|
2024-05-11 00:04:11 +03:00
|
|
|
applyToSelectedReplace.visible = isMaterial
|
|
|
|
|
applyToSelectedAdd.visible = isMaterial
|
|
|
|
|
|
2022-10-26 19:57:41 +03:00
|
|
|
popup()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
closePolicy: StudioControls.Menu.CloseOnEscape | StudioControls.Menu.CloseOnPressOutside
|
|
|
|
|
|
|
|
|
|
StudioControls.MenuItem {
|
2024-05-11 00:04:11 +03:00
|
|
|
id: applyToSelectedReplace
|
2022-10-26 19:57:41 +03:00
|
|
|
text: qsTr("Apply to selected (replace)")
|
2024-05-11 00:04:11 +03:00
|
|
|
height: visible ? implicitHeight : 0
|
|
|
|
|
enabled: root.targetAvailable && ContentLibraryBackend.rootView.hasModelSelection
|
2024-03-21 12:47:09 +02:00
|
|
|
onTriggered: root.applyToSelected(false)
|
2022-10-26 19:57:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StudioControls.MenuItem {
|
2024-05-11 00:04:11 +03:00
|
|
|
id: applyToSelectedAdd
|
2022-10-26 19:57:41 +03:00
|
|
|
text: qsTr("Apply to selected (add)")
|
2024-05-11 00:04:11 +03:00
|
|
|
height: visible ? implicitHeight : 0
|
|
|
|
|
enabled: root.targetAvailable && ContentLibraryBackend.rootView.hasModelSelection
|
2024-03-21 12:47:09 +02:00
|
|
|
onTriggered: root.applyToSelected(true)
|
2022-10-26 19:57:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StudioControls.MenuSeparator {}
|
|
|
|
|
|
|
|
|
|
StudioControls.MenuItem {
|
2022-11-29 16:56:08 +02:00
|
|
|
enabled: root.targetAvailable
|
2022-10-26 19:57:41 +03:00
|
|
|
text: qsTr("Add an instance to project")
|
2024-05-11 00:04:11 +03:00
|
|
|
onTriggered: root.addToProject()
|
2022-10-26 19:57:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StudioControls.MenuItem {
|
2024-05-11 00:04:11 +03:00
|
|
|
enabled: root.targetAvailable && root.targetItem.bundleItemImported
|
2022-10-26 19:57:41 +03:00
|
|
|
text: qsTr("Remove from project")
|
2024-03-21 12:47:09 +02:00
|
|
|
onTriggered: root.unimport()
|
2022-10-26 19:57:41 +03:00
|
|
|
}
|
2024-04-25 11:59:01 +03:00
|
|
|
|
|
|
|
|
StudioControls.MenuItem {
|
|
|
|
|
text: qsTr("Remove from Content Library")
|
|
|
|
|
visible: root.enableRemove && root.targetAvailable
|
|
|
|
|
height: visible ? implicitHeight : 0
|
|
|
|
|
onTriggered: root.removeFromContentLib()
|
|
|
|
|
}
|
2022-10-26 19:57:41 +03:00
|
|
|
}
|