Loading isis/src/qisis/objs/CnetEditorView/CnetEditorView.cpp +34 −35 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ #include "FileName.h" #include "Project.h" #include "XmlStackedHandlerReader.h" #include "MenuItem.h" namespace Isis { /** Loading Loading @@ -81,6 +82,13 @@ namespace Isis { createMenus(); createToolBars(); // Store the actions for easy enable/disable. foreach (QAction *action, m_permToolBar->actions()) { addAction(action); } // On default, actions are disabled until the cursor enters the view. disableActions(); } /** Loading @@ -90,60 +98,36 @@ namespace Isis { delete m_cnetEditorWidget; delete m_permToolBar; delete m_tablesMenu; m_tablesMenu = 0; m_permToolBar = 0; } /** * Uses the actions created by CnetEditorWidget, tries to find the menus to put * the actions under, and creates the menus if said menus do not exist. Currently, * the menus added are Table and Help. * the actions under, and creates the menus if said menus do not exist. */ void CnetEditorView::createMenus() { QMap< QAction *, QList< QString > > actionMap = m_cnetEditorWidget->menuActions(); QMapIterator< QAction *, QList< QString > > actionMapIter(actionMap); QMap<QString, QMenu *> topLevelMenus; m_tablesMenu = new MenuItem("&Tables"); connect(m_tablesMenu, SIGNAL(menuClosed()), this, SLOT(disableActions())); menuBar()->addMenu(m_tablesMenu); while ( actionMapIter.hasNext() ) { actionMapIter.next(); QAction *actionToAdd = actionMapIter.key(); QList< QString > location = actionMapIter.value(); // Skip the Help menu for now because we do not want to add the "What's This?" // action (it is in the main help menu of IPCE) if (location.first() == "&Help") { // Skip the "What's This?" action because it is in the main help menu of IPCE if (actionToAdd->text() == "What's This?") { continue; } QMenu *menuToPutActionInto = NULL; if ( location.count() ) { QString topLevelMenuTitle = location.takeFirst(); if (!topLevelMenus[topLevelMenuTitle]) { topLevelMenus[topLevelMenuTitle] = menuBar()->addMenu(topLevelMenuTitle); } menuToPutActionInto = topLevelMenus[topLevelMenuTitle]; } foreach (QString menuName, location) { bool foundSubMenu = false; foreach ( QAction *possibleSubMenu, menuToPutActionInto->actions() ) { if (!foundSubMenu && possibleSubMenu->menu() && possibleSubMenu->menu()->title() == menuName) { foundSubMenu = true; menuToPutActionInto = possibleSubMenu->menu(); } } if (!foundSubMenu) { menuToPutActionInto = menuToPutActionInto->addMenu(menuName); m_tablesMenu->addAction(actionToAdd); } } menuToPutActionInto->addAction(actionToAdd); } } /** * Uses and adds the actions created by CnetEditorWidget to the view's toolbars Loading @@ -169,6 +153,21 @@ namespace Isis { } } /** * Disables actions when cursor leaves the view. Overriden method * If a menu is visible, i.e. clicked on, this causes a leave event. We want the * actions to still be enabled when a menu is visible. * * @param event The leave event */ void CnetEditorView::leaveEvent(QEvent *event) { if (!m_tablesMenu->isVisible()) { disableActions(); } } /** * Returns the cnetEditorWidget. * Loading isis/src/qisis/objs/CnetEditorView/CnetEditorView.h +10 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ namespace Isis { class Project; class ToolPad; class XmlStackedHandlerReader; class MenuItem; /** * Ipce view containing the CnetEditorWidget Loading @@ -62,6 +63,11 @@ namespace Isis { * view has its own toolbar, so having getters that return toolbar * actions to fill the toolbar of the IpceMainWindow are unnecessary. * Removed methods that returned menu and toolbar actions. * @history 2018-06-25 Kaitlyn Lee - When multiple views are open, there is a possibility of getting * ambiguous shortcut errors. To counter this, we enable/disable actions. Overrode * leaveEvent() to handle open menus causing a leave event. On default, a view's * actions are disabled. To enable the actions, move the cursor over the view. * When a user moves the cursor outside of the view, the actions are disabled. */ class CnetEditorView : public AbstractProjectItemView { Loading @@ -84,6 +90,8 @@ class CnetEditorView : public AbstractProjectItemView { private: void createToolBars(); void createMenus(); void leaveEvent(QEvent *event); /** * @author 2012-09-?? Steven Lambright Loading Loading @@ -112,6 +120,8 @@ class CnetEditorView : public AbstractProjectItemView { QPointer<Control> m_control; QToolBar *m_permToolBar; //!< The permanent tool bar MenuItem *m_tablesMenu; //!< View menu for storing actions }; } Loading isis/src/qisis/objs/CubeDnView/CubeDnView.h +4 −3 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ namespace Isis { class ToolPad; class Workspace; class XmlStackedHandlerReader; class MenuItem; /** * View that displays cubes in a QView-like way. Loading Loading @@ -169,9 +170,9 @@ namespace Isis { QMap<Cube *, ProjectItem *> m_cubeItemMap; //!< Maps cubes to their items Workspace *m_workspace; //!< The workspace QMenu *m_viewMenu; //!< View menu for storing actions QMenu *m_optionsMenu; //!< Options menu for storing actions QMenu *m_windowMenu; //!< Window menu for storing actions MenuItem *m_viewMenu; //!< View menu for storing actions MenuItem *m_optionsMenu; //!< Options menu for storing actions MenuItem *m_windowMenu; //!< Window menu for storing actions QAction *m_separatorAction; //!< A separator action that is reused Loading Loading
isis/src/qisis/objs/CnetEditorView/CnetEditorView.cpp +34 −35 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ #include "FileName.h" #include "Project.h" #include "XmlStackedHandlerReader.h" #include "MenuItem.h" namespace Isis { /** Loading Loading @@ -81,6 +82,13 @@ namespace Isis { createMenus(); createToolBars(); // Store the actions for easy enable/disable. foreach (QAction *action, m_permToolBar->actions()) { addAction(action); } // On default, actions are disabled until the cursor enters the view. disableActions(); } /** Loading @@ -90,60 +98,36 @@ namespace Isis { delete m_cnetEditorWidget; delete m_permToolBar; delete m_tablesMenu; m_tablesMenu = 0; m_permToolBar = 0; } /** * Uses the actions created by CnetEditorWidget, tries to find the menus to put * the actions under, and creates the menus if said menus do not exist. Currently, * the menus added are Table and Help. * the actions under, and creates the menus if said menus do not exist. */ void CnetEditorView::createMenus() { QMap< QAction *, QList< QString > > actionMap = m_cnetEditorWidget->menuActions(); QMapIterator< QAction *, QList< QString > > actionMapIter(actionMap); QMap<QString, QMenu *> topLevelMenus; m_tablesMenu = new MenuItem("&Tables"); connect(m_tablesMenu, SIGNAL(menuClosed()), this, SLOT(disableActions())); menuBar()->addMenu(m_tablesMenu); while ( actionMapIter.hasNext() ) { actionMapIter.next(); QAction *actionToAdd = actionMapIter.key(); QList< QString > location = actionMapIter.value(); // Skip the Help menu for now because we do not want to add the "What's This?" // action (it is in the main help menu of IPCE) if (location.first() == "&Help") { // Skip the "What's This?" action because it is in the main help menu of IPCE if (actionToAdd->text() == "What's This?") { continue; } QMenu *menuToPutActionInto = NULL; if ( location.count() ) { QString topLevelMenuTitle = location.takeFirst(); if (!topLevelMenus[topLevelMenuTitle]) { topLevelMenus[topLevelMenuTitle] = menuBar()->addMenu(topLevelMenuTitle); } menuToPutActionInto = topLevelMenus[topLevelMenuTitle]; } foreach (QString menuName, location) { bool foundSubMenu = false; foreach ( QAction *possibleSubMenu, menuToPutActionInto->actions() ) { if (!foundSubMenu && possibleSubMenu->menu() && possibleSubMenu->menu()->title() == menuName) { foundSubMenu = true; menuToPutActionInto = possibleSubMenu->menu(); } } if (!foundSubMenu) { menuToPutActionInto = menuToPutActionInto->addMenu(menuName); m_tablesMenu->addAction(actionToAdd); } } menuToPutActionInto->addAction(actionToAdd); } } /** * Uses and adds the actions created by CnetEditorWidget to the view's toolbars Loading @@ -169,6 +153,21 @@ namespace Isis { } } /** * Disables actions when cursor leaves the view. Overriden method * If a menu is visible, i.e. clicked on, this causes a leave event. We want the * actions to still be enabled when a menu is visible. * * @param event The leave event */ void CnetEditorView::leaveEvent(QEvent *event) { if (!m_tablesMenu->isVisible()) { disableActions(); } } /** * Returns the cnetEditorWidget. * Loading
isis/src/qisis/objs/CnetEditorView/CnetEditorView.h +10 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ namespace Isis { class Project; class ToolPad; class XmlStackedHandlerReader; class MenuItem; /** * Ipce view containing the CnetEditorWidget Loading @@ -62,6 +63,11 @@ namespace Isis { * view has its own toolbar, so having getters that return toolbar * actions to fill the toolbar of the IpceMainWindow are unnecessary. * Removed methods that returned menu and toolbar actions. * @history 2018-06-25 Kaitlyn Lee - When multiple views are open, there is a possibility of getting * ambiguous shortcut errors. To counter this, we enable/disable actions. Overrode * leaveEvent() to handle open menus causing a leave event. On default, a view's * actions are disabled. To enable the actions, move the cursor over the view. * When a user moves the cursor outside of the view, the actions are disabled. */ class CnetEditorView : public AbstractProjectItemView { Loading @@ -84,6 +90,8 @@ class CnetEditorView : public AbstractProjectItemView { private: void createToolBars(); void createMenus(); void leaveEvent(QEvent *event); /** * @author 2012-09-?? Steven Lambright Loading Loading @@ -112,6 +120,8 @@ class CnetEditorView : public AbstractProjectItemView { QPointer<Control> m_control; QToolBar *m_permToolBar; //!< The permanent tool bar MenuItem *m_tablesMenu; //!< View menu for storing actions }; } Loading
isis/src/qisis/objs/CubeDnView/CubeDnView.h +4 −3 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ namespace Isis { class ToolPad; class Workspace; class XmlStackedHandlerReader; class MenuItem; /** * View that displays cubes in a QView-like way. Loading Loading @@ -169,9 +170,9 @@ namespace Isis { QMap<Cube *, ProjectItem *> m_cubeItemMap; //!< Maps cubes to their items Workspace *m_workspace; //!< The workspace QMenu *m_viewMenu; //!< View menu for storing actions QMenu *m_optionsMenu; //!< Options menu for storing actions QMenu *m_windowMenu; //!< Window menu for storing actions MenuItem *m_viewMenu; //!< View menu for storing actions MenuItem *m_optionsMenu; //!< Options menu for storing actions MenuItem *m_windowMenu; //!< Window menu for storing actions QAction *m_separatorAction; //!< A separator action that is reused Loading