Commit 36f2e413 authored by Tracie Sucharski's avatar Tracie Sucharski
Browse files

Fixed recent projects. The readSettings must be called before...

Fixed recent projects.  The readSettings must be called before initializeActions to get the recent projects from the config file before filling menus.
parent b808f0b6
Loading
Loading
Loading
Loading
+64 −55
Original line number Diff line number Diff line
@@ -164,13 +164,14 @@ namespace Isis {
      statusBar()->addWidget(progressBar);
    }

    // Read default app settings.  NOTE: This must be completed before initializing actions in order
    // to read the recent projects from the config file.
    readSettings(m_directory->project() );

    initializeActions();
    createMenus();
    createToolBars();

    // Read default app settings
    readSettings(m_directory->project() );

    QStringList args = QCoreApplication::arguments();

    if (args.count() == 2) {
@@ -660,28 +661,24 @@ namespace Isis {
      QString msg = "Cannot read settings with a NULL Project pointer.";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }
    if (project->name() == "Project") {
      setWindowTitle("ipce");
    }
    else {
      setWindowTitle( project->name() );
      QString projName = project->name();
      setWindowTitle(projName );
    }

    QString appName = QApplication::applicationName();

    qDebug()<<"readSettings filename = "<<FileName("$HOME/.Isis/" + appName + "/" + appName + "_" + project->name() + ".config").expanded();

    QSettings settings(
        FileName("$HOME/.Isis/" + appName + "/" + appName + "_" + project->name() + ".config")
          .expanded(), QSettings::NativeFormat);

    setGeometry(settings.value("geometry").value<QRect>());
    restoreState(settings.value("windowState").toByteArray());
    // General settings
    if (project->name() == "Project") {
      setWindowTitle("ipce");

      QStringList projectNameList;
      QStringList projectPathList;
      settings.beginGroup("recent_projects");
      QStringList keys = settings.allKeys();

      qDebug()<<"::readSettings keys.count = "<<keys.count();
      QRegExp underscore("%%%%%");

      foreach (QString key, keys) {
@@ -695,7 +692,7 @@ namespace Isis {
      settings.endGroup();

      QStringList projectPathReverseList;

      qDebug()<<"::readSettings projectPathList.count = "<<projectPathList.count();
      for (int i = projectPathList.count()-1;i>=0;i--) {
        projectPathReverseList.append(projectPathList[i]);
      }
@@ -714,18 +711,30 @@ namespace Isis {
       }


      qDebug()<<"::readSettings before setRecentProjectsList projectPathListTruncated.count = "<<projectPathListTruncated.count();
      m_directory->setRecentProjectsList(projectPathListTruncated);
      m_directory->updateRecentProjects();
      m_maxThreadCount = settings.value("maxThreadCount", m_maxThreadCount).toInt();
      qDebug()<<"::readSettings thread = "<<m_maxThreadCount;
      applyMaxThreadCount();
    }
    //  Project specific settings
    else {
      setWindowTitle( project->name() );
      if (settings.contains("geometry")) {
        setGeometry(settings.value("geometry").value<QRect>()); 
      }
      if (settings.contains("windowState")) {
        restoreState(settings.value("windowState").toByteArray()); 
      }

      // 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())
      if (!settings.value("pos").toPoint().isNull()) {
        move(settings.value("pos").toPoint());

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

      }
    }
  }


@@ -755,7 +764,7 @@ namespace Isis {
        m_directory->project()->save();
      }
    }
    //writeSettings(m_directory->project());
    writeSettings(m_directory->project());
    m_directory->project()->clear();

    QMainWindow::closeEvent(event);
+4 −1
Original line number Diff line number Diff line
@@ -138,6 +138,9 @@ namespace Isis {
   *                           Cleanup connections are made for the views and the docks to ensure
   *                           that cleanup happens for both.  Fixes #5433.
   *   @history 2018-06-13 Tracie Sucharski - Fixed cleanup of views and QDockWidgets.
   *   @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.
   *  
   */
  class IpceMainWindow : public QMainWindow {