Commit 05349763 authored by David Thompson's avatar David Thompson
Browse files

Make resource panel ask application for configuration.

parent 0deb3354
......@@ -27,7 +27,7 @@ QMetaObject::Connection g_trackerConnection;
std::vector<ApplicationConfiguration::ConfigurationObserver>
ApplicationConfiguration::s_uiComponents;
void ApplicationConfiguration::notify(ConfigurationObserver observer)
bool ApplicationConfiguration::notify(ConfigurationObserver observer)
{
// Queue the observer in the list of UI components to be initialized.
s_uiComponents.push_back(observer);
......@@ -43,7 +43,7 @@ void ApplicationConfiguration::notify(ConfigurationObserver observer)
{
if (ApplicationConfiguration::found(dynamic_cast<QObject*>(iface)))
{
return;
return true;
}
}
}
......@@ -56,6 +56,7 @@ void ApplicationConfiguration::notify(ConfigurationObserver observer)
});
}
}
return false;
}
bool ApplicationConfiguration::found(QObject* iface)
......
......@@ -49,8 +49,12 @@ public:
* or later upon the `pqInterfaceTracker::interfaceRegistered()` signal.)
* Once found, the observer is invoked so it can configure components as needed by
* calling methods on the interface.
*
* This method returns true if the configuration instance was invoked immediately
* and false if a signal is queued to fire should a configuration instance be
* registered later.
*/
static void notify(ConfigurationObserver observer);
static bool notify(ConfigurationObserver observer);
/**\brief Method for applications to provide configuration information for panels.
*
......
......@@ -11,6 +11,7 @@
#include "smtk/extension/paraview/appcomponents/pqSMTKResourceBrowser.h"
#include "smtk/extension/paraview/appcomponents/ApplicationConfiguration.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKBehavior.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKWrapper.h"
......@@ -26,12 +27,25 @@
pqSMTKResourcePanel::pqSMTKResourcePanel(QWidget* parent)
: Superclass(parent)
{
// Parse a json representation of our default config, save it.
nlohmann::json j = nlohmann::json::parse(pqSMTKResourceBrowser::getJSONConfiguration());
smtk::view::ConfigurationPtr config = j[0];
this->setView(config);
this->setObjectName("pqSMTKResourcePanel");
// Either we get the application's configuration or we use a default
// until the application's configuration plugin is loaded.
if (!smtk::paraview::ApplicationConfiguration::notify(
[this](smtk::paraview::ApplicationConfiguration& configurator) {
auto viewInfo = configurator.panelConfiguration(this);
// Extract just the view configuration.
auto viewConfig = viewInfo.get<smtk::view::ConfigurationPtr>();
this->setView(viewConfig);
}))
{
// Parse a json representation of our default config, and use it
// since the application can't immediately configure us.
nlohmann::json j = nlohmann::json::parse(pqSMTKResourceBrowser::getJSONConfiguration());
smtk::view::ConfigurationPtr config = j[0];
this->setView(config);
}
auto* smtkBehavior = pqSMTKBehavior::instance();
// Now listen for future connections.
QObject::connect(
......
Supports Markdown
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