New channels dock with add channels button replaces add channel from sampling devices control. Implements #628

pull/638/head
f4exb 2020-09-12 10:37:16 +02:00
rodzic 9936a5e2c4
commit 5c1dc1e5a7
12 zmienionych plików z 450 dodań i 79 usunięć

Wyświetl plik

@ -14,6 +14,8 @@ set(sdrgui_SOURCES
gui/basicchannelsettingsdialog.cpp
gui/basicdevicesettingsdialog.cpp
gui/buttonswitch.cpp
gui/channeladddialog.cpp
gui/channelsdock.cpp
gui/channelwindow.cpp
gui/clickablelabel.cpp
gui/colormapper.cpp
@ -86,6 +88,8 @@ set(sdrgui_HEADERS
gui/basicchannelsettingsdialog.h
gui/basicdevicesettingsdialog.h
gui/buttonswitch.h
gui/channeladddialog.h
gui/channelsdock.h
gui/channelwindow.h
gui/colormapper.h
gui/commanditem.h
@ -154,6 +158,7 @@ set(sdrgui_FORMS
gui/ambedevicesdialog.ui
gui/basicchannelsettingsdialog.ui
gui/basicdevicesettingsdialog.ui
gui/channeladddialog.ui
gui/commandoutputdialog.ui
gui/cwkeyergui.ui
gui/devicestreamselectiondialog.ui

Wyświetl plik

@ -0,0 +1,54 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 F4EXB //
// written by Edouard Griffiths //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QStringList>
#include "channeladddialog.h"
#include "ui_channeladddialog.h"
ChannelAddDialog::ChannelAddDialog(QWidget* parent) :
QDialog(parent),
ui(new Ui::ChannelAddDialog)
{
ui->setupUi(this);
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(apply(QAbstractButton*)));
}
ChannelAddDialog::~ChannelAddDialog()
{
delete ui;
}
void ChannelAddDialog::resetChannelNames()
{
ui->channelSelect->clear();
}
void ChannelAddDialog::addChannelNames(const QStringList& channelNames)
{
ui->channelSelect->addItems(channelNames);
}
void ChannelAddDialog::apply(QAbstractButton *button)
{
if (button == (QAbstractButton*) ui->buttonBox->button(QDialogButtonBox::Apply))
{
int selectedChannelIndex = ui->channelSelect->currentIndex();
emit(addChannel(selectedChannelIndex));
}
}

Wyświetl plik

@ -0,0 +1,54 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 F4EXB //
// written by Edouard Griffiths //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRGUI_GUI_CHANNELADDDIALOG_H_
#define SDRGUI_GUI_CHANNELADDDIALOG_H_
#include <QDialog>
#include <vector>
#include "export.h"
class QStringList;
class QAbstractButton;
namespace Ui {
class ChannelAddDialog;
}
class SDRGUI_API ChannelAddDialog : public QDialog {
Q_OBJECT
public:
explicit ChannelAddDialog(QWidget* parent = nullptr);
~ChannelAddDialog();
void resetChannelNames();
void addChannelNames(const QStringList& channelNames);
private:
Ui::ChannelAddDialog* ui;
std::vector<int> m_channelIndexes;
private slots:
void apply(QAbstractButton*);
signals:
void addChannel(int);
};
#endif /* SDRGUI_GUI_CHANNELADDDIALOG_H_ */

Wyświetl plik

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChannelAddDialog</class>
<widget class="QDialog" name="ChannelAddDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>324</width>
<height>139</height>
</rect>
</property>
<property name="font">
<font>
<family>Liberation Sans</family>
<pointsize>9</pointsize>
</font>
</property>
<property name="windowTitle">
<string>Add Channels</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>70</height>
</size>
</property>
<property name="font">
<font>
<family>Liberation Sans</family>
<pointsize>9</pointsize>
</font>
</property>
<property name="title">
<string>Available channels</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="1">
<widget class="QComboBox" name="channelSelect">
<property name="font">
<font>
<family>Liberation Sans</family>
<pointsize>9</pointsize>
</font>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="font">
<font>
<family>Liberation Sans</family>
<pointsize>9</pointsize>
</font>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ChannelAddDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>257</x>
<y>194</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>203</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ChannelAddDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>314</x>
<y>194</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>203</y>
</hint>
</hints>
</connection>
</connections>
</ui>

Wyświetl plik

@ -0,0 +1,109 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 F4EXB //
// written by Edouard Griffiths //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QStyle>
#include "channelsdock.h"
ChannelsDock::ChannelsDock(QWidget *parent, Qt::WindowFlags flags) :
QDockWidget(parent, flags),
m_channelAddDialog(this)
{
m_titleBar = new QWidget();
m_titleBarLayout = new QHBoxLayout();
m_titleBarLayout->setMargin(0);
m_titleBar->setLayout(m_titleBarLayout);
m_titleLabel = new QLabel();
m_titleLabel->setText(QString("Channels"));
m_addChannelButton = new QPushButton();
QIcon addIcon(":/create.png");
m_addChannelButton->setIcon(addIcon);
m_addChannelButton->setToolTip("Add channels");
m_addChannelButton->setFixedSize(16, 16);
m_normalButton = new QPushButton();
QIcon normalIcon = style()->standardIcon(QStyle::SP_TitleBarNormalButton, 0, this);
m_normalButton->setIcon(normalIcon);
m_normalButton->setFixedSize(12, 12);
m_closeButton = new QPushButton();
QIcon closeIcon = style()->standardIcon(QStyle::SP_TitleBarCloseButton, 0, this);
m_closeButton->setIcon(closeIcon);
m_closeButton->setFixedSize(12, 12);
m_titleBarLayout->addWidget(m_addChannelButton);
m_titleBarLayout->addWidget(m_titleLabel);
m_titleBarLayout->addWidget(m_normalButton);
m_titleBarLayout->addWidget(m_closeButton);
setTitleBarWidget(m_titleBar);
QObject::connect(
m_addChannelButton,
&QPushButton::clicked,
this,
&ChannelsDock::addChannelDialog
);
QObject::connect(
m_normalButton,
&QPushButton::clicked,
this,
&ChannelsDock::toggleFloating
);
QObject::connect(
&m_channelAddDialog,
&ChannelAddDialog::addChannel,
this,
&ChannelsDock::addChannelEmitted
);
connect(m_closeButton, SIGNAL(clicked()), this, SLOT(hide()));
}
ChannelsDock::~ChannelsDock()
{
delete m_closeButton;
delete m_normalButton;
delete m_titleLabel;
delete m_titleBarLayout;
delete m_titleBar;
}
void ChannelsDock::toggleFloating()
{
setFloating(!isFloating());
}
void ChannelsDock::addChannelDialog()
{
m_channelAddDialog.exec();
}
void ChannelsDock::addChannelEmitted(int channelIndex)
{
if (channelIndex >= 0) {
emit addChannel(channelIndex);
}
}

Wyświetl plik

@ -0,0 +1,59 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 F4EXB //
// written by Edouard Griffiths //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRGUI_GUI_CHANNELDOCK_H_
#define SDRGUI_GUI_CHANNELDOCK_H_
#include <QDockWidget>
#include "channeladddialog.h"
class QHBoxLayout;
class QLabel;
class QPushButton;
class QStringList;
class ChannelsDock : public QDockWidget
{
Q_OBJECT
public:
ChannelsDock(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
~ChannelsDock();
void resetAvailableChannels() { m_channelAddDialog.resetChannelNames(); }
void addAvailableChannels(const QStringList& channelNames) { m_channelAddDialog.addChannelNames(channelNames); }
private:
QPushButton *m_addChannelButton;
QWidget *m_titleBar;
QHBoxLayout *m_titleBarLayout;
QLabel *m_titleLabel;
QPushButton *m_normalButton;
QPushButton *m_closeButton;
ChannelAddDialog m_channelAddDialog;
private slots:
void toggleFloating();
void addChannelDialog();
void addChannelEmitted(int channelIndex);
signals:
void addChannel(int);
};
#endif // SDRGUI_GUI_CHANNELDOCK_H_

Wyświetl plik

@ -98,13 +98,3 @@ void SamplingDeviceControl::removeSelectedDeviceIndex()
m_selectedDeviceIndex = -1;
}
QComboBox *SamplingDeviceControl::getChannelSelector()
{
return ui->channelSelect;
}
QPushButton *SamplingDeviceControl::getAddChannelButton()
{
return ui->addChannel;
}

Wyświetl plik

@ -42,10 +42,7 @@ public:
int getSelectedDeviceIndex() const { return m_selectedDeviceIndex; }
void setSelectedDeviceIndex(int index);
void removeSelectedDeviceIndex();
void setPluginManager(PluginManager *pluginManager) { m_pluginManager = pluginManager; }
QComboBox *getChannelSelector();
QPushButton *getAddChannelButton();
private slots:
void on_deviceChange_clicked();

Wyświetl plik

@ -7,13 +7,13 @@
<x>0</x>
<y>0</y>
<width>300</width>
<height>76</height>
<height>40</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>76</height>
<height>40</height>
</size>
</property>
<property name="maximumSize">
@ -104,43 +104,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="channelSelect">
<property name="toolTip">
<string>Select channel plugin</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addChannel">
<property name="minimumSize">
<size>
<width>24</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Add a new channel</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/plusw.png</normaloff>:/plusw.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>

Wyświetl plik

@ -211,6 +211,7 @@ MainWindow::MainWindow(qtwebapp::LoggerWithFile *logger, const MainParser& parse
int deviceIndex = DeviceEnumerator::instance()->getRxSamplingDeviceIndex(m_settings.getSourceDeviceId(), m_settings.getSourceIndex());
addSourceDevice(deviceIndex); // add the first device set with file input device as default if device in settings is not enumerated
m_deviceUIs.back()->m_deviceAPI->setBuddyLeader(true); // the first device is always the leader
tabChannelsIndexChanged(); // force channel selection list update
splash->showStatusMessage("load current preset settings...", Qt::white);
qDebug() << "MainWindow::MainWindow: load current preset settings...";
@ -224,6 +225,8 @@ MainWindow::MainWindow(qtwebapp::LoggerWithFile *logger, const MainParser& parse
splash->showStatusMessage("finishing...", Qt::white);
connect(ui->tabInputsView, SIGNAL(currentChanged(int)), this, SLOT(tabInputViewIndexChanged()));
connect(ui->tabChannels, SIGNAL(currentChanged(int)), this, SLOT(tabChannelsIndexChanged()));
connect(ui->channelDock, SIGNAL(addChannel(int)), this, SLOT(channelAddClicked(int)));
QString applicationDirPath = qApp->applicationDirPath();
@ -314,11 +317,7 @@ void MainWindow::addSourceDevice(int deviceIndex)
m_deviceUIs.back()->m_samplingDeviceControl->setPluginManager(m_pluginManager);
QList<QString> channelNames;
m_pluginManager->listRxChannels(channelNames);
QStringList channelNamesList(channelNames);
m_deviceUIs.back()->m_samplingDeviceControl->getChannelSelector()->addItems(channelNamesList);
m_deviceUIs.back()->setNumberOfAvailableRxChannels(channelNamesList.size());
connect(m_deviceUIs.back()->m_samplingDeviceControl->getAddChannelButton(), SIGNAL(clicked(bool)), this, SLOT(channelAddClicked(bool)));
m_deviceUIs.back()->setNumberOfAvailableRxChannels(channelNames.size());
dspDeviceSourceEngine->addSink(m_deviceUIs.back()->m_spectrumVis);
ui->tabSpectra->addTab(m_deviceUIs.back()->m_spectrum, tabNameCStr);
@ -396,11 +395,7 @@ void MainWindow::addSinkDevice()
m_deviceUIs.back()->m_samplingDeviceControl->setPluginManager(m_pluginManager);
QList<QString> channelNames;
m_pluginManager->listTxChannels(channelNames);
QStringList channelNamesList(channelNames);
m_deviceUIs.back()->m_samplingDeviceControl->getChannelSelector()->addItems(channelNamesList);
m_deviceUIs.back()->setNumberOfAvailableTxChannels(channelNamesList.size());
connect(m_deviceUIs.back()->m_samplingDeviceControl->getAddChannelButton(), SIGNAL(clicked(bool)), this, SLOT(channelAddClicked(bool)));
m_deviceUIs.back()->setNumberOfAvailableTxChannels(channelNames.size());
dspDeviceSinkEngine->addSpectrumSink(m_deviceUIs.back()->m_spectrumVis);
m_deviceUIs.back()->m_spectrum->setDisplayedStream(false, 0);
@ -979,9 +974,7 @@ bool MainWindow::handleMessage(const Message& cmd)
{
MsgAddChannel& notif = (MsgAddChannel&) cmd;
ui->tabInputsSelect->setCurrentIndex(notif.getDeviceSetIndex());
DeviceUISet *deviceUI = m_deviceUIs[notif.getDeviceSetIndex()];
deviceUI->m_samplingDeviceControl->getChannelSelector()->setCurrentIndex(notif.getChannelRegistrationIndex());
channelAddClicked(true);
channelAddClicked(notif.getChannelRegistrationIndex());
return true;
}
@ -1903,9 +1896,8 @@ void MainWindow::sampleMIMOChanged()
}
}
void MainWindow::channelAddClicked(bool checked)
void MainWindow::channelAddClicked(int channelIndex)
{
(void) checked;
// Do it in the currently selected source tab
int currentSourceTabIndex = ui->tabInputsSelect->currentIndex();
@ -1916,27 +1908,26 @@ void MainWindow::channelAddClicked(bool checked)
if (deviceUI->m_deviceSourceEngine) // source device => Rx channels
{
m_pluginManager->createRxChannelInstance(
deviceUI->m_samplingDeviceControl->getChannelSelector()->currentIndex(), deviceUI, deviceUI->m_deviceAPI);
channelIndex, deviceUI, deviceUI->m_deviceAPI);
}
else if (deviceUI->m_deviceSinkEngine) // sink device => Tx channels
{
m_pluginManager->createTxChannelInstance(
deviceUI->m_samplingDeviceControl->getChannelSelector()->currentIndex(), deviceUI, deviceUI->m_deviceAPI);
channelIndex, deviceUI, deviceUI->m_deviceAPI);
}
else if (deviceUI->m_deviceMIMOEngine) // MIMO device => all possible channels. Depends on index range
{
int nbRxChannels = deviceUI->getNumberOfAvailableRxChannels();
int nbTxChannels = deviceUI->getNumberOfAvailableTxChannels();
int selectedIndex = deviceUI->m_samplingDeviceControl->getChannelSelector()->currentIndex();
qDebug("MainWindow::channelAddClicked: MIMO: tab: %d nbRx: %d nbTx: %d selected: %d",
currentSourceTabIndex, nbRxChannels, nbTxChannels, selectedIndex);
currentSourceTabIndex, nbRxChannels, nbTxChannels, channelIndex);
if (selectedIndex < nbRxChannels) {
if (channelIndex < nbRxChannels) {
m_pluginManager->createRxChannelInstance(
selectedIndex, deviceUI, deviceUI->m_deviceAPI);
} else if (selectedIndex < nbRxChannels + nbTxChannels) {
channelIndex, deviceUI, deviceUI->m_deviceAPI);
} else if (channelIndex < nbRxChannels + nbTxChannels) {
m_pluginManager->createTxChannelInstance(
selectedIndex - nbRxChannels, deviceUI, deviceUI->m_deviceAPI);
channelIndex - nbRxChannels, deviceUI, deviceUI->m_deviceAPI);
}
}
}
@ -1990,6 +1981,38 @@ void MainWindow::tabInputViewIndexChanged()
ui->tabSpectraGUI->setCurrentIndex(inputViewIndex);
}
void MainWindow::tabChannelsIndexChanged()
{
int channelsTabIndex = ui->tabChannels->currentIndex();
if (channelsTabIndex >= 0)
{
DeviceUISet *deviceUI = m_deviceUIs[channelsTabIndex];
QList<QString> channelNames;
ui->channelDock->resetAvailableChannels();
if (deviceUI->m_deviceSourceEngine) // source device
{
m_pluginManager->listRxChannels(channelNames);
ui->channelDock->addAvailableChannels(channelNames);
}
else if (deviceUI->m_deviceSinkEngine) // sink device
{
m_pluginManager->listTxChannels(channelNames);
ui->channelDock->addAvailableChannels(channelNames);
}
else if (deviceUI->m_deviceMIMOEngine) // MIMO device
{
m_pluginManager->listMIMOChannels(channelNames);
ui->channelDock->addAvailableChannels(channelNames);
m_pluginManager->listRxChannels(channelNames);
ui->channelDock->addAvailableChannels(channelNames);
m_pluginManager->listTxChannels(channelNames);
ui->channelDock->addAvailableChannels(channelNames);
}
}
}
void MainWindow::updateStatus()
{
m_dateTimeWidget->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss t"));

Wyświetl plik

@ -400,7 +400,7 @@ private slots:
void sampleSourceChanged();
void sampleSinkChanged();
void sampleMIMOChanged();
void channelAddClicked(bool checked);
void channelAddClicked(int channelIndex);
void on_action_Loaded_Plugins_triggered();
void on_action_About_triggered();
void on_action_addSourceDevice_triggered();
@ -408,6 +408,7 @@ private slots:
void on_action_addMIMODevice_triggered();
void on_action_removeLastDevice_triggered();
void tabInputViewIndexChanged();
void tabChannelsIndexChanged();
void commandKeyPressed(Qt::Key key, Qt::KeyboardModifiers keyModifiers, bool release);
};

Wyświetl plik

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1012</width>
<height>721</height>
<height>811</height>
</rect>
</property>
<property name="font">
@ -64,7 +64,7 @@
<x>0</x>
<y>0</y>
<width>1012</width>
<height>20</height>
<height>27</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
@ -500,7 +500,7 @@
</layout>
</widget>
</widget>
<widget class="QDockWidget" name="channelDock">
<widget class="ChannelsDock" name="channelDock">
<property name="windowTitle">
<string>Channels</string>
</property>
@ -960,6 +960,12 @@
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget>
<class>ChannelsDock</class>
<extends>QDockWidget</extends>
<header>gui/channelsdock.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>presetTree</tabstop>