Commit 68a9d099 authored by Adam Goins's avatar Adam Goins
Browse files

Created a the ViewSubWindow subclass of QMainWindow to properly handle closing...

Created a the ViewSubWindow subclass of QMainWindow to properly handle closing detached views. Fixes #5109

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@8287 41f8697f-d340-4b68-9986-7bafba869bb8
parent 99b2b2c2
Loading
Loading
Loading
Loading
+31 −32
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@
 */
#include "IpceMainWindow.h"


#include <QApplication>
#include <QColor>
#include <QDebug>
@@ -55,6 +54,7 @@
#include "OpenProjectWorkOrder.h"
#include "SensorInfoWidget.h"
#include "TargetInfoWidget.h"
#include "ViewSubWindow.h"

namespace Isis {
  /**
@@ -615,7 +615,6 @@ namespace Isis {
   */
  void IpceMainWindow::writeSettings(const Project *project) const {


    // Ensure that we are not using a NULL pointer
    if (!project) {
      QString msg = "Cannot write settings with a NULL Project pointer.";
@@ -647,9 +646,7 @@ namespace Isis {
    QMap<QString,QString> recentProjects;

    foreach (QString key,keys) {

      recentProjects[key]=globalSettings.value(key).toString();

    }

    QList<QString> projectPaths = recentProjects.values();
@@ -659,8 +656,6 @@ namespace Isis {
      //Clear out the recent projects before repopulating this group
      globalSettings.remove("");



      //If the currently open project is a project that has been saved and is not within the current
      //list of recently open projects, then remove the oldest project from the list.
      if (!project->projectPath().contains("tmpProject") && !projectPaths.contains(project->projectPath()) ) {
@@ -680,27 +675,19 @@ namespace Isis {

      //Iterate through the recentProjects QMap and set the <key,val> pairs.
      for (i=recentProjects.begin();i!=recentProjects.end();i++) {

          globalSettings.setValue(i.key(),i.value());


      }

      //Get a unique time value for generating a key
      long t0 = QDateTime::currentMSecsSinceEpoch();
      QString projName = project->name();



      QString projName = project->name();
      QString t0String=QString::number(t0);

      //Save the project location
      if (!project->projectPath().contains("tmpProject") ) {
              globalSettings.setValue(t0String+"%%%%%"+projName,project->projectPath());


      }

    }

    //The numer of recent open projects is less than m_maxRecentProjects
@@ -713,17 +700,8 @@ namespace Isis {
      if (!project->projectPath().contains("tmpProject") && !projectPaths.contains( project->projectPath() ) ) {
        globalSettings.setValue(t0String+"%%%%%"+projName,project->projectPath());
      }

    }


    globalSettings.endGroup();






  }


@@ -944,6 +922,21 @@ namespace Isis {
    m_tileViewsAction->setEnabled(true);
  }

  /**
   * Closes the detached window and removes it from the m_detachedViews list
   */
  void IpceMainWindow::closeDetachedView() {

    ViewSubWindow *viewWindow = qobject_cast<ViewSubWindow *>( sender() );

    if (!viewWindow) {
      return;
    }

    m_detachedViews.removeAt(m_detachedViews.indexOf(viewWindow));
    viewWindow->close();
  }


  /**
   * Moves the active view from the mdi area to its own independent
@@ -966,7 +959,14 @@ namespace Isis {
      mdiArea->closeActiveSubWindow();
    }

    QMainWindow *newWindow = new QMainWindow(this, Qt::Window);
    ViewSubWindow *newWindow = new ViewSubWindow(this, Qt::Window);

    connect( newWindow, SIGNAL( closeWindow() ),
             this, SLOT( closeDetachedView() ) );

    connect( newWindow, SIGNAL( closeWindow() ),
             view, SLOT( deleteLater() ) );

    m_detachedViews.append(newWindow);
    newWindow->setCentralWidget(view);
    newWindow->setWindowTitle( view->windowTitle() );
@@ -1053,7 +1053,6 @@ namespace Isis {
      menuBar->addMenu(helpMenu);
    }
    newWindow->show();

  }


+10 −4
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@
 *   http://www.usgs.gov/privacy.html.
 */

#include <QMainWindow>
#include "ViewSubWindow.h"
#include <QPointer>
#include <QProgressBar>
#include <QMdiSubWindow>
@@ -106,6 +106,11 @@ namespace Isis {
   *   @history 2017-11-02 Tyler Wilson - Added the ability to read/write settings for recent
   *                           projects.  Also re-implemented the functionality for loading
   *                           recent projects in IPCE.  Fixes #4492.
   *   @history 2017-11-03 Adam Goins - Modified the detached QMainWindow to be a ViewSubWindow
   *                           so that we can capture the windowClose() signal and remove
   *                           detached views from the m_detachedViews list appropriately.
   *                           This fixes an issue where a detached view would appear to be
   *                           open even after it has been closed. Fixes #5109.
   */
  class IpceMainWindow : public QMainWindow {
      Q_OBJECT
@@ -135,6 +140,7 @@ namespace Isis {
      void setTabbedViewMode();
      void setSubWindowViewMode();

      void closeDetachedView();
      void detachActiveView();
      void reattachView();

@@ -156,7 +162,7 @@ namespace Isis {
      QPointer<Directory> m_directory;

      QDockWidget *m_projectDock;
      QList<QMainWindow *> m_detachedViews; //!< List to keep track of any detached main windows
      QList<ViewSubWindow *> m_detachedViews; //!< List to keep track of any detached main windows
      QDockWidget *m_warningsDock;
      /**
       * This is the "goal" or "estimated" maximum number of active threads running in this program
+7 −0
Original line number Diff line number Diff line
ifeq ($(ISISROOT), $(BLANK))
.SILENT:
error:
	echo "Please set ISISROOT";
else
	include $(ISISROOT)/make/isismake.objs
endif
 No newline at end of file
+54 −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 &amp; 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 "ViewSubWindow.h"

namespace Isis {
    
  /**
   * Constructs a ViewSubWindow object
   */
  ViewSubWindow::ViewSubWindow(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, flags) {
    
  }


  /**
   *  Destructor
   */
  ViewSubWindow::~ViewSubWindow() {
      
  }



  /**
   * This emits a signal on close so that we can handle removing the window from the
   *
   * @param event
   */
  void ViewSubWindow::closeEvent(QCloseEvent *event) {
    emit closeWindow();
    QMainWindow::closeEvent(event);
  }
}
+57 −0
Original line number Diff line number Diff line
#ifndef ViewSubWindow_h
#define ViewSubWindow_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 &amp; 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 <QMainWindow>

namespace Isis {

  /**
   * @brief This class exists to contain detached views from ipce.
   *          the purpose is for it to emit the closeWindow() signal
   *          so that we can track when detached windows are closed. 
   *
   * @ingroup Visualization Tools
   *
   * @author 2017-10-25 Adam Goins
   *
   * @internal
   *
   *  @history 2017-10-25 Adam Goins - This class created. 
   */
  class ViewSubWindow : public QMainWindow {
      Q_OBJECT

    signals:
      void closeWindow(); //!< Signal called when the window receives a close event

    public:
      ViewSubWindow(QWidget *parent, Qt::WindowFlags flags = 0);
      virtual ~ViewSubWindow();

    protected:
      virtual void closeEvent(QCloseEvent *event);
  };
};

#endif
Loading