mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 09:33:36 +02:00
Merge pull request #2093 from ZappoMan/menu_js
Adds support for editing application Menus to JS
This commit is contained in:
commit
bf3b5c07d5
16 changed files with 732 additions and 90 deletions
|
@ -12,67 +12,67 @@
|
|||
var selectedVoxel = { x: 0, y: 0, z: 0, s: 0 };
|
||||
var selectedSize = 4;
|
||||
|
||||
function printKeyEvent(eventName, event) {
|
||||
print(eventName);
|
||||
print(" event.key=" + event.key);
|
||||
print(" event.text=" + event.text);
|
||||
print(" event.isShifted=" + event.isShifted);
|
||||
print(" event.isControl=" + event.isControl);
|
||||
print(" event.isMeta=" + event.isMeta);
|
||||
print(" event.isAlt=" + event.isAlt);
|
||||
print(" event.isKeypad=" + event.isKeypad);
|
||||
function setupMenus() {
|
||||
// hook up menus
|
||||
Menu.menuItemEvent.connect(menuItemEvent);
|
||||
|
||||
// delete the standard application menu item
|
||||
Menu.removeMenuItem("Edit", "Cut");
|
||||
Menu.removeMenuItem("Edit", "Copy");
|
||||
Menu.removeMenuItem("Edit", "Paste");
|
||||
Menu.removeMenuItem("Edit", "Delete");
|
||||
Menu.removeMenuItem("Edit", "Nudge");
|
||||
Menu.removeMenuItem("File", "Export Voxels");
|
||||
Menu.removeMenuItem("File", "Import Voxels");
|
||||
|
||||
// delete the standard application menu item
|
||||
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Cut", shortcutKey: "CTRL+X", afterItem: "Voxels" });
|
||||
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Copy", shortcutKey: "CTRL+C", afterItem: "Cut" });
|
||||
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Paste", shortcutKey: "CTRL+V", afterItem: "Copy" });
|
||||
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Nudge", shortcutKey: "CTRL+N", afterItem: "Paste" });
|
||||
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Delete", shortcutKeyEvent: { text: "backspace" }, afterItem: "Nudge" });
|
||||
Menu.addMenuItem({ menuName: "File", menuItemName: "Export Voxels", shortcutKey: "CTRL+E", afterItem: "Voxels" });
|
||||
Menu.addMenuItem({ menuName: "File", menuItemName: "Import Voxels", shortcutKey: "CTRL+I", afterItem: "Export Voxels" });
|
||||
}
|
||||
|
||||
|
||||
function keyPressEvent(event) {
|
||||
var debug = false;
|
||||
function menuItemEvent(menuItem) {
|
||||
var debug = true;
|
||||
if (debug) {
|
||||
printKeyEvent("keyPressEvent", event);
|
||||
}
|
||||
}
|
||||
|
||||
function keyReleaseEvent(event) {
|
||||
var debug = false;
|
||||
if (debug) {
|
||||
printKeyEvent("keyReleaseEvent", event);
|
||||
print("menuItemEvent " + menuItem);
|
||||
}
|
||||
|
||||
// Note: this sample uses Alt+ as the key codes for these clipboard items
|
||||
if ((event.key == 199 || event.key == 67 || event.text == "C" || event.text == "c") && event.isAlt) {
|
||||
print("the Alt+C key was pressed");
|
||||
if (menuItem == "Copy") {
|
||||
print("copying...");
|
||||
Clipboard.copyVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
if ((event.key == 8776 || event.key == 88 || event.text == "X" || event.text == "x") && event.isAlt) {
|
||||
print("the Alt+X key was pressed");
|
||||
if (menuItem == "Cut") {
|
||||
print("cutting...");
|
||||
Clipboard.cutVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
if ((event.key == 8730 || event.key == 86 || event.text == "V" || event.text == "v") && event.isAlt) {
|
||||
print("the Alt+V key was pressed");
|
||||
if (menuItem == "Paste") {
|
||||
print("pasting...");
|
||||
Clipboard.pasteVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
if (event.text == "DELETE" || event.text == "BACKSPACE") {
|
||||
print("the DELETE/BACKSPACE key was pressed");
|
||||
if (menuItem == "Delete") {
|
||||
print("deleting...");
|
||||
Clipboard.deleteVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
|
||||
if ((event.text == "E" || event.text == "e") && event.isMeta) {
|
||||
print("the Ctl+E key was pressed");
|
||||
if (menuItem == "Export Voxels") {
|
||||
print("export");
|
||||
Clipboard.exportVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
if ((event.text == "I" || event.text == "i") && event.isMeta) {
|
||||
print("the Ctl+I key was pressed");
|
||||
if (menuItem == "Import Voxels") {
|
||||
print("import");
|
||||
Clipboard.importVoxels();
|
||||
}
|
||||
if ((event.key == 78 || event.text == "N" || event.text == "n") && event.isMeta) {
|
||||
print("the Ctl+N key was pressed, nudging to left 1 meter");
|
||||
if (menuItem == "Nudge") {
|
||||
print("nudge");
|
||||
Clipboard.nudgeVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s, { x: -1, y: 0, z: 0 });
|
||||
}
|
||||
}
|
||||
|
||||
// Map keyPress and mouse move events to our callbacks
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||
|
||||
var selectCube = Overlays.addOverlay("cube", {
|
||||
position: { x: 0, y: 0, z: 0},
|
||||
size: selectedSize,
|
||||
|
@ -149,3 +149,5 @@ function scriptEnding() {
|
|||
}
|
||||
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
|
||||
setupMenus();
|
|
@ -164,7 +164,7 @@ for (s = 0; s < numColors; s++) {
|
|||
width: swatchWidth,
|
||||
height: swatchHeight,
|
||||
subImage: { x: imageFromX, y: imageFromY, width: (swatchWidth - 1), height: swatchHeight },
|
||||
imageURL: "http://highfidelity-public.s3-us-west-1.amazonaws.com/images/testing-swatches.svg",
|
||||
imageURL: "http://highfidelity-public.s3-us-west-1.amazonaws.com/images/swatches.svg",
|
||||
color: colors[s],
|
||||
alpha: 1,
|
||||
visible: editToolsOn
|
||||
|
@ -1012,43 +1012,78 @@ function keyReleaseEvent(event) {
|
|||
|
||||
// handle clipboard items
|
||||
if (selectToolSelected) {
|
||||
var pickRay = Camera.computePickRay(trackLastMouseX, trackLastMouseY);
|
||||
var intersection = Voxels.findRayIntersection(pickRay);
|
||||
selectedVoxel = calculateVoxelFromIntersection(intersection,"select");
|
||||
|
||||
// Note: this sample uses Alt+ as the key codes for these clipboard items
|
||||
if ((event.key == 199 || event.key == 67 || event.text == "C" || event.text == "c") && event.isAlt) {
|
||||
print("the Alt+C key was pressed... copy");
|
||||
Clipboard.copyVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
if ((event.key == 8776 || event.key == 88 || event.text == "X" || event.text == "x") && event.isAlt) {
|
||||
print("the Alt+X key was pressed... cut");
|
||||
Clipboard.cutVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
if ((event.key == 8730 || event.key == 86 || event.text == "V" || event.text == "v") && event.isAlt) {
|
||||
print("the Alt+V key was pressed... paste");
|
||||
Clipboard.pasteVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
if (event.text == "DELETE" || event.text == "BACKSPACE") {
|
||||
print("the DELETE/BACKSPACE key was pressed... delete");
|
||||
// menu tied to BACKSPACE, so we handle DELETE key here...
|
||||
if (event.text == "DELETE") {
|
||||
var pickRay = Camera.computePickRay(trackLastMouseX, trackLastMouseY);
|
||||
var intersection = Voxels.findRayIntersection(pickRay);
|
||||
selectedVoxel = calculateVoxelFromIntersection(intersection,"select");
|
||||
print("the DELETE key was pressed... delete");
|
||||
Clipboard.deleteVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
|
||||
if ((event.text == "E" || event.text == "e") && event.isMeta) {
|
||||
print("the Ctl+E key was pressed... export");
|
||||
Clipboard.exportVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
if ((event.text == "I" || event.text == "i") && event.isMeta) {
|
||||
print("the Ctl+I key was pressed... import");
|
||||
Clipboard.importVoxels();
|
||||
}
|
||||
if ((event.key == 78 || event.text == "N" || event.text == "n") && event.isMeta) {
|
||||
print("the Ctl+N key was pressed, nudging to left 1 meter... nudge");
|
||||
Clipboard.nudgeVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s, { x: -1, y: 0, z: 0 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setupMenus() {
|
||||
// hook up menus
|
||||
Menu.menuItemEvent.connect(menuItemEvent);
|
||||
|
||||
// delete the standard application menu item
|
||||
Menu.removeMenuItem("Edit", "Cut");
|
||||
Menu.removeMenuItem("Edit", "Copy");
|
||||
Menu.removeMenuItem("Edit", "Paste");
|
||||
Menu.removeMenuItem("Edit", "Delete");
|
||||
Menu.removeMenuItem("Edit", "Nudge");
|
||||
Menu.removeMenuItem("File", "Export Voxels");
|
||||
Menu.removeMenuItem("File", "Import Voxels");
|
||||
|
||||
// delete the standard application menu item
|
||||
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Cut", shortcutKey: "CTRL+X", afterItem: "Voxels" });
|
||||
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Copy", shortcutKey: "CTRL+C", afterItem: "Cut" });
|
||||
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Paste", shortcutKey: "CTRL+V", afterItem: "Copy" });
|
||||
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Nudge", shortcutKey: "CTRL+N", afterItem: "Paste" });
|
||||
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Delete", shortcutKeyEvent: { text: "backspace" }, afterItem: "Nudge" });
|
||||
Menu.addMenuItem({ menuName: "File", menuItemName: "Export Voxels", shortcutKey: "CTRL+E", afterItem: "Voxels" });
|
||||
Menu.addMenuItem({ menuName: "File", menuItemName: "Import Voxels", shortcutKey: "CTRL+I", afterItem: "Export Voxels" });
|
||||
}
|
||||
|
||||
function menuItemEvent(menuItem) {
|
||||
|
||||
// handle clipboard items
|
||||
if (selectToolSelected) {
|
||||
var pickRay = Camera.computePickRay(trackLastMouseX, trackLastMouseY);
|
||||
var intersection = Voxels.findRayIntersection(pickRay);
|
||||
selectedVoxel = calculateVoxelFromIntersection(intersection,"select");
|
||||
if (menuItem == "Copy") {
|
||||
print("copying...");
|
||||
Clipboard.copyVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
if (menuItem == "Cut") {
|
||||
print("cutting...");
|
||||
Clipboard.cutVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
if (menuItem == "Paste") {
|
||||
print("pasting...");
|
||||
Clipboard.pasteVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
if (menuItem == "Delete") {
|
||||
print("deleting...");
|
||||
Clipboard.deleteVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
|
||||
if (menuItem == "Export Voxels") {
|
||||
print("export");
|
||||
Clipboard.exportVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
if (menuItem == "Import Voxels") {
|
||||
print("import");
|
||||
Clipboard.importVoxels();
|
||||
}
|
||||
if (menuItem == "Nudge") {
|
||||
print("nudge");
|
||||
Clipboard.nudgeVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s, { x: -1, y: 0, z: 0 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mouseMoveEvent(event) {
|
||||
if (!editToolsOn) {
|
||||
|
@ -1403,8 +1438,6 @@ function scriptEnding() {
|
|||
}
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
|
||||
|
||||
Script.willSendVisualDataCallback.connect(update);
|
||||
|
||||
|
||||
|
||||
setupMenus();
|
||||
|
|
104
examples/menuExample.js
Normal file
104
examples/menuExample.js
Normal file
|
@ -0,0 +1,104 @@
|
|||
//
|
||||
// menuExample.js
|
||||
// hifi
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 2/24/14
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
//
|
||||
// This is an example script that demonstrates use of the Menu object
|
||||
//
|
||||
|
||||
|
||||
function setupMenus() {
|
||||
Menu.addMenu("Foo");
|
||||
Menu.addMenuItem("Foo","Foo item 1", "SHIFT+CTRL+F" );
|
||||
Menu.addMenuItem("Foo","Foo item 2", "SHIFT+F" );
|
||||
Menu.addMenuItem("Foo","Foo item 3", "META+F" );
|
||||
Menu.addMenuItem({
|
||||
menuName: "Foo",
|
||||
menuItemName: "Foo item 4",
|
||||
isCheckable: true,
|
||||
isChecked: true
|
||||
});
|
||||
|
||||
Menu.addMenuItem({
|
||||
menuName: "Foo",
|
||||
menuItemName: "Foo item 5",
|
||||
shortcutKey: "ALT+F",
|
||||
isCheckable: true
|
||||
});
|
||||
|
||||
|
||||
Menu.addSeparator("Foo","Removable Tools");
|
||||
Menu.addMenuItem("Foo","Remove Foo item 4");
|
||||
Menu.addMenuItem("Foo","Remove Foo");
|
||||
Menu.addMenu("Bar");
|
||||
|
||||
Menu.addMenuItem("Bar","Bar item 1", "b");
|
||||
Menu.addMenuItem({
|
||||
menuName: "Bar",
|
||||
menuItemName: "Bar item 2",
|
||||
shortcutKeyEvent: { text: "B", isControl: true }
|
||||
});
|
||||
|
||||
Menu.addMenu("Bar > Spam");
|
||||
Menu.addMenuItem("Bar > Spam","Spam item 1");
|
||||
Menu.addMenuItem({
|
||||
menuName: "Bar > Spam",
|
||||
menuItemName: "Spam item 2",
|
||||
isCheckable: true,
|
||||
isChecked: false
|
||||
});
|
||||
|
||||
Menu.addSeparator("Bar > Spam","Other Items");
|
||||
Menu.addMenuItem("Bar > Spam","Remove Spam item 2");
|
||||
Menu.addMenuItem("Foo","Remove Spam item 2");
|
||||
|
||||
Menu.addMenuItem({
|
||||
menuName: "Foo",
|
||||
menuItemName: "Remove Spam item 2"
|
||||
});
|
||||
|
||||
Menu.addMenuItem({
|
||||
menuName: "Edit",
|
||||
menuItemName: "before Cut",
|
||||
beforeItem: "Cut"
|
||||
});
|
||||
|
||||
Menu.addMenuItem({
|
||||
menuName: "Edit",
|
||||
menuItemName: "after Nudge",
|
||||
afterItem: "Nudge"
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function scriptEnding() {
|
||||
print("SCRIPT ENDNG!!!\n");
|
||||
|
||||
Menu.removeMenu("Foo");
|
||||
Menu.removeMenu("Bar");
|
||||
}
|
||||
|
||||
function menuItemEvent(menuItem) {
|
||||
print("menuItemEvent() in JS... menuItem=" + menuItem);
|
||||
if (menuItem == "Foo item 4") {
|
||||
print(" checked=" + Menu.isOptionChecked("Foo item 4"));
|
||||
}
|
||||
if (menuItem == "Remove Foo item 4") {
|
||||
Menu.removeMenuItem("Foo", "Foo item 4");
|
||||
}
|
||||
if (menuItem == "Remove Foo") {
|
||||
Menu.removeMenu("Foo");
|
||||
}
|
||||
if (menuItem == "Remove Spam item 2") {
|
||||
Menu.removeMenuItem("Bar > Spam", "Spam item 2");
|
||||
}
|
||||
}
|
||||
|
||||
setupMenus();
|
||||
|
||||
// register our scriptEnding callback
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
|
||||
Menu.menuItemEvent.connect(menuItemEvent);
|
|
@ -65,6 +65,7 @@
|
|||
#include "ClipboardScriptingInterface.h"
|
||||
#include "InterfaceVersion.h"
|
||||
#include "Menu.h"
|
||||
#include "MenuScriptingInterface.h"
|
||||
#include "Swatch.h"
|
||||
#include "Util.h"
|
||||
#include "devices/OculusManager.h"
|
||||
|
@ -4290,6 +4291,7 @@ void Application::loadScript(const QString& fileNameString) {
|
|||
connect(scriptEngine, SIGNAL(finished(const QString&)), clipboardScriptable, SLOT(deleteLater()));
|
||||
|
||||
scriptEngine->registerGlobalObject("Overlays", &_overlays);
|
||||
scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
|
||||
|
||||
QThread* workerThread = new QThread(this);
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "DatagramProcessor.h"
|
||||
#include "Environment.h"
|
||||
#include "GLCanvas.h"
|
||||
#include "Menu.h"
|
||||
#include "MetavoxelSystem.h"
|
||||
#include "PacketHeaders.h"
|
||||
#include "PieMenu.h"
|
||||
|
|
|
@ -70,8 +70,8 @@ void ClipboardScriptingInterface::exportVoxel(float x, float y, float z, float s
|
|||
z / (float)TREE_SCALE,
|
||||
s / (float)TREE_SCALE };
|
||||
|
||||
// TODO: should we be calling invokeMethod() in all these cases?
|
||||
Application::getInstance()->exportVoxels(sourceVoxel);
|
||||
QMetaObject::invokeMethod(Application::getInstance(), "exportVoxels",
|
||||
Q_ARG(const VoxelDetail&, sourceVoxel));
|
||||
}
|
||||
|
||||
void ClipboardScriptingInterface::importVoxels() {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <QLineEdit>
|
||||
#include <QMainWindow>
|
||||
#include <QMenuBar>
|
||||
#include <QShortcut>
|
||||
#include <QSlider>
|
||||
#include <QStandardPaths>
|
||||
#include <QUuid>
|
||||
|
@ -29,6 +30,7 @@
|
|||
|
||||
#include "Application.h"
|
||||
#include "Menu.h"
|
||||
#include "MenuScriptingInterface.h"
|
||||
#include "Util.h"
|
||||
#include "InfoView.h"
|
||||
#include "ui/MetavoxelEditor.h"
|
||||
|
@ -171,7 +173,7 @@ Menu::Menu() :
|
|||
addCheckableActionToQMenuAndActionHash(editMenu, MenuOption::ClickToFly);
|
||||
|
||||
addAvatarCollisionSubMenu(editMenu);
|
||||
|
||||
|
||||
QMenu* toolsMenu = addMenu("Tools");
|
||||
|
||||
_voxelModeActionsGroup = new QActionGroup(this);
|
||||
|
@ -496,7 +498,6 @@ Menu::Menu() :
|
|||
QAction* helpAction = helpMenu->addAction(MenuOption::AboutApp);
|
||||
connect(helpAction, SIGNAL(triggered()), this, SLOT(aboutApp()));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
Menu::~Menu() {
|
||||
|
@ -682,14 +683,30 @@ QAction* Menu::addActionToQMenuAndActionHash(QMenu* destinationMenu,
|
|||
const QKeySequence& shortcut,
|
||||
const QObject* receiver,
|
||||
const char* member,
|
||||
QAction::MenuRole role) {
|
||||
QAction* action;
|
||||
QAction::MenuRole role,
|
||||
int menuItemLocation) {
|
||||
QAction* action = NULL;
|
||||
QAction* actionBefore = NULL;
|
||||
|
||||
if (receiver && member) {
|
||||
action = destinationMenu->addAction(actionName, receiver, member, shortcut);
|
||||
if (menuItemLocation >= 0 && destinationMenu->actions().size() > menuItemLocation) {
|
||||
actionBefore = destinationMenu->actions()[menuItemLocation];
|
||||
}
|
||||
|
||||
if (!actionBefore) {
|
||||
if (receiver && member) {
|
||||
action = destinationMenu->addAction(actionName, receiver, member, shortcut);
|
||||
} else {
|
||||
action = destinationMenu->addAction(actionName);
|
||||
action->setShortcut(shortcut);
|
||||
}
|
||||
} else {
|
||||
action = destinationMenu->addAction(actionName);
|
||||
action = new QAction(actionName, destinationMenu);
|
||||
action->setShortcut(shortcut);
|
||||
destinationMenu->insertAction(actionBefore, action);
|
||||
|
||||
if (receiver && member) {
|
||||
connect(action, SIGNAL(triggered()), receiver, member);
|
||||
}
|
||||
}
|
||||
action->setMenuRole(role);
|
||||
|
||||
|
@ -703,8 +720,11 @@ QAction* Menu::addCheckableActionToQMenuAndActionHash(QMenu* destinationMenu,
|
|||
const QKeySequence& shortcut,
|
||||
const bool checked,
|
||||
const QObject* receiver,
|
||||
const char* member) {
|
||||
QAction* action = addActionToQMenuAndActionHash(destinationMenu, actionName, shortcut, receiver, member);
|
||||
const char* member,
|
||||
int menuItemLocation) {
|
||||
|
||||
QAction* action = addActionToQMenuAndActionHash(destinationMenu, actionName, shortcut, receiver, member,
|
||||
QAction::NoRole, menuItemLocation);
|
||||
action->setCheckable(true);
|
||||
action->setChecked(checked);
|
||||
|
||||
|
@ -1148,7 +1168,6 @@ void Menu::showMetavoxelEditor() {
|
|||
_MetavoxelEditor = new MetavoxelEditor();
|
||||
}
|
||||
_MetavoxelEditor->raise();
|
||||
_MetavoxelEditor->activateWindow();
|
||||
}
|
||||
|
||||
void Menu::audioMuteToggled() {
|
||||
|
@ -1319,3 +1338,174 @@ QString Menu::replaceLastOccurrence(QChar search, QChar replace, QString string)
|
|||
|
||||
return string;
|
||||
}
|
||||
|
||||
QAction* Menu::getActionFromName(const QString& menuName, QMenu* menu) {
|
||||
QList<QAction*> menuActions;
|
||||
if (menu) {
|
||||
menuActions = menu->actions();
|
||||
} else {
|
||||
menuActions = actions();
|
||||
}
|
||||
|
||||
foreach (QAction* menuAction, menuActions) {
|
||||
if (menuName == menuAction->text()) {
|
||||
return menuAction;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QMenu* Menu::getSubMenuFromName(const QString& menuName, QMenu* menu) {
|
||||
QAction* action = getActionFromName(menuName, menu);
|
||||
if (action) {
|
||||
return action->menu();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QMenu* Menu::getMenuParent(const QString& menuName, QString& finalMenuPart) {
|
||||
QStringList menuTree = menuName.split(">");
|
||||
QMenu* parent = NULL;
|
||||
QMenu* menu = NULL;
|
||||
foreach (QString menuTreePart, menuTree) {
|
||||
parent = menu;
|
||||
finalMenuPart = menuTreePart.trimmed();
|
||||
menu = getSubMenuFromName(finalMenuPart, parent);
|
||||
if (!menu) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
QMenu* Menu::getMenu(const QString& menuName) {
|
||||
QStringList menuTree = menuName.split(">");
|
||||
QMenu* parent = NULL;
|
||||
QMenu* menu = NULL;
|
||||
int item = 0;
|
||||
foreach (QString menuTreePart, menuTree) {
|
||||
menu = getSubMenuFromName(menuTreePart.trimmed(), parent);
|
||||
if (!menu) {
|
||||
break;
|
||||
}
|
||||
parent = menu;
|
||||
item++;
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
|
||||
QAction* Menu::getMenuAction(const QString& menuName) {
|
||||
QStringList menuTree = menuName.split(">");
|
||||
QMenu* parent = NULL;
|
||||
QAction* action = NULL;
|
||||
foreach (QString menuTreePart, menuTree) {
|
||||
action = getActionFromName(menuTreePart.trimmed(), parent);
|
||||
if (!action) {
|
||||
break;
|
||||
}
|
||||
parent = action->menu();
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
int Menu::findPositionOfMenuItem(QMenu* menu, const QString& searchMenuItem) {
|
||||
int position = 0;
|
||||
foreach(QAction* action, menu->actions()) {
|
||||
if (action->text() == searchMenuItem) {
|
||||
return position;
|
||||
}
|
||||
position++;
|
||||
}
|
||||
return UNSPECIFIED_POSITION; // not found
|
||||
}
|
||||
|
||||
QMenu* Menu::addMenu(const QString& menuName) {
|
||||
QStringList menuTree = menuName.split(">");
|
||||
QMenu* addTo = NULL;
|
||||
QMenu* menu = NULL;
|
||||
foreach (QString menuTreePart, menuTree) {
|
||||
menu = getSubMenuFromName(menuTreePart.trimmed(), addTo);
|
||||
if (!menu) {
|
||||
if (!addTo) {
|
||||
menu = QMenuBar::addMenu(menuTreePart.trimmed());
|
||||
} else {
|
||||
menu = addTo->addMenu(menuTreePart.trimmed());
|
||||
}
|
||||
}
|
||||
addTo = menu;
|
||||
}
|
||||
|
||||
QMenuBar::repaint();
|
||||
return menu;
|
||||
}
|
||||
|
||||
void Menu::removeMenu(const QString& menuName) {
|
||||
QAction* action = getMenuAction(menuName);
|
||||
|
||||
// only proceed if the menu actually exists
|
||||
if (action) {
|
||||
QString finalMenuPart;
|
||||
QMenu* parent = getMenuParent(menuName, finalMenuPart);
|
||||
|
||||
if (parent) {
|
||||
removeAction(parent, finalMenuPart);
|
||||
} else {
|
||||
QMenuBar::removeAction(action);
|
||||
}
|
||||
|
||||
QMenuBar::repaint();
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::addSeparator(const QString& menuName, const QString& separatorName) {
|
||||
QMenu* menuObj = getMenu(menuName);
|
||||
if (menuObj) {
|
||||
addDisabledActionAndSeparator(menuObj, separatorName);
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::addMenuItem(const MenuItemProperties& properties) {
|
||||
QMenu* menuObj = getMenu(properties.menuName);
|
||||
if (menuObj) {
|
||||
QShortcut* shortcut = NULL;
|
||||
if (!properties.shortcutKeySequence.isEmpty()) {
|
||||
shortcut = new QShortcut(properties.shortcutKeySequence, this);
|
||||
}
|
||||
|
||||
// check for positioning requests
|
||||
int requestedPosition = properties.position;
|
||||
if (requestedPosition == UNSPECIFIED_POSITION && !properties.beforeItem.isEmpty()) {
|
||||
requestedPosition = findPositionOfMenuItem(menuObj, properties.beforeItem);
|
||||
}
|
||||
if (requestedPosition == UNSPECIFIED_POSITION && !properties.afterItem.isEmpty()) {
|
||||
int afterPosition = findPositionOfMenuItem(menuObj, properties.afterItem);
|
||||
if (afterPosition != UNSPECIFIED_POSITION) {
|
||||
requestedPosition = afterPosition + 1;
|
||||
}
|
||||
}
|
||||
|
||||
QAction* menuItemAction;
|
||||
if (properties.isCheckable) {
|
||||
menuItemAction = addCheckableActionToQMenuAndActionHash(menuObj, properties.menuItemName,
|
||||
properties.shortcutKeySequence, properties.isChecked,
|
||||
MenuScriptingInterface::getInstance(), SLOT(menuItemTriggered()), requestedPosition);
|
||||
} else {
|
||||
menuItemAction = addActionToQMenuAndActionHash(menuObj, properties.menuItemName, properties.shortcutKeySequence,
|
||||
MenuScriptingInterface::getInstance(), SLOT(menuItemTriggered()),
|
||||
QAction::NoRole, requestedPosition);
|
||||
}
|
||||
if (shortcut) {
|
||||
connect(shortcut, SIGNAL(activated()), menuItemAction, SLOT(trigger()));
|
||||
}
|
||||
QMenuBar::repaint();
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::removeMenuItem(const QString& menu, const QString& menuitem) {
|
||||
QMenu* menuObj = getMenu(menu);
|
||||
if (menuObj) {
|
||||
removeAction(menuObj, menuitem);
|
||||
}
|
||||
QMenuBar::repaint();
|
||||
};
|
||||
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
#include <QPointer>
|
||||
|
||||
#include <AbstractMenuInterface.h>
|
||||
#include <EventTypes.h>
|
||||
#include <MenuItemProperties.h>
|
||||
#include <OctreeConstants.h>
|
||||
|
||||
const float ADJUST_LOD_DOWN_FPS = 40.0;
|
||||
const float ADJUST_LOD_UP_FPS = 55.0;
|
||||
|
@ -52,6 +55,7 @@ class BandwidthDialog;
|
|||
class LodToolsDialog;
|
||||
class MetavoxelEditor;
|
||||
class VoxelStatsDialog;
|
||||
class MenuItemProperties;
|
||||
|
||||
class Menu : public QMenuBar, public AbstractMenuInterface {
|
||||
Q_OBJECT
|
||||
|
@ -94,7 +98,8 @@ public:
|
|||
const QKeySequence& shortcut = 0,
|
||||
const QObject* receiver = NULL,
|
||||
const char* member = NULL,
|
||||
QAction::MenuRole role = QAction::NoRole);
|
||||
QAction::MenuRole role = QAction::NoRole,
|
||||
int menuItemLocation = UNSPECIFIED_POSITION);
|
||||
virtual void removeAction(QMenu* menu, const QString& actionName);
|
||||
bool goToDestination(QString destination);
|
||||
void goToOrientation(QString orientation);
|
||||
|
@ -114,6 +119,12 @@ public slots:
|
|||
|
||||
void toggleLoginMenuItem();
|
||||
|
||||
QMenu* addMenu(const QString& menuName);
|
||||
void removeMenu(const QString& menuName);
|
||||
void addSeparator(const QString& menuName, const QString& separatorName);
|
||||
void addMenuItem(const MenuItemProperties& properties);
|
||||
void removeMenuItem(const QString& menuName, const QString& menuitem);
|
||||
|
||||
private slots:
|
||||
void aboutApp();
|
||||
void editPreferences();
|
||||
|
@ -149,12 +160,22 @@ private:
|
|||
const QKeySequence& shortcut = 0,
|
||||
const bool checked = false,
|
||||
const QObject* receiver = NULL,
|
||||
const char* member = NULL);
|
||||
const char* member = NULL,
|
||||
int menuItemLocation = UNSPECIFIED_POSITION);
|
||||
|
||||
void updateFrustumRenderModeAction();
|
||||
|
||||
void addAvatarCollisionSubMenu(QMenu* overMenu);
|
||||
|
||||
QAction* getActionFromName(const QString& menuName, QMenu* menu);
|
||||
QMenu* getSubMenuFromName(const QString& menuName, QMenu* menu);
|
||||
QMenu* getMenuParent(const QString& menuName, QString& finalMenuPart);
|
||||
|
||||
QAction* getMenuAction(const QString& menuName);
|
||||
int findPositionOfMenuItem(QMenu* menu, const QString& searchMenuItem);
|
||||
QMenu* getMenu(const QString& menuName);
|
||||
|
||||
|
||||
QHash<QString, QAction*> _actionHash;
|
||||
int _audioJitterBufferSamples; /// number of extra samples to wait before starting audio playback
|
||||
BandwidthDialog* _bandwidthDialog;
|
||||
|
|
67
interface/src/MenuScriptingInterface.cpp
Normal file
67
interface/src/MenuScriptingInterface.cpp
Normal file
|
@ -0,0 +1,67 @@
|
|||
//
|
||||
// MenuScriptingInterface.cpp
|
||||
// hifi
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 2/25/14
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
#include "MenuScriptingInterface.h"
|
||||
|
||||
|
||||
MenuScriptingInterface* MenuScriptingInterface::getInstance() {
|
||||
static MenuScriptingInterface sharedInstance;
|
||||
return &sharedInstance;
|
||||
}
|
||||
|
||||
void MenuScriptingInterface::menuItemTriggered() {
|
||||
QAction* menuItemAction = dynamic_cast<QAction*>(sender());
|
||||
if (menuItemAction) {
|
||||
// emit the event
|
||||
emit menuItemEvent(menuItemAction->text());
|
||||
}
|
||||
}
|
||||
|
||||
void MenuScriptingInterface::addMenu(const QString& menu) {
|
||||
QMetaObject::invokeMethod(Menu::getInstance(), "addMenu", Q_ARG(const QString&, menu));
|
||||
}
|
||||
|
||||
void MenuScriptingInterface::removeMenu(const QString& menu) {
|
||||
QMetaObject::invokeMethod(Menu::getInstance(), "removeMenu", Q_ARG(const QString&, menu));
|
||||
}
|
||||
|
||||
void MenuScriptingInterface::addSeparator(const QString& menuName, const QString& separatorName) {
|
||||
QMetaObject::invokeMethod(Menu::getInstance(), "addSeparator",
|
||||
Q_ARG(const QString&, menuName),
|
||||
Q_ARG(const QString&, separatorName));
|
||||
}
|
||||
|
||||
void MenuScriptingInterface::addMenuItem(const MenuItemProperties& properties) {
|
||||
QMetaObject::invokeMethod(Menu::getInstance(), "addMenuItem", Q_ARG(const MenuItemProperties&, properties));
|
||||
}
|
||||
|
||||
void MenuScriptingInterface::addMenuItem(const QString& menu, const QString& menuitem, const QString& shortcutKey) {
|
||||
MenuItemProperties properties(menu, menuitem, shortcutKey);
|
||||
QMetaObject::invokeMethod(Menu::getInstance(), "addMenuItem", Q_ARG(const MenuItemProperties&, properties));
|
||||
}
|
||||
|
||||
void MenuScriptingInterface::addMenuItem(const QString& menu, const QString& menuitem) {
|
||||
MenuItemProperties properties(menu, menuitem);
|
||||
QMetaObject::invokeMethod(Menu::getInstance(), "addMenuItem", Q_ARG(const MenuItemProperties&, properties));
|
||||
}
|
||||
|
||||
void MenuScriptingInterface::removeMenuItem(const QString& menu, const QString& menuitem) {
|
||||
QMetaObject::invokeMethod(Menu::getInstance(), "removeMenuItem",
|
||||
Q_ARG(const QString&, menu),
|
||||
Q_ARG(const QString&, menuitem));
|
||||
};
|
||||
|
||||
bool MenuScriptingInterface::isOptionChecked(const QString& menuOption) {
|
||||
return Menu::getInstance()->isOptionChecked(menuOption);
|
||||
}
|
||||
|
||||
void MenuScriptingInterface::setIsOptionChecked(const QString& menuOption, bool isChecked) {
|
||||
return Menu::getInstance()->setIsOptionChecked(menuOption, isChecked);
|
||||
}
|
49
interface/src/MenuScriptingInterface.h
Normal file
49
interface/src/MenuScriptingInterface.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
//
|
||||
// MenuScriptingInterface.h
|
||||
// hifi
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 2/25/14
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef __hifi__MenuScriptingInterface__
|
||||
#define __hifi__MenuScriptingInterface__
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "Menu.h"
|
||||
#include <MenuItemProperties.h>
|
||||
|
||||
class MenuScriptingInterface : public QObject {
|
||||
Q_OBJECT
|
||||
MenuScriptingInterface() { };
|
||||
public:
|
||||
static MenuScriptingInterface* getInstance();
|
||||
|
||||
private slots:
|
||||
friend class Menu;
|
||||
void menuItemTriggered();
|
||||
|
||||
public slots:
|
||||
void addMenu(const QString& menuName);
|
||||
void removeMenu(const QString& menuName);
|
||||
|
||||
void addSeparator(const QString& menuName, const QString& separatorName);
|
||||
|
||||
void addMenuItem(const MenuItemProperties& properties);
|
||||
void addMenuItem(const QString& menuName, const QString& menuitem, const QString& shortcutKey);
|
||||
void addMenuItem(const QString& menuName, const QString& menuitem);
|
||||
|
||||
void removeMenuItem(const QString& menuName, const QString& menuitem);
|
||||
|
||||
bool isOptionChecked(const QString& menuOption);
|
||||
void setIsOptionChecked(const QString& menuOption, bool isChecked);
|
||||
|
||||
signals:
|
||||
void menuItemEvent(const QString& menuItem);
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__MenuScriptingInterface__) */
|
|
@ -126,6 +126,30 @@ bool KeyEvent::operator==(const KeyEvent& other) const {
|
|||
&& other.isKeypad == isKeypad;
|
||||
}
|
||||
|
||||
|
||||
KeyEvent::operator QKeySequence() const {
|
||||
int resultCode = 0;
|
||||
if (text.size() == 1 && text >= "a" && text <= "z") {
|
||||
resultCode = text.toUpper().at(0).unicode();
|
||||
} else {
|
||||
resultCode = key;
|
||||
}
|
||||
|
||||
if (isMeta) {
|
||||
resultCode |= Qt::META;
|
||||
}
|
||||
if (isAlt) {
|
||||
resultCode |= Qt::ALT;
|
||||
}
|
||||
if (isControl) {
|
||||
resultCode |= Qt::CTRL;
|
||||
}
|
||||
if (isShifted) {
|
||||
resultCode |= Qt::SHIFT;
|
||||
}
|
||||
return QKeySequence(resultCode);
|
||||
}
|
||||
|
||||
QScriptValue keyEventToScriptValue(QScriptEngine* engine, const KeyEvent& event) {
|
||||
QScriptValue obj = engine->newObject();
|
||||
obj.setProperty("key", event.key);
|
||||
|
|
|
@ -24,6 +24,8 @@ public:
|
|||
KeyEvent();
|
||||
KeyEvent(const QKeyEvent& event);
|
||||
bool operator==(const KeyEvent& other) const;
|
||||
operator QKeySequence() const;
|
||||
|
||||
int key;
|
||||
QString text;
|
||||
bool isShifted;
|
||||
|
|
95
libraries/script-engine/src/MenuItemProperties.cpp
Normal file
95
libraries/script-engine/src/MenuItemProperties.cpp
Normal file
|
@ -0,0 +1,95 @@
|
|||
//
|
||||
// MenuItemProperties.cpp
|
||||
// hifi
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 1/28/14.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
//
|
||||
// Used to register meta-types with Qt for very various event types so that they can be exposed to our
|
||||
// scripting engine
|
||||
|
||||
#include <QDebug>
|
||||
#include <RegisteredMetaTypes.h>
|
||||
#include "MenuItemProperties.h"
|
||||
|
||||
MenuItemProperties::MenuItemProperties() :
|
||||
menuName(""),
|
||||
menuItemName(""),
|
||||
shortcutKey(""),
|
||||
shortcutKeyEvent(),
|
||||
shortcutKeySequence(),
|
||||
position(UNSPECIFIED_POSITION),
|
||||
beforeItem(""),
|
||||
afterItem(""),
|
||||
isCheckable(false),
|
||||
isChecked(false)
|
||||
{
|
||||
};
|
||||
|
||||
MenuItemProperties::MenuItemProperties(const QString& menuName, const QString& menuItemName,
|
||||
const QString& shortcutKey, bool checkable, bool checked) :
|
||||
menuName(menuName),
|
||||
menuItemName(menuItemName),
|
||||
shortcutKey(shortcutKey),
|
||||
shortcutKeyEvent(),
|
||||
shortcutKeySequence(shortcutKey),
|
||||
position(UNSPECIFIED_POSITION),
|
||||
beforeItem(""),
|
||||
afterItem(""),
|
||||
isCheckable(checkable),
|
||||
isChecked(checked)
|
||||
{
|
||||
}
|
||||
|
||||
MenuItemProperties::MenuItemProperties(const QString& menuName, const QString& menuItemName,
|
||||
const KeyEvent& shortcutKeyEvent, bool checkable, bool checked) :
|
||||
menuName(menuName),
|
||||
menuItemName(menuItemName),
|
||||
shortcutKey(""),
|
||||
shortcutKeyEvent(shortcutKeyEvent),
|
||||
shortcutKeySequence(shortcutKeyEvent),
|
||||
position(UNSPECIFIED_POSITION),
|
||||
beforeItem(""),
|
||||
afterItem(""),
|
||||
isCheckable(checkable),
|
||||
isChecked(checked)
|
||||
{
|
||||
}
|
||||
|
||||
void registerMenuItemProperties(QScriptEngine* engine) {
|
||||
qScriptRegisterMetaType(engine, menuItemPropertiesToScriptValue, menuItemPropertiesFromScriptValue);
|
||||
}
|
||||
|
||||
QScriptValue menuItemPropertiesToScriptValue(QScriptEngine* engine, const MenuItemProperties& properties) {
|
||||
QScriptValue obj = engine->newObject();
|
||||
// not supported
|
||||
return obj;
|
||||
}
|
||||
|
||||
void menuItemPropertiesFromScriptValue(const QScriptValue& object, MenuItemProperties& properties) {
|
||||
properties.menuName = object.property("menuName").toVariant().toString();
|
||||
properties.menuItemName = object.property("menuItemName").toVariant().toString();
|
||||
properties.isCheckable = object.property("isCheckable").toVariant().toBool();
|
||||
properties.isChecked = object.property("isChecked").toVariant().toBool();
|
||||
|
||||
// handle the shortcut key options in order...
|
||||
QScriptValue shortcutKeyValue = object.property("shortcutKey");
|
||||
if (shortcutKeyValue.isValid()) {
|
||||
properties.shortcutKey = shortcutKeyValue.toVariant().toString();
|
||||
properties.shortcutKeySequence = properties.shortcutKey;
|
||||
} else {
|
||||
QScriptValue shortcutKeyEventValue = object.property("shortcutKeyEvent");
|
||||
if (shortcutKeyEventValue.isValid()) {
|
||||
keyEventFromScriptValue(shortcutKeyEventValue, properties.shortcutKeyEvent);
|
||||
properties.shortcutKeySequence = properties.shortcutKeyEvent;
|
||||
}
|
||||
}
|
||||
|
||||
if (object.property("position").isValid()) {
|
||||
properties.position = object.property("position").toVariant().toInt();
|
||||
}
|
||||
properties.beforeItem = object.property("beforeItem").toVariant().toString();
|
||||
properties.afterItem = object.property("afterItem").toVariant().toString();
|
||||
}
|
||||
|
||||
|
50
libraries/script-engine/src/MenuItemProperties.h
Normal file
50
libraries/script-engine/src/MenuItemProperties.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
//
|
||||
// MenuItemProperties.h
|
||||
// hifi
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 1/28/14.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef __hifi_MenuItemProperties_h__
|
||||
#define __hifi_MenuItemProperties_h__
|
||||
|
||||
#include <QtScript/QScriptEngine>
|
||||
|
||||
#include "EventTypes.h"
|
||||
|
||||
const int UNSPECIFIED_POSITION = -1;
|
||||
|
||||
class MenuItemProperties {
|
||||
public:
|
||||
MenuItemProperties();
|
||||
MenuItemProperties(const QString& menuName, const QString& menuItemName,
|
||||
const QString& shortcutKey = QString(""), bool checkable = false, bool checked = false);
|
||||
MenuItemProperties(const QString& menuName, const QString& menuItemName,
|
||||
const KeyEvent& shortcutKeyEvent, bool checkable = false, bool checked = false);
|
||||
|
||||
QString menuName;
|
||||
QString menuItemName;
|
||||
|
||||
// Shortcut key items: in order of priority
|
||||
QString shortcutKey;
|
||||
KeyEvent shortcutKeyEvent;
|
||||
QKeySequence shortcutKeySequence; // this is what we actually use, it's set from one of the above
|
||||
|
||||
// location related items: in order of priority
|
||||
int position;
|
||||
QString beforeItem;
|
||||
QString afterItem;
|
||||
|
||||
// other properties
|
||||
bool isCheckable;
|
||||
bool isChecked;
|
||||
};
|
||||
Q_DECLARE_METATYPE(MenuItemProperties)
|
||||
QScriptValue menuItemPropertiesToScriptValue(QScriptEngine* engine, const MenuItemProperties& props);
|
||||
void menuItemPropertiesFromScriptValue(const QScriptValue& object, MenuItemProperties& props);
|
||||
void registerMenuItemProperties(QScriptEngine* engine);
|
||||
|
||||
|
||||
|
||||
#endif // __hifi_MenuItemProperties_h__
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <Sound.h>
|
||||
|
||||
#include "MenuItemProperties.h"
|
||||
#include "ScriptEngine.h"
|
||||
|
||||
const unsigned int VISUAL_DATA_CALLBACK_USECS = (1.0 / 60.0) * 1000 * 1000;
|
||||
|
@ -140,8 +141,8 @@ void ScriptEngine::init() {
|
|||
// register various meta-types
|
||||
registerMetaTypes(&_engine);
|
||||
registerVoxelMetaTypes(&_engine);
|
||||
//registerParticleMetaTypes(&_engine);
|
||||
registerEventTypes(&_engine);
|
||||
registerMenuItemProperties(&_engine);
|
||||
|
||||
qScriptRegisterMetaType(&_engine, ParticlePropertiesToScriptValue, ParticlePropertiesFromScriptValue);
|
||||
qScriptRegisterMetaType(&_engine, ParticleIDtoScriptValue, ParticleIDfromScriptValue);
|
||||
|
|
|
@ -25,7 +25,8 @@ public:
|
|||
const QKeySequence& shortcut = 0,
|
||||
const QObject* receiver = NULL,
|
||||
const char* member = NULL,
|
||||
QAction::MenuRole role = QAction::NoRole) = 0;
|
||||
QAction::MenuRole role = QAction::NoRole,
|
||||
int menuItemLocation = -1) = 0;
|
||||
virtual void removeAction(QMenu* menu, const QString& actionName) = 0;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue