Commit 3a60bac3 authored by Kaitlyn Lee's avatar Kaitlyn Lee
Browse files

Created MenuItem, removed zoom shortcuts from ControlMeasureEditWidget, and...

Created MenuItem, removed zoom shortcuts from ControlMeasureEditWidget, and fixed disabling when a menu is visible.
parent c9ef6f4a
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
/**
 * @file
 * $Date$
 * $Revision$
 *
 *   Unless noted otherwise, the portions of Isis written by the USGS are
 *   public domain. See individual third-party library and package descriptions
 *   for intellectual property information, user agreements, and related
 *   information.
 *
 *   Although Isis has been used by the USGS, no warranty, expressed or
 *   implied, is made by the USGS as to the accuracy and functioning of such
 *   software and related material nor shall the fact of distribution
 *   constitute any such warranty, and no responsibility is assumed by the
 *   USGS in connection therewith.
 *
 *   For additional information, launch
 *   $ISISROOT/doc//documents/Disclaimers/Disclaimers.html
 *   in a browser or see the Privacy & Disclaimers page on the Isis website,
 *   http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on
 *   http://www.usgs.gov/privacy.html.
 */
#include "MenuItem.h"

namespace Isis {

  /**
   * Constructs a MenuItem with the QMenu constructor
   *
   * @param title  Title of the menu
   *
   * @param parent Parent widget
   */
  //  MenuItem::MenuItem(const QString &title, QWidget *parent = 0) {
  //   QMenu(title, parent);
  // }


  /**
   * Overrides the closeEvent to emit the signal menuClosed().
   * menuClosed() is connected to the slot disableActions() in a view.
   *
   * @param event The close event
   */
  void MenuItem::closeEvent(QCloseEvent *event) {
    emit menuClosed();
  }
}
+53 −0
Original line number Diff line number Diff line
#ifndef MenuItem_h
#define MenuItem_h
/**
 * @file
 * $Date$
 * $Revision$
 *
 *   Unless noted otherwise, the portions of Isis written by the USGS are
 *   public domain. See individual third-party library and package descriptions
 *   for intellectual property information, user agreements, and related
 *   information.
 *
 *   Although Isis has been used by the USGS, no warranty, expressed or
 *   implied, is made by the USGS as to the accuracy and functioning of such
 *   software and related material nor shall the fact of distribution
 *   constitute any such warranty, and no responsibility is assumed by the
 *   USGS in connection therewith.
 *
 *   For additional information, launch
 *   $ISISROOT/doc//documents/Disclaimers/Disclaimers.html
 *   in a browser or see the Privacy & Disclaimers page on the Isis website,
 *   http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on
 *   http://www.usgs.gov/privacy.html.
 */

#include <QMenu>

namespace Isis {

  /**
   * QMenu subclass that overrides the closeEvent.
   *
   * @author 2018-06-27 Kaitlyn Lee
   *
   * @internal
   *   @history 2018-06-27 Kaitlyn Lee - Original version.
   */

  class MenuItem : public QMenu {
    Q_OBJECT

    public:
      MenuItem(const QString &title, QWidget *parent = 0) : QMenu(title, parent){};

    signals:
      void menuClosed();

    private:
      void closeEvent(QCloseEvent *event);
  };
}

