mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 10:37:56 +02:00
Add context menu to asset manager
This commit is contained in:
parent
0df05d273d
commit
273acc6a7e
1 changed files with 65 additions and 6 deletions
|
@ -109,16 +109,22 @@ Window {
|
||||||
Entities.addModelEntity(url, MyAvatar.position);
|
Entities.addModelEntity(url, MyAvatar.position);
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyURLToClipboard() {
|
function copyURLToClipboard(index) {
|
||||||
var path = assetMappingsModel.data(treeView.currentIndex, 0x103);
|
if (!index) {
|
||||||
|
index = treeView.currentIndex;
|
||||||
|
}
|
||||||
|
var path = assetMappingsModel.data(index, 0x103);
|
||||||
if (!path) {
|
if (!path) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Window.copyToClipboard(path);
|
Window.copyToClipboard(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renameFile() {
|
function renameFile(index) {
|
||||||
var path = assetMappingsModel.data(treeView.currentIndex, 0x100);
|
if (!index) {
|
||||||
|
index = treeView.currentIndex;
|
||||||
|
}
|
||||||
|
var path = assetMappingsModel.data(index, 0x100);
|
||||||
if (!path) {
|
if (!path) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -141,8 +147,11 @@ Window {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function deleteFile() {
|
function deleteFile(index) {
|
||||||
var path = assetMappingsModel.data(treeView.currentIndex, 0x100);
|
if (!index) {
|
||||||
|
index = treeView.currentIndex;
|
||||||
|
}
|
||||||
|
var path = assetMappingsModel.data(index, 0x100);
|
||||||
if (!path) {
|
if (!path) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -271,6 +280,34 @@ Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Menu {
|
||||||
|
id: contextMenu
|
||||||
|
title: "Edit"
|
||||||
|
property var url: ""
|
||||||
|
property var currentIndex: null
|
||||||
|
|
||||||
|
MenuItem {
|
||||||
|
text: "Copy URL"
|
||||||
|
onTriggered: {
|
||||||
|
copyURLToClipboard(contextMenu.currentIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuItem {
|
||||||
|
text: "Rename"
|
||||||
|
onTriggered: {
|
||||||
|
renameFile(contextMenu.currentIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuItem {
|
||||||
|
text: "Delete"
|
||||||
|
onTriggered: {
|
||||||
|
deleteFile(contextMenu.currentIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HifiControls.Tree {
|
HifiControls.Tree {
|
||||||
id: treeView
|
id: treeView
|
||||||
height: 400
|
height: 400
|
||||||
|
@ -278,6 +315,28 @@ Window {
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
onClicked: {
|
||||||
|
print('here');
|
||||||
|
}
|
||||||
|
rowDelegate: Rectangle {
|
||||||
|
height: hifi.dimensions.tableRowHeight
|
||||||
|
color: styleData.selected
|
||||||
|
? hifi.colors.primaryHighlight
|
||||||
|
: treeView.isLightColorScheme
|
||||||
|
? (styleData.alternate ? hifi.colors.tableRowLightEven : hifi.colors.tableRowLightOdd)
|
||||||
|
: (styleData.alternate ? hifi.colors.tableRowDarkEven : hifi.colors.tableRowDarkOdd)
|
||||||
|
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
propagateComposedEvents: true
|
||||||
|
anchors.fill: parent
|
||||||
|
acceptedButtons: Qt.RightButton
|
||||||
|
onClicked: {
|
||||||
|
var index = treeView.indexAt(mouse.x, mouse.y);
|
||||||
|
contextMenu.currentIndex = index;
|
||||||
|
contextMenu.popup();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue