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

Enable/disable the tile and tab view menu options.

parent 6b00e075
Loading
Loading
Loading
Loading
+58 −32
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@
#include "FileName.h"
#include "IException.h"
#include "IString.h"
#include "JigsawRunWidget.h"
#include "MosaicSceneWidget.h"
#include "ProgressWidget.h"
#include "Project.h"
@@ -80,36 +81,27 @@ namespace Isis {
      QMainWindow(parent) {
    m_maxThreadCount = -1;

    //  Set the initialize size of the mainwindow to fullscreen so that created views do not
    //  get squished.  Saved projects with view had the internal widgets squished because the
    //  initial size of this mainwindow was small and it does not get restored to the saved project
    //  size until after views are created.  For instance, the viewports within a CubeDnView were
    //  restored to a small size based on the original mainwindow size.  If the internal state
    //  of the views such as the viewport sizes, zooms, etc get serialized, this code will not be
    //  needed.
    QDesktopWidget deskTop;
    QRect mainScreenSize = deskTop.availableGeometry(deskTop.primaryScreen());
    resize(mainScreenSize.width(), mainScreenSize.height());

    QWidget *centralWidget = new QWidget;
    setCentralWidget(centralWidget);

    setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::South);

    // This was causing some buggy behavior, but this is what we would ultimately like.
    // Allows a user to undock a group of tabs.
    //setDockOptions(GroupedDragging | AllowTabbedDocks);

    //centralWidget->hide();
    setDockNestingEnabled(true);

    //  Set the splitter frames to a reasonable color/size for resizing the docks.
    setStyleSheet("QMainWindow::separator {background: gray; width: 10; height: 10px;}");
    setStyleSheet("QMainWindow::separator {background: black; width: 3; height: 3px;}");

    try {
      m_directory = new Directory(this);
      connect(m_directory, SIGNAL( newWidgetAvailable(QWidget *) ),
              this, SLOT( addView(QWidget *) ) );

      // Currently this connection is only used by Directory when a new active is chosen & user
      // chooses to discard any edits in the old active control which is in a CnetEditorWidget.
      // The only view which will not be updated with the new control are any CnetEditorViews
      // showing the old active control.  CnetEditorWidget classes do not have the ability to reload
      // a control net, so the CnetEditor view displaying the old control is removed, then recreated.
      connect(m_directory, SIGNAL(viewClosed(QWidget *)),
      connect(m_directory, SIGNAL(closeView(QWidget *)),
              this, SLOT(removeView(QWidget *)));

      connect(m_directory, SIGNAL( directoryCleaned() ),
@@ -194,6 +186,14 @@ namespace Isis {
      OpenProjectWorkOrder *workorder = new OpenProjectWorkOrder(m_directory->project());
      workorder->execute();
    }

    // QTimer *timer = new QTimer(this);
    // connect(timer, SIGNAL(timeout()), this, SLOT(setProjectClean()));
    // connect(timer, SIGNAL(timeout()), timer, SLOT(stop()));
    // timer->start(1000);
  }
  void IpceMainWindow::setProjectClean() {
    m_directory->project()->setClean(true);
  }


@@ -204,6 +204,11 @@ namespace Isis {
   */
  void IpceMainWindow::addView(QWidget *newWidget, Qt::DockWidgetArea area,
                               Qt::Orientation orientation) {
    // JigsawRunWidget is already a QDockWidget, and no modifications need to be made to it
    if (qobject_cast<JigsawRunWidget *>(newWidget)) {
      splitDockWidget(m_projectDock, (QDockWidget*)newWidget, Qt::Vertical);
      return;
    }

    QDockWidget *dock = new QDockWidget(newWidget->windowTitle(), this);
    dock->setWidget(newWidget);
@@ -239,6 +244,10 @@ namespace Isis {

    // Save view docks for cleanup during a project close
    m_viewDocks.append(dock);

    if (m_viewDocks.size == 1) {
      emit enableViewActions(true);
    }
  }


@@ -248,19 +257,27 @@ namespace Isis {
    if (dock) {
      m_viewDocks.removeAll(dock);
    }

    if (m_viewDocks.size == 0) {
      emit enableViewActions(false);
    }
  }


  /**
   * This slot is connected from Directory::viewClosed(QWidget *) signal.  It will
   * close the given view and delete the view. This was written to handle
   * This slot is connected from Directory::closeView(QWidget *) signal.  It will close the given
   * view and delete the view.
   *
   * @param view QWidget* The view to close.
   */
  void IpceMainWindow::removeView(QWidget *view) {

    view->close();
    delete view;
    QDockWidget *parentDock = qobject_cast<QDockWidget *>(view->parent());
    removeDockWidget(parentDock);
    delete parentDock;
    if (m_viewDocks.size == 0) {
      emit enableViewActions(false);
    }
  }


@@ -277,6 +294,9 @@ namespace Isis {
      }
    }
    m_viewDocks.clear();
    if (m_viewDocks.size == 0) {
      emit enableViewActions(false);
    }
  }


@@ -385,11 +405,19 @@ namespace Isis {

    QAction *tabViewsAction = new QAction("Tab Views", this);
    connect( tabViewsAction, SIGNAL(triggered()), this, SLOT(tabViews()) );
    connect( this, SIGNAL(enableViewActions(bool)), tabViewsAction, SLOT(setEnabled(bool)) );
    m_viewMenuActions.append(tabViewsAction);
    if (m_viewDocks.size() == 0) {
      tabViewsAction.setDisabled(true);
    }

    QAction *tileViewsAction = new QAction("Tile Views", this);
    connect( tileViewsAction, SIGNAL(triggered()), this, SLOT(tileViews()) );
    connect( this, SIGNAL(enableViewActions(bool)), tileViewsAction, SLOT(setEnabled(bool)) );
    m_viewMenuActions.append(tileViewsAction);
    if (m_viewDocks.size() == 0) {
      tileViewsAction.setDisabled(true);
    }

    QAction *undoAction = m_directory->undoAction();
    undoAction->setShortcut(Qt::Key_Z | Qt::CTRL);
@@ -528,7 +556,12 @@ namespace Isis {
    QSettings globalSettings(FileName("$HOME/.Isis/" + appName + "/ipce.config").expanded(),
        QSettings::NativeFormat);

    if (project->isTemporaryProject()) {
    // If no config file exists and a user immediately opens a project,
    // the project's geometry will be saved as a default for when ipce is
    // opened again. Previously, the ipce's default size was small,
    // until a user opened ipce (but not a project) and resized to how they
    // wanted it to be sized, then closed ipce.
    if (project->isTemporaryProject() || !globalSettings.contains("geometry")) {
      globalSettings.setValue("geometry", QVariant(geometry()));
    }

@@ -754,13 +787,6 @@ namespace Isis {
      m_maxThreadCount = globalSettings.value("maxThreadCount", m_maxThreadCount).toInt();
      applyMaxThreadCount();
    }

    // The geom/state isn't enough for main windows to correctly remember
    //   their position and size, so let's restore those on top of
    //   the geom and state.
    if (!projectSettings.value("pos").toPoint().isNull()) {
      move(projectSettings.value("pos").toPoint());
    }
  //  m_directory->project()->setClean(true);
  }

+39 −18
Original line number Diff line number Diff line
@@ -131,6 +131,8 @@ namespace Isis {
   *                           test to determine whether project needs saving.
   *   @history 2018-05-01 Tracie Sucharski - Code accidently left commented from previous checking.
   *                           Fixes #5412.
   *   @history 2018-05-31 Christopher Combs - Added support for JigsawRunWidget to be created as a
   *                           dockable widget in addView(). Fixes #5428.
   *   @history 2018-05-30 Tracie Sucharski - Fix to handle the re-factored docked views.
   *                           Changed from MDI to SDI, changing the centralWidget to a dumy, unused
   *                           widget. Remove all methods having to do with MDI sub-windows,
@@ -141,20 +143,23 @@ namespace Isis {
   *   @history 2018-06-13 Tracie Sucharski - Fixed cleanup of views and QDockWidgets.
   *   @history 2018-06-13 Kaitlyn Lee - Since views now inherit from QMainWindow, each individual
   *                           view has its own toolbar, so having an active toolbar and tool pad is
   *                           not needed. Removed code adding the save active control net button and
   *                           the toolpad, since control nets can be saved with the project save button.
   *                           not needed. Removed code adding the save active control net button
   *                           and the toolpad, since control nets can be saved with the project
   *                           save button.
   *   @history 2018-06-14 Christopher Combs - Changed addView method to take in JigsawRunWidget as
   *                           a QDockWidget object instead of wrapping it in one.
   *   @history 2018-06-15 Tracie Sucharski - Fixed break to recent projects.  The readSettings
   *                           must be called before initializeActions to get the recent projects
   *                           from the config file.
   *   @history 2018-06-18 Makayla Shepherd - Set the QApplication name so that BundleAdjust does
   *                           not output text to the command line for ipce. Fixes #4171.
   *   @history 2018-06-19 Kaitlyn Lee - Added tabViews() and the menu option under the View menu to
   *                           tab the views. Currently, this can tab all attached/detached views. I
   *                           left the line setting dock options to allow grouped dragging, but tabbing
   *                           views does not always work with this enabled. With this option enabled, the
   *                           type of a view will randomly change and setting its type has no effect.
   *                           Use windowType() to get the type. Also added the toolbar title in the
   *                           permanent toolbar constructor.
   *                           tab the views. Currently, this can tab all attached/detached views.
   *                           I left the line setting dock options to allow grouped dragging, but
   *                           tabbing views does not always work with this enabled. With this
   *                           option enabled, the type of a view will randomly change and setting
   *                           its type has no effect. Use windowType() to get the type. Also added
   *                           the toolbar title in the permanent toolbar constructor.
   *   @history 2018-06-22 Tracie Sucharski - Cleanup destruction of dock widgets and the views they
   *                           hold.  Extra destroy slots were causing double deletion of memory.
   *   @history 2018-06-22 Tracie Sucharski - Added a showEvent handler so that the project clean
@@ -164,10 +169,10 @@ namespace Isis {
   *   @history 2018-07-07 Summer Stapleton - Added check in the closeEvent() for changes to any
   *                           TemplateEditorWidget currently open to create a pop-up warning/
   *                           option to save.
   *   @history 2018-07-09 Kaitlyn Lee - Added tileViews() and the menu option to tile all docked/undocked
   *                           and tabbed/untabbed views. Changed removeView() to delete the parent dock widget.
   *                           If we do not delete the dock widget, an empty dock widget will remain where the
   *                           view used to be.
   *   @history 2018-07-09 Kaitlyn Lee - Added tileViews() and the menu option to tile all
   *                           docked/undocked and tabbed/untabbed views. Changed removeView() to
   *                           delete the parent dock widget. If we do not delete the dock widget,
   *                           an empty dock widget will remain where the view used to be.
   *   @history 2018-07-10 Tracie Sucharski - Change initial interface of views to tabbed view.
   *                           Changed the QMainWindow separator to a different color and wider size
   *                           for ease of use.  Create the QMainWindow initial size to prevent the
@@ -175,7 +180,21 @@ namespace Isis {
   *   @history 2018-07-11 Kaitlyn Lee - Added a value in the project settings that stores whether a
   *                           project was in fullscreen or not when saved. If not, we call showNormal()
   *                           to restore the poject's window size. This also fixes the warning/history tabs
   *                           being misplaced when opening a project. Fixes #5175.
   *                           being misplaced when opening a project. Fixes #5175. References #5436.
   *   @history 2018-07-12 Tracie Sucharski - Renamed the signal Directory::viewClosed to
   *                           Directory::closeView since Directory does not close the view but
   *                           indicate that the view needs closing.  This signal is now used by
   *                           more than the cnetEditorView, so updated documentation.  Did a little
   *                           cleanup on the removeView  method by removing some code that
   *                           automatically happens due to connection made on destroyed signal.
   *   @history 2018-07-12 Kaitlyn Lee - Removed code that makes the window fullscreen in memory,
   *                           since this was causing a project's window size to not be restored
   *                           when opening from the command line. Decreased the size and changed
   *                           the color of the splitter. In writeGlobalSettings(), check to see if
   *                           the geometry value does not exist in the config file. This allows the
   *                           geometry to be saved if the config file does not exist and a user
   *                           opens a project. Before, it would not save the geometry because the
   *                           opened project was not temporary. References #5433
   */
  class IpceMainWindow : public QMainWindow {
      Q_OBJECT
@@ -183,6 +202,9 @@ namespace Isis {
      explicit IpceMainWindow(QWidget *parent = 0);
      ~IpceMainWindow();

    signals:
      void enableViewActions();

    public slots:
      void addView(QWidget *newWidget, Qt::DockWidgetArea area = Qt::LeftDockWidgetArea,
                   Qt::Orientation orientation = Qt::Horizontal);
@@ -209,6 +231,8 @@ namespace Isis {

      void cleanupViewDockList(QObject *obj);

      void setProjectClean();

    private:
      Q_DISABLE_COPY(IpceMainWindow);

@@ -256,9 +280,6 @@ namespace Isis {
      QList<QAction *> m_helpMenuActions;//!< Internal list of help actions

      QList<QAction *> m_permToolBarActions;//!< Internal list of permanent toolbar actions

      QAction *m_cascadeViewsAction; //!< Action that cascades the mdi area
      QAction *m_tileViewsAction; //!< Action that tiles the mdi area
  };
}