Added reload devices option

This commit is contained in:
f4exb 2017-01-12 01:24:08 +01:00
parent 5c4078d672
commit fb562f197c
6 changed files with 175 additions and 23 deletions

View File

@ -22,7 +22,6 @@
#include <QFileInfo>
#include <QFileDialog>
#include <QTextStream>
#include <QMessageBox>
#include <QDateTime>
#include <QSysInfo>
@ -278,7 +277,7 @@ void MainWindow::removeLastDevice()
ui->tabInputsSelect->removeTab(ui->tabInputsSelect->count() - 1);
m_deviceWidgetTabs.removeLast();
m_deviceWidgetTabs.removeLast();m_pluginManager->loadPlugins();
ui->tabInputsView->clear();
for (int i = 0; i < m_deviceWidgetTabs.size(); i++)
@ -930,6 +929,61 @@ void MainWindow::on_action_removeLastDevice_triggered()
}
}
void MainWindow::on_action_reloadDevices_triggered()
{
// all devices must be stopped
std::vector<DeviceUISet*>::iterator it = m_deviceUIs.begin();
for (; it != m_deviceUIs.end(); ++it)
{
if ((*it)->m_deviceSourceEngine) // it is a source device
{
if ((*it)->m_deviceSourceEngine->state() == DSPDeviceSourceEngine::StRunning)
{
QMessageBox::information(this, tr("Message"), tr("Stop all devices for reload to take effect"));
return;
}
}
if ((*it)->m_deviceSinkEngine) // it is a sink device
{
if ((*it)->m_deviceSinkEngine->state() == DSPDeviceSinkEngine::StRunning)
{
QMessageBox::information(this, tr("Message"), tr("Stop all devices for reload to take effect"));
return;
}
}
}
// re-scan devices
m_pluginManager->updateSampleSourceDevices();
m_pluginManager->updateSampleSinkDevices();
// re-populate device selectors keeping the same selection
it = m_deviceUIs.begin();
for (; it != m_deviceUIs.end(); ++it)
{
if ((*it)->m_deviceSourceEngine) // it is a source device
{
QComboBox *deviceSelectorComboBox = (*it)->m_samplingDeviceControl->getDeviceSelector();
bool sampleSourceSignalsBlocked = deviceSelectorComboBox->blockSignals(true);
m_pluginManager->fillSampleSourceSelector(deviceSelectorComboBox, (*it)->m_deviceSourceEngine->getUID());
int newIndex = m_pluginManager->getSampleSourceSelectorIndex(deviceSelectorComboBox, (*it)->m_deviceSourceAPI);
deviceSelectorComboBox->setCurrentIndex(newIndex);
deviceSelectorComboBox->blockSignals(sampleSourceSignalsBlocked);
}
if ((*it)->m_deviceSinkEngine) // it is a sink device
{
QComboBox *deviceSelectorComboBox = (*it)->m_samplingDeviceControl->getDeviceSelector();
bool sampleSinkSignalsBlocked = deviceSelectorComboBox->blockSignals(true);
m_pluginManager->fillSampleSinkSelector(deviceSelectorComboBox, (*it)->m_deviceSinkEngine->getUID());
int newIndex = m_pluginManager->getSampleSourceSelectorIndex(deviceSelectorComboBox, (*it)->m_deviceSourceAPI);
deviceSelectorComboBox->setCurrentIndex(newIndex);
deviceSelectorComboBox->blockSignals(sampleSinkSignalsBlocked);
}
}
}
void MainWindow::on_action_Exit_triggered()
{
savePresetSettings(m_settings.getWorkingPreset(), 0);

View File

@ -162,6 +162,7 @@ private slots:
void on_action_addSourceDevice_triggered();
void on_action_addSinkDevice_triggered();
void on_action_removeLastDevice_triggered();
void on_action_reloadDevices_triggered();
void on_action_Exit_triggered();
void tabInputViewIndexChanged();
};

View File

@ -33,7 +33,16 @@
</font>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@ -94,6 +103,7 @@
<addaction name="action_addSourceDevice"/>
<addaction name="action_addSinkDevice"/>
<addaction name="action_removeLastDevice"/>
<addaction name="action_reloadDevices"/>
</widget>
<widget class="QMenu" name="menu_View">
<property name="font">
@ -164,7 +174,16 @@
</attribute>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout_6">
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<property name="spacing">
@ -392,7 +411,16 @@
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
@ -423,7 +451,16 @@
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
@ -460,7 +497,16 @@
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
@ -488,7 +534,16 @@
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
@ -625,6 +680,11 @@
<string>Add sink device</string>
</property>
</action>
<action name="action_reloadDevices">
<property name="text">
<string>Reload devices</string>
</property>
</action>
<zorder>presetDock</zorder>
<zorder>channelDock</zorder>
</widget>

View File

