From 05c3fe7e6ecc1b8271a24b3e9265983781e070e5 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 15 May 2014 00:01:47 +0200 Subject: [PATCH] refs #239, some finetuning for runtime based components * virtual method to be called for signal slot hook up * comments --- src/blackgui/runtimebasedcomponent.cpp | 8 ++++++++ src/blackgui/runtimebasedcomponent.h | 14 ++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/blackgui/runtimebasedcomponent.cpp b/src/blackgui/runtimebasedcomponent.cpp index 54d767f70..7f43e6213 100644 --- a/src/blackgui/runtimebasedcomponent.cpp +++ b/src/blackgui/runtimebasedcomponent.cpp @@ -27,6 +27,14 @@ namespace BlackGui return this->m_runtime->getIContextAudio(); } + void CRuntimeBasedComponent::setRuntime(BlackCore::CRuntime *runtime, bool runtimeOwner) + { + Q_ASSERT(runtime); + this->m_runtime = runtime; + this->m_runtimeOwner = runtimeOwner; + this->runtimeHasBeenSet(); + } + void CRuntimeBasedComponent::setRuntimeForComponents(BlackCore::CRuntime *runtime, QWidget *parent) { if (!parent) return; diff --git a/src/blackgui/runtimebasedcomponent.h b/src/blackgui/runtimebasedcomponent.h index b50ce0e43..5beca8225 100644 --- a/src/blackgui/runtimebasedcomponent.h +++ b/src/blackgui/runtimebasedcomponent.h @@ -3,6 +3,7 @@ #include "blackcore/context_runtime.h" #include "blackcore/context_all_interfaces.h" +#include namespace BlackGui { @@ -16,17 +17,15 @@ namespace BlackGui { public: //! Set runtime, usually set by runtime owner (must only be one, usually main window) - void setRuntime(BlackCore::CRuntime *runtime, bool runtimeOwner = false) - { - this->m_runtime = runtime; this->m_runtimeOwner = runtimeOwner; - } + void setRuntime(BlackCore::CRuntime *runtime, bool runtimeOwner = false); //! Set runtime for each CRuntimeBasedComponent static void setRuntimeForComponents(BlackCore::CRuntime *runtime, QWidget *parent); protected: //! Constructor - //! \remarks usually runtime will be provide later, not at initialization time + //! \remarks Usually runtime will be provided later, not at initialization time. + //! If runtime is provided right now, make sure to call runtimeHasBeenSet afterwards CRuntimeBasedComponent(BlackCore::CRuntime *runtime = nullptr, bool runtimeOwner = false) : m_runtime(runtime), m_runtimeOwner(runtimeOwner) {} @@ -79,10 +78,13 @@ namespace BlackGui //! Owner? bool isRuntimeOwner() const { return this->m_runtimeOwner; } + //! "Callback" when runtime is initialized, done this way as we do not have signals/slots here + //! \remarks use this methods to hook up signal/slots with runtime + virtual void runtimeHasBeenSet() {} + private: BlackCore::CRuntime *m_runtime; bool m_runtimeOwner; - }; } // namespace