1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-06-16 13:32:27 -04:00

Massive UI revamping (v7): fixed spectrum move and device workspace index save in preset

This commit is contained in:
f4exb 2022-04-14 03:07:33 +02:00
parent d019d85904
commit 3604bf8091
4 changed files with 78 additions and 43 deletions

View File

@ -87,7 +87,7 @@ void HackRFInput::destroy()
bool HackRFInput::openDevice() bool HackRFInput::openDevice()
{ {
if (m_dev != 0) if (m_dev)
{ {
closeDevice(); closeDevice();
} }
@ -109,7 +109,7 @@ bool HackRFInput::openDevice()
return false; return false;
} }
if (buddySharedParams->m_dev == 0) // device is not opened by buddy if (buddySharedParams->m_dev == nullptr) // device is not opened by buddy
{ {
qCritical("HackRFInput::openDevice: could not get HackRF handle from buddy"); qCritical("HackRFInput::openDevice: could not get HackRF handle from buddy");
return false; return false;
@ -123,12 +123,14 @@ bool HackRFInput::openDevice()
if ((m_dev = DeviceHackRF::open_hackrf(qPrintable(m_deviceAPI->getSamplingDeviceSerial()))) == 0) if ((m_dev = DeviceHackRF::open_hackrf(qPrintable(m_deviceAPI->getSamplingDeviceSerial()))) == 0)
{ {
qCritical("HackRFInput::openDevice: could not open HackRF %s", qPrintable(m_deviceAPI->getSamplingDeviceSerial())); qCritical("HackRFInput::openDevice: could not open HackRF %s", qPrintable(m_deviceAPI->getSamplingDeviceSerial()));
m_dev = nullptr;
return false; return false;
} }
m_sharedParams.m_dev = m_dev; m_sharedParams.m_dev = m_dev;
} }
qDebug("HackRFInput::openDevice: success");
return true; return true;
} }
@ -172,7 +174,7 @@ void HackRFInput::closeDevice()
{ {
qDebug("HackRFInput::closeDevice: closing device since Tx side is not open"); qDebug("HackRFInput::closeDevice: closing device since Tx side is not open");
if(m_dev != 0) // close BladeRF if (m_dev) // close HackRF
{ {
hackrf_close(m_dev); hackrf_close(m_dev);
//hackrf_exit(); // TODO: this may not work if several HackRF Devices are running concurrently. It should be handled globally in the application //hackrf_exit(); // TODO: this may not work if several HackRF Devices are running concurrently. It should be handled globally in the application
@ -180,7 +182,7 @@ void HackRFInput::closeDevice()
} }
m_sharedParams.m_dev = 0; m_sharedParams.m_dev = 0;
m_dev = 0; m_dev = nullptr;
} }
void HackRFInput::stop() void HackRFInput::stop()

View File

@ -214,6 +214,7 @@ void DeviceUISet::saveDeviceSetSettings(Preset* preset) const
(int) m_deviceAPI->getSamplingDeviceSequence(), (int) m_deviceAPI->getSamplingDeviceSequence(),
(int) m_deviceAPI->getDeviceItemIndex() (int) m_deviceAPI->getDeviceItemIndex()
}); });
preset->setDeviceWorkspaceIndex(m_deviceGUI->getWorkspaceIndex());
preset->clearChannels(); preset->clearChannels();
if (m_deviceSourceEngine) // source device if (m_deviceSourceEngine) // source device

View File

