forked from qt-creator/qt-creator
Also some relevant tweaks. Change-Id: I7bace9ce6bd7b45951cc18f7175b4646251196f0 Reviewed-by: Ali Kianian <ali.kianian@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
72 lines
2.2 KiB
QML
72 lines
2.2 KiB
QML
// Copyright (C) 2024 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
import QtQuick
|
|
import StudioControls as StudioControls
|
|
import StudioTheme as StudioTheme
|
|
import ContentLibraryBackend
|
|
|
|
StudioControls.Menu {
|
|
id: root
|
|
|
|
property var targetItem: null
|
|
property bool enableRemove: false // true: adds an option to remove targetItem
|
|
|
|
readonly property bool targetAvailable: targetItem && !ContentLibraryBackend.rootView.importerRunning
|
|
|
|
signal unimport();
|
|
signal addToProject()
|
|
signal applyToSelected(bool add)
|
|
signal removeFromContentLib()
|
|
|
|
function popupMenu(item = null)
|
|
{
|
|
root.targetItem = item
|
|
|
|
let isMaterial = root.targetItem.itemType === "material"
|
|
applyToSelectedReplace.visible = isMaterial
|
|
applyToSelectedAdd.visible = isMaterial
|
|
|
|
popup()
|
|
}
|
|
|
|
closePolicy: StudioControls.Menu.CloseOnEscape | StudioControls.Menu.CloseOnPressOutside
|
|
|
|
StudioControls.MenuItem {
|
|
id: applyToSelectedReplace
|
|
text: qsTr("Apply to selected (replace)")
|
|
height: visible ? implicitHeight : 0
|
|
enabled: root.targetAvailable && ContentLibraryBackend.rootView.hasModelSelection
|
|
onTriggered: root.applyToSelected(false)
|
|
}
|
|
|
|
StudioControls.MenuItem {
|
|
id: applyToSelectedAdd
|
|
text: qsTr("Apply to selected (add)")
|
|
height: visible ? implicitHeight : 0
|
|
enabled: root.targetAvailable && ContentLibraryBackend.rootView.hasModelSelection
|
|
onTriggered: root.applyToSelected(true)
|
|
}
|
|
|
|
StudioControls.MenuSeparator {}
|
|
|
|
StudioControls.MenuItem {
|
|
enabled: root.targetAvailable
|
|
text: qsTr("Add an instance to project")
|
|
onTriggered: root.addToProject()
|
|
}
|
|
|
|
StudioControls.MenuItem {
|
|
enabled: root.targetAvailable && root.targetItem.bundleItemImported
|
|
text: qsTr("Remove from project")
|
|
onTriggered: root.unimport()
|
|
}
|
|
|
|
StudioControls.MenuItem {
|
|
text: qsTr("Remove from Content Library")
|
|
visible: root.enableRemove && root.targetAvailable
|
|
height: visible ? implicitHeight : 0
|
|
onTriggered: root.removeFromContentLib()
|
|
}
|
|
}
|