Showing the changes to interface/src/Menu.cpp (1 of 7 files). Show all
Unified · Split
| @@ -68,16 +68,22 @@ Menu::Menu() { · 67 unmodified lines | ||
| 68 | 68 | dialogsManager.data(), &DialogsManager::toggleLoginDialog); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | − addDisabledActionAndSeparator(fileMenu, "Scripts"); | |
| 71 | + // File Menu > Scripts section -- "Advanced" grouping | |
| 72 | + addDisabledActionAndSeparator(fileMenu, "Scripts", UNSPECIFIED_POSITION, "Advanced"); | |
| 72 | 73 | addActionToQMenuAndActionHash(fileMenu, MenuOption::LoadScript, Qt::CTRL | Qt::Key_O, |
| 73 | − qApp, SLOT(loadDialog())); | |
| 74 | + qApp, SLOT(loadDialog()), | |
| 75 | + QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); | |
| 74 | 76 | addActionToQMenuAndActionHash(fileMenu, MenuOption::LoadScriptURL, |
| 75 | − Qt::CTRL | Qt::SHIFT | Qt::Key_O, qApp, SLOT(loadScriptURLDialog())); | |
| 76 | − addActionToQMenuAndActionHash(fileMenu, MenuOption::StopAllScripts, 0, qApp, SLOT(stopAllScripts())); | |
| 77 | + Qt::CTRL | Qt::SHIFT | Qt::Key_O, qApp, SLOT(loadScriptURLDialog()), | |
| 78 | + QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); | |
| 79 | + addActionToQMenuAndActionHash(fileMenu, MenuOption::StopAllScripts, 0, qApp, SLOT(stopAllScripts()), | |
| 80 | + QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); | |
| 77 | 81 | addActionToQMenuAndActionHash(fileMenu, MenuOption::ReloadAllScripts, Qt::CTRL | Qt::Key_R, |
| 78 | − qApp, SLOT(reloadAllScripts())); | |
| 82 | + qApp, SLOT(reloadAllScripts()), | |
| 83 | + QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); | |
| 79 | 84 | addActionToQMenuAndActionHash(fileMenu, MenuOption::RunningScripts, Qt::CTRL | Qt::Key_J, |
| 80 | − qApp, SLOT(toggleRunningScriptsWidget())); | |
| 85 | + qApp, SLOT(toggleRunningScriptsWidget()), | |
| 86 | + QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); | |
| 81 | 87 | |
| 82 | 88 | auto addressManager = DependencyManager::get<AddressManager>(); |
| 83 | 89 | |
| @@ -112,9 +118,11 @@ Menu::Menu() { · 28 unmodified lines | ||
| 112 | 118 | dialogsManager.data(), |
| 113 | 119 | SLOT(toggleAddressBar())); |
| 114 | 120 | addActionToQMenuAndActionHash(fileMenu, MenuOption::CopyAddress, 0, |
| 115 | − addressManager.data(), SLOT(copyAddress())); | |
| 121 | + addressManager.data(), SLOT(copyAddress()), | |
| 122 | + QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); | |
| 116 | 123 | addActionToQMenuAndActionHash(fileMenu, MenuOption::CopyPath, 0, |
| 117 | − addressManager.data(), SLOT(copyPath())); | |
| 124 | + addressManager.data(), SLOT(copyPath()), | |
| 125 | + QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); | |
| 118 | 126 | |
| 119 | 127 | addActionToQMenuAndActionHash(fileMenu, |
| 120 | 128 | MenuOption::Quit, |
| @@ -143,11 +151,13 @@ Menu::Menu() { · 22 unmodified lines | ||
| 143 | 151 | QAction::PreferencesRole); |
| 144 | 152 | |
| 145 | 153 | addActionToQMenuAndActionHash(editMenu, MenuOption::Attachments, 0, |
| 146 | − dialogsManager.data(), SLOT(editAttachments())); | |
| 154 | + dialogsManager.data(), SLOT(editAttachments()), | |
| 155 | + QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); | |
| 147 | 156 | |
| 148 | 157 | MenuWrapper* toolsMenu = addMenu("Tools"); |
| 149 | 158 | addActionToQMenuAndActionHash(toolsMenu, MenuOption::ScriptEditor, Qt::ALT | Qt::Key_S, |
| 150 | − dialogsManager.data(), SLOT(showScriptEditor())); | |
| 159 | + dialogsManager.data(), SLOT(showScriptEditor()), | |
| 160 | + QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); | |
| 151 | 161 | |
| 152 | 162 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) |
| 153 | 163 | auto speechRecognizer = DependencyManager::get<SpeechRecognizer>(); |
| @@ -155,13 +165,16 @@ Menu::Menu() { · 1 unmodified line | ||
| 155 | 165 | Qt::CTRL | Qt::SHIFT | Qt::Key_C, |
| 156 | 166 | speechRecognizer->getEnabled(), |
| 157 | 167 | speechRecognizer.data(), |
| 158 | − SLOT(setEnabled(bool))); | |
| 168 | + SLOT(setEnabled(bool)), | |
| 169 | + UNSPECIFIED_POSITION, "Advanced"); | |
| 159 | 170 | connect(speechRecognizer.data(), SIGNAL(enabledUpdated(bool)), speechRecognizerAction, SLOT(setChecked(bool))); |
| 160 | 171 | #endif |
| 161 | 172 | |
| 162 | 173 | addActionToQMenuAndActionHash(toolsMenu, MenuOption::Chat, |
| 163 | 174 | 0, // QML Qt::Key_Backslash, |
| 164 | − dialogsManager.data(), SLOT(showIRCLink())); | |
| 175 | + dialogsManager.data(), SLOT(showIRCLink()), | |
| 176 | + QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); | |
| 177 | + | |
| 165 | 178 | addActionToQMenuAndActionHash(toolsMenu, MenuOption::AddRemoveFriends, 0, |
| 166 | 179 | qApp, SLOT(showFriendsWindow())); |
| 167 | 180 | |
| @@ -193,22 +206,26 @@ Menu::Menu() { · 25 unmodified lines | ||
| 193 | 206 | MenuOption::ToolWindow, |
| 194 | 207 | Qt::CTRL | Qt::ALT | Qt::Key_T, |
| 195 | 208 | dialogsManager.data(), |
| 196 | − SLOT(toggleToolWindow())); | |
| 209 | + SLOT(toggleToolWindow()), | |
| 210 | + QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); | |
| 197 | 211 | |
| 198 | 212 | addActionToQMenuAndActionHash(toolsMenu, |
| 199 | 213 | MenuOption::Console, |
| 200 | 214 | Qt::CTRL | Qt::ALT | Qt::Key_J, |
| 201 | 215 | DependencyManager::get<StandAloneJSConsole>().data(), |
| 202 | − SLOT(toggleConsole())); | |
| 216 | + SLOT(toggleConsole()), | |
| 217 | + QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); | |
| 203 | 218 | |
| 204 | 219 | addActionToQMenuAndActionHash(toolsMenu, |
| 205 | 220 | MenuOption::ResetSensors, |
| 206 | 221 | 0, // QML Qt::Key_Apostrophe, |
| 207 | 222 | qApp, |
| 208 | − SLOT(resetSensors())); | |
| 223 | + SLOT(resetSensors()), | |
| 224 | + QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); | |
| 209 | 225 | |
| 210 | 226 | addActionToQMenuAndActionHash(toolsMenu, MenuOption::PackageModel, 0, |
| 211 | − qApp, SLOT(packageModel())); | |
| 227 | + qApp, SLOT(packageModel()), | |
| 228 | + QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); | |
| 212 | 229 | |
| 213 | 230 | addMenu(DisplayPlugin::MENU_PATH()); |
| 214 | 231 | { |
| @@ -220,7 +237,7 @@ Menu::Menu() { · 5 unmodified lines | ||
| 220 | 237 | MenuWrapper* avatarMenu = addMenu("Avatar"); |
| 221 | 238 | QObject* avatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); |
| 222 | 239 | |
| 223 | − MenuWrapper* inputModeMenu = addMenu(MenuOption::InputMenu); | |
| 240 | + MenuWrapper* inputModeMenu = addMenu(MenuOption::InputMenu, "Advanced"); | |
| 224 | 241 | QActionGroup* inputModeGroup = new QActionGroup(inputModeMenu); |
| 225 | 242 | inputModeGroup->setExclusive(false); |
| 226 | 243 | |
| @@ -241,17 +258,15 @@ Menu::Menu() { · 14 unmodified lines | ||
| 241 | 258 | avatar, |
| 242 | 259 | SLOT(resetSize())); |
| 243 | 260 | |
| 244 | − addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::KeyboardMotorControl, | |
| 245 | − Qt::CTRL | Qt::SHIFT | Qt::Key_K, true, avatar, SLOT(updateMotionBehaviorFromMenu())); | |
| 246 | − addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::ScriptedMotorControl, 0, true, | |
| 247 | − avatar, SLOT(updateMotionBehaviorFromMenu())); | |
| 248 | − addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::NamesAboveHeads, 0, true); | |
| 249 | − addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::BlueSpeechSphere, 0, true); | |
| 250 | − addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::EnableCharacterController, 0, true, | |
| 251 | − avatar, SLOT(updateMotionBehaviorFromMenu())); | |
| 261 | + addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::NamesAboveHeads, 0, true, | |
| 262 | + NULL, NULL, UNSPECIFIED_POSITION, "Advanced"); | |
| 263 | + | |
| 264 | + addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::BlueSpeechSphere, 0, true, | |
| 265 | + NULL, NULL, UNSPECIFIED_POSITION, "Advanced"); | |
| 252 | 266 | |
| 253 | 267 | MenuWrapper* viewMenu = addMenu("View"); |
| 254 | − addActionToQMenuAndActionHash(viewMenu, MenuOption::ReloadContent, 0, qApp, SLOT(reloadResourceCaches())); | |
| 268 | + addActionToQMenuAndActionHash(viewMenu, MenuOption::ReloadContent, 0, qApp, SLOT(reloadResourceCaches()), | |
| 269 | + QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); | |
| 255 | 270 | |
| 256 | 271 | MenuWrapper* cameraModeMenu = viewMenu->addMenu("Camera Mode"); |
| 257 | 272 | QActionGroup* cameraModeGroup = new QActionGroup(cameraModeMenu); |
| @@ -275,30 +290,29 @@ Menu::Menu() { · 17 unmodified lines | ||
| 275 | 290 | addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Mirror, |
| 276 | 291 | 0, //QML Qt::SHIFT | Qt::Key_H, |
| 277 | 292 | true); |
| 278 | − addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::FullscreenMirror, | |
| 279 | − 0, // QML Qt::Key_H, | |
| 280 | − false, qApp, SLOT(cameraMenuChanged())); | |
| 281 | 293 | |
| 282 | 294 | addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::CenterPlayerInView, |
| 283 | − 0, false, qApp, SLOT(rotationModeChanged())); | |
| 284 | − | |
| 285 | − addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::TurnWithHead, 0, false); | |
| 295 | + 0, false, qApp, SLOT(rotationModeChanged()), | |
| 296 | + UNSPECIFIED_POSITION, "Advanced"); | |
| 286 | 297 | |
| 287 | − addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::WorldAxes); | |
| 288 | − | |
| 289 | − addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Stats); | |
| 298 | + addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::WorldAxes, 0, false, NULL, NULL, UNSPECIFIED_POSITION, "Developer"); | |
| 299 | + addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Stats, 0, false, NULL, NULL, UNSPECIFIED_POSITION, "Developer"); | |
| 290 | 300 | addActionToQMenuAndActionHash(viewMenu, MenuOption::Log, |
| 291 | − Qt::CTRL | Qt::SHIFT | Qt::Key_L, | |
| 292 | − qApp, SLOT(toggleLogDialog())); | |
| 301 | + Qt::CTRL | Qt::SHIFT | Qt::Key_L, | |
| 302 | + qApp, SLOT(toggleLogDialog()), QAction::NoRole, UNSPECIFIED_POSITION, "Developer"); | |
| 303 | + | |
| 293 | 304 | addActionToQMenuAndActionHash(viewMenu, MenuOption::AudioNetworkStats, 0, |
| 294 | − dialogsManager.data(), SLOT(audioStatsDetails())); | |
| 305 | + dialogsManager.data(), SLOT(audioStatsDetails()), QAction::NoRole, UNSPECIFIED_POSITION, "Developer"); | |
| 306 | + | |
| 295 | 307 | addActionToQMenuAndActionHash(viewMenu, MenuOption::BandwidthDetails, 0, |
| 296 | − dialogsManager.data(), SLOT(bandwidthDetails())); | |
| 308 | + dialogsManager.data(), SLOT(bandwidthDetails()), QAction::NoRole, UNSPECIFIED_POSITION, "Developer"); | |
| 297 | 309 | addActionToQMenuAndActionHash(viewMenu, MenuOption::OctreeStats, 0, |
| 298 | − dialogsManager.data(), SLOT(octreeStatsDetails())); | |
| 310 | + dialogsManager.data(), SLOT(octreeStatsDetails()), QAction::NoRole, UNSPECIFIED_POSITION, "Developer"); | |
| 299 | 311 | |
| 312 | + addCheckableActionToQMenuAndActionHash(viewMenu, "Advanced Menus", 0, false, this, SLOT(toggleAdvancedMenus())); | |
| 313 | + addCheckableActionToQMenuAndActionHash(viewMenu, "Developer Menus", 0, false, this, SLOT(toggleDeveloperMenus())); | |
| 300 | 314 | |
| 301 | − MenuWrapper* developerMenu = addMenu("Developer"); | |
| 315 | + MenuWrapper* developerMenu = addMenu("Developer", "Developer"); | |
| 302 | 316 | |
| 303 | 317 | MenuWrapper* renderOptionsMenu = developerMenu->addMenu("Render"); |
| 304 | 318 | addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Atmosphere, |
| @@ -447,9 +461,23 @@ Menu::Menu() { · 142 unmodified lines | ||
| 447 | 461 | addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::MeshVisible, 0, true, |
| 448 | 462 | avatar, SLOT(setEnableMeshVisible(bool))); |
| 449 | 463 | addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::DisableEyelidAdjustment, 0, false); |
| 450 | − | |
| 464 | + addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::TurnWithHead, 0, false); | |
| 451 | 465 | addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ComfortMode, 0, true); |
| 452 | 466 | |
| 467 | + addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::KeyboardMotorControl, | |
| 468 | + Qt::CTRL | Qt::SHIFT | Qt::Key_K, true, avatar, SLOT(updateMotionBehaviorFromMenu()), | |
| 469 | + UNSPECIFIED_POSITION, "Developer"); | |
| 470 | + | |
| 471 | + addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ScriptedMotorControl, 0, true, | |
| 472 | + avatar, SLOT(updateMotionBehaviorFromMenu()), | |
| 473 | + UNSPECIFIED_POSITION, "Developer"); | |
| 474 | + | |
| 475 | + addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::EnableCharacterController, 0, true, | |
| 476 | + avatar, SLOT(updateMotionBehaviorFromMenu()), | |
| 477 | + UNSPECIFIED_POSITION, "Developer"); | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 453 | 481 | MenuWrapper* handOptionsMenu = developerMenu->addMenu("Hands"); |
| 454 | 482 | addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHandTargets, 0, false); |
| 455 | 483 | addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::EnableHandMouseInput, 0, false); |
| @@ -573,6 +601,14 @@ Menu::Menu() { · 117 unmodified lines | ||
| 573 | 601 | #endif |
| 574 | 602 | } |
| 575 | 603 | |
| 604 | +void Menu::toggleAdvancedMenus() { | |
| 605 | + setGroupingIsVisible("Advanced", !getGroupingIsVisible("Advanced")); | |
| 606 | +} | |
| 607 | + | |
| 608 | +void Menu::toggleDeveloperMenus() { | |
| 609 | + setGroupingIsVisible("Developer", !getGroupingIsVisible("Developer")); | |
| 610 | +} | |
| 611 | + | |
| 576 | 612 | void Menu::loadSettings() { |
| 577 | 613 | scanMenuBar(&Menu::loadAction); |
| 578 | 614 | } |
| @@ -610,23 +646,36 @@ void Menu::scanMenu(QMenu& menu, settingsAction modifySetting, Settings& setting · 31 unmodified lines | ||
| 610 | 646 | settings.endGroup(); |
| 611 | 647 | } |
| 612 | 648 | |
| 613 | −void Menu::addDisabledActionAndSeparator(MenuWrapper* destinationMenu, const QString& actionName, int menuItemLocation) { | |
| 649 | +void Menu::addDisabledActionAndSeparator(MenuWrapper* destinationMenu, const QString& actionName, | |
| 650 | + int menuItemLocation, const QString& grouping) { | |
| 614 | 651 | QAction* actionBefore = NULL; |
| 652 | + QAction* separator; | |
| 653 | + QAction* separatorText; | |
| 654 | + | |
| 615 | 655 | if (menuItemLocation >= 0 && destinationMenu->actions().size() > menuItemLocation) { |
| 616 | 656 | actionBefore = destinationMenu->actions()[menuItemLocation]; |
| 617 | 657 | } |
| 618 | 658 | if (actionBefore) { |
| 619 | − QAction* separator = new QAction("",destinationMenu); | |
| 659 | + separator = new QAction("",destinationMenu); | |
| 620 | 660 | destinationMenu->insertAction(actionBefore, separator); |
| 621 | 661 | separator->setSeparator(true); |
| 622 | 662 | |
| 623 | − QAction* separatorText = new QAction(actionName,destinationMenu); | |
| 663 | + separatorText = new QAction(actionName,destinationMenu); | |
| 624 | 664 | separatorText->setEnabled(false); |
| 625 | 665 | destinationMenu->insertAction(actionBefore, separatorText); |
| 626 | 666 | |
| 627 | 667 | } else { |
| 628 | − destinationMenu->addSeparator(); | |
| 629 | − (destinationMenu->addAction(actionName))->setEnabled(false); | |
| 668 | + separator = destinationMenu->addSeparator(); | |
| 669 | + separatorText = destinationMenu->addAction(actionName); | |
| 670 | + separatorText->setEnabled(false); | |
| 671 | + } | |
| 672 | + | |
| 673 | + if (isValidGrouping(grouping)) { | |
| 674 | + _groupingActions[grouping] << separator; | |
| 675 | + _groupingActions[grouping] << separatorText; | |
| 676 | + bool isVisible = getGroupingIsVisible(grouping); | |
| 677 | + separator->setVisible(isVisible); | |
| 678 | + separatorText->setVisible(isVisible); | |
| 630 | 679 | } |
| 631 | 680 | } |
| 632 | 681 | |
| @@ -636,7 +685,8 @@ QAction* Menu::addActionToQMenuAndActionHash(MenuWrapper* destinationMenu, · 3 unmodified lines | ||
| 636 | 685 | const QObject* receiver, |
| 637 | 686 | const char* member, |
| 638 | 687 | QAction::MenuRole role, |
| 639 | − int menuItemLocation) { | |
| 688 | + int menuItemLocation, | |
| 689 | + const QString& grouping) { | |
| 640 | 690 | QAction* action = NULL; |
| 641 | 691 | QAction* actionBefore = NULL; |
| 642 | 692 | |
| @@ -664,6 +714,11 @@ QAction* Menu::addActionToQMenuAndActionHash(MenuWrapper* destinationMenu, · 21 unmodified lines | ||
| 664 | 714 | |
| 665 | 715 | _actionHash.insert(actionName, action); |
| 666 | 716 | |
| 717 | + if (isValidGrouping(grouping)) { | |
| 718 | + _groupingActions[grouping] << action; | |
| 719 | + action->setVisible(getGroupingIsVisible(grouping)); | |
| 720 | + } | |
| 721 | + | |
| 667 | 722 | return action; |
| 668 | 723 | } |
| 669 | 724 | |
| @@ -672,7 +727,8 @@ QAction* Menu::addActionToQMenuAndActionHash(MenuWrapper* destinationMenu, · 2 unmodified lines | ||
| 672 | 727 | const QString& actionName, |
| 673 | 728 | const QKeySequence& shortcut, |
| 674 | 729 | QAction::MenuRole role, |
| 675 | − int menuItemLocation) { | |
| 730 | + int menuItemLocation, | |
| 731 | + const QString& grouping) { | |
| 676 | 732 | QAction* actionBefore = NULL; |
| 677 | 733 | |
| 678 | 734 | if (menuItemLocation >= 0 && destinationMenu->actions().size() > menuItemLocation) { |
| @@ -699,6 +755,11 @@ QAction* Menu::addActionToQMenuAndActionHash(MenuWrapper* destinationMenu, · 20 unmodified lines | ||
| 699 | 755 | |
| 700 | 756 | _actionHash.insert(action->text(), action); |
| 701 | 757 | |
| 758 | + if (isValidGrouping(grouping)) { | |
| 759 | + _groupingActions[grouping] << action; | |
| 760 | + action->setVisible(getGroupingIsVisible(grouping)); | |
| 761 | + } | |
| 762 | + | |
| 702 | 763 | return action; |
| 703 | 764 | } |
| 704 | 765 | |
| @@ -708,19 +769,29 @@ QAction* Menu::addCheckableActionToQMenuAndActionHash(MenuWrapper* destinationMe · 3 unmodified lines | ||
| 708 | 769 | const bool checked, |
| 709 | 770 | const QObject* receiver, |
| 710 | 771 | const char* member, |
| 711 | − int menuItemLocation) { | |
| 772 | + int menuItemLocation, | |
| 773 | + const QString& grouping) { | |
| 712 | 774 | |
| 713 | 775 | QAction* action = addActionToQMenuAndActionHash(destinationMenu, actionName, shortcut, receiver, member, |
| 714 | 776 | QAction::NoRole, menuItemLocation); |
| 715 | 777 | action->setCheckable(true); |
| 716 | 778 | action->setChecked(checked); |
| 717 | 779 | |
| 780 | + if (isValidGrouping(grouping)) { | |
| 781 | + _groupingActions[grouping] << action; | |
| 782 | + action->setVisible(getGroupingIsVisible(grouping)); | |
| 783 | + } | |
| 784 | + | |
| 718 | 785 | return action; |
| 719 | 786 | } |
| 720 | 787 | |
| 721 | 788 | void Menu::removeAction(MenuWrapper* menu, const QString& actionName) { |
| 722 | − menu->removeAction(_actionHash.value(actionName)); | |
| 789 | + auto action = _actionHash.value(actionName); | |
| 790 | + menu->removeAction(action); | |
| 723 | 791 | _actionHash.remove(actionName); |
| 792 | + for (auto& grouping : _groupingActions) { | |
| 793 | + grouping.remove(action); | |
| 794 | + } | |
| 724 | 795 | } |
| 725 | 796 | |
| 726 | 797 | void Menu::setIsOptionChecked(const QString& menuOption, bool isChecked) { |
| @@ -850,7 +921,7 @@ int Menu::positionBeforeSeparatorIfNeeded(MenuWrapper* menu, int requestedPositi · 123 unmodified lines | ||
| 850 | 921 | } |
| 851 | 922 | |
| 852 | 923 | |
| 853 | −MenuWrapper* Menu::addMenu(const QString& menuName) { | |
| 924 | +MenuWrapper* Menu::addMenu(const QString& menuName, const QString& grouping) { | |
| 854 | 925 | QStringList menuTree = menuName.split(">"); |
| 855 | 926 | MenuWrapper* addTo = NULL; |
| 856 | 927 | MenuWrapper* menu = NULL; |
| @@ -866,6 +937,14 @@ MenuWrapper* Menu::addMenu(const QString& menuName) { · 9 unmodified lines | ||
| 866 | 937 | addTo = menu; |
| 867 | 938 | } |
| 868 | 939 | |
| 940 | + if (isValidGrouping(grouping)) { | |
| 941 | + auto action = getMenuAction(menuName); | |
| 942 | + if (action) { | |
| 943 | + _groupingActions[grouping] << action; | |
| 944 | + action->setVisible(getGroupingIsVisible(grouping)); | |
| 945 | + } | |
| 946 | + } | |
| 947 | + | |
| 869 | 948 | QMenuBar::repaint(); |
| 870 | 949 | return menu; |
| 871 | 950 | } |
| @@ -897,7 +976,7 @@ bool Menu::menuExists(const QString& menuName) { · 25 unmodified lines | ||
| 897 | 976 | return false; |
| 898 | 977 | } |
| 899 | 978 | |
| 900 | −void Menu::addSeparator(const QString& menuName, const QString& separatorName) { | |
| 979 | +void Menu::addSeparator(const QString& menuName, const QString& separatorName, const QString& grouping) { | |
| 901 | 980 | MenuWrapper* menuObj = getMenu(menuName); |
| 902 | 981 | if (menuObj) { |
| 903 | 982 | addDisabledActionAndSeparator(menuObj, separatorName); |
| @@ -952,15 +1031,16 @@ void Menu::addMenuItem(const MenuItemProperties& properties) { · 48 unmodified lines | ||
| 952 | 1031 | |
| 953 | 1032 | QAction* menuItemAction = NULL; |
| 954 | 1033 | if (properties.isSeparator) { |
| 955 | − addDisabledActionAndSeparator(menuObj, properties.menuItemName, requestedPosition); | |
| 1034 | + addDisabledActionAndSeparator(menuObj, properties.menuItemName, requestedPosition, properties.grouping); | |
| 956 | 1035 | } else if (properties.isCheckable) { |
| 957 | 1036 | menuItemAction = addCheckableActionToQMenuAndActionHash(menuObj, properties.menuItemName, |
| 958 | 1037 | properties.shortcutKeySequence, properties.isChecked, |
| 959 | − MenuScriptingInterface::getInstance(), SLOT(menuItemTriggered()), requestedPosition); | |
| 1038 | + MenuScriptingInterface::getInstance(), SLOT(menuItemTriggered()), | |
| 1039 | + requestedPosition, properties.grouping); | |
| 960 | 1040 | } else { |
| 961 | 1041 | menuItemAction = addActionToQMenuAndActionHash(menuObj, properties.menuItemName, properties.shortcutKeySequence, |
| 962 | 1042 | MenuScriptingInterface::getInstance(), SLOT(menuItemTriggered()), |
| 963 | − QAction::NoRole, requestedPosition); | |
| 1043 | + QAction::NoRole, requestedPosition, properties.grouping); | |
| 964 | 1044 | } |
| 965 | 1045 | if (shortcut && menuItemAction) { |
| 966 | 1046 | connect(shortcut, SIGNAL(activated()), menuItemAction, SLOT(trigger())); |
| @@ -975,7 +1055,7 @@ void Menu::removeMenuItem(const QString& menu, const QString& menuitem) { · 8 unmodified lines | ||
| 975 | 1055 | removeAction(menuObj, menuitem); |
| 976 | 1056 | QMenuBar::repaint(); |
| 977 | 1057 | } |
| 978 | −}; | |
| 1058 | +} | |
| 979 | 1059 | |
| 980 | 1060 | bool Menu::menuItemExists(const QString& menu, const QString& menuitem) { |
| 981 | 1061 | QAction* menuItemAction = _actionHash.value(menuitem); |
| @@ -983,7 +1063,31 @@ bool Menu::menuItemExists(const QString& menu, const QString& menuitem) { · 1 unmodified line | ||
| 983 | 1063 | return (getMenu(menu) != NULL); |
| 984 | 1064 | } |
| 985 | 1065 | return false; |
| 986 | −}; | |
| 1066 | +} | |
| 1067 | + | |
| 1068 | +bool Menu::getGroupingIsVisible(const QString& grouping) { | |
| 1069 | + if (grouping.isEmpty() || grouping.isNull()) { | |
| 1070 | + return true; | |
| 1071 | + } | |
| 1072 | + if (_groupingVisible.contains(grouping)) { | |
| 1073 | + return _groupingVisible[grouping]; | |
| 1074 | + } | |
| 1075 | + return false; | |
| 1076 | +} | |
| 1077 | + | |
| 1078 | +void Menu::setGroupingIsVisible(const QString& grouping, bool isVisible) { | |
| 1079 | + // NOTE: Default grouping always visible | |
| 1080 | + if (grouping.isEmpty() || grouping.isNull()) { | |
| 1081 | + return; | |
| 1082 | + } | |
| 1083 | + _groupingVisible[grouping] = isVisible; | |
| 1084 | + | |
| 1085 | + for (auto action: _groupingActions[grouping]) { | |
| 1086 | + action->setVisible(isVisible); | |
| 1087 | + } | |
| 1088 | + | |
| 1089 | + QMenuBar::repaint(); | |
| 1090 | +} | |
| 987 | 1091 | |
| 988 | 1092 | |
| 989 | 1093 | MenuWrapper::MenuWrapper(QMenu* menu) : _realMenu(menu) { |
| @@ -1005,8 +1109,8 @@ void MenuWrapper::setEnabled(bool enabled) { · 15 unmodified lines | ||
| 1005 | 1109 | _realMenu->setEnabled(enabled); |
| 1006 | 1110 | } |
| 1007 | 1111 | |
| 1008 | −void MenuWrapper::addSeparator() { | |
| 1009 | − _realMenu->addSeparator(); | |
| 1112 | +QAction* MenuWrapper::addSeparator() { | |
| 1113 | + return _realMenu->addSeparator(); | |
| 1010 | 1114 | } |
| 1011 | 1115 | |
| 1012 | 1116 | void MenuWrapper::addAction(QAction* action) { |