mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-07-31 12:52:25 -04:00
Cleanup: about, digital console and device dialogs
This commit is contained in:
parent
296f7790f1
commit
592ffa2050
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
class AboutDialog : public AboutDialogBase {
|
class AboutDialog : public AboutDialogBase {
|
||||||
public:
|
public:
|
||||||
AboutDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("About"),
|
explicit AboutDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("About"),
|
||||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 530, 420 ),
|
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 530, 420 ),
|
||||||
long style = wxDEFAULT_DIALOG_STYLE );
|
long style = wxDEFAULT_DIALOG_STYLE );
|
||||||
|
|
||||||
|
@ -11,9 +11,7 @@ ActionDialog::ActionDialog( wxWindow* parent, wxWindowID id, const wxString& tit
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ActionDialog::~ActionDialog() {
|
ActionDialog::~ActionDialog() = default;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ActionDialog::showDialog(ActionDialog *dlg) {
|
void ActionDialog::showDialog(ActionDialog *dlg) {
|
||||||
if (activeDialog) { // rejected
|
if (activeDialog) { // rejected
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
|
|
||||||
class ActionDialog : public ActionDialogBase {
|
class ActionDialog : public ActionDialogBase {
|
||||||
public:
|
public:
|
||||||
ActionDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("QuestionTitle"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE );
|
explicit ActionDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("QuestionTitle"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE );
|
||||||
~ActionDialog();
|
~ActionDialog() override;
|
||||||
|
|
||||||
void onClickCancel( wxCommandEvent& event );
|
void onClickCancel( wxCommandEvent& event ) override;
|
||||||
void onClickOK( wxCommandEvent& event );
|
void onClickOK( wxCommandEvent& event ) override;
|
||||||
|
|
||||||
virtual void doClickCancel();
|
virtual void doClickCancel();
|
||||||
virtual void doClickOK();
|
virtual void doClickOK();
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "rs232.h"
|
#include "rs232.h"
|
||||||
#include "CubicSDR.h"
|
#include "CubicSDR.h"
|
||||||
|
|
||||||
PortSelectorDialog::PortSelectorDialog( wxWindow* parent, wxWindowID id, std::string defaultPort ) : PortSelectorDialogBase(parent, id) {
|
PortSelectorDialog::PortSelectorDialog( wxWindow* parent, wxWindowID id, const std::string& defaultPort ) : PortSelectorDialogBase(parent, id) {
|
||||||
comEnumerate();
|
comEnumerate();
|
||||||
|
|
||||||
int nPorts = comGetNoPorts();
|
int nPorts = comGetNoPorts();
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
class PortSelectorDialog : public PortSelectorDialogBase {
|
class PortSelectorDialog : public PortSelectorDialogBase {
|
||||||
public:
|
public:
|
||||||
PortSelectorDialog( wxWindow* parent, wxWindowID id = wxID_ANY, std::string defaultPort = "" );
|
explicit PortSelectorDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const std::string& defaultPort = "" );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onListSelect( wxCommandEvent& event );
|
void onListSelect( wxCommandEvent& event ) override;
|
||||||
void onCancelButton( wxCommandEvent& event );
|
void onCancelButton( wxCommandEvent& event ) override;
|
||||||
void onOKButton( wxCommandEvent& event );
|
void onOKButton( wxCommandEvent& event ) override;
|
||||||
void onClose( wxCloseEvent& event );
|
void onClose( wxCloseEvent& event ) override;
|
||||||
};
|
};
|
||||||
|
@ -51,7 +51,7 @@ void DigitalConsole::OnClear( wxCommandEvent& /* event */ ) {
|
|||||||
m_dataView->Clear();
|
m_dataView->Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DigitalConsole::write(std::string outp) {
|
void DigitalConsole::write(const std::string& outp) {
|
||||||
if (streamPaused.load()) {
|
if (streamPaused.load()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -76,13 +76,11 @@ ModemDigitalOutputConsole::ModemDigitalOutputConsole(): ModemDigitalOutput(), di
|
|||||||
streamWritten.store(false);
|
streamWritten.store(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ModemDigitalOutputConsole::~ModemDigitalOutputConsole() {
|
ModemDigitalOutputConsole::~ModemDigitalOutputConsole() = default;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModemDigitalOutputConsole::setDialog(DigitalConsole *dialog_in) {
|
void ModemDigitalOutputConsole::setDialog(DigitalConsole *dialog_in) {
|
||||||
dialog = dialog_in;
|
dialog = dialog_in;
|
||||||
if (dialog && dialogTitle != "") {
|
if (dialog && !dialogTitle.empty()) {
|
||||||
dialog->SetTitle(dialogTitle);
|
dialog->SetTitle(dialogTitle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,7 +117,7 @@ void ModemDigitalOutputConsole::Close() {
|
|||||||
dialog = nullptr;
|
dialog = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModemDigitalOutputConsole::setTitle(std::string title) {
|
void ModemDigitalOutputConsole::setTitle(const std::string& title) {
|
||||||
if (dialog) {
|
if (dialog) {
|
||||||
dialog->SetTitle(title);
|
dialog->SetTitle(title);
|
||||||
}
|
}
|
||||||
|
@ -16,19 +16,19 @@ class ModemDigitalOutputConsole;
|
|||||||
class DigitalConsole: public DigitalConsoleFrame {
|
class DigitalConsole: public DigitalConsoleFrame {
|
||||||
public:
|
public:
|
||||||
DigitalConsole( wxWindow* parent, ModemDigitalOutputConsole *doParent );
|
DigitalConsole( wxWindow* parent, ModemDigitalOutputConsole *doParent );
|
||||||
~DigitalConsole();
|
~DigitalConsole() override;
|
||||||
|
|
||||||
|
|
||||||
void write(std::string outp);
|
void write(const std::string& outp);
|
||||||
void write(char outc);
|
void write(char outc);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DoRefresh( wxTimerEvent& event );
|
void DoRefresh( wxTimerEvent& event ) override;
|
||||||
void OnClose( wxCloseEvent& event );
|
void OnClose( wxCloseEvent& event ) override;
|
||||||
void OnClear( wxCommandEvent& event );
|
void OnClear( wxCommandEvent& event ) override;
|
||||||
|
|
||||||
void OnCopy( wxCommandEvent& event );
|
void OnCopy( wxCommandEvent& event ) override;
|
||||||
void OnPause( wxCommandEvent& event );
|
void OnPause( wxCommandEvent& event ) override;
|
||||||
|
|
||||||
std::stringstream streamBuf;
|
std::stringstream streamBuf;
|
||||||
std::mutex stream_busy;
|
std::mutex stream_busy;
|
||||||
@ -40,19 +40,19 @@ private:
|
|||||||
class ModemDigitalOutputConsole: public ModemDigitalOutput {
|
class ModemDigitalOutputConsole: public ModemDigitalOutput {
|
||||||
public:
|
public:
|
||||||
ModemDigitalOutputConsole();
|
ModemDigitalOutputConsole();
|
||||||
~ModemDigitalOutputConsole();
|
~ModemDigitalOutputConsole() override;
|
||||||
|
|
||||||
void setDialog(DigitalConsole *dialog_in);
|
void setDialog(DigitalConsole *dialog_in);
|
||||||
DigitalConsole *getDialog();
|
DigitalConsole *getDialog();
|
||||||
|
|
||||||
void setTitle(std::string title);
|
void setTitle(const std::string& title);
|
||||||
|
|
||||||
void write(std::string outp);
|
void write(std::string outp) override;
|
||||||
void write(char outc);
|
void write(char outc) override;
|
||||||
|
|
||||||
void Show();
|
void Show() override;
|
||||||
void Hide();
|
void Hide() override;
|
||||||
void Close();
|
void Close() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DigitalConsole *dialog;
|
DigitalConsole *dialog;
|
||||||
|
@ -48,7 +48,7 @@ void SDRDeviceAddDialog::OnOkButton( wxCommandEvent& /* event */) {
|
|||||||
Close(true);
|
Close(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDRDeviceAddDialog::wasOkPressed() {
|
bool SDRDeviceAddDialog::wasOkPressed() const {
|
||||||
return okPressed;
|
return okPressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,13 +7,13 @@
|
|||||||
|
|
||||||
class SDRDeviceAddDialog : public SDRDeviceAddForm {
|
class SDRDeviceAddDialog : public SDRDeviceAddForm {
|
||||||
public:
|
public:
|
||||||
SDRDeviceAddDialog( wxWindow* parent );
|
explicit SDRDeviceAddDialog( wxWindow* parent );
|
||||||
|
|
||||||
void OnSoapyModuleChanged( wxCommandEvent& event );
|
void OnSoapyModuleChanged( wxCommandEvent& event ) override;
|
||||||
void OnCancelButton( wxCommandEvent& event );
|
void OnCancelButton( wxCommandEvent& event ) override;
|
||||||
void OnOkButton( wxCommandEvent& event );
|
void OnOkButton( wxCommandEvent& event ) override;
|
||||||
|
|
||||||
bool wasOkPressed();
|
bool wasOkPressed() const;
|
||||||
std::string getSelectedModule();
|
std::string getSelectedModule();
|
||||||
std::string getModuleParam();
|
std::string getModuleParam();
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "SDRDevices.h"
|
#include "SDRDevices.h"
|
||||||
|
|
||||||
#include <wx/textdlg.h>
|
|
||||||
#include <wx/msgdlg.h>
|
#include <wx/msgdlg.h>
|
||||||
|
|
||||||
#include "CubicSDR.h"
|
#include "CubicSDR.h"
|
||||||
@ -45,7 +44,7 @@ void SDRDevicesDialog::OnDeleteItem( wxTreeEvent& event ) {
|
|||||||
|
|
||||||
wxPGProperty *SDRDevicesDialog::addArgInfoProperty(wxPropertyGrid *pg, SoapySDR::ArgInfo arg) {
|
wxPGProperty *SDRDevicesDialog::addArgInfoProperty(wxPropertyGrid *pg, SoapySDR::ArgInfo arg) {
|
||||||
|
|
||||||
wxPGProperty *prop = NULL;
|
wxPGProperty *prop = nullptr;
|
||||||
|
|
||||||
int intVal;
|
int intVal;
|
||||||
double floatVal;
|
double floatVal;
|
||||||
@ -55,7 +54,7 @@ wxPGProperty *SDRDevicesDialog::addArgInfoProperty(wxPropertyGrid *pg, SoapySDR:
|
|||||||
case SoapySDR::ArgInfo::INT:
|
case SoapySDR::ArgInfo::INT:
|
||||||
try {
|
try {
|
||||||
intVal = std::stoi(arg.value);
|
intVal = std::stoi(arg.value);
|
||||||
} catch (std::invalid_argument e) {
|
} catch (const std::invalid_argument &e) {
|
||||||
intVal = 0;
|
intVal = 0;
|
||||||
}
|
}
|
||||||
prop = pg->Append( new wxIntProperty(arg.name, wxPG_LABEL, intVal) );
|
prop = pg->Append( new wxIntProperty(arg.name, wxPG_LABEL, intVal) );
|
||||||
@ -67,7 +66,7 @@ wxPGProperty *SDRDevicesDialog::addArgInfoProperty(wxPropertyGrid *pg, SoapySDR:
|
|||||||
case SoapySDR::ArgInfo::FLOAT:
|
case SoapySDR::ArgInfo::FLOAT:
|
||||||
try {
|
try {
|
||||||
floatVal = std::stod(arg.value);
|
floatVal = std::stod(arg.value);
|
||||||
} catch (std::invalid_argument e) {
|
} catch (const std::invalid_argument &e) {
|
||||||
floatVal = 0;
|
floatVal = 0;
|
||||||
}
|
}
|
||||||
prop = pg->Append( new wxFloatProperty(arg.name, wxPG_LABEL, floatVal) );
|
prop = pg->Append( new wxFloatProperty(arg.name, wxPG_LABEL, floatVal) );
|
||||||
@ -80,13 +79,13 @@ wxPGProperty *SDRDevicesDialog::addArgInfoProperty(wxPropertyGrid *pg, SoapySDR:
|
|||||||
prop = pg->Append( new wxBoolProperty(arg.name, wxPG_LABEL, (arg.value=="true")) );
|
prop = pg->Append( new wxBoolProperty(arg.name, wxPG_LABEL, (arg.value=="true")) );
|
||||||
break;
|
break;
|
||||||
case SoapySDR::ArgInfo::STRING:
|
case SoapySDR::ArgInfo::STRING:
|
||||||
if (arg.options.size()) {
|
if (!arg.options.empty()) {
|
||||||
intVal = 0;
|
intVal = 0;
|
||||||
prop = pg->Append( new wxEnumProperty(arg.name, wxPG_LABEL) );
|
prop = pg->Append( new wxEnumProperty(arg.name, wxPG_LABEL) );
|
||||||
for (stringIter = arg.options.begin(); stringIter != arg.options.end(); stringIter++) {
|
for (stringIter = arg.options.begin(); stringIter != arg.options.end(); stringIter++) {
|
||||||
std::string optName = (*stringIter);
|
std::string optName = (*stringIter);
|
||||||
std::string displayName = optName;
|
std::string displayName = optName;
|
||||||
if (arg.optionNames.size()) {
|
if (!arg.optionNames.empty()) {
|
||||||
displayName = arg.optionNames[intVal];
|
displayName = arg.optionNames[intVal];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +102,7 @@ wxPGProperty *SDRDevicesDialog::addArgInfoProperty(wxPropertyGrid *pg, SoapySDR:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prop != NULL) {
|
if (prop != nullptr) {
|
||||||
prop->SetHelpString(arg.key + ": " + arg.description);
|
prop->SetHelpString(arg.key + ": " + arg.description);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +156,7 @@ void SDRDevicesDialog::refreshDeviceProperties() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//build device settings
|
//build device settings
|
||||||
for (std::string antenna : antennaOpts) {
|
for (const std::string& antenna : antennaOpts) {
|
||||||
antennasArg.options.push_back(antenna);
|
antennasArg.options.push_back(antenna);
|
||||||
antennasArg.optionNames.push_back(antenna);
|
antennasArg.optionNames.push_back(antenna);
|
||||||
}
|
}
|
||||||
@ -208,11 +207,11 @@ void SDRDevicesDialog::refreshDeviceProperties() {
|
|||||||
runtimeProps.clear();
|
runtimeProps.clear();
|
||||||
streamProps.clear();
|
streamProps.clear();
|
||||||
|
|
||||||
if (args.size()) {
|
if (!args.empty()) {
|
||||||
m_propertyGrid->Append(new wxPropertyCategory("Run-time Settings"));
|
m_propertyGrid->Append(new wxPropertyCategory("Run-time Settings"));
|
||||||
|
|
||||||
for (SoapySDR::ArgInfoList::const_iterator args_i = args.begin(); args_i != args.end(); args_i++) {
|
for (const auto & args_i : args) {
|
||||||
SoapySDR::ArgInfo arg = (*args_i);
|
SoapySDR::ArgInfo arg = args_i;
|
||||||
//We-reread the Device configuration, else we use the user settings.
|
//We-reread the Device configuration, else we use the user settings.
|
||||||
if (dev) {
|
if (dev) {
|
||||||
//Apply saved settings
|
//Apply saved settings
|
||||||
@ -234,18 +233,18 @@ void SDRDevicesDialog::refreshDeviceProperties() {
|
|||||||
|
|
||||||
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId());
|
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId());
|
||||||
ConfigSettings devStreamOpts = devConfig->getStreamOpts();
|
ConfigSettings devStreamOpts = devConfig->getStreamOpts();
|
||||||
if (devStreamOpts.size()) {
|
if (!devStreamOpts.empty()) {
|
||||||
for (int j = 0, jMax = args.size(); j < jMax; j++) {
|
for (auto & arg : args) {
|
||||||
if (devStreamOpts.find(args[j].key) != devStreamOpts.end()) {
|
if (devStreamOpts.find(arg.key) != devStreamOpts.end()) {
|
||||||
args[j].value = devStreamOpts[args[j].key];
|
arg.value = devStreamOpts[arg.key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.size()) {
|
if (!args.empty()) {
|
||||||
m_propertyGrid->Append(new wxPropertyCategory("Stream Settings"));
|
m_propertyGrid->Append(new wxPropertyCategory("Stream Settings"));
|
||||||
|
|
||||||
for (SoapySDR::ArgInfo arg : args) {
|
for (const SoapySDR::ArgInfo& arg : args) {
|
||||||
|
|
||||||
streamProps[arg.key] = addArgInfoProperty(m_propertyGrid, arg);
|
streamProps[arg.key] = addArgInfoProperty(m_propertyGrid, arg);
|
||||||
}
|
}
|
||||||
@ -316,7 +315,7 @@ void SDRDevicesDialog::OnAddRemote( wxMouseEvent& /* event */) {
|
|||||||
if (module == "SoapyRemote") {
|
if (module == "SoapyRemote") {
|
||||||
if (!SDREnumerator::hasRemoteModule()) {
|
if (!SDREnumerator::hasRemoteModule()) {
|
||||||
wxMessageDialog *info;
|
wxMessageDialog *info;
|
||||||
info = new wxMessageDialog(NULL, wxT("Install SoapyRemote module to add remote servers.\n\nhttps://github.com/pothosware/SoapyRemote"), wxT("SoapyRemote not found."), wxOK | wxICON_ERROR);
|
info = new wxMessageDialog(nullptr, wxT("Install SoapyRemote module to add remote servers.\n\nhttps://github.com/pothosware/SoapyRemote"), wxT("SoapyRemote not found."), wxOK | wxICON_ERROR);
|
||||||
info->ShowModal();
|
info->ShowModal();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -339,27 +338,27 @@ void SDRDevicesDialog::OnAddRemote( wxMouseEvent& /* event */) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDRDeviceInfo *SDRDevicesDialog::getSelectedDevice(wxTreeItemId selId) {
|
SDRDeviceInfo *SDRDevicesDialog::getSelectedDevice(wxTreeItemId selId_in) {
|
||||||
devItems_i = devItems.find(selId);
|
devItems_i = devItems.find(selId_in);
|
||||||
if (devItems_i != devItems.end()) {
|
if (devItems_i != devItems.end()) {
|
||||||
return devItems[selId];
|
return devItems[selId_in];
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDRDevicesDialog::OnUseSelected( wxMouseEvent& event) {
|
void SDRDevicesDialog::OnUseSelected( wxMouseEvent& event) {
|
||||||
if (dev != NULL) {
|
if (dev != nullptr) {
|
||||||
|
|
||||||
SoapySDR::ArgInfoList args = dev->getSoapyDevice()->getSettingInfo();
|
SoapySDR::ArgInfoList args = dev->getSoapyDevice()->getSettingInfo();
|
||||||
|
|
||||||
SoapySDR::Kwargs settingArgs;
|
SoapySDR::Kwargs settingArgs;
|
||||||
SoapySDR::Kwargs streamArgs;
|
SoapySDR::Kwargs streamArgs;
|
||||||
|
|
||||||
for (SoapySDR::ArgInfo arg : args) {
|
for (const SoapySDR::ArgInfo& arg : args) {
|
||||||
|
|
||||||
wxPGProperty *prop = runtimeProps[arg.key];
|
wxPGProperty *prop = runtimeProps[arg.key];
|
||||||
|
|
||||||
if (arg.type == SoapySDR::ArgInfo::STRING && arg.options.size()) {
|
if (arg.type == SoapySDR::ArgInfo::STRING && !arg.options.empty()) {
|
||||||
settingArgs[arg.key] = getSelectedChoiceOption(prop, arg);
|
settingArgs[arg.key] = getSelectedChoiceOption(prop, arg);
|
||||||
} else if (arg.type == SoapySDR::ArgInfo::BOOL) {
|
} else if (arg.type == SoapySDR::ArgInfo::BOOL) {
|
||||||
settingArgs[arg.key] = (prop->GetValueAsString()=="True")?"true":"false";
|
settingArgs[arg.key] = (prop->GetValueAsString()=="True")?"true":"false";
|
||||||
@ -371,12 +370,12 @@ void SDRDevicesDialog::OnUseSelected( wxMouseEvent& event) {
|
|||||||
if (dev) {
|
if (dev) {
|
||||||
args = dev->getSoapyDevice()->getStreamArgsInfo(SOAPY_SDR_RX, 0);
|
args = dev->getSoapyDevice()->getStreamArgsInfo(SOAPY_SDR_RX, 0);
|
||||||
|
|
||||||
if (args.size()) {
|
if (!args.empty()) {
|
||||||
for (SoapySDR::ArgInfoList::const_iterator args_i = args.begin(); args_i != args.end(); args_i++) {
|
for (const auto & args_i : args) {
|
||||||
SoapySDR::ArgInfo arg = (*args_i);
|
SoapySDR::ArgInfo arg = args_i;
|
||||||
wxPGProperty *prop = streamProps[arg.key];
|
wxPGProperty *prop = streamProps[arg.key];
|
||||||
|
|
||||||
if (arg.type == SoapySDR::ArgInfo::STRING && arg.options.size()) {
|
if (arg.type == SoapySDR::ArgInfo::STRING && !arg.options.empty()) {
|
||||||
streamArgs[arg.key] = getSelectedChoiceOption(prop, arg);
|
streamArgs[arg.key] = getSelectedChoiceOption(prop, arg);
|
||||||
} else if (arg.type == SoapySDR::ArgInfo::BOOL) {
|
} else if (arg.type == SoapySDR::ArgInfo::BOOL) {
|
||||||
streamArgs[arg.key] = (prop->GetValueAsString()=="True")?"true":"false";
|
streamArgs[arg.key] = (prop->GetValueAsString()=="True")?"true":"false";
|
||||||
@ -415,7 +414,7 @@ void SDRDevicesDialog::OnDeviceTimer( wxTimerEvent& event ) {
|
|||||||
if (!failed) {
|
if (!failed) {
|
||||||
failed = true;
|
failed = true;
|
||||||
wxMessageDialog *info;
|
wxMessageDialog *info;
|
||||||
info = new wxMessageDialog(NULL, wxT("\nNo SoapySDR modules were found.\n\nCubicSDR requires at least one SoapySDR device support module to be installed.\n\nPlease visit https://github.com/cjcliffe/CubicSDR/wiki and in the build instructions for your platform read the 'Support Modules' section for more information."), wxT("\x28\u256F\xB0\u25A1\xB0\uFF09\u256F\uFE35\x20\u253B\u2501\u253B"), wxOK | wxICON_ERROR);
|
info = new wxMessageDialog(nullptr, wxT("\nNo SoapySDR modules were found.\n\nCubicSDR requires at least one SoapySDR device support module to be installed.\n\nPlease visit https://github.com/cjcliffe/CubicSDR/wiki and in the build instructions for your platform read the 'Support Modules' section for more information."), wxT("\x28\u256F\xB0\u25A1\xB0\uFF09\u256F\uFE35\x20\u253B\u2501\u253B"), wxOK | wxICON_ERROR);
|
||||||
info->ShowModal();
|
info->ShowModal();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -439,9 +438,9 @@ void SDRDevicesDialog::OnDeviceTimer( wxTimerEvent& event ) {
|
|||||||
wxTreeItemId manualBranch = devTree->AppendItem(devRoot, "Manual");
|
wxTreeItemId manualBranch = devTree->AppendItem(devRoot, "Manual");
|
||||||
|
|
||||||
devs[""] = SDREnumerator::enumerate_devices("",true);
|
devs[""] = SDREnumerator::enumerate_devices("",true);
|
||||||
if (devs[""] != NULL) {
|
if (devs[""] != nullptr) {
|
||||||
for (devs_i = devs[""]->begin(); devs_i != devs[""]->end(); devs_i++) {
|
for (devs_i = devs[""]->begin(); devs_i != devs[""]->end(); devs_i++) {
|
||||||
DeviceConfig *devConfig = nullptr;
|
DeviceConfig *devConfig;
|
||||||
if ((*devs_i)->isManual()) {
|
if ((*devs_i)->isManual()) {
|
||||||
std::string devName = "Unknown";
|
std::string devName = "Unknown";
|
||||||
if ((*devs_i)->isAvailable()) {
|
if ((*devs_i)->isAvailable()) {
|
||||||
@ -465,14 +464,14 @@ void SDRDevicesDialog::OnDeviceTimer( wxTimerEvent& event ) {
|
|||||||
|
|
||||||
std::vector<SDRDeviceInfo *>::iterator remoteDevs_i;
|
std::vector<SDRDeviceInfo *>::iterator remoteDevs_i;
|
||||||
|
|
||||||
if (remotes.size()) {
|
if (!remotes.empty()) {
|
||||||
for (std::string remote : remotes) {
|
for (const std::string& remote : remotes) {
|
||||||
devs[remote] = SDREnumerator::enumerate_devices(remote, true);
|
devs[remote] = SDREnumerator::enumerate_devices(remote, true);
|
||||||
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(remote);
|
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(remote);
|
||||||
|
|
||||||
wxTreeItemId remoteNode = devTree->AppendItem(remoteBranch, devConfig->getDeviceName());
|
wxTreeItemId remoteNode = devTree->AppendItem(remoteBranch, devConfig->getDeviceName());
|
||||||
|
|
||||||
if (devs[remote] != NULL) {
|
if (devs[remote] != nullptr) {
|
||||||
for (remoteDevs_i = devs[remote]->begin(); remoteDevs_i != devs[remote]->end(); remoteDevs_i++) {
|
for (remoteDevs_i = devs[remote]->begin(); remoteDevs_i != devs[remote]->end(); remoteDevs_i++) {
|
||||||
devItems[devTree->AppendItem(remoteNode, (*remoteDevs_i)->getName())] = (*remoteDevs_i);
|
devItems[devTree->AppendItem(remoteNode, (*remoteDevs_i)->getName())] = (*remoteDevs_i);
|
||||||
}
|
}
|
||||||
@ -498,11 +497,11 @@ void SDRDevicesDialog::OnRefreshDevices( wxMouseEvent& /* event */) {
|
|||||||
|
|
||||||
std::string SDRDevicesDialog::getSelectedChoiceOption(wxPGProperty* prop, const SoapySDR::ArgInfo& arg) {
|
std::string SDRDevicesDialog::getSelectedChoiceOption(wxPGProperty* prop, const SoapySDR::ArgInfo& arg) {
|
||||||
|
|
||||||
std::string optionName = "";
|
std::string optionName;
|
||||||
|
|
||||||
int choiceIndex = prop->GetChoiceSelection();
|
int choiceIndex = prop->GetChoiceSelection();
|
||||||
|
|
||||||
if (arg.options.size() > 0) {
|
if (!arg.options.empty()) {
|
||||||
int choiceMax = arg.options.size();
|
int choiceMax = arg.options.size();
|
||||||
|
|
||||||
if (choiceIndex >= 0 && choiceIndex < choiceMax) {
|
if (choiceIndex >= 0 && choiceIndex < choiceMax) {
|
||||||
@ -529,7 +528,7 @@ void SDRDevicesDialog::OnPropGridChanged( wxPropertyGridEvent& event ) {
|
|||||||
if (editId) {
|
if (editId) {
|
||||||
devTree->SetItemText(editId, devConfig->getDeviceName());
|
devTree->SetItemText(editId, devConfig->getDeviceName());
|
||||||
}
|
}
|
||||||
if (devName == "") {
|
if (devName.empty()) {
|
||||||
event.GetProperty()->SetValueFromString(devConfig->getDeviceName());
|
event.GetProperty()->SetValueFromString(devConfig->getDeviceName());
|
||||||
}
|
}
|
||||||
} else if (dev && event.GetProperty() == devSettings["offset"]) {
|
} else if (dev && event.GetProperty() == devSettings["offset"]) {
|
||||||
@ -556,7 +555,7 @@ void SDRDevicesDialog::OnPropGridChanged( wxPropertyGridEvent& event ) {
|
|||||||
if (dev->isActive() || !wxGetApp().getDevice()) {
|
if (dev->isActive() || !wxGetApp().getDevice()) {
|
||||||
wxGetApp().setSampleRate(srate);
|
wxGetApp().setSampleRate(srate);
|
||||||
}
|
}
|
||||||
} catch (std::invalid_argument e) {
|
} catch (const std::invalid_argument &e) {
|
||||||
// nop
|
// nop
|
||||||
}
|
}
|
||||||
} else if (dev && event.GetProperty() == devSettings["antenna"]) {
|
} else if (dev && event.GetProperty() == devSettings["antenna"]) {
|
||||||
@ -571,19 +570,19 @@ void SDRDevicesDialog::OnPropGridChanged( wxPropertyGridEvent& event ) {
|
|||||||
wxGetApp().setAntennaName(strAntennaName);
|
wxGetApp().setAntennaName(strAntennaName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::invalid_argument e) {
|
catch (const std::invalid_argument &e) {
|
||||||
// nop
|
// nop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dev) {
|
else if (dev) {
|
||||||
wxPGProperty *prop = event.GetProperty();
|
wxPGProperty *prop = event.GetProperty();
|
||||||
//change value of RuntimeProps
|
//change value of RuntimeProps
|
||||||
for (std::map<std::string, wxPGProperty *>::iterator rtp = runtimeProps.begin(); rtp != runtimeProps.end(); rtp++) {
|
for (auto & runtimeProp : runtimeProps) {
|
||||||
if (rtp->second == prop) {
|
if (runtimeProp.second == prop) {
|
||||||
SoapySDR::Device *soapyDev = dev->getSoapyDevice();
|
SoapySDR::Device *soapyDev = dev->getSoapyDevice();
|
||||||
std::string settingValue = prop->GetValueAsString().ToStdString();
|
std::string settingValue = prop->GetValueAsString().ToStdString();
|
||||||
SoapySDR::ArgInfo arg = runtimeArgs[rtp->first];
|
SoapySDR::ArgInfo arg = runtimeArgs[runtimeProp.first];
|
||||||
if (arg.type == SoapySDR::ArgInfo::STRING && arg.options.size()) {
|
if (arg.type == SoapySDR::ArgInfo::STRING && !arg.options.empty()) {
|
||||||
settingValue = getSelectedChoiceOption(prop, arg);
|
settingValue = getSelectedChoiceOption(prop, arg);
|
||||||
} else if (arg.type == SoapySDR::ArgInfo::BOOL) {
|
} else if (arg.type == SoapySDR::ArgInfo::BOOL) {
|
||||||
settingValue = (prop->GetValueAsString()=="True")?"true":"false";
|
settingValue = (prop->GetValueAsString()=="True")?"true":"false";
|
||||||
@ -591,9 +590,9 @@ void SDRDevicesDialog::OnPropGridChanged( wxPropertyGridEvent& event ) {
|
|||||||
settingValue = prop->GetValueAsString();
|
settingValue = prop->GetValueAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
soapyDev->writeSetting(rtp->first, settingValue);
|
soapyDev->writeSetting(runtimeProp.first, settingValue);
|
||||||
if (dev->isActive()) {
|
if (dev->isActive()) {
|
||||||
wxGetApp().getSDRThread()->writeSetting(rtp->first, settingValue);
|
wxGetApp().getSDRThread()->writeSetting(runtimeProp.first, settingValue);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -13,24 +13,24 @@
|
|||||||
|
|
||||||
class SDRDevicesDialog: public devFrame {
|
class SDRDevicesDialog: public devFrame {
|
||||||
public:
|
public:
|
||||||
SDRDevicesDialog( wxWindow* parent, const wxPoint &wxPos = wxDefaultPosition);
|
explicit SDRDevicesDialog( wxWindow* parent, const wxPoint &wxPos = wxDefaultPosition);
|
||||||
|
|
||||||
void OnClose( wxCloseEvent& event );
|
void OnClose( wxCloseEvent& event ) override;
|
||||||
void OnDeleteItem( wxTreeEvent& event );
|
void OnDeleteItem( wxTreeEvent& event ) override;
|
||||||
void OnSelectionChanged( wxTreeEvent& event );
|
void OnSelectionChanged( wxTreeEvent& event ) override;
|
||||||
void OnAddRemote( wxMouseEvent& event );
|
void OnAddRemote( wxMouseEvent& event ) override;
|
||||||
void OnUseSelected( wxMouseEvent& event );
|
void OnUseSelected( wxMouseEvent& event ) override;
|
||||||
void OnTreeDoubleClick( wxMouseEvent& event );
|
void OnTreeDoubleClick( wxMouseEvent& event ) override;
|
||||||
void OnDeviceTimer( wxTimerEvent& event );
|
void OnDeviceTimer( wxTimerEvent& event ) override;
|
||||||
void OnRefreshDevices( wxMouseEvent& event );
|
void OnRefreshDevices( wxMouseEvent& event ) override;
|
||||||
void OnPropGridChanged( wxPropertyGridEvent& event );
|
void OnPropGridChanged( wxPropertyGridEvent& event ) override;
|
||||||
void OnPropGridFocus( wxFocusEvent& event );
|
void OnPropGridFocus( wxFocusEvent& event ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void refreshDeviceProperties();
|
void refreshDeviceProperties();
|
||||||
void doRefreshDevices();
|
void doRefreshDevices();
|
||||||
|
|
||||||
SDRDeviceInfo *getSelectedDevice(wxTreeItemId selId);
|
SDRDeviceInfo *getSelectedDevice(wxTreeItemId selId_in);
|
||||||
wxPGProperty *addArgInfoProperty(wxPropertyGrid *pg, SoapySDR::ArgInfo arg);
|
wxPGProperty *addArgInfoProperty(wxPropertyGrid *pg, SoapySDR::ArgInfo arg);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user