diff --git a/App/Loader.cpp b/App/Loader.cpp index de181c8..6a98267 100644 --- a/App/Loader.cpp +++ b/App/Loader.cpp @@ -67,7 +67,8 @@ InitThread::run() sing->init_ui_config(); emit change("Loading profile history"); sing->init_recent_list(); - emit change("Init done, reloading devices"); + emit change("Init done, triggering delayed plugin tasks..."); + sing->trigger_delayed(); } catch (Suscan::Exception const &e) { emit failure(QString(e.what())); } diff --git a/Default/Source/SourceWidget.cpp b/Default/Source/SourceWidget.cpp index 16691a7..92fd7a6 100644 --- a/Default/Source/SourceWidget.cpp +++ b/Default/Source/SourceWidget.cpp @@ -396,7 +396,6 @@ SourceWidget::applySourceInfo(Suscan::AnalyzerSourceInfo const &info) this->clearGains(); info.getGainInfo(gains); - for (auto p: gains) { gain = new DeviceGain(nullptr, p); this->gainControls.push_back(gain); @@ -414,13 +413,13 @@ SourceWidget::applySourceInfo(Suscan::AnalyzerSourceInfo const &info) SLOT(onGainChanged(QString, float))); gain->setGain(p.getDefault()); } - - if (this->gainControls.size() == 0) - this->ui->gainsFrame->hide(); - else - this->ui->gainsFrame->show(); } + if (this->gainControls.size() == 0) + this->ui->gainsFrame->hide(); + else + this->ui->gainsFrame->show(); + // Everything is set, time to decide what is enabled and what is not this->refreshUi(); diff --git a/SigDigger.pro b/SigDigger.pro index 07d7790..8b2581b 100644 --- a/SigDigger.pro +++ b/SigDigger.pro @@ -239,6 +239,7 @@ INSTALL_HEADERS += \ include/Palette.h \ include/PersistentWidget.h \ include/RemoteControlConfig.h \ + include/SourceConfigWidgetFactory.h \ include/TabWidgetFactory.h \ include/TLESourceConfig.h \ include/ToolWidgetFactory.h \ @@ -375,7 +376,6 @@ HEADERS += \ include/Loader.h \ include/SaveProfileDialog.h \ include/SNREstimator.h \ - include/SourceConfigWidgetFactory.h \ include/TLESourceTab.h \ include/TimeWindow.h \ include/FileDataSaver.h \ diff --git a/Suscan/Library.cpp b/Suscan/Library.cpp index 5b0df32..3c705ab 100644 --- a/Suscan/Library.cpp +++ b/Suscan/Library.cpp @@ -562,6 +562,13 @@ Singleton::detect_devices(void) this->refreshDevices(); } +void +Singleton::trigger_delayed(void) +{ + for (auto p : pluginCallbacks) + (p.first)(p.second); +} + void Singleton::init_ui_config(void) { @@ -728,6 +735,12 @@ Singleton::sync(void) } // Singleton methods +void +Singleton::registerDelayedCallback(DelayedPluginCallback cb, Plugin *plugin) +{ + pluginCallbacks.push_back(std::pair(cb, plugin)); +} + void Singleton::registerSourceConfig(suscan_source_config_t *config) { diff --git a/include/Suscan/Library.h b/include/Suscan/Library.h index ae9e739..41a0d33 100644 --- a/include/Suscan/Library.h +++ b/include/Suscan/Library.h @@ -55,6 +55,7 @@ namespace Suscan { uint qHash(const Suscan::Source::Device &dev); class MultitaskController; + class Plugin; typedef std::map ConfigMap; @@ -249,6 +250,8 @@ namespace Suscan { void debug(void) const; }; + typedef void (*DelayedPluginCallback) (Suscan::Plugin *); + class Singleton { static Singleton *instance; static Logger *logger; @@ -271,6 +274,9 @@ namespace Suscan { QMap spectrumUnits; QHash networkProfiles; + // Delayed plugin callbacks + std::list> pluginCallbacks; + // Feature object factories QList toolWidgetFactories; QList tabWidgetFactories; @@ -323,11 +329,13 @@ namespace Suscan { void init_tle(void); void init_plugins(void); void detect_devices(void); + void trigger_delayed(void); void sync(void); void killBackgroundTaskController(void); + void registerDelayedCallback(DelayedPluginCallback, Plugin *); void registerSourceConfig(suscan_source_config_t *config); void registerNetworkProfile(const suscan_source_config_t *config); void registerSourceDevice(const suscan_source_device_t *dev);