#endif
+11 −17
Original line number Diff line number Diff line
@@ -142,21 +142,18 @@ namespace Isis {
    leftZoomIn->setIconSize(isize);
    leftZoomIn->setToolTip("Zoom In 2x");
    leftZoomIn->setWhatsThis("Zoom In 2x on left measure.");
    leftZoomIn->setShortcut(Qt::Key_Plus);

    QToolButton *leftZoomOut = new QToolButton();
    leftZoomOut->setIcon(QPixmap(toolIconDir + "/viewmag-.png"));
    leftZoomOut->setIconSize(isize);
    leftZoomOut->setToolTip("Zoom Out 2x");
    leftZoomOut->setWhatsThis("Zoom Out 2x on left measure.");
    leftZoomOut->setShortcut(Qt::Key_Minus);

    QToolButton *leftZoom1 = new QToolButton();
    leftZoom1->setIcon(QPixmap(toolIconDir + "/viewmag1.png"));
    leftZoom1->setIconSize(isize);
    leftZoom1->setToolTip("Zoom 1:1");
    leftZoom1->setWhatsThis("Show left measure at full resolution.");
    leftZoom1->setShortcut(Qt::Key_Slash);

    QHBoxLayout *leftZoomPan = new QHBoxLayout;
    leftZoomPan->addWidget(leftZoomIn);
@@ -216,7 +213,6 @@ namespace Isis {
    m_rightZoomIn->setIconSize(isize);
    m_rightZoomIn->setToolTip("Zoom In 2x");
    m_rightZoomIn->setWhatsThis("Zoom In 2x on right measure.");
    m_rightZoomIn->setShortcut(Qt::Key_Plus);

    m_rightZoomOut = new QToolButton();
    m_rightZoomOut->setIcon(QIcon(FileName("$base/icons/viewmag-.png").
@@ -224,14 +220,12 @@ namespace Isis {
    m_rightZoomOut->setIconSize(isize);
    m_rightZoomOut->setToolTip("Zoom Out 2x");
    m_rightZoomOut->setWhatsThis("Zoom Out 2x on right measure.");
    m_rightZoomOut->setShortcut(Qt::Key_Minus);

    m_rightZoom1 = new QToolButton();
    m_rightZoom1->setIcon(QPixmap(toolIconDir + "/viewmag1.png"));
    m_rightZoom1->setIconSize(isize);
    m_rightZoom1->setToolTip("Zoom 1:1");
    m_rightZoom1->setWhatsThis("Show right measure at full resolution.");
    m_rightZoom1->setShortcut(Qt::Key_Slash);

    QHBoxLayout *rightZoomPan = new QHBoxLayout;
    rightZoomPan->addWidget(m_rightZoomIn);
@@ -604,7 +598,7 @@ namespace Isis {

    QHBoxLayout *rightLayout = new QHBoxLayout();
    m_autoReg = new QPushButton("Register");
    m_autoReg->setShortcut(Qt::Key_R);
    //m_autoReg->setShortcut(Qt::Key_R);
    m_autoReg->setToolTip("Sub-pixel register the right measure to the left. "
                          "<strong>Shortcut: R</strong>");
    m_autoReg->setToolTip("Sub-pixel register the right measure to the left");
@@ -748,10 +742,10 @@ namespace Isis {
      //  Undo Registration
      m_autoRegShown = false;
      m_autoRegExtension->hide();
      m_autoReg->setText("Register");
      m_autoReg->setToolTip("Sub-pixel register the right measure to the left."
                            "<strong>Shortcut: R</strong>");
      m_autoReg->setShortcut(Qt::Key_R);
      // m_autoReg->setText("Register");
      // m_autoReg->setToolTip("Sub-pixel register the right measure to the left."
      //                       "<strong>Shortcut: R</strong>");
      // m_autoReg->setShortcut(Qt::Key_R);
    }

    m_leftMeasure = leftMeasure;
@@ -810,8 +804,8 @@ namespace Isis {
      //  Undo Registration
      m_autoRegShown = false;
      m_autoRegExtension->hide();
      m_autoReg->setText("Register");
      m_autoReg->setShortcut(Qt::Key_R);
      // m_autoReg->setText("Register");
      // m_autoReg->setShortcut(Qt::Key_R);
    }
    m_autoRegAttempted = false;

@@ -913,10 +907,10 @@ namespace Isis {
      //  Undo Registration
      m_autoRegShown = false;
      m_autoRegExtension->hide();
      m_autoReg->setText("Register");
      m_autoReg->setToolTip("Sub-pixel register the right measure to the left. "
                            "<strong>Shortcut: R</strong>");
      m_autoReg->setShortcut(Qt::Key_R);
    //   m_autoReg->setText("Register");
    //   m_autoReg->setToolTip("Sub-pixel register the right measure to the left. "
    //                         "<strong>Shortcut: R</strong>");
    //   m_autoReg->setShortcut(Qt::Key_R);
    }

    QString pos = "Sample: " + QString::number(m_rightView->tackSample()) +
+45 −7
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@
#include <QSize>
#include <QSizePolicy>
#include <QToolBar>
#include <QVBoxLayout>
#include <QWidgetAction>

#include "ControlNet.h"
@@ -53,15 +52,16 @@ namespace Isis {
    //       net, while the editors might be using a different net.  Will Directory keep track?
    //

    QWidget *centralWidget = new QWidget;
    setCentralWidget(centralWidget);
    QVBoxLayout *layout = new QVBoxLayout;
    centralWidget->setLayout(layout);

    layout->addWidget(m_controlPointEditWidget);
    setCentralWidget(m_controlPointEditWidget);

    setAcceptDrops(true);

    // Store the actions for easy enable/disable.
    m_buttons = m_controlPointEditWidget->findChildren<QPushButton *>();

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

    QSizePolicy policy = sizePolicy();
    policy.setHorizontalPolicy(QSizePolicy::Expanding);
    policy.setVerticalPolicy(QSizePolicy::Expanding);
@@ -97,4 +97,42 @@ namespace Isis {
  QSize ControlPointEditView::sizeHint() const {
    return QSize(800, 600);
  }


  /**
   * Disables toolbars and toolpad actions
   */
  void ControlPointEditView::disableActions() {
    foreach (QPushButton *button, m_buttons) {
      button->setDisabled(true);
    }
  }


  /**
   * Enables toolbars and toolpad actions
   */
  void ControlPointEditView::enableActions() {
    foreach (QPushButton *button, m_buttons) {
      button->setEnabled(true);
    }
  }

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


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

}
+7 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <QPointer>
#include <QToolBar>
#include <QWidgetAction>
#include <QPushButton>

#include "AbstractProjectItemView.h"

@@ -68,8 +69,14 @@ class ControlPointEditView : public AbstractProjectItemView {
  QSize sizeHint() const;

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

    QPointer<ControlPointEditWidget> m_controlPointEditWidget;
    QMap<Control *, ProjectItem *> m_controlItemMap;  //!<Maps control net to project item
    QList<QPushButton *> m_buttons;
  };
}

Loading