From 30957e30026ae611ccb6a73e01dd903aaa3a505f Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 18 Aug 2015 09:24:56 +0200 Subject: [PATCH] Deep redesign: Init sequence review phase #1: Fixing channel GUI init --- plugins/channel/nfm/nfmdemodgui.cpp | 21 +++++++++ plugins/channel/nfm/nfmdemodgui.h | 3 +- plugins/samplesource/bladerf/bladerfinput.cpp | 44 +++++++++---------- sdrbase/gui/aboutdialog.ui | 2 +- sdrbase/mainwindow.cpp | 41 +++++++++++++++-- sdrbase/mainwindow.ui | 2 +- sdrbase/plugin/pluginmanager.cpp | 38 +++++++++++----- 7 files changed, 111 insertions(+), 40 deletions(-) diff --git a/plugins/channel/nfm/nfmdemodgui.cpp b/plugins/channel/nfm/nfmdemodgui.cpp index fef4f525c..4b76cf411 100644 --- a/plugins/channel/nfm/nfmdemodgui.cpp +++ b/plugins/channel/nfm/nfmdemodgui.cpp @@ -44,11 +44,15 @@ qint64 NFMDemodGUI::getCenterFrequency() const void NFMDemodGUI::resetToDefaults() { + blockGUISignals(true); + ui->rfBW->setValue(4); ui->afBW->setValue(3); ui->volume->setValue(20); ui->squelch->setValue(-40); ui->deltaFrequency->setValue(0); + + blockGUISignals(false); applySettings(); } @@ -81,6 +85,9 @@ bool NFMDemodGUI::deserialize(const QByteArray& data) QByteArray bytetmp; quint32 u32tmp; qint32 tmp; + + blockGUISignals(true); + d.readS32(1, &tmp, 0); m_channelMarker->setCenterFrequency(tmp); d.readS32(2, &tmp, 4); @@ -97,6 +104,9 @@ bool NFMDemodGUI::deserialize(const QByteArray& data) m_channelMarker->setColor(u32tmp); d.readS32(8, &tmp, 0); ui->ctcss->setCurrentIndex(tmp); + + blockGUISignals(false); + applySettings(); return true; } @@ -287,3 +297,14 @@ void NFMDemodGUI::setCtcssFreq(Real ctcssFreq) } } +void NFMDemodGUI::blockGUISignals(bool block) +{ + m_channelMarker->blockSignals(block); + ui->deltaFrequency->blockSignals(block); + ui->deltaMinus->blockSignals(block); + ui->rfBW->blockSignals(block); + ui->afBW->blockSignals(block); + ui->volume->blockSignals(block); + ui->squelch->blockSignals(block); +} + diff --git a/plugins/channel/nfm/nfmdemodgui.h b/plugins/channel/nfm/nfmdemodgui.h index 44170fd76..878578aa5 100644 --- a/plugins/channel/nfm/nfmdemodgui.h +++ b/plugins/channel/nfm/nfmdemodgui.h @@ -59,8 +59,9 @@ private: static const int m_rfBW[]; explicit NFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent = NULL); - ~NFMDemodGUI(); + virtual ~NFMDemodGUI(); + void blockGUISignals(bool block); void applySettings(); void leaveEvent(QEvent*); diff --git a/plugins/samplesource/bladerf/bladerfinput.cpp b/plugins/samplesource/bladerf/bladerfinput.cpp index d807b9825..8544bdc7c 100644 --- a/plugins/samplesource/bladerf/bladerfinput.cpp +++ b/plugins/samplesource/bladerf/bladerfinput.cpp @@ -61,17 +61,17 @@ void BladerfInput::Settings::resetToDefaults() QByteArray BladerfInput::Settings::serialize() const { SimpleSerializer s(1); - s.writeU64(1, m_centerFrequency); - s.writeS32(2, m_devSampleRate); - s.writeS32(3, m_lnaGain); - s.writeS32(4, m_vga1); - s.writeS32(5, m_vga2); - s.writeU32(6, m_log2Decim); - s.writeBool(7, m_xb200); - s.writeS32(8, (int) m_xb200Path); - s.writeS32(9, (int) m_xb200Filter); - s.writeS32(10, m_bandwidth); - s.writeS32(11, (int) m_fcPos); + s.writeS32(1, m_lnaGain); + s.writeS32(2, m_vga1); + s.writeS32(3, m_vga2); + s.writeU32(4, m_log2Decim); + s.writeBool(5, m_xb200); + s.writeS32(6, (int) m_xb200Path); + s.writeS32(7, (int) m_xb200Filter); + s.writeS32(8, m_bandwidth); + s.writeS32(9, (int) m_fcPos); + s.writeU64(10, m_centerFrequency); + s.writeS32(11, m_devSampleRate); return s.final(); } @@ -88,20 +88,20 @@ bool BladerfInput::Settings::deserialize(const QByteArray& data) if (d.getVersion() == 1) { int intval; - d.readU64(1, &m_centerFrequency, 435000*1000); - d.readS32(2, &m_devSampleRate, 3072000); - d.readS32(3, &m_lnaGain, 0); - d.readS32(4, &m_vga1, 20); - d.readS32(5, &m_vga2, 9); - d.readU32(6, &m_log2Decim, 0); - d.readBool(7, &m_xb200); - d.readS32(8, &intval); + d.readS32(1, &m_lnaGain, 0); + d.readS32(2, &m_vga1, 20); + d.readS32(3, &m_vga2, 9); + d.readU32(4, &m_log2Decim, 0); + d.readBool(5, &m_xb200); + d.readS32(6, &intval); m_xb200Path = (bladerf_xb200_path) intval; - d.readS32(9, &intval); + d.readS32(7, &intval); m_xb200Filter = (bladerf_xb200_filter) intval; - d.readS32(10, &m_bandwidth, 0); - d.readS32(11, &intval, 0); + d.readS32(8, &m_bandwidth, 0); + d.readS32(9, &intval, 0); m_fcPos = (fcPos_t) intval; + d.readU64(10, &m_centerFrequency, 435000*1000); + d.readS32(11, &m_devSampleRate, 3072000); return true; } else diff --git a/sdrbase/gui/aboutdialog.ui b/sdrbase/gui/aboutdialog.ui index d5c17a76f..2e79e85be 100644 --- a/sdrbase/gui/aboutdialog.ui +++ b/sdrbase/gui/aboutdialog.ui @@ -80,7 +80,7 @@ <p>Copyright (C) 2013 maintech GmbH, Otto-Hahn-Str. 15, 97204 Höchberg, Germany<br> Written by Christian Daniel.</p> -<p>Copyright (C) 2015 Edouard Griffiths, F4EXB. Code branch at: <a href="https://github.com/f4exb/rtl-sdrangelove/tree/f4exb">https://github.com/f4exb/rtl-sdrangelove/tree/f4exb</a>.</p> +<p>Version 2 Copyright (C) 2015 Edouard Griffiths, F4EXB. Code branch at: <a href="https://github.com/f4exb/rtl-sdrangelove/tree/f4exb">https://github.com/f4exb/rtl-sdrangelove/tree/f4exb</a>. Complete redesign.</p> <p>Many thanks to the osmocom developer team - especially horizon, Hoernchen &amp; tnt.</p> <p>SDRangelove itself is licensed as "GPL2+" with the added exception, that plugins using only header files from the "include"-subdirectory and not from the "include-gpl"-subdirectory do not count as derived works.</p> <p>The following rules apply to the SDRangelove main application and libsdrbase:<br> diff --git a/sdrbase/mainwindow.cpp b/sdrbase/mainwindow.cpp index 15d920e9a..715b7987f 100644 --- a/sdrbase/mainwindow.cpp +++ b/sdrbase/mainwindow.cpp @@ -53,6 +53,7 @@ MainWindow::MainWindow(QWidget* parent) : m_sampleFileName(std::string("./test.sdriq")), m_pluginManager(new PluginManager(this, m_dspEngine)) { + qDebug() << "MainWindow::MainWindow: start"; connect(m_dspEngine->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection); m_dspEngine->start(); @@ -60,11 +61,15 @@ MainWindow::MainWindow(QWidget* parent) : delete ui->mainToolBar; createStatusBar(); + qDebug() << "MainWindow::MainWindow: step #1"; + setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); + qDebug() << "MainWindow::MainWindow: step #2"; + // work around broken Qt dock widget ordering removeDockWidget(ui->inputDock); removeDockWidget(ui->processingDock); @@ -74,18 +79,26 @@ MainWindow::MainWindow(QWidget* parent) : addDockWidget(Qt::LeftDockWidgetArea, ui->processingDock); addDockWidget(Qt::LeftDockWidgetArea, ui->presetDock); addDockWidget(Qt::RightDockWidgetArea, ui->channelDock); + + qDebug() << "MainWindow::MainWindow: step #3"; + ui->inputDock->show(); ui->processingDock->show(); ui->presetDock->show(); ui->channelDock->show(); + qDebug() << "MainWindow::MainWindow: step #4"; + ui->menu_Window->addAction(ui->inputDock->toggleViewAction()); ui->menu_Window->addAction(ui->processingDock->toggleViewAction()); ui->menu_Window->addAction(ui->presetDock->toggleViewAction()); ui->menu_Window->addAction(ui->channelDock->toggleViewAction()); + qDebug() << "MainWindow::MainWindow: step #5"; + connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection); - //connect(m_dspEngine->getReportQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection); + + qDebug() << "MainWindow::MainWindow: step #6"; connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus())); m_statusTimer.start(500); @@ -94,11 +107,13 @@ MainWindow::MainWindow(QWidget* parent) : m_pluginManager->loadPlugins(); + qDebug() << "MainWindow::MainWindow: step #7"; + bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true); m_pluginManager->fillSampleSourceSelector(ui->sampleSource); ui->sampleSource->blockSignals(sampleSourceSignalsBlocked); - //m_dspEngine->start(); + qDebug() << "MainWindow::MainWindow: step #8 (was DSP engine start)"; m_spectrumVis = new SpectrumVis(ui->glSpectrum); m_dspEngine->addSink(m_spectrumVis); @@ -109,19 +124,36 @@ MainWindow::MainWindow(QWidget* parent) : ui->glSpectrum->connectTimer(m_masterTimer); ui->glSpectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum); + qDebug() << "MainWindow::MainWindow: step #9"; + loadSettings(); + qDebug() << "MainWindow::MainWindow: step #10"; + int sampleSourceIndex = m_pluginManager->selectSampleSource(m_settings.getCurrent()->getSource()); // select SampleSource from settings - if(sampleSourceIndex >= 0) { + + qDebug() << "MainWindow::MainWindow: step #11"; + + if(sampleSourceIndex >= 0) + { bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true); ui->sampleSource->setCurrentIndex(sampleSourceIndex); ui->sampleSource->blockSignals(sampleSourceSignalsBlocked); } + qDebug() << "MainWindow::MainWindow: step #12"; + loadSettings(m_settings.getCurrent()); + qDebug() << "MainWindow::MainWindow: step #13"; + applySettings(); + + qDebug() << "MainWindow::MainWindow: step #14"; + updatePresets(); + + qDebug() << "MainWindow::MainWindow: end"; } MainWindow::~MainWindow() @@ -182,6 +214,7 @@ void MainWindow::setInputGUI(QWidget* gui) void MainWindow::loadSettings() { qDebug() << "MainWindow::loadSettings"; + m_settings.load(); for(int i = 0; i < m_settings.getPresetCount(); ++i) @@ -191,7 +224,7 @@ void MainWindow::loadSettings() Preset* current = m_settings.getCurrent(); - loadSettings(current); + //loadSettings(current); } void MainWindow::loadSettings(const Preset* preset) diff --git a/sdrbase/mainwindow.ui b/sdrbase/mainwindow.ui index 95c09e382..b7129d48a 100644 --- a/sdrbase/mainwindow.ui +++ b/sdrbase/mainwindow.ui @@ -11,7 +11,7 @@ - SDRangelove + SDRangelove V2 diff --git a/sdrbase/plugin/pluginmanager.cpp b/sdrbase/plugin/pluginmanager.cpp index b82fd2a93..f7bc13a91 100644 --- a/sdrbase/plugin/pluginmanager.cpp +++ b/sdrbase/plugin/pluginmanager.cpp @@ -82,41 +82,57 @@ void PluginManager::loadSettings(const Preset* preset) { qDebug() << "PluginManager::loadSettings"; - fprintf(stderr, "-------- [%s | %s] --------\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription())); + fprintf(stderr, "Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription())); // copy currently open channels and clear list ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations; m_channelInstanceRegistrations.clear(); - for(int i = 0; i < preset->getChannelCount(); i++) { + for(int i = 0; i < preset->getChannelCount(); i++) + { const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i); ChannelInstanceRegistration reg; + // if we have one instance available already, use it - for(int i = 0; i < openChannels.count(); i++) { - qDebug("compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channel)); - if(openChannels[i].m_channelName == channelConfig.m_channel) { + + for(int i = 0; i < openChannels.count(); i++) + { + qDebug(" - compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channel)); + + if(openChannels[i].m_channelName == channelConfig.m_channel) + { qDebug("channel [%s] found", qPrintable(openChannels[i].m_channelName)); reg = openChannels.takeAt(i); m_channelInstanceRegistrations.append(reg); break; } } + // if we haven't one already, create one - if(reg.m_gui == NULL) { - for(int i = 0; i < m_channelRegistrations.count(); i++) { - if(m_channelRegistrations[i].m_channelName == channelConfig.m_channel) { - qDebug("creating new channel [%s]", qPrintable(channelConfig.m_channel)); + + if(reg.m_gui == NULL) + { + for(int i = 0; i < m_channelRegistrations.count(); i++) + { + if(m_channelRegistrations[i].m_channelName == channelConfig.m_channel) + { + qDebug(" - creating new channel [%s]", qPrintable(channelConfig.m_channel)); reg = ChannelInstanceRegistration(channelConfig.m_channel, m_channelRegistrations[i].m_plugin->createChannel(channelConfig.m_channel)); break; } } } + if(reg.m_gui != NULL) + { + qDebug(" - deserializing channel [%s]", qPrintable(channelConfig.m_channel)); reg.m_gui->deserialize(channelConfig.m_config); + } } // everything, that is still "available" is not needed anymore - for(int i = 0; i < openChannels.count(); i++) { + for(int i = 0; i < openChannels.count(); i++) + { qDebug("destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName)); openChannels[i].m_gui->destroy(); } @@ -131,7 +147,7 @@ void PluginManager::loadSettings(const Preset* preset) */ if(m_sampleSourceName == preset->getSource()) { - qDebug() << "m_sampleSourcePluginGUI->deserialize (" << m_sampleSourceName .toStdString().c_str() << ")"; + qDebug() << " - deserializing source " << qPrintable(m_sampleSourceName); m_sampleSourcePluginGUI->deserialize(preset->getSourceConfig()); } }