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

Fixed combo box disabling and refactored Footprint2DView.

parent 1e04af17
Loading
Loading
Loading
Loading
+53 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <QAction>
#include <QDebug>
#include <QHBoxLayout>
#include <QKeySequence>
#include <QMap>
#include <QMdiArea>
#include <QMdiSubWindow>
@@ -236,10 +237,34 @@ namespace Isis {
        m_permToolBar->addSeparator();
      }
    }
    // Store the actions for easy enable/disable.

    // Store the actions and widgets for easy enable/disable.
    foreach (QAction *action, findChildren<QAction *>()) {
      // Remove the edit tool's save button shortcut because the ipce main window
      // already has one and this causes an ambiquous shortcut error.
      if (action->toolTip() == "Save") {
        action->setShortcut(QKeySequence());
      }
      // The active toolbar's actions are inside of a container that is a QWidgetAction.
      // We want to skip adding this because we want to disable the active toolbar's
      // actions separately.
      if ( QString::fromLatin1(action->metaObject()->className()) == "QWidgetAction") {
        continue;
      }
      addAction(action);
    }

    // There was a problem with disabling/enabling the combo boxes. The only way to
    // get this to work was to skip disabling the combo boxes. We also skip QWidgets
    // because the combo boxes are contained inside of a QWidget.
    foreach (QWidget *child, m_activeToolBar->findChildren<QWidget *>()) {
      if (QString::fromLatin1(child->metaObject()->className()).contains("ComboBox") |
          QString::fromLatin1(child->metaObject()->className()).contains("Widget")) {
        continue;
      }
      m_childWidgets.append(child);
    }

    // On default, actions are disabled until the cursor enters the view.
    disableActions();

@@ -285,7 +310,33 @@ namespace Isis {


  /**
   * A slot function that is called when directory emits a siganl that an active
   * Disables toolbars and toolpad actions/widgets. Overriden method.
   */
  void CubeDnView::disableActions() {
    foreach (QAction *action, actions()) {
      action->setDisabled(true);
    }
    foreach (QWidget *widget, m_childWidgets) {
      widget->setDisabled(true);
    }
  }


  /**
   * Disables toolbars and toolpad actions/widgets. Overriden method.
   */
  void CubeDnView::enableActions() {
    foreach (QAction *action, actions()) {
      action->setEnabled(true);
    }
    foreach (QWidget *widget, m_childWidgets) {
      widget->setEnabled(true);
    }
  }


  /**
   * A slot function that is called when directory emits a signal that an active
   * control network is set. It enables the control network editor tool in the
   * toolpad and loads the network.
   *
+10 −4
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ class QMenu;
class QModelIndex;
class QToolBar;
class QXmlStreamWriter;
class QWidget;

namespace Isis {

@@ -95,10 +96,12 @@ namespace Isis {
   *                           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 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.
   *                           ambiguous shortcut errors. To counter this, we enable/disable actions.
   *                           Overrode leaveEvent() to handle open menus causing a leave event. Overrode
   *                           enable/disableActions() because we need to disable the active toolbar's widgets.
   *                           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 CubeDnView : public AbstractProjectItemView {

@@ -136,11 +139,13 @@ namespace Isis {
      void onItemAdded(ProjectItem *item);
      void onCubeViewportAdded(MdiCubeViewport *viewport);
      void onCubeViewportDeleted(QObject *obj);
      void disableActions();

    private:
      Cube *workspaceActiveCube();
      void setWorkspaceActiveCube(Image *image);
      void leaveEvent(QEvent *event);
      void enableActions();

    private:
      /**
@@ -179,6 +184,7 @@ 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<QWidget *> m_childWidgets;  //!< Child widgets of the active toolbar
  };
}

+1 −7
Original line number Diff line number Diff line
@@ -138,13 +138,7 @@ namespace Isis {
    m_sceneWidget->addTo(m_toolPad);

    // 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.