Showing the changes to interface/src/Menu.cpp (1 of 595 files). Show all
Unified · Split
| @@ -162,6 +162,7 @@ Menu::Menu() : · 161 unmodified lines | |||
| 162 | 162 | ||
| 163 | QMenu* toolsMenu = addMenu("Tools"); | 163 | QMenu* toolsMenu = addMenu("Tools"); |
| 164 | addActionToQMenuAndActionHash(toolsMenu, MenuOption::MetavoxelEditor, 0, this, SLOT(showMetavoxelEditor())); | 164 | addActionToQMenuAndActionHash(toolsMenu, MenuOption::MetavoxelEditor, 0, this, SLOT(showMetavoxelEditor())); |
| 165 | addActionToQMenuAndActionHash(toolsMenu, MenuOption::FstUploader, 0, Application::getInstance(), SLOT(uploadFST())); | ||
| 165 | 166 | ||
| 166 | 167 | ||
| 167 | QMenu* viewMenu = addMenu("View"); | 168 | QMenu* viewMenu = addMenu("View"); |
| @@ -274,7 +275,6 @@ Menu::Menu() : · 106 unmodified lines | |||
| 274 | SLOT(setFilter(bool))); | 275 | SLOT(setFilter(bool))); |
| 275 | addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHands, 0, true); | 276 | addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHands, 0, true); |
| 276 | addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHandTargets, 0, false); | 277 | addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHandTargets, 0, false); |
| 277 | addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::VoxelDrumming, 0, false); | ||
| 278 | addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::PlaySlaps, 0, false); | 278 | addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::PlaySlaps, 0, false); |
| 279 | addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::HandsCollideWithSelf, 0, false); | 279 | addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::HandsCollideWithSelf, 0, false); |
| 280 | 280 | ||
| @@ -284,11 +284,6 @@ Menu::Menu() : · 3 unmodified lines | |||
| 284 | addCheckableActionToQMenuAndActionHash(timingMenu, MenuOption::TestPing, 0, true); | 284 | addCheckableActionToQMenuAndActionHash(timingMenu, MenuOption::TestPing, 0, true); |
| 285 | addCheckableActionToQMenuAndActionHash(timingMenu, MenuOption::FrameTimer); | 285 | addCheckableActionToQMenuAndActionHash(timingMenu, MenuOption::FrameTimer); |
| 286 | addActionToQMenuAndActionHash(timingMenu, MenuOption::RunTimingTests, 0, this, SLOT(runTests())); | 286 | addActionToQMenuAndActionHash(timingMenu, MenuOption::RunTimingTests, 0, this, SLOT(runTests())); |
| 287 | addActionToQMenuAndActionHash(timingMenu, | ||
| 288 | MenuOption::TreeStats, | ||
| 289 | Qt::SHIFT | Qt::Key_S, | ||
| 290 | appInstance->getVoxels(), | ||
| 291 | SLOT(collectStatsForTreesAndVBOs())); | ||
| 292 | 287 | ||
| 293 | QMenu* frustumMenu = developerMenu->addMenu("View Frustum Debugging Tools"); | 288 | QMenu* frustumMenu = developerMenu->addMenu("View Frustum Debugging Tools"); |
| 294 | addCheckableActionToQMenuAndActionHash(frustumMenu, MenuOption::DisplayFrustum, Qt::SHIFT | Qt::Key_F); | 289 | addCheckableActionToQMenuAndActionHash(frustumMenu, MenuOption::DisplayFrustum, Qt::SHIFT | Qt::Key_F); |
| @@ -304,62 +299,6 @@ Menu::Menu() : · 9 unmodified lines | |||
| 304 | addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::PipelineWarnings, Qt::CTRL | Qt::SHIFT | Qt::Key_P); | 299 | addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::PipelineWarnings, Qt::CTRL | Qt::SHIFT | Qt::Key_P); |
| 305 | addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::SuppressShortTimings, Qt::CTRL | Qt::SHIFT | Qt::Key_S); | 300 | addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::SuppressShortTimings, Qt::CTRL | Qt::SHIFT | Qt::Key_S); |
| 306 | 301 | ||
| 307 | addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::AutomaticallyAuditTree); | ||
| 308 | |||
| 309 | |||
| 310 | addActionToQMenuAndActionHash(renderDebugMenu, | ||
| 311 | MenuOption::ShowAllLocalVoxels, | ||
| 312 | Qt::CTRL | Qt::Key_A, | ||
| 313 | appInstance->getVoxels(), | ||
| 314 | SLOT(showAllLocalVoxels())); | ||
| 315 | |||
| 316 | addActionToQMenuAndActionHash(renderDebugMenu, | ||
| 317 | MenuOption::KillLocalVoxels, | ||
| 318 | Qt::CTRL | Qt::Key_K, | ||
| 319 | appInstance, SLOT(doKillLocalVoxels())); | ||
| 320 | |||
| 321 | addActionToQMenuAndActionHash(renderDebugMenu, | ||
| 322 | MenuOption::RandomizeVoxelColors, | ||
| 323 | Qt::CTRL | Qt::Key_R, | ||
| 324 | appInstance->getVoxels(), | ||
| 325 | SLOT(randomizeVoxelColors())); | ||
| 326 | |||
| 327 | addActionToQMenuAndActionHash(renderDebugMenu, | ||
| 328 | MenuOption::FalseColorRandomly, | ||
| 329 | 0, | ||
| 330 | appInstance->getVoxels(), | ||
| 331 | SLOT(falseColorizeRandom())); | ||
| 332 | |||
| 333 | addActionToQMenuAndActionHash(renderDebugMenu, | ||
| 334 | MenuOption::FalseColorEveryOtherVoxel, | ||
| 335 | 0, | ||
| 336 | appInstance->getVoxels(), | ||
| 337 | SLOT(falseColorizeRandomEveryOther())); | ||
| 338 | |||
| 339 | addActionToQMenuAndActionHash(renderDebugMenu, | ||
| 340 | MenuOption::FalseColorByDistance, | ||
| 341 | 0, | ||
| 342 | appInstance->getVoxels(), | ||
| 343 | SLOT(falseColorizeDistanceFromView())); | ||
| 344 | |||
| 345 | addActionToQMenuAndActionHash(renderDebugMenu, | ||
| 346 | MenuOption::FalseColorOutOfView, | ||
| 347 | 0, | ||
| 348 | appInstance->getVoxels(), | ||
| 349 | SLOT(falseColorizeInView())); | ||
| 350 | |||
| 351 | addActionToQMenuAndActionHash(renderDebugMenu, | ||
| 352 | MenuOption::FalseColorBySource, | ||
| 353 | 0, | ||
| 354 | appInstance->getVoxels(), | ||
| 355 | SLOT(falseColorizeBySource())); | ||
| 356 | |||
| 357 | addActionToQMenuAndActionHash(renderDebugMenu, | ||
| 358 | MenuOption::ShowTrueColors, | ||
| 359 | Qt::CTRL | Qt::Key_T, | ||
| 360 | appInstance->getVoxels(), | ||
| 361 | SLOT(trueColorize())); | ||
| 362 | |||
| 363 | addCheckableActionToQMenuAndActionHash(renderDebugMenu, | 302 | addCheckableActionToQMenuAndActionHash(renderDebugMenu, |
| 364 | MenuOption::CullSharedFaces, | 303 | MenuOption::CullSharedFaces, |
| 365 | Qt::CTRL | Qt::SHIFT | Qt::Key_C, | 304 | Qt::CTRL | Qt::SHIFT | Qt::Key_C, |
| @@ -374,22 +313,6 @@ Menu::Menu() : · 8 unmodified lines | |||
| 374 | appInstance->getVoxels(), | 313 | appInstance->getVoxels(), |
| 375 | SLOT(showCulledSharedFaces())); | 314 | SLOT(showCulledSharedFaces())); |
| 376 | 315 | ||
| 377 | addDisabledActionAndSeparator(renderDebugMenu, "Coverage Maps"); | ||
| 378 | addActionToQMenuAndActionHash(renderDebugMenu, | ||
| 379 | MenuOption::FalseColorOccluded, | ||
| 380 | 0, | ||
| 381 | appInstance->getVoxels(), | ||
| 382 | SLOT(falseColorizeOccluded())); | ||
| 383 | |||
| 384 | addActionToQMenuAndActionHash(renderDebugMenu, | ||
| 385 | MenuOption::FalseColorOccludedV2, | ||
| 386 | 0, | ||
| 387 | appInstance->getVoxels(), | ||
| 388 | SLOT(falseColorizeOccludedV2())); | ||
| 389 | |||
| 390 | addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::CoverageMap, Qt::SHIFT | Qt::CTRL | Qt::Key_O); | ||
| 391 | addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::CoverageMapV2, Qt::SHIFT | Qt::CTRL | Qt::Key_P); | ||
| 392 | |||
| 393 | QMenu* audioDebugMenu = developerMenu->addMenu("Audio Debugging Tools"); | 316 | QMenu* audioDebugMenu = developerMenu->addMenu("Audio Debugging Tools"); |
| 394 | addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::AudioNoiseReduction, | 317 | addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::AudioNoiseReduction, |
| 395 | 0, | 318 | 0, |
| @@ -589,9 +512,24 @@ void Menu::handleViewFrustumOffsetKeyModifier(int key) { · 193 unmodified lines | |||
| 589 | } | 512 | } |
| 590 | } | 513 | } |
| 591 | 514 | ||
| 592 | void Menu::addDisabledActionAndSeparator(QMenu* destinationMenu, const QString& actionName) { | 515 | void Menu::addDisabledActionAndSeparator(QMenu* destinationMenu, const QString& actionName, int menuItemLocation) { |
| 593 | destinationMenu->addSeparator(); | 516 | QAction* actionBefore = NULL; |
| 594 | (destinationMenu->addAction(actionName))->setEnabled(false); | 517 | if (menuItemLocation >= 0 && destinationMenu->actions().size() > menuItemLocation) { |
| 518 | actionBefore = destinationMenu->actions()[menuItemLocation]; | ||
| 519 | } | ||
| 520 | if (actionBefore) { | ||
| 521 | QAction* separator = new QAction("",destinationMenu); | ||
| 522 | destinationMenu->insertAction(actionBefore, separator); | ||
| 523 | separator->setSeparator(true); | ||
| 524 | |||
| 525 | QAction* separatorText = new QAction(actionName,destinationMenu); | ||
| 526 | separatorText->setEnabled(false); | ||
| 527 | destinationMenu->insertAction(actionBefore, separatorText); | ||
| 528 | |||
| 529 | } else { | ||
| 530 | destinationMenu->addSeparator(); | ||
| 531 | (destinationMenu->addAction(actionName))->setEnabled(false); | ||
| 532 | } | ||
| 595 | } | 533 | } |
| 596 | 534 | ||
| 597 | QAction* Menu::addActionToQMenuAndActionHash(QMenu* destinationMenu, | 535 | QAction* Menu::addActionToQMenuAndActionHash(QMenu* destinationMenu, |
| @@ -652,11 +590,18 @@ void Menu::removeAction(QMenu* menu, const QString& actionName) { · 54 unmodified lines | |||
| 652 | } | 590 | } |
| 653 | 591 | ||
| 654 | void Menu::setIsOptionChecked(const QString& menuOption, bool isChecked) { | 592 | void Menu::setIsOptionChecked(const QString& menuOption, bool isChecked) { |
| 655 | return _actionHash.value(menuOption)->setChecked(isChecked); | 593 | QAction* menu = _actionHash.value(menuOption); |
| 594 | if (menu) { | ||
| 595 | menu->setChecked(isChecked); | ||
| 596 | } | ||
| 656 | } | 597 | } |
| 657 | 598 | ||
| 658 | bool Menu::isOptionChecked(const QString& menuOption) { | 599 | bool Menu::isOptionChecked(const QString& menuOption) { |
| 659 | return _actionHash.value(menuOption)->isChecked(); | 600 | QAction* menu = _actionHash.value(menuOption); |
| 601 | if (menu) { | ||
| 602 | return menu->isChecked(); | ||
| 603 | } | ||
| 604 | return false; | ||
| 660 | } | 605 | } |
| 661 | 606 | ||
| 662 | void Menu::triggerOption(const QString& menuOption) { | 607 | void Menu::triggerOption(const QString& menuOption) { |
| @@ -1319,6 +1264,18 @@ int Menu::findPositionOfMenuItem(QMenu* menu, const QString& searchMenuItem) { · 656 unmodified lines | |||
| 1319 | return UNSPECIFIED_POSITION; // not found | 1264 | return UNSPECIFIED_POSITION; // not found |
| 1320 | } | 1265 | } |
| 1321 | 1266 | ||
| 1267 | int Menu::positionBeforeSeparatorIfNeeded(QMenu* menu, int requestedPosition) { | ||
| 1268 | QList<QAction*> menuActions = menu->actions(); | ||
| 1269 | if (requestedPosition > 1 && requestedPosition < menuActions.size()) { | ||
| 1270 | QAction* beforeRequested = menuActions[requestedPosition - 1]; | ||
| 1271 | if (beforeRequested->isSeparator()) { | ||
| 1272 | requestedPosition--; | ||
| 1273 | } | ||
| 1274 | } | ||
| 1275 | return requestedPosition; | ||
| 1276 | } | ||
| 1277 | |||
| 1278 | |||
| 1322 | QMenu* Menu::addMenu(const QString& menuName) { | 1279 | QMenu* Menu::addMenu(const QString& menuName) { |
| 1323 | QStringList menuTree = menuName.split(">"); | 1280 | QStringList menuTree = menuName.split(">"); |
| 1324 | QMenu* addTo = NULL; | 1281 | QMenu* addTo = NULL; |
| @@ -1364,6 +1321,29 @@ void Menu::addSeparator(const QString& menuName, const QString& separatorName) { · 39 unmodified lines | |||
| 1364 | } | 1321 | } |
| 1365 | } | 1322 | } |
| 1366 | 1323 | ||
| 1324 | void Menu::removeSeparator(const QString& menuName, const QString& separatorName) { | ||
| 1325 | QMenu* menu = getMenu(menuName); | ||
| 1326 | bool separatorRemoved = false; | ||
| 1327 | if (menu) { | ||
| 1328 | int textAt = findPositionOfMenuItem(menu, separatorName); | ||
| 1329 | QList<QAction*> menuActions = menu->actions(); | ||
| 1330 | QAction* separatorText = menuActions[textAt]; | ||
| 1331 | if (textAt > 0 && textAt < menuActions.size()) { | ||
| 1332 | QAction* separatorLine = menuActions[textAt - 1]; | ||
| 1333 | if (separatorLine) { | ||
| 1334 | if (separatorLine->isSeparator()) { | ||
| 1335 | menu->removeAction(separatorText); | ||
| 1336 | menu->removeAction(separatorLine); | ||
| 1337 | separatorRemoved = true; | ||
| 1338 | } | ||
| 1339 | } | ||
| 1340 | } | ||
| 1341 | } | ||
| 1342 | if (separatorRemoved) { | ||
| 1343 | QMenuBar::repaint(); | ||
| 1344 | } | ||
| 1345 | } | ||
| 1346 | |||
| 1367 | void Menu::addMenuItem(const MenuItemProperties& properties) { | 1347 | void Menu::addMenuItem(const MenuItemProperties& properties) { |
| 1368 | QMenu* menuObj = getMenu(properties.menuName); | 1348 | QMenu* menuObj = getMenu(properties.menuName); |
| 1369 | if (menuObj) { | 1349 | if (menuObj) { |
| @@ -1376,6 +1356,8 @@ void Menu::addMenuItem(const MenuItemProperties& properties) { · 6 unmodified lines | |||
| 1376 | int requestedPosition = properties.position; | 1356 | int requestedPosition = properties.position; |
| 1377 | if (requestedPosition == UNSPECIFIED_POSITION && !properties.beforeItem.isEmpty()) { | 1357 | if (requestedPosition == UNSPECIFIED_POSITION && !properties.beforeItem.isEmpty()) { |
| 1378 | requestedPosition = findPositionOfMenuItem(menuObj, properties.beforeItem); | 1358 | requestedPosition = findPositionOfMenuItem(menuObj, properties.beforeItem); |
| 1359 | // double check that the requested location wasn't a separator label | ||
| 1360 | requestedPosition = positionBeforeSeparatorIfNeeded(menuObj, requestedPosition); | ||
| 1379 | } | 1361 | } |
| 1380 | if (requestedPosition == UNSPECIFIED_POSITION && !properties.afterItem.isEmpty()) { | 1362 | if (requestedPosition == UNSPECIFIED_POSITION && !properties.afterItem.isEmpty()) { |
| 1381 | int afterPosition = findPositionOfMenuItem(menuObj, properties.afterItem); | 1363 | int afterPosition = findPositionOfMenuItem(menuObj, properties.afterItem); |
| @@ -1384,9 +1366,11 @@ void Menu::addMenuItem(const MenuItemProperties& properties) { · 2 unmodified lines | |||
| 1384 | } | 1366 | } |
| 1385 | } | 1367 | } |
| 1386 | 1368 | ||
| 1387 | QAction* menuItemAction; | 1369 | QAction* menuItemAction = NULL; |
| 1388 | if (properties.isCheckable) { | 1370 | if (properties.isSeparator) { |
| 1389 | menuItemAction = addCheckableActionToQMenuAndActionHash(menuObj, properties.menuItemName, | 1371 | addDisabledActionAndSeparator(menuObj, properties.menuItemName, requestedPosition); |
| 1372 | } else if (properties.isCheckable) { | ||
| 1373 | menuItemAction = addCheckableActionToQMenuAndActionHash(menuObj, properties.menuItemName, | ||
| 1390 | properties.shortcutKeySequence, properties.isChecked, | 1374 | properties.shortcutKeySequence, properties.isChecked, |
| 1391 | MenuScriptingInterface::getInstance(), SLOT(menuItemTriggered()), requestedPosition); | 1375 | MenuScriptingInterface::getInstance(), SLOT(menuItemTriggered()), requestedPosition); |
| 1392 | } else { | 1376 | } else { |
| @@ -1394,7 +1378,7 @@ void Menu::addMenuItem(const MenuItemProperties& properties) { · 1 unmodified line | |||
| 1394 | MenuScriptingInterface::getInstance(), SLOT(menuItemTriggered()), | 1378 | MenuScriptingInterface::getInstance(), SLOT(menuItemTriggered()), |
| 1395 | QAction::NoRole, requestedPosition); | 1379 | QAction::NoRole, requestedPosition); |
| 1396 | } | 1380 | } |
| 1397 | if (shortcut) { | 1381 | if (shortcut && menuItemAction) { |
| 1398 | connect(shortcut, SIGNAL(activated()), menuItemAction, SLOT(trigger())); | 1382 | connect(shortcut, SIGNAL(activated()), menuItemAction, SLOT(trigger())); |
| 1399 | } | 1383 | } |
| 1400 | QMenuBar::repaint(); | 1384 | QMenuBar::repaint(); |