Commit e45f85d4 authored by Kaitlyn Lee's avatar Kaitlyn Lee
Browse files

Added methods to enable/disable tools when a cursor enter/leaves a view.

parent 111d812b
Loading
Loading
Loading
Loading
+56 −2
Original line number Diff line number Diff line
@@ -136,7 +136,6 @@ namespace Isis {

    m_toolPad = new ToolPad("Tool Pad", this);
    m_toolPad->setObjectName("toolPad");
     m_toolPad->setFocusPolicy(Qt::ClickFocus);
    addToolBar(Qt::RightToolBarArea, m_toolPad);

    // Create tools
@@ -234,10 +233,60 @@ namespace Isis {
      }
    }

    // Store the actions for easy enable/disable.
    foreach (QAction * action, m_toolPad->actions()) {
      m_actions.append(action);
    }
    foreach (QAction * action, m_permToolBar->actions()) {
      m_actions.append(action);
    }
    foreach (QAction * action, m_activeToolBar->actions()) {
      m_actions.append(action);
    }
    // On default, actions are disabled until the cursor enters the view.
    disableActions();

    zoomTool->activate(true);
  }


  /**
   * Disables toolbars and toolpad actions
   */
  void CubeDnView::disableActions() {
    foreach (QAction * action, m_actions) {
      action->setDisabled(true);
    }
  }


  /**
   * Enables toolbars and toolpad actions
   */
  void CubeDnView::enableActions() {
    foreach (QAction * action, m_actions) {
      action->setEnabled(true);
    }
  }

  /**
   * Enables actions when cursor etners on the view
   * @param event The enter event
   */
  void CubeDnView::enterEvent(QEvent *event) {
    enableActions();
  }


  /**
   * Disables actions when cursor leaves the view
   * @param event The leave event
   */
  void CubeDnView::leaveEvent(QEvent *event) {
    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
@@ -412,7 +461,12 @@ namespace Isis {
    if (m_workspace->cubeToMdiWidget(cube)) {
      return;
    }
    m_workspace->addCubeViewport(cube);
    // Set the focus policy of the added cubes so the main view will always have focus
    MdiCubeViewport *itemAdded = m_workspace->addCubeViewport(cube);
    //itemAdded->setFocusPolicy(Qt::NoFocus);
    //ViewportMdiSubWindow *mdiSubWindow = qobject_cast<ViewportMdiSubWindow *>(itemAdded->parent()->parent());
    //mdiSubWindow->setFocusPolicy(Qt::NoFocus);

    m_cubeItemMap.insert(cube, item);
  }

+12 −0
Original line number Diff line number Diff line
@@ -93,6 +93,12 @@ namespace Isis {
   *                           Removed methods that returned menu and toolbar actions.
   *                           Removed connections that connected the project and CubeDnView and called
   *                           enableControlNetTool() because Directory now does this.
   *   @history 2018-06-25 Kaitlyn Lee - When multiple views are open, there is a possibility of getting 
   *                           ambiguous shortcut errors. To counter this, we need a way to focus on one
   *                           widget. Giving the views focus did not work completely. Instead,
   *                           enabling/disabling actions was the best option. Added enableActions(),
   *                           disableActions(), enterEvent(), and leaveEvent(). On default, a view's
   *                           actions are disabled. To enable the actions, move the cursor over the view.
   */
  class CubeDnView : public AbstractProjectItemView {

@@ -134,6 +140,10 @@ namespace Isis {
    private:
      Cube *workspaceActiveCube();
      void setWorkspaceActiveCube(Image *image);
      void enterEvent(QEvent *event);
      void leaveEvent(QEvent *event);
      void disableActions();
      void enableActions();

    private:
      /**
@@ -173,6 +183,8 @@ namespace Isis {
      QToolBar *m_permToolBar; //!< A tool bar for storing actions
      QToolBar *m_activeToolBar; //!< A tool bar for storing actions
      ToolPad *m_toolPad; //!< A tool bar for storing actions

      QList<QAction *> m_actions; //!< List of all toolbar and toolpad actions
  };
}

+51 −0
Original line number Diff line number Diff line
@@ -137,6 +137,19 @@ namespace Isis {
    m_sceneWidget->addTo(m_activeToolBar);
    m_sceneWidget->addTo(m_toolPad);

    // Store the actions for easy enable/disable.
    foreach (QAction * action, m_toolPad->actions()) {
      m_actions.append(action);
    }
    foreach (QAction * action, m_permToolBar->actions()) {
      m_actions.append(action);
    }
    foreach (QAction * action, m_activeToolBar->actions()) {
      m_actions.append(action);
    }
    // On default, actions are disabled until the cursor enters the view.
    disableActions();

    // MosaicSceneWidget's default is to have the Control Net Tool enabled.
    // In ipce, we want it to be disabled if an active control is not set.
    foreach (QAction * action, m_toolPad->actions()) {
@@ -328,6 +341,44 @@ namespace Isis {
    m_controlNetTool->setEnabled(value);
  }


  /**
   * Disables toolbars and toolpad actions
   */
  void CubeDnView::disableActions() {
    foreach (QAction * action, m_actions) {
      action->setDisabled(true);
    }
  }


  /**
   * Enables toolbars and toolpad actions
   */
  void CubeDnView::enableActions() {
    foreach (QAction * action, m_actions) {
      action->setEnabled(true);
    }
  }

  /**
   * Enables actions when cursor enters on the view
   * @param event The enter event
   */
  void CubeDnView::enterEvent(QEvent *event) {
    enableActions();
  }


  /**
   * Disables actions when cursor leaves the view
   * @param event The leave event
   */
  void CubeDnView::leaveEvent(QEvent *event) {
    disableActions();
  }


  /**
   * @brief Loads the Footprint2DView from an XML file.
   * @param xmlReader  The reader that takes in and parses the XML file.
+13 −1
Original line number Diff line number Diff line
@@ -86,7 +86,12 @@ namespace Isis {
   *                           the Control Net Tool will be disabled.
   *                           Added enableControlNetTool(bool) so when an active control net is set,
   *                           the tool becomes enabled.

   *   @history 2018-06-25 Kaitlyn Lee - When multiple views are open, there is a possibility of getting
   *                           ambiguous shortcut errors. To counter this, we need a way to focus on one
   *                           widget. Giving the views focus did not work completely. Instead,
   *                           enabling/disabling actions was the best option. Added enableActions(),
   *                           disableActions(), enterEvent(), and leaveEvent(). On default, a view's
   *                           actions are disabled. To enable the actions, move the cursor over the view. 
   */
  class Footprint2DView : public AbstractProjectItemView {

@@ -124,6 +129,11 @@ namespace Isis {
      void onMosItemRemoved(Image *image);

    private:
      void enterEvent(QEvent *event);
      void leaveEvent(QEvent *event);
      void disableActions();
      void enableActions();

      /**
       * @author 2018-05-11 Tracie Sucharski
       *
@@ -156,6 +166,8 @@ namespace Isis {
      ToolPad *m_toolPad; //!< The tool pad

      QAction *m_controlNetTool;  //!< The Control Point Editor Tool

      QList<QAction *> m_actions; //!< List of all toolbar and toolpad actions
  };
}