Commit e352528b authored by Adam Goins's avatar Adam Goins
Browse files

Added optional parameter to accept a possible close event and if the popup...

Added optional parameter to accept a possible close event and if the popup dialogue's "cancel" option was selected, set the event to unaccepted so that the window doesn't close.
parent 0998e2e4
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -219,11 +219,19 @@ namespace Isis {
    emit newControlNetwork(controlNet());
  }


  /**
   *  Exit the program
   *
   *  @internal
   *  @history 2018-04-24 Adam Goins - Added QCloseEvent optional parameter to
   *                          set the CloseEvent triggered by an onwindowclose
   *                          to ignore the event if the 'cancel' option was selected
   *                          after clicking the close button of the viewport window.
   *                          This fixes an issue where clicking the close button and then clicking
   *                          'cancel' from the QMessageBox would close the window but keep the
   *                          application running. Fixes #4146.
   */
  void QnetFileTool::exit() {
  void QnetFileTool::exit(QCloseEvent *event) {
    //  If control net has been changed , prompt for user to save
    if (m_isDirty) {
      int resp = QMessageBox::warning((QWidget *)parent(), "QnetTool",
@@ -236,14 +244,15 @@ namespace Isis {
        saveAs();
      }
      if (resp == QMessageBox::Cancel) {
        if (event) {
          event->setAccepted(false);
        }
        return;
      }
    }
    qApp->quit();
  }



    /**
   *  Save control network with given file
   *  @internal
+12 −4
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
 */

#include "FileTool.h"
#include <QCloseEvent>

class QString;
class QWidget;
@@ -79,6 +80,13 @@ namespace Isis {
   *   @history 2016-04-22 Jeannie Backer - Modified to use cube labels to set
   *                           ControlNet's target instead of the TargetName.
   *                           References #3892
   *  @history 2018-04-24 Adam Goins - Added QCloseEvent optional parameter to slot "exit()" to
   *                          set the CloseEvent triggered by an onwindowclose
   *                          to ignore the event if the 'cancel' option was selected
   *                          after clicking the close button of the viewport window.
   *                          This fixes an issue where clicking the close button and then clicking
   *                          'cancel' from the QMessageBox would close the window but keep the
   *                          application running. Fixes #4146.
   *
   */

@@ -103,7 +111,7 @@ namespace Isis {

    public slots:
      virtual void open();
      virtual void exit();
      virtual void exit(QCloseEvent *event = NULL);
      virtual void save();
      virtual void saveAs();
      void loadPointImages(ControlPoint *point);