Unverified Commit 68352b4a authored by Kaitlyn Lee's avatar Kaitlyn Lee Committed by GitHub
Browse files

Merge pull request #506 from AgoinsUSGS/Goins_Adam_m04146

parents 3be233d4 ec29de18
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -225,8 +225,11 @@ int main(int argc, char *argv[]) {
    /**** EXITING ****/
    // Connect the viewport's close signal to the file tool's exit method
    // Added 2008-12-04 by Jeannie Walldren
    QObject::connect(vw , SIGNAL(closeWindow()),
                     ftool, SLOT(exit()));
    // Added 2018-04-24 by Adam Goins - Added in optional parameters to the closeWindow() signal
    //                         And the exit() slot so that the window's closeEvent can be handled
    //                         Appropriately. Fixes #4146.
    QObject::connect(vw , SIGNAL(closeWindow(QCloseEvent *)),
                     ftool, SLOT(exit(QCloseEvent *)));
    //-----------------------------------------------------------------

    vw->show();
+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);
+15 −3
Original line number Diff line number Diff line
@@ -103,15 +103,27 @@ namespace Isis {
   * signal and ignores the close event.
   *
   * @param event
   *
   *  @internal
   *  @history 2018-04-24 Adam Goins - Added optional parameter QCloseEvent to
   *                          the closeWindow() signal so that the close event can be caught
   *                          and set to rejected by listening applications (such as qnet).
   *                          Fixes an issue where closing qnet and clicking 'cancel' from the
   *                          proceeding popup dialogue would still close the window but leave
   *                          the application running. Fixes #4146.
   */
  void ViewportMainWindow::closeEvent(QCloseEvent *event) {
    if (p_workspace->confirmClose()) {
      emit closeWindow();
      emit closeWindow(event);
      if (event->isAccepted()) {
        MainWindow::closeEvent(event);
      }
      else {
        event->ignore();
      }
    }
    else {
      event->ignore();
    }
  }
}
+7 −1
Original line number Diff line number Diff line
@@ -33,12 +33,18 @@ namespace Isis {
   *           when exception occured
   *  @history 2012-05-29 Steven Lambright - Updated closeEvent() to ask the user to save any
   *                          unsaved modifications to the opened cube. References #854.
   *  @history 2018-04-24 Adam Goins - Added optional parameter QCloseEvent to
   *                          the closeWindow() signal so that the close event can be caught
   *                          and set to rejected by listening applications (such as qnet).
   *                          Fixes an issue where closing qnet and clicking 'cancel' from the
   *                          proceeding popup dialogue would still close the window but leave
   *                          the application running. Fixes #4146.
   */
  class ViewportMainWindow : public MainWindow {
      Q_OBJECT

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

    public slots:
      void displayWarning(std::string &pStr, const std::string &pExStr);