Commit 1c703cc6 authored by Cory Quammen's avatar Cory Quammen

Set an active view after loading state

State files do not store the active view, so set the first view after
state is loaded.
parent d0d86ab4
......@@ -4,6 +4,7 @@
#include "pqActiveObjects.h"
#include "pqApplicationCore.h"
#include "pqEventDispatcher.h"
#include "pqLoadStateReaction.h"
#include "vtkPVConfig.h"
#include "vtkPVFileInformation.h"
......@@ -106,6 +107,9 @@ void pqExampleVisualizationsDialog::onButtonPressed()
xmldata.replace("$PARAVIEW_EXAMPLES_DATA", dataPath);
pqApplicationCore::instance()->loadStateFromString(
xmldata.toUtf8().data(), pqActiveObjects::instance().activeServer());
// This is needed since XML state currently does not save active view.
pqLoadStateReaction::activateView();
}
else
{
......
......@@ -116,15 +116,9 @@ void pqLoadStateReaction::loadState(const QString& filename, bool dialogBlocked,
server, filename);
}
pqPVApplicationCore::instance()->setLoadingState(false);
// activate a view in the state.
// this is needed since XML state currently does not save active view.
auto smmodel = pqApplicationCore::instance()->getServerManagerModel();
auto views = smmodel->findItems<pqView*>(server);
if (views.size())
{
pqActiveObjects::instance().setActiveView(views[0]);
}
// This is needed since XML state currently does not save active view.
pqLoadStateReaction::activateView();
}
}
else
......@@ -156,3 +150,15 @@ void pqLoadStateReaction::loadState()
pqLoadStateReaction::loadState(selectedFile);
}
}
//-----------------------------------------------------------------------------
void pqLoadStateReaction::activateView()
{
auto server = pqActiveObjects::instance().activeServer();
auto smmodel = pqApplicationCore::instance()->getServerManagerModel();
auto views = smmodel->findItems<pqView*>(server);
if (views.size())
{
pqActiveObjects::instance().setActiveView(views[0]);
}
}
......@@ -62,6 +62,11 @@ public:
const QString& filename, bool dialogBlocked = false, pqServer* server = NULL);
static void loadState();
/**
* Set default active view after state is loaded. Make the first view active.
*/
static void activateView();
public slots:
/**
* Updates the enabled state. Applications need not explicitly call
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment