History

first cut at adding advanced and developer menu groupings

Brad Hefta-Gaub committed 10 years ago

Commit 2815cb01 parent 63c3f7c7 files · +250 −101Browse files

Showing the changes to interface/src/Menu.cpp (1 of 7 files). Show all

Unified · Split

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