@ -295,6 +295,23 @@ void PluginManager::fillSampleSourceSelector(QComboBox* comboBox, uint deviceUID
}
}
int PluginManager::getSampleSourceSelectorIndex(QComboBox* comboBox, DeviceSourceAPI *deviceSourceAPI)
{
for (int i = 0; i < comboBox->count(); i++)
{
SamplingDevice *samplingDevice = (SamplingDevice*) (comboBox->itemData(i)).value<void *>();
if ((samplingDevice->m_deviceId == deviceSourceAPI->getSampleSourceId()) &&
(samplingDevice->m_deviceSerial == deviceSourceAPI->getSampleSourceSerial()) &&
(samplingDevice->m_deviceSequence == deviceSourceAPI->getSampleSourceSequence()))
{
return i;
}
}
return 0; // default to first item
}
void PluginManager::fillSampleSinkSelector(QComboBox* comboBox, uint deviceUID)
{
comboBox->clear();
@ -313,6 +330,23 @@ void PluginManager::fillSampleSinkSelector(QComboBox* comboBox, uint deviceUID)
}
}
int PluginManager::getSampleSinkSelectorIndex(QComboBox* comboBox, DeviceSinkAPI *deviceSinkAPI)
{
for (int i = 0; i < comboBox->count(); i++)
{
SamplingDevice *samplingDevice = (SamplingDevice*) (comboBox->itemData(i)).value<void *>();
if ((samplingDevice->m_deviceId == deviceSinkAPI->getSampleSinkId()) &&
(samplingDevice->m_deviceSerial == deviceSinkAPI->getSampleSinkSerial()) &&
(samplingDevice->m_deviceSequence == deviceSinkAPI->getSampleSinkSequence()))
{
return i;
}
}
return 0; // default to first item
}
int PluginManager::selectSampleSourceByIndex(int index, DeviceSourceAPI *deviceAPI)
{
qDebug("PluginManager::selectSampleSourceByIndex: index: %d", index);

View File

@ -53,10 +53,12 @@ public:
void updateSampleSourceDevices();
void duplicateLocalSampleSourceDevices(uint deviceUID);
void fillSampleSourceSelector(QComboBox* comboBox, uint deviceUID);
int getSampleSourceSelectorIndex(QComboBox* comboBox, DeviceSourceAPI *deviceSourceAPI);
void updateSampleSinkDevices();
void duplicateLocalSampleSinkDevices(uint deviceUID);
void fillSampleSinkSelector(QComboBox* comboBox, uint deviceUID);
int getSampleSinkSelectorIndex(QComboBox* comboBox, DeviceSinkAPI *deviceSinkAPI);
int selectSampleSourceByIndex(int index, DeviceSourceAPI *deviceAPI);
int selectFirstSampleSource(const QString& sourceId, DeviceSourceAPI *deviceAPI);

View File

@ -29,26 +29,27 @@ In each slave tab group (2), (3), (4) and (5) an individual tab corresponding to
The following items are presented hierarchically from left to right:
- File:
- Exit (shortcut Ctl-Q): Exit the program
- _Exit_ (shortcut Ctl-Q): Exit the program
- View:
- Fullscreen (Shortcut F11): Toggle full screen mode
- _Fullscreen_ (Shortcut F11): Toggle full screen mode
- Devices:
- Add source device: adds a new source (receiver) device slot to the device stack (last position)
- Add sink device: adds a new sink (transmitter) device slot to the device stack (last position)
- Remove device: removes the last device slot from thte device stack
- _Add source device_: adds a new source (receiver) device slot to the device stack (last position)
- _Add sink device_: adds a new sink (transmitter) device slot to the device stack (last position)
- _Remove device_: removes the last device slot from thte device stack
- _Reload devices_: re-scan the system for devices. Devices selectors are updated with new devices and missing devices are removed. All devices must be stopped for this to take effect.
- Window: presents the list of dockable windows. Check to make it visible. Uncheck to hide. These windows are:
- Sampling devices control: control of which sampling devices is used and add channels
- Sampling devices: the sampling devices UIs
- Spectrum display: the main spectrum displays (output from the sampling devices)
- Presets: the saved presets
- Channels: the channels active for each device
- _Sampling devices control_: control of which sampling devices is used and add channels
- _Sampling devices_: the sampling devices UIs
- _Spectrum display_: the main spectrum displays (output from the sampling devices)
- _Presets_: the saved presets
- _Channels_: the channels active for each device
- Preferences:
- Audio: opens a dialog to choose the audio output device (see 1.1 below for details)
- DV Serial: if you have one or more AMBE3000 serial devices for AMBE digital voice check to connect them. If unchecked DV decoding will resort to mbelib if available else no audio will be produced for AMBE digital voice
- My Position: opens a dialog to enter your station ("My Position") coordinates in decimal degrees with north latitudes positive and east longitudes positive. This is used whenever positional data is to be displayed (APRS, DPRS, ...). For it now only works with D-Star $$CRC frames. See [DSD demod plugin](../plugins/channel/demoddsd/readme.md) for details on how to decode Digital Voice modes.
- _Audio_: opens a dialog to choose the audio output device (see 1.1 below for details)
- _DV Serial_: if you have one or more AMBE3000 serial devices for AMBE digital voice check to connect them. If unchecked DV decoding will resort to mbelib if available else no audio will be produced for AMBE digital voice
- _My Position_: opens a dialog to enter your station ("My Position") coordinates in decimal degrees with north latitudes positive and east longitudes positive. This is used whenever positional data is to be displayed (APRS, DPRS, ...). For it now only works with D-Star $$CRC frames. See [DSD demod plugin](../plugins/channel/demoddsd/readme.md) for details on how to decode Digital Voice modes.
- Help:
- Loaded Plugins: shows details about the loaded plugins (see 1.2 below for details)
- About: current version and blah blah.
- _Loaded Plugins_: shows details about the loaded plugins (see 1.2 below for details)
- _About_: current version and blah blah.
<h4>1.1. Preferences - Audio</h4>