Improved handling of runtime based GUI components, allows to init all child components in one step

refs #195, follow up of fixing FSX configuration page as result of #217
This commit is contained in:
Klaus Basan
2014-04-28 19:12:27 +02:00
parent 72843fac90
commit 5e0e9faf71
3 changed files with 39 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
#include "runtimebasedcomponent.h"
#include <QWidget>
namespace BlackGui
{
@@ -26,6 +27,18 @@ namespace BlackGui
return this->m_runtime->getIContextAudio();
}
void CRuntimeBasedComponent::setRuntimeForComponents(BlackCore::CRuntime *runtime, QWidget *parent)
{
if (!parent) return;
QList<QWidget *> children = parent->findChildren<QWidget *>();
foreach(QWidget * widget, children)
{
if (widget->objectName().isEmpty()) continue; // rule out unamed widgets
CRuntimeBasedComponent *rbc = dynamic_cast<CRuntimeBasedComponent *>(widget);
if (rbc) rbc->setRuntime(runtime, false);
}
}
void CRuntimeBasedComponent::createRuntime(const BlackCore::CRuntimeConfig &config, QObject *parent)
{
this->m_runtime = new BlackCore::CRuntime(config, parent);
@@ -67,4 +80,16 @@ namespace BlackGui
if (!this->m_runtime) return nullptr;
return this->m_runtime->getIContextSimulator();
}
void CRuntimeBasedComponent::sendStatusMessage(const BlackMisc::CStatusMessage &statusMessage)
{
Q_ASSERT(this->getIContextApplication());
this->getIContextApplication()->sendStatusMessage(statusMessage);
}
void CRuntimeBasedComponent::sendStatusMessages(const BlackMisc::CStatusMessageList &statusMessages)
{
Q_ASSERT(this->getIContextApplication());
this->getIContextApplication()->sendStatusMessages(statusMessages);
}
}