@ -357,7 +357,7 @@ MainWindow::~MainWindow()
qDebug() << "MainWindow::~MainWindow: end"; qDebug() << "MainWindow::~MainWindow: end";
} }
void MainWindow::sampleSourceAdd(Workspace *workspace, int deviceIndex) void MainWindow::sampleSourceAdd(Workspace *deviceWorkspace, Workspace *spectrumWorkspace, int deviceIndex)
{ {
DSPDeviceSourceEngine *dspDeviceSourceEngine = m_dspEngine->addDeviceSourceEngine(); DSPDeviceSourceEngine *dspDeviceSourceEngine = m_dspEngine->addDeviceSourceEngine();
dspDeviceSourceEngine->start(); dspDeviceSourceEngine->start();
@ -393,25 +393,26 @@ void MainWindow::sampleSourceAdd(Workspace *workspace, int deviceIndex)
} }
sampleSourceCreate(deviceSetIndex, deviceIndex, deviceAPI, m_deviceUIs.back()); sampleSourceCreate(deviceSetIndex, deviceIndex, deviceAPI, m_deviceUIs.back());
m_deviceUIs.back()->m_deviceGUI->setWorkspaceIndex(workspace->getIndex()); m_deviceUIs.back()->m_deviceGUI->setWorkspaceIndex(deviceWorkspace->getIndex());
m_deviceUIs.back()->m_mainSpectrumGUI->setWorkspaceIndex(workspace->getIndex()); m_deviceUIs.back()->m_mainSpectrumGUI->setWorkspaceIndex(spectrumWorkspace->getIndex());
MainSpectrumGUI *mainSpectrumGUI = m_deviceUIs.back()->m_mainSpectrumGUI;
QObject::connect( QObject::connect(
m_deviceUIs.back()->m_mainSpectrumGUI, mainSpectrumGUI,
&MainSpectrumGUI::moveToWorkspace, &MainSpectrumGUI::moveToWorkspace,
this, this,
[=](int wsIndexDest){ this->mainSpectrumMove(m_deviceUIs.back()->m_mainSpectrumGUI, wsIndexDest); } [=](int wsIndexDest){ this->mainSpectrumMove(mainSpectrumGUI, wsIndexDest); }
); );
QObject::connect( QObject::connect(
m_deviceUIs.back()->m_deviceGUI, m_deviceUIs.back()->m_deviceGUI,
&DeviceGUI::addChannelEmitted, &DeviceGUI::addChannelEmitted,
this, this,
[=](int channelIndex){ this->channelAddClicked(workspace, deviceSetIndex, channelIndex); } [=](int channelIndex){ this->channelAddClicked(deviceWorkspace, deviceSetIndex, channelIndex); }
); );
workspace->addToMdiArea(m_deviceUIs.back()->m_deviceGUI); deviceWorkspace->addToMdiArea(m_deviceUIs.back()->m_deviceGUI);
workspace->addToMdiArea(m_deviceUIs.back()->m_mainSpectrumGUI); spectrumWorkspace->addToMdiArea(m_deviceUIs.back()->m_mainSpectrumGUI);
emit m_mainCore->deviceSetAdded(deviceSetIndex, deviceAPI); emit m_mainCore->deviceSetAdded(deviceSetIndex, deviceAPI);
} }
@ -574,7 +575,7 @@ void MainWindow::sampleSourceCreate(
mainSpectrumGUI->setTitle(samplingDevice->displayedName.split(" ")[0]); mainSpectrumGUI->setTitle(samplingDevice->displayedName.split(" ")[0]);
} }
void MainWindow::sampleSinkAdd(Workspace *workspace, int deviceIndex) void MainWindow::sampleSinkAdd(Workspace *deviceWorkspace, Workspace *spectrumWorkspace, int deviceIndex)
{ {
DSPDeviceSinkEngine *dspDeviceSinkEngine = m_dspEngine->addDeviceSinkEngine(); DSPDeviceSinkEngine *dspDeviceSinkEngine = m_dspEngine->addDeviceSinkEngine();
dspDeviceSinkEngine->start(); dspDeviceSinkEngine->start();
@ -610,25 +611,26 @@ void MainWindow::sampleSinkAdd(Workspace *workspace, int deviceIndex)
} }
sampleSinkCreate(deviceSetIndex, deviceIndex, deviceAPI, m_deviceUIs.back()); sampleSinkCreate(deviceSetIndex, deviceIndex, deviceAPI, m_deviceUIs.back());
m_deviceUIs.back()->m_deviceGUI->setWorkspaceIndex(workspace->getIndex()); m_deviceUIs.back()->m_deviceGUI->setWorkspaceIndex(deviceWorkspace->getIndex());
m_deviceUIs.back()->m_mainSpectrumGUI->setWorkspaceIndex(workspace->getIndex()); m_deviceUIs.back()->m_mainSpectrumGUI->setWorkspaceIndex(spectrumWorkspace->getIndex());
MainSpectrumGUI *mainSpectrumGUI = m_deviceUIs.back()->m_mainSpectrumGUI;
QObject::connect( QObject::connect(
m_deviceUIs.back()->m_mainSpectrumGUI, mainSpectrumGUI,
&MainSpectrumGUI::moveToWorkspace, &MainSpectrumGUI::moveToWorkspace,
this, this,
[=](int wsIndexDest){ this->mainSpectrumMove(m_deviceUIs.back()->m_mainSpectrumGUI, wsIndexDest); } [=](int wsIndexDest){ this->mainSpectrumMove(mainSpectrumGUI, wsIndexDest); }
); );
QObject::connect( QObject::connect(
m_deviceUIs.back()->m_deviceGUI, m_deviceUIs.back()->m_deviceGUI,
&DeviceGUI::addChannelEmitted, &DeviceGUI::addChannelEmitted,
this, this,
[=](int channelIndex){ this->channelAddClicked(workspace, deviceSetIndex, channelIndex); } [=](int channelIndex){ this->channelAddClicked(deviceWorkspace, deviceSetIndex, channelIndex); }
); );
workspace->addToMdiArea(m_deviceUIs.back()->m_deviceGUI); deviceWorkspace->addToMdiArea(m_deviceUIs.back()->m_deviceGUI);
workspace->addToMdiArea(m_deviceUIs.back()->m_mainSpectrumGUI); spectrumWorkspace->addToMdiArea(m_deviceUIs.back()->m_mainSpectrumGUI);
emit m_mainCore->deviceSetAdded(deviceSetIndex, deviceAPI); emit m_mainCore->deviceSetAdded(deviceSetIndex, deviceAPI);
} }
@ -791,7 +793,7 @@ void MainWindow::sampleSinkCreate(
spectrumGUI->setTitle(samplingDevice->displayedName.split(" ")[0]); spectrumGUI->setTitle(samplingDevice->displayedName.split(" ")[0]);
} }
void MainWindow::sampleMIMOAdd(Workspace *workspace, int deviceIndex) void MainWindow::sampleMIMOAdd(Workspace *deviceWorkspace, Workspace *spectrumWorkspace, int deviceIndex)
{ {
DSPDeviceMIMOEngine *dspDeviceMIMOEngine = m_dspEngine->addDeviceMIMOEngine(); DSPDeviceMIMOEngine *dspDeviceMIMOEngine = m_dspEngine->addDeviceMIMOEngine();
dspDeviceMIMOEngine->start(); dspDeviceMIMOEngine->start();
@ -835,25 +837,26 @@ void MainWindow::sampleMIMOAdd(Workspace *workspace, int deviceIndex)
} }
sampleMIMOCreate(deviceSetIndex, deviceIndex, deviceAPI, m_deviceUIs.back()); sampleMIMOCreate(deviceSetIndex, deviceIndex, deviceAPI, m_deviceUIs.back());
m_deviceUIs.back()->m_deviceGUI->setWorkspaceIndex(workspace->getIndex()); m_deviceUIs.back()->m_deviceGUI->setWorkspaceIndex(deviceWorkspace->getIndex());
m_deviceUIs.back()->m_mainSpectrumGUI->setWorkspaceIndex(workspace->getIndex()); m_deviceUIs.back()->m_mainSpectrumGUI->setWorkspaceIndex(spectrumWorkspace->getIndex());
MainSpectrumGUI *mainSpectrumGUI = m_deviceUIs.back()->m_mainSpectrumGUI;
QObject::connect( QObject::connect(
m_deviceUIs.back()->m_mainSpectrumGUI, mainSpectrumGUI,
&MainSpectrumGUI::moveToWorkspace, &MainSpectrumGUI::moveToWorkspace,
this, this,
[=](int wsIndexDest){ this->mainSpectrumMove(m_deviceUIs.back()->m_mainSpectrumGUI, wsIndexDest); } [=](int wsIndexDest){ this->mainSpectrumMove(mainSpectrumGUI, wsIndexDest); }
); );
QObject::connect( QObject::connect(
m_deviceUIs.back()->m_deviceGUI, m_deviceUIs.back()->m_deviceGUI,
&DeviceGUI::addChannelEmitted, &DeviceGUI::addChannelEmitted,
this, this,
[=](int channelIndex){ this->channelAddClicked(workspace, deviceSetIndex, channelIndex); } [=](int channelIndex){ this->channelAddClicked(deviceWorkspace, deviceSetIndex, channelIndex); }
); );
workspace->addToMdiArea(m_deviceUIs.back()->m_deviceGUI); deviceWorkspace->addToMdiArea(m_deviceUIs.back()->m_deviceGUI);
workspace->addToMdiArea(m_deviceUIs.back()->m_mainSpectrumGUI); spectrumWorkspace->addToMdiArea(m_deviceUIs.back()->m_mainSpectrumGUI);
emit m_mainCore->deviceSetAdded(deviceSetIndex, deviceAPI); emit m_mainCore->deviceSetAdded(deviceSetIndex, deviceAPI);
} }
@ -1351,10 +1354,17 @@ void MainWindow::loadConfiguration(const Configuration *configuration, bool from
deviceSetPreset.getSelectedDevice().m_deviceSequence, deviceSetPreset.getSelectedDevice().m_deviceSequence,
deviceSetPreset.getSelectedDevice().m_deviceItemIndex deviceSetPreset.getSelectedDevice().m_deviceItemIndex
); );
int workspaceIndex = deviceSetPreset.getDeviceWorkspaceIndex() < m_workspaces.size() ? qDebug("MainWindow::loadConfiguration: add source %s in workspace %d spectrum in %d",
qPrintable(deviceSetPreset.getSelectedDevice().m_deviceId),
deviceSetPreset.getDeviceWorkspaceIndex(),
deviceSetPreset.getSpectrumWorkspaceIndex());
int deviceWorkspaceIndex = deviceSetPreset.getDeviceWorkspaceIndex() < m_workspaces.size() ?
deviceSetPreset.getDeviceWorkspaceIndex() : deviceSetPreset.getDeviceWorkspaceIndex() :
0; 0;
sampleSourceAdd(m_workspaces[workspaceIndex], bestDeviceIndex); int spectrumWorkspaceIndex = deviceSetPreset.getSpectrumWorkspaceIndex() < m_workspaces.size() ?
deviceSetPreset.getSpectrumWorkspaceIndex() :
deviceWorkspaceIndex;
sampleSourceAdd(m_workspaces[deviceWorkspaceIndex], m_workspaces[spectrumWorkspaceIndex], bestDeviceIndex);
} }
else if (deviceSetPreset.isSinkPreset()) else if (deviceSetPreset.isSinkPreset())
{ {
@ -1364,10 +1374,17 @@ void MainWindow::loadConfiguration(const Configuration *configuration, bool from
deviceSetPreset.getSelectedDevice().m_deviceSequence, deviceSetPreset.getSelectedDevice().m_deviceSequence,
deviceSetPreset.getSelectedDevice().m_deviceItemIndex deviceSetPreset.getSelectedDevice().m_deviceItemIndex
); );
int workspaceIndex = deviceSetPreset.getDeviceWorkspaceIndex() < m_workspaces.size() ? qDebug("MainWindow::loadConfiguration: add sink %s in workspace %d spectrum in %d",
qPrintable(deviceSetPreset.getSelectedDevice().m_deviceId),
deviceSetPreset.getDeviceWorkspaceIndex(),
deviceSetPreset.getSpectrumWorkspaceIndex());
int deviceWorkspaceIndex = deviceSetPreset.getDeviceWorkspaceIndex() < m_workspaces.size() ?
deviceSetPreset.getDeviceWorkspaceIndex() : deviceSetPreset.getDeviceWorkspaceIndex() :
0; 0;
sampleSinkAdd(m_workspaces[workspaceIndex], bestDeviceIndex); int spectrumWorkspaceIndex = deviceSetPreset.getSpectrumWorkspaceIndex() < m_workspaces.size() ?
deviceSetPreset.getSpectrumWorkspaceIndex() :
deviceWorkspaceIndex;
sampleSinkAdd(m_workspaces[deviceWorkspaceIndex], m_workspaces[spectrumWorkspaceIndex], bestDeviceIndex);
} else if (deviceSetPreset.isMIMOPreset()) } else if (deviceSetPreset.isMIMOPreset())
{ {
int bestDeviceIndex = DeviceEnumerator::instance()->getBestMIMOSamplingDeviceIndex( int bestDeviceIndex = DeviceEnumerator::instance()->getBestMIMOSamplingDeviceIndex(
@ -1375,10 +1392,17 @@ void MainWindow::loadConfiguration(const Configuration *configuration, bool from
deviceSetPreset.getSelectedDevice().m_deviceSerial, deviceSetPreset.getSelectedDevice().m_deviceSerial,
deviceSetPreset.getSelectedDevice().m_deviceSequence deviceSetPreset.getSelectedDevice().m_deviceSequence
); );
int workspaceIndex = deviceSetPreset.getDeviceWorkspaceIndex() < m_workspaces.size() ? qDebug("MainWindow::loadConfiguration: add MIMO %s in workspace %d spectrum in %d",
qPrintable(deviceSetPreset.getSelectedDevice().m_deviceId),
deviceSetPreset.getDeviceWorkspaceIndex(),
deviceSetPreset.getSpectrumWorkspaceIndex());
int deviceWorkspaceIndex = deviceSetPreset.getDeviceWorkspaceIndex() < m_workspaces.size() ?
deviceSetPreset.getDeviceWorkspaceIndex() : deviceSetPreset.getDeviceWorkspaceIndex() :
0; 0;
sampleMIMOAdd(m_workspaces[workspaceIndex], bestDeviceIndex); int spectrumWorkspaceIndex = deviceSetPreset.getSpectrumWorkspaceIndex() < m_workspaces.size() ?
deviceSetPreset.getSpectrumWorkspaceIndex() :
deviceWorkspaceIndex;
sampleMIMOAdd(m_workspaces[deviceWorkspaceIndex], m_workspaces[spectrumWorkspaceIndex], bestDeviceIndex);
} }
m_deviceUIs.back()->m_deviceGUI->restoreGeometry(deviceSetPreset.getDeviceGeometry()); m_deviceUIs.back()->m_deviceGUI->restoreGeometry(deviceSetPreset.getDeviceGeometry());
@ -1445,6 +1469,10 @@ void MainWindow::saveConfiguration(Configuration *configuration)
deviceSetPresets.back().setSpectrumWorkspaceIndex(deviceUISet->m_mainSpectrumGUI->getWorkspaceIndex()); deviceSetPresets.back().setSpectrumWorkspaceIndex(deviceUISet->m_mainSpectrumGUI->getWorkspaceIndex());
deviceSetPresets.back().setDeviceGeometry(deviceUISet->m_deviceGUI->saveGeometry()); deviceSetPresets.back().setDeviceGeometry(deviceUISet->m_deviceGUI->saveGeometry());
deviceSetPresets.back().setDeviceWorkspaceIndex(deviceUISet->m_deviceGUI->getWorkspaceIndex()); deviceSetPresets.back().setDeviceWorkspaceIndex(deviceUISet->m_deviceGUI->getWorkspaceIndex());
qDebug("MainWindow::saveConfiguration: %s device in workspace %d spectrun in %d",
qPrintable(deviceUISet->m_deviceAPI->getSamplingDeviceId()),
deviceUISet->m_deviceGUI->getWorkspaceIndex(),
deviceUISet->m_mainSpectrumGUI->getWorkspaceIndex());
} }
m_featureUIs[0]->saveFeatureSetSettings(&configuration->getFeatureSetPreset()); m_featureUIs[0]->saveFeatureSetSettings(&configuration->getFeatureSetPreset());
@ -1733,11 +1761,11 @@ bool MainWindow::handleMessage(const Message& cmd)
// in Server flavor. Set nullptr for workspace if index is out of bonds // in Server flavor. Set nullptr for workspace if index is out of bonds
if (direction == 1) { // Single stream Tx if (direction == 1) { // Single stream Tx
sampleSinkAdd(nullptr, -1); // create with file output device by default sampleSinkAdd(nullptr, nullptr, -1); // create with file output device by default
} else if (direction == 0) { // Single stream Rx } else if (direction == 0) { // Single stream Rx
sampleSourceAdd(nullptr, -1); // create with file input device by default sampleSourceAdd(nullptr, nullptr, -1); // create with file input device by default
} else if (direction == 2) { // MIMO } else if (direction == 2) { // MIMO
sampleMIMOAdd(nullptr, -1); // create with testMI MIMO device y default sampleMIMOAdd(nullptr, nullptr, -1); // create with testMI MIMO device y default
} }
return true; return true;
@ -1886,21 +1914,21 @@ void MainWindow::addWorkspace()
m_workspaces.back(), m_workspaces.back(),
&Workspace::addRxDevice, &Workspace::addRxDevice,
this, this,
&MainWindow::sampleSourceAdd [=](Workspace *inWorkspace, int deviceIndex) { this->sampleSourceAdd(inWorkspace, inWorkspace, deviceIndex); }
); );
QObject::connect( QObject::connect(
m_workspaces.back(), m_workspaces.back(),
&Workspace::addTxDevice, &Workspace::addTxDevice,
this, this,
&MainWindow::sampleSinkAdd [=](Workspace *inWorkspace, int deviceIndex) { this->sampleSourceAdd(inWorkspace, inWorkspace, deviceIndex); }
); );
QObject::connect( QObject::connect(
m_workspaces.back(), m_workspaces.back(),
&Workspace::addMIMODevice, &Workspace::addMIMODevice,
this, this,
&MainWindow::sampleMIMOAdd [=](Workspace *inWorkspace, int deviceIndex) { this->sampleSourceAdd(inWorkspace, inWorkspace, deviceIndex); }
); );
QObject::connect( QObject::connect(
@ -2700,6 +2728,8 @@ void MainWindow::featureMove(FeatureGUI *gui, int wsIndexDestnation)
void MainWindow::deviceMove(DeviceGUI *gui, int wsIndexDestnation) void MainWindow::deviceMove(DeviceGUI *gui, int wsIndexDestnation)
{ {
int wsIndexOrigin = gui->getWorkspaceIndex(); int wsIndexOrigin = gui->getWorkspaceIndex();
qDebug("MainWindow::deviceMove: %s from %d to %d",
qPrintable(gui->getTitle()), wsIndexOrigin, wsIndexDestnation);
if (wsIndexOrigin == wsIndexDestnation) { if (wsIndexOrigin == wsIndexDestnation) {
return; return;
@ -2726,6 +2756,8 @@ void MainWindow::channelMove(ChannelGUI *gui, int wsIndexDestnation)
void MainWindow::mainSpectrumMove(MainSpectrumGUI *gui, int wsIndexDestnation) void MainWindow::mainSpectrumMove(MainSpectrumGUI *gui, int wsIndexDestnation)
{ {
int wsIndexOrigin = gui->getWorkspaceIndex(); int wsIndexOrigin = gui->getWorkspaceIndex();
qDebug("MainWindow::mainSpectrumMove: %s from %d to %d",
qPrintable(gui->getTitle()), wsIndexOrigin, wsIndexDestnation);
if (wsIndexOrigin == wsIndexDestnation) { if (wsIndexOrigin == wsIndexDestnation) {
return; return;

View File

@ -181,9 +181,9 @@ private slots:
void removeEmptyWorkspaces(); void removeEmptyWorkspaces();
void loadConfiguration(const Configuration *configuration, bool fromDialog = false); void loadConfiguration(const Configuration *configuration, bool fromDialog = false);
void saveConfiguration(Configuration *configuration); void saveConfiguration(Configuration *configuration);
void sampleSourceAdd(Workspace *workspace, int deviceIndex); void sampleSourceAdd(Workspace *deviceWorkspace, Workspace *spectrumWorkspace, int deviceIndex);
void sampleSinkAdd(Workspace *workspace, int deviceIndex); void sampleSinkAdd(Workspace *workspace, Workspace *spectrumWorkspace, int deviceIndex);
void sampleMIMOAdd(Workspace *workspace, int deviceIndex); void sampleMIMOAdd(Workspace *workspace, Workspace *spectrumWorkspace, int deviceIndex);
void sampleDeviceChangeHandler(DeviceGUI *deviceGUI, int newDeviceIndex); void sampleDeviceChangeHandler(DeviceGUI *deviceGUI, int newDeviceIndex);
void on_action_View_Fullscreen_toggled(bool checked); void on_action_View_Fullscreen_toggled(bool checked);