Commit e1be3e8b authored by Makayla Shepherd's avatar Makayla Shepherd
Browse files

Fixing merge commits

parent b5cda25e
Loading
Loading
Loading
Loading
+113 −104
Original line number Diff line number Diff line
@@ -174,9 +174,6 @@ namespace Isis {
    createMenus();
    createToolBars();
    
    // Read default app settings
    readSettings(m_directory->project() );

    QStringList args = QCoreApplication::arguments();

    if (args.count() == 2) {
@@ -210,12 +207,10 @@ namespace Isis {
      addDockWidget(area, dock, orientation);
    }

    // Connections for cleanup in both directions to make sure both views and docks are cleaned up
    connect(newWidget, SIGNAL(destroyed(QObject *)), dock, SLOT(deleteLater()));
    // When dock widget is destroyed, make sure the view it holds is also destroyed
    connect(dock, SIGNAL(destroyed(QObject *)), newWidget, SLOT(deleteLater()));
    // The list of dock widgets needs cleanup as each view is destroyed
    connect(dock, SIGNAL(destroyed(QObject *)),
            this, SLOT(cleanupViewDockList(QObject *)));
    connect(dock, SIGNAL(destroyed(QObject *)), this, SLOT(cleanupViewDockList(QObject *)));

    // Save view docks for cleanup during a project close
    m_viewDocks.append(dock);
@@ -266,6 +261,22 @@ namespace Isis {
  }


  /** 
   * This is needed so that the project clean flag is not set to false when move and resize events 
   * are emitted from ipce.cpp when IpceMainWindow::show() is called. 
   * The non-spontaneous or internal QShowEvent is only emitted once from ipce.cpp, so the project 
   * clean flag can be reset. 
   * 
   * @param event QShowEvent* 
   *
   */
  void IpceMainWindow::showEvent(QShowEvent *event) {
    if (!event->spontaneous()) {
      m_directory->project()->setClean(true);
    }
  }


  /**
   * Filters out events from views so they can be handled by the main
   * window. Filters out DragEnter Drop and ContextMenu events from
@@ -488,54 +499,18 @@ namespace Isis {


  /**
   * Write the window positioning and state information out to a
   * config file. This allows us to restore the settings when we
   * create another main window (the next time this program is run).
   *
   * The state will be saved according to the currently loaded project and its name.
   *
   * When no project is loaded (i.e. the default "Project" is open), the config file used is
   * $HOME/.Isis/$APPNAME/$APPNAME_Project.config.
   * When a project, ProjectName, is loaded, the config file used is
   * $HOME/.Isis/$APPNAME/$APPNAME_ProjectName.config.
   *
   * @param[in] project Pointer to the project that is currently loaded (default is "Project")
   *
   * @internal
   *   @history 2016-11-09 Ian Humphrey - Settings are now written according to the loaded project.
   *                           References #4358.
   *   @history 2017-10-17 Tyler Wilson Added a [recent projects] group for the saving and
   *                           restoring of recently opened projects.  References #4492.
   * Writes the global settings like recent projects and thread count.
   */
  void IpceMainWindow::writeSettings(Project *project) {
  void IpceMainWindow::writeGlobalSettings(Project *project) {

    // Ensure that we are not using a NULL pointer
    if (!project) {
      QString msg = "Cannot write settings with a NULL Project pointer.";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }
    QString appName = QApplication::applicationName();

    QString filePath = project->newProjectRoot() + "/ipce.config";  
    if (project->isTemporaryProject()) {
      filePath = "$HOME/.Isis/" + appName + "/ipce.config";
    }
        
    QSettings projectSettings(FileName(filePath).expanded(), QSettings::NativeFormat);

    QSettings globalSettings(
        FileName("$HOME/.Isis/" + appName + "/ipce.config")
          .expanded(),
    QSettings globalSettings(FileName("$HOME/.Isis/" + appName + "/ipce.config").expanded(),
        QSettings::NativeFormat);

    projectSettings.setValue("geometry", QVariant(geometry()));
    
    // If we try to restore a state when we don't have the cubes for a view it could cause a crash
    // Therefore we only want to save the state if we are NOT saving to the default area
    if (!project->isTemporaryProject()) {
      projectSettings.setValue("windowState", saveState());
    if (project->isTemporaryProject()) {
      globalSettings.setValue("geometry", QVariant(geometry()));
    }
    projectSettings.sync();
    
    globalSettings.setValue("maxThreadCount", m_maxThreadCount); 
    globalSettings.setValue("maxRecentProjects",m_maxRecentProjects);
@@ -597,7 +572,7 @@ namespace Isis {
      QString projName = project->name();
      QString t0String=QString::number(t0);

      if (!project->projectRoot().contains("tmpProject") &&
      if (!project->isTemporaryProject() &&
          !projectPaths.contains( project->projectRoot())) {
        globalSettings.setValue(t0String+"%%%%%"+projName,project->projectRoot());
      }
@@ -607,6 +582,40 @@ namespace Isis {
  }


  /**
   * Write the window positioning and state information out to a
   * config file. This allows us to restore the settings when we
   * create another main window (the next time this program is run).
   *
   * The state will be saved in the currently loaded project's root.
   *
   * @param[in] project Pointer to the project that is currently loaded (default is "Project")
   *
   * @internal
   *   @history 2016-11-09 Ian Humphrey - Settings are now written according to the loaded project.
   *                           References #4358.
   *   @history 2017-10-17 Tyler Wilson Added a [recent projects] group for the saving and
   *                           restoring of recently opened projects.  References #4492.
   */
  void IpceMainWindow::writeSettings(Project *project) {

    // Ensure that we are not using a NULL pointer
    if (!project) {
      QString msg = "Cannot write settings with a NULL Project pointer.";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }
    QSettings projectSettings(FileName(project->newProjectRoot() + "/ipce.config").expanded(),
        QSettings::NativeFormat);

    projectSettings.setValue("geometry", QVariant(geometry()));
    projectSettings.setValue("windowState", saveState());
    projectSettings.sync();

    //TODO Do we really need this? Isn't this a global setting? Can the user even change this?
    projectSettings.setValue("maxThreadCount", m_maxThreadCount);
  }


  /**
   * Read the window positioning and state information from the config file.
   *
@@ -638,15 +647,13 @@ namespace Isis {
    // If the file does not exist then we read settings from .Isis/ipce/ipce.config
    QString appName = QApplication::applicationName();
    QString filePath = project->projectRoot() + "/ipce.config";
    
    bool setFullScreen = false;
    bool isFullScreen = false;
    if (!FileName(filePath).fileExists()) {
      filePath = "$HOME/.Isis/" + appName + "/ipce.config";
      
      // If the $HOME/.Isis/ipce/ipce.config does not exist then we want ipce to show up in 
      // in full screen. In other words the default geometry is full screen
      if (!FileName(filePath).fileExists()) {
        setFullScreen = true;
        isFullScreen = true;
      }
    }
    
@@ -655,26 +662,29 @@ namespace Isis {
    }
    else {
      setWindowTitle( project->name() );
      QString projName = project->name();
      setWindowTitle(projName );
    }

    QSettings settings(FileName(filePath).expanded(), QSettings::NativeFormat);
    QSettings projectSettings(FileName(filePath).expanded(), QSettings::NativeFormat);
    
    if (!setFullScreen) {
      setGeometry(settings.value("geometry").value<QRect>());
      restoreState(settings.value("windowState").toByteArray());
    if (!isFullScreen) {
      setGeometry(projectSettings.value("geometry").value<QRect>());
      if (!project->isTemporaryProject()) {
        restoreState(projectSettings.value("windowState").toByteArray());
      }
    }
    else {
      this->showMaximized();
    }

    if (project->name() == "Project") {
      QSettings globalSettings(FileName("$HOME/.Isis/" + appName + "/ipce.config").expanded(), 
                              QSettings::NativeFormat);
      QStringList projectNameList;
      QStringList projectPathList;
    QSettings globalSettings(
                FileName("$HOME/.Isis/" + appName + "/ipce.config").expanded(), 
                QSettings::NativeFormat);
      globalSettings.beginGroup("recent_projects");
      QStringList keys = globalSettings.allKeys();

      QRegExp underscore("%%%%%");

      foreach (QString key, keys) {
@@ -688,7 +698,6 @@ namespace Isis {
      globalSettings.endGroup();

      QStringList projectPathReverseList;

      for (int i = projectPathList.count() - 1; i >= 0; i--) {
        projectPathReverseList.append(projectPathList[i]);
      }
@@ -706,19 +715,18 @@ namespace Isis {
          break;
        }


      m_directory->setRecentProjectsList(projectPathListTruncated);
      m_directory->updateRecentProjects();
      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 (!settings.value("pos").toPoint().isNull())
      move(settings.value("pos").toPoint());

    m_maxThreadCount = globalSettings.value("maxThreadCount", m_maxThreadCount).toInt();
    applyMaxThreadCount();

    if (!projectSettings.value("pos").toPoint().isNull()) {
      move(projectSettings.value("pos").toPoint());
    }
  }


@@ -748,7 +756,8 @@ namespace Isis {
        m_directory->project()->save();
      }
    }
    writeSettings(m_directory->project());
    //  Write global settings, for now this is for the project "Project"
    writeGlobalSettings(m_directory->project());
    m_directory->project()->clear();

    QMainWindow::closeEvent(event);
+11 −15
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
 */

#include "ViewSubWindow.h"
#include <QEvent>
#include <QMainWindow>
#include <QPointer>
#include <QProgressBar>
@@ -132,8 +133,6 @@ namespace Isis {
   *                           Fixes #5412.
   *   @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. Added addDock method. Remove all methods having to do with
   *                           MDI sub-windows, detached views.
   *                           widget. Remove all methods having to do with MDI sub-windows,
   *                           detached views.  The dock widgets holding the views are saved off
   *                           for cleanup because there is no way to get the dock from the view.
@@ -144,11 +143,6 @@ namespace Isis {
   *                           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.
   *   @history 2018-06-14 Makayla Shepherd - ipce now defaults to full screen if there is not an
   *                           ipce.config in the project or in ~/.Isis/ipce.
   *   @history 2018-06-14 Makayla Shepherd - Stopped saving the state of a temporary project.
   *   @history 2018-06-14 Makayla Shepherd - Save and Save As now save the geometry and state of 
   *                           the project. 
   *   @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.
@@ -159,11 +153,12 @@ namespace Isis {
   *                           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-20 Makayla Shepherd - ipce now defaults to full screen if there is not an
   *                           ipce.config in the project or in ~/.Isis/ipce.
   *   @history 2018-06-20 Makayla Shepherd - Stopped saving the state of a temporary project.
   *   @history 2018-06-20 Makayla Shepherd - Save and Save As now save the geometry and state of 
   *                           the project.
   *   @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
   *                           state can be reset after the IpceMainWindow::show() causes resize and
   *                           move events which in turn cause the project clean flag to be false
   *                           even though the project has just opened.
   */
  class IpceMainWindow : public QMainWindow {
      Q_OBJECT
@@ -178,8 +173,11 @@ namespace Isis {
      void removeAllViews();

      void readSettings(Project *);
      void writeSettings(Project *project);
      void writeGlobalSettings(Project *project);

    protected:
      void showEvent(QShowEvent *event);
      void closeEvent(QCloseEvent *event);
      bool eventFilter(QObject *watched, QEvent *event);

@@ -190,10 +188,8 @@ namespace Isis {
      void tabViews();

      void raiseWarningTab();
      
      void writeSettings(Project *project);

      void cleanupViewDockList(QObject *obj);

    private:
      Q_DISABLE_COPY(IpceMainWindow);

+6 −4
Original line number Diff line number Diff line
@@ -2192,11 +2192,12 @@ namespace Isis {
        m_isTemporaryProject = false;
        save( QFileInfo(newDestination + "/").absolutePath() );
        
        
        // delete the temporary project
        deleteAllProjectFiles();
        relocateProjectRoot(newDestination);

//         emit projectSave((const Project *)this);
        
        // 2014-03-14 kle This is a lame kludge because we think that relocateProjectRoot is not
        // working properly. For example, when we save a new project and try to view a control net
        // the it thinks it's still in the /tmp area
@@ -2217,6 +2218,7 @@ namespace Isis {
      }

      save(m_projectRoot->absolutePath(), false);
//       emit projectSave((const Project *)this);
    }

    return saveDialogCompleted;
@@ -2429,8 +2431,8 @@ namespace Isis {
    directoryStateWriter.writeEndDocument();
    m_isOpen = true;

    m_isTemporaryProject = false;
    emit projectSaved(this);

  }


+11 −5
Original line number Diff line number Diff line
@@ -255,8 +255,17 @@ namespace Isis {
   *                           the wrong place on the project tree. Fixes #5274.
   *  @history 2018-06-06 Kaitlyn Lee - activeControlModified() calls setClean(false) to enable the save
   *                           button when the active control net is modified, i.e. a point is modified.
   *  @history 2018-06-14 Makayla Shepherd - Save and Save As now save the geometry and state of 
   *                           the project.
   *  
   *  !!!!!!!!!!!!!   Delete following history entry when project save/restore geometry/state
   *                   implemented
   *  !!!!!!!!!!!!!!!
   *  @history 2018-06-08 Tracie Sucharski - Quick fix for the project save/restore prototype: The
   *                          changes made to readSettings, writeSettings cause following problem:
   *                          save project with view, close view and exit, the project
   *                          geometry/state is saved on closeEvent instead of project save. Quickly
   *                          added signal when project is saved, so the writeSettings can happen
   *                          for project.  This will be cleaned up when save/restore is fully
   *                          implemented.
   *  
   */
  class Project : public QObject {
@@ -376,8 +385,6 @@ namespace Isis {

      void warn(QString text);

      void loadProjectSettings();

    signals:
      /**
       * apparently not used?
@@ -483,7 +490,6 @@ namespace Isis {
       * Emitted when project is saved.
       * receivers: IpceMainWindow
       */

      void projectSaved(Project *);

      /**