mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-22 11:49:38 -05:00
Merge pull request #728 from cjcliffe/rigmenu_serial
Fix port selector dialog; simplify rig model selection with manufacturer sub-menus
This commit is contained in:
commit
19b922a863
@ -483,7 +483,7 @@ ModeSelectorCanvas *AppFrame::makeModemAdvSelectorPanel(wxPanel *parent, const w
|
||||
|
||||
#ifdef USE_HAMLIB
|
||||
wxMenu *AppFrame::makeRigMenu() {
|
||||
wxMenu *pMenu = new wxMenu;
|
||||
auto *pMenu = new wxMenu;
|
||||
|
||||
rigEnableMenuItem = pMenu->AppendCheckItem(wxID_RIG_TOGGLE, wxT("Enable Rig"));
|
||||
|
||||
@ -501,20 +501,37 @@ wxMenu *AppFrame::makeRigMenu() {
|
||||
rigFollowModemMenuItem = pMenu->AppendCheckItem(wxID_RIG_FOLLOW_MODEM, wxT("Track Modem"));
|
||||
rigFollowModemMenuItem->Check(wxGetApp().getConfig()->getRigFollowModem());
|
||||
|
||||
wxMenu *rigModelMenu = new wxMenu;
|
||||
auto *rigModelMenu = new wxMenu;
|
||||
RigList &rl = RigThread::enumerate();
|
||||
numRigs = rl.size();
|
||||
|
||||
std::map<string, int> mfgCount;
|
||||
std::map<string, wxMenu *> mfgMenu;
|
||||
for (auto ri : rl) {
|
||||
mfgCount[ri->mfg_name]++;
|
||||
}
|
||||
|
||||
int modelMenuId = wxID_RIG_MODEL_BASE;
|
||||
for (auto ri = rl.begin(); ri != rl.end(); ri++) {
|
||||
string modelString((*ri)->mfg_name);
|
||||
|
||||
for (auto ri : rl) {
|
||||
string modelString(ri->mfg_name);
|
||||
modelString.append(" ");
|
||||
modelString.append((*ri)->model_name);
|
||||
modelString.append(ri->model_name);
|
||||
|
||||
rigModelMenuItems[(*ri)->rig_model] = rigModelMenu->AppendRadioItem(modelMenuId, modelString, wxT("Description?"));
|
||||
wxMenu *parentMenu = nullptr;
|
||||
|
||||
if (rigModel == (*ri)->rig_model) {
|
||||
rigModelMenuItems[(*ri)->rig_model]->Check(true);
|
||||
if (mfgCount[ri->mfg_name] > 1) {
|
||||
if (mfgMenu.find(ri->mfg_name) == mfgMenu.end()) {
|
||||
rigModelMenu->AppendSubMenu(mfgMenu[ri->mfg_name] = new wxMenu(), ri->mfg_name);
|
||||
}
|
||||
parentMenu = mfgMenu[ri->mfg_name];
|
||||
} else {
|
||||
parentMenu = rigModelMenu;
|
||||
}
|
||||
|
||||
rigModelMenuItems[ri->rig_model] = parentMenu->AppendCheckItem(modelMenuId, modelString, ri->copyright);
|
||||
|
||||
if (rigModel == ri->rig_model) {
|
||||
rigModelMenuItems[ri->rig_model]->Check(true);
|
||||
}
|
||||
|
||||
modelMenuId++;
|
||||
@ -522,7 +539,7 @@ wxMenu *AppFrame::makeRigMenu() {
|
||||
|
||||
pMenu->AppendSubMenu(rigModelMenu, wxT("Model"));
|
||||
|
||||
wxMenu *rigSerialMenu = new wxMenu;
|
||||
auto *rigSerialMenu = new wxMenu;
|
||||
|
||||
rigSerialRates.push_back(1200);
|
||||
rigSerialRates.push_back(2400);
|
||||
@ -536,15 +553,15 @@ wxMenu *AppFrame::makeRigMenu() {
|
||||
rigSerialRates.push_back(256000);
|
||||
|
||||
int rateMenuId = wxID_RIG_SERIAL_BASE;
|
||||
for (auto rate_i = rigSerialRates.begin(); rate_i != rigSerialRates.end(); rate_i++) {
|
||||
for (auto rate_i : rigSerialRates) {
|
||||
string rateString;
|
||||
rateString.append(std::to_string((*rate_i)));
|
||||
rateString.append(std::to_string(rate_i));
|
||||
rateString.append(" baud");
|
||||
|
||||
rigSerialMenuItems[(*rate_i)] = rigSerialMenu->AppendRadioItem(rateMenuId, rateString, wxT("Description?"));
|
||||
rigSerialMenuItems[rate_i] = rigSerialMenu->AppendRadioItem(rateMenuId, rateString, wxT("Description?"));
|
||||
|
||||
if (rigSerialRate == (*rate_i)) {
|
||||
rigSerialMenuItems[(*rate_i)]->Check(true);
|
||||
if (rigSerialRate == rate_i) {
|
||||
rigSerialMenuItems[rate_i]->Check(true);
|
||||
}
|
||||
|
||||
rateMenuId++;
|
||||
@ -1822,12 +1839,16 @@ bool AppFrame::actionOnMenuRig(wxCommandEvent &event) {
|
||||
|
||||
bool resetRig = false;
|
||||
if (event.GetId() >= wxID_RIG_MODEL_BASE && event.GetId() < wxID_RIG_MODEL_BASE + numRigs) {
|
||||
|
||||
int rigIdx = event.GetId() - wxID_RIG_MODEL_BASE;
|
||||
|
||||
RigList &rl = RigThread::enumerate();
|
||||
rigModel = rl[rigIdx]->rig_model;
|
||||
|
||||
if (devInfo != nullptr) {
|
||||
std::string deviceId = devInfo->getDeviceId();
|
||||
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(deviceId);
|
||||
|
||||
rigSDRIF = devConfig->getRigIF(rigModel);
|
||||
if (rigSDRIF) {
|
||||
wxGetApp().lockFrequency(rigSDRIF);
|
||||
@ -1837,9 +1858,15 @@ bool AppFrame::actionOnMenuRig(wxCommandEvent &event) {
|
||||
} else {
|
||||
wxGetApp().unlockFrequency();
|
||||
}
|
||||
resetRig = true;
|
||||
|
||||
resetRig = true;
|
||||
bManaged = true;
|
||||
|
||||
for (auto ri : rigModelMenuItems) {
|
||||
ri.second->Check(false);
|
||||
}
|
||||
|
||||
rigModelMenuItems[rigModel]->Check(true);
|
||||
}
|
||||
|
||||
int rigSerialIdMax = wxID_RIG_SERIAL_BASE + rigSerialRates.size();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Aug 8 2018)
|
||||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
@ -11,57 +11,53 @@
|
||||
|
||||
PortSelectorDialogBase::PortSelectorDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
|
||||
{
|
||||
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
||||
|
||||
this->SetSizeHints( wxSize( 300,200 ), wxDefaultSize );
|
||||
|
||||
wxBoxSizer* dlgSizer;
|
||||
dlgSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
|
||||
m_staticText1 = new wxStaticText( this, wxID_ANY, wxT("Select a detected port or enter your own"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText1->Wrap( -1 );
|
||||
dlgSizer->Add( m_staticText1, 0, wxEXPAND|wxALL, 5 );
|
||||
|
||||
m_portList = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
|
||||
dlgSizer->Add( m_staticText1, 0, wxALIGN_CENTER|wxTOP, 5 );
|
||||
|
||||
m_portList = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
|
||||
dlgSizer->Add( m_portList, 1, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
wxBoxSizer* bSizer3;
|
||||
bSizer3 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
bSizer3->SetMinSize( wxSize( -1,30 ) );
|
||||
|
||||
bSizer3->SetMinSize( wxSize( -1,30 ) );
|
||||
m_staticText2 = new wxStaticText( this, wxID_ANY, wxT("Port"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText2->Wrap( -1 );
|
||||
bSizer3->Add( m_staticText2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
bSizer3->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
m_portSelection = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer3->Add( m_portSelection, 1, wxEXPAND|wxRIGHT, 5 );
|
||||
|
||||
|
||||
dlgSizer->Add( bSizer3, 1, wxEXPAND, 5 );
|
||||
|
||||
m_buttonPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
bSizer3->Add( m_portSelection, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
|
||||
dlgSizer->Add( bSizer3, 0, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bSizer2;
|
||||
bSizer2 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_cancelButton = new wxButton( m_buttonPanel, wxID_ANY, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
|
||||
m_cancelButton = new wxButton( this, wxID_ANY, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer2->Add( m_cancelButton, 0, wxALL|wxALIGN_BOTTOM, 5 );
|
||||
|
||||
|
||||
|
||||
|
||||
bSizer2->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||
|
||||
m_okButton = new wxButton( m_buttonPanel, wxID_ANY, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
|
||||
m_okButton = new wxButton( this, wxID_ANY, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer2->Add( m_okButton, 0, wxALL|wxALIGN_BOTTOM, 5 );
|
||||
|
||||
|
||||
m_buttonPanel->SetSizer( bSizer2 );
|
||||
m_buttonPanel->Layout();
|
||||
bSizer2->Fit( m_buttonPanel );
|
||||
dlgSizer->Add( m_buttonPanel, 0, wxEXPAND | wxALL, 5 );
|
||||
|
||||
|
||||
|
||||
|
||||
dlgSizer->Add( bSizer2, 0, wxEXPAND, 5 );
|
||||
|
||||
|
||||
this->SetSizer( dlgSizer );
|
||||
this->Layout();
|
||||
|
||||
|
||||
this->Centre( wxBOTH );
|
||||
|
||||
|
||||
// Connect Events
|
||||
m_portList->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( PortSelectorDialogBase::onListSelect ), NULL, this );
|
||||
m_cancelButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PortSelectorDialogBase::onCancelButton ), NULL, this );
|
||||
@ -74,5 +70,5 @@ PortSelectorDialogBase::~PortSelectorDialogBase()
|
||||
m_portList->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( PortSelectorDialogBase::onListSelect ), NULL, this );
|
||||
m_cancelButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PortSelectorDialogBase::onCancelButton ), NULL, this );
|
||||
m_okButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PortSelectorDialogBase::onOKButton ), NULL, this );
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Aug 8 2018)
|
||||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __PORTSELECTORDIALOGBASE_H__
|
||||
#define __PORTSELECTORDIALOGBASE_H__
|
||||
#pragma once
|
||||
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
@ -23,7 +22,6 @@
|
||||
#include <wx/image.h>
|
||||
#include <wx/icon.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/dialog.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -32,30 +30,28 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class PortSelectorDialogBase
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class PortSelectorDialogBase : public wxDialog
|
||||
class PortSelectorDialogBase : public wxDialog
|
||||
{
|
||||
private:
|
||||
|
||||
|
||||
protected:
|
||||
wxStaticText* m_staticText1;
|
||||
wxListBox* m_portList;
|
||||
wxStaticText* m_staticText2;
|
||||
wxTextCtrl* m_portSelection;
|
||||
wxPanel* m_buttonPanel;
|
||||
wxButton* m_cancelButton;
|
||||
wxButton* m_okButton;
|
||||
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void onListSelect( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onCancelButton( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onOKButton( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
PortSelectorDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Select Port"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 304,197 ), long style = wxDEFAULT_DIALOG_STYLE );
|
||||
|
||||
PortSelectorDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Select Port"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 320,260 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
~PortSelectorDialogBase();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //__PORTSELECTORDIALOGBASE_H__
|
||||
|
Loading…
Reference in New Issue
Block a user