Commit 1e04af17 authored by Kaitlyn Lee's avatar Kaitlyn Lee
Browse files

Fixed toolpad menus disabling actions.

parent 05036c19
Loading
Loading
Loading
Loading
+42 −15
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include <QSizePolicy>
#include <QStatusBar>
#include <QToolBar>
#include <QToolButton>
#include <QVBoxLayout>
#include <QWidgetAction>
#include <QXmlStreamWriter>
@@ -124,7 +125,6 @@ namespace Isis {

  void CubeDnView::createActions(Directory *directory) {


    m_permToolBar = new QToolBar("Standard Tools", this);
    m_permToolBar->setObjectName("permToolBar");
    m_permToolBar->setIconSize(QSize(22, 22));
@@ -143,7 +143,9 @@ namespace Isis {
    ToolList *tools = new ToolList;

    tools->append(new RubberBandTool(this));
    tools->append(NULL);

    // 2018-07-02 Kaitlyn Lee - Commented this out; not sure why it was here
    //tools->append(NULL);

    ControlNetTool *controlNetTool = new ControlNetTool(directory, this);
    tools->append(controlNetTool);
@@ -234,15 +236,8 @@ namespace Isis {
        m_permToolBar->addSeparator();
      }
    }

    // Store the actions for easy enable/disable.
    foreach (QAction *action, m_toolPad->actions()) {
      addAction(action);
    }
    foreach (QAction *action, m_permToolBar->actions()) {
      addAction(action);
    }
    foreach (QAction *action, m_activeToolBar->actions()) {
    foreach (QAction *action, findChildren<QAction *>()) {
      addAction(action);
    }
    // On default, actions are disabled until the cursor enters the view.
@@ -253,23 +248,48 @@ 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.
   * Disables actions when the cursor leaves the view. Overriden method
   * If a project item view menu or toolpad action 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 CubeDnView::leaveEvent(QEvent *event) {
  //   bool menuVisible = false;
  //   // Find the toolpad actions (buttons) with menus and check if they are visible
  //   foreach (QToolButton *button, findChildren<QToolButton *>()) {
  //     if (button->menu() && button->menu()->isVisible()) {
  //       menuVisible = true;
  //       break;
  //     }
  //   }
  //   if ( !(menuVisible | m_optionsMenu->isVisible() | m_viewMenu->isVisible()
  //          | m_windowMenu->isVisible()) ) {
  //     disableActions();
  //   }
  // }

  void CubeDnView::leaveEvent(QEvent *event) {
    if ( !(m_optionsMenu->isVisible() | m_viewMenu->isVisible() | m_windowMenu->isVisible()) ) {
      disableActions();
    if (m_optionsMenu->isVisible() | m_viewMenu->isVisible() | m_windowMenu->isVisible()) {
      return;
    }
    // Find the toolpad actions (buttons) with menus and check if they are visible
    foreach (QToolButton *button, findChildren<QToolButton *>()) {
      if (button->menu() && button->menu()->isVisible()) {
        return;
      }
    }
    disableActions();
  }


  /**
   * A slot function that is called when directory emits a siganl that an active
   * control network is set. It enables the control network editor tool in the
   * toolpad and loads the network.
   *
   * @param value The boolean that holds if a control network has been set.
   */
  void CubeDnView::enableControlNetTool(bool value) {
    foreach (QAction *action, m_toolPad->actions()) {
@@ -290,10 +310,17 @@ namespace Isis {
    delete m_permToolBar;
    delete m_activeToolBar;
    delete m_toolPad;
    delete m_viewMenu;
    delete m_optionsMenu;
    delete m_windowMenu;


    m_permToolBar = 0;
    m_activeToolBar = 0;
    m_toolPad = 0;
    m_viewMenu = 0;
    m_optionsMenu = 0;
    m_windowMenu = 0;
  }


+4 −2
Original line number Diff line number Diff line
@@ -333,10 +333,12 @@ namespace Isis {
  /**
   * A slot function that is called when directory emits a siganl that an active
   * control network is set. It enables the control network editor tool in the
   * toolpad and loads the network.
   * toolpad.
   * We do not load the network here because the network does not open until
   * the tool is enabled. This is done in MosaicControlNetTool::updateTool() and
   * the tool is beng used. This is done in MosaicControlNetTool::updateTool() and
   * is connected in MosaicTool.
   *
   * @param value The boolean that holds if a control network has been set.
   */
  void Footprint2DView::enableControlNetTool(bool value) {
    m_controlNetTool->setEnabled(value);