AppFrrame::OnMenu() tidy, correct wrong ColorTheme name (harmless)

This commit is contained in:
vsonnier 2017-02-26 11:18:09 +01:00
parent 1e14eece65
commit 469fc41805
3 changed files with 293 additions and 152 deletions

View File

@ -998,114 +998,10 @@ bool AppFrame::actionOnMenuDisplay(wxCommandEvent& event) {
return bManaged;
}
void AppFrame::OnMenu(wxCommandEvent& event) {
bool AppFrame::actionOnMenuReset(wxCommandEvent& event) {
// if (event.GetId() >= wxID_RT_AUDIO_DEVICE && event.GetId() < wxID_RT_AUDIO_DEVICE + (int)devices.size()) {
// if (activeDemodulator) {
// activeDemodulator->setOutputDevice(event.GetId() - wxID_RT_AUDIO_DEVICE);
// activeDemodulator = NULL;
// }
// return;
// }
if (event.GetId() == wxID_RESET) {
#ifdef __APPLE__
if (event.GetId() == wxApp::s_macAboutMenuItemId) {
#else
if (event.GetId() == wxID_ABOUT_CUBICSDR) {
#endif
if (aboutDlg != nullptr) {
aboutDlg->Raise();
aboutDlg->SetFocus();
} else {
aboutDlg = new AboutDialog(NULL);
aboutDlg->Connect( wxEVT_CLOSE_WINDOW, wxCommandEventHandler( AppFrame::OnAboutDialogClose ), NULL, this );
aboutDlg->Show();
}
}
if (event.GetId() == wxID_SDR_START_STOP) {
if (!wxGetApp().getSDRThread()->isTerminated()) {
wxGetApp().stopDevice(true, 2000);
} else {
SDRDeviceInfo *dev = wxGetApp().getDevice();
if (dev != nullptr) {
wxGetApp().setDevice(dev, 0);
}
}
} else if (event.GetId() == wxID_LOW_PERF) {
lowPerfMode = lowPerfMenuItem->IsChecked();
wxGetApp().getConfig()->setLowPerfMode(lowPerfMode);
} else if (event.GetId() == wxID_SET_TIPS ) {
if (wxGetApp().getConfig()->getShowTips()) {
wxGetApp().getConfig()->setShowTips(false);
} else {
wxGetApp().getConfig()->setShowTips(true);
}
} else if (event.GetId() == wxID_SET_IQSWAP) {
wxGetApp().getSDRThread()->setIQSwap(!wxGetApp().getSDRThread()->getIQSwap());
} else if (event.GetId() == wxID_SET_FREQ_OFFSET) {
long ofs = wxGetNumberFromUser("Shift the displayed frequency by this amount.\ni.e. -125000000 for -125 MHz", "Frequency (Hz)",
"Frequency Offset", wxGetApp().getOffset(), -2000000000, 2000000000, this);
if (ofs != -1) {
wxGetApp().setOffset(ofs);
}
} else if (event.GetId() == wxID_SET_DB_OFFSET) {
long ofs = wxGetNumberFromUser("Shift the displayed RF power level by this amount.\ni.e. -30 for -30 dB", "Decibels (dB)",
"Power Level Offset", wxGetApp().getConfig()->getDBOffset(), -1000, 1000, this);
if (ofs != -1) {
wxGetApp().getConfig()->setDBOffset(ofs);
}
} else if (event.GetId() == wxID_AGC_CONTROL) {
if (wxGetApp().getDevice() == NULL) {
agcMenuItem->Check(true);
return;
}
if (!wxGetApp().getAGCMode()) {
wxGetApp().setAGCMode(true);
gainSpacerItem->Show(false);
gainSizerItem->Show(false);
demodTray->Layout();
} else {
wxGetApp().setAGCMode(false);
gainSpacerItem->Show(true);
gainSizerItem->Show(true);
gainSizerItem->SetMinSize(wxGetApp().getDevice()->getSoapyDevice()->listGains(SOAPY_SDR_RX, 0).size()*40,0);
demodTray->Layout();
gainCanvas->updateGainUI();
gainCanvas->Refresh();
gainCanvas->Refresh();
}
} else if (event.GetId() == wxID_SDR_DEVICES) {
wxGetApp().deviceSelector();
} else if (event.GetId() == wxID_SET_PPM) {
long ofs = wxGetNumberFromUser("Frequency correction for device in PPM.\ni.e. -51 for -51 PPM\n\nNote: you can adjust PPM interactively\nby holding ALT over the frequency tuning bar.\n", "Parts per million (PPM)",
"Frequency Correction", wxGetApp().getPPM(), -1000, 1000, this);
wxGetApp().setPPM(ofs);
} else if (event.GetId() == wxID_SAVE) {
if (!currentSessionFile.empty()) {
saveSession(currentSessionFile);
} else {
wxFileDialog saveFileDialog(this, _("Save XML Session file"), "", "", "XML files (*.xml)|*.xml", wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
if (saveFileDialog.ShowModal() == wxID_CANCEL) {
return;
}
saveSession(saveFileDialog.GetPath().ToStdString());
}
} else if (event.GetId() == wxID_OPEN) {
wxFileDialog openFileDialog(this, _("Open XML Session file"), "", "", "XML files (*.xml)|*.xml", wxFD_OPEN | wxFD_FILE_MUST_EXIST);
if (openFileDialog.ShowModal() == wxID_CANCEL) {
return;
}
loadSession(openFileDialog.GetPath().ToStdString());
} else if (event.GetId() == wxID_SAVEAS) {
wxFileDialog saveFileDialog(this, _("Save XML Session file"), "", "", "XML files (*.xml)|*.xml", wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
if (saveFileDialog.ShowModal() == wxID_CANCEL) {
return;
}
saveSession(saveFileDialog.GetPath().ToStdString());
} else if (event.GetId() == wxID_RESET) {
wxGetApp().getDemodMgr().terminateAll();
wxGetApp().setFrequency(100000000);
wxGetApp().getDemodMgr().setLastDemodulatorType("FM");
@ -1132,16 +1028,43 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
//force all windows refresh
Refresh();
} else if (event.GetId() == wxID_CLOSE || event.GetId() == wxID_EXIT) {
Close(false);
return true;
}
else if (actionOnMenuDisplay(event)) {
//done in actionOnMenuDisplay
return;
return false;
}
else if (event.GetId() >= wxID_SETTINGS_BASE && event.GetId() < settingsIdMax) {
bool AppFrame::actionOnMenuAbout(wxCommandEvent& event) {
#ifdef __APPLE__
if (event.GetId() == wxApp::s_macAboutMenuItemId) {
#else
if (event.GetId() == wxID_ABOUT_CUBICSDR) {
#endif
if (aboutDlg != nullptr) {
aboutDlg->Raise();
aboutDlg->SetFocus();
}
else {
aboutDlg = new AboutDialog(NULL);
aboutDlg->Connect(wxEVT_CLOSE_WINDOW, wxCommandEventHandler(AppFrame::OnAboutDialogClose), NULL, this);
aboutDlg->Show();
}
return true;
}
return false;
}
bool AppFrame::actionOnMenuSettings(wxCommandEvent& event) {
if (event.GetId() >= wxID_SETTINGS_BASE && event.GetId() < settingsIdMax) {
int setIdx = event.GetId() - wxID_SETTINGS_BASE;
int menuIdx = 0;
for (std::vector<SoapySDR::ArgInfo>::iterator arg_i = settingArgs.begin(); arg_i != settingArgs.end(); arg_i++) {
SoapySDR::ArgInfo &arg = (*arg_i);
@ -1149,23 +1072,28 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
int optIdx = setIdx - menuIdx;
wxGetApp().getSDRThread()->writeSetting(arg.key, arg.options[optIdx]);
break;
} else if (arg.type == SoapySDR::ArgInfo::STRING && arg.options.size()) {
}
else if (arg.type == SoapySDR::ArgInfo::STRING && arg.options.size()) {
menuIdx += arg.options.size();
} else if (menuIdx == setIdx) {
}
else if (menuIdx == setIdx) {
if (arg.type == SoapySDR::ArgInfo::BOOL) {
wxGetApp().getSDRThread()->writeSetting(arg.key, (wxGetApp().getSDRThread()->readSetting(arg.key) == "true") ? "false" : "true");
break;
} else if (arg.type == SoapySDR::ArgInfo::STRING) {
}
else if (arg.type == SoapySDR::ArgInfo::STRING) {
wxString stringVal = wxGetTextFromUser(arg.description, arg.name, wxGetApp().getSDRThread()->readSetting(arg.key));
if (stringVal.ToStdString() != "") {
wxGetApp().getSDRThread()->writeSetting(arg.key, stringVal.ToStdString());
}
break;
} else if (arg.type == SoapySDR::ArgInfo::INT) {
}
else if (arg.type == SoapySDR::ArgInfo::INT) {
int currentVal;
try {
currentVal = std::stoi(wxGetApp().getSDRThread()->readSetting(arg.key));
} catch (std::invalid_argument e) {
}
catch (std::invalid_argument e) {
currentVal = 0;
}
int intVal = wxGetNumberFromUser(arg.description, arg.units, arg.name, currentVal, arg.range.minimum(), arg.range.maximum(), this);
@ -1173,27 +1101,69 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
wxGetApp().getSDRThread()->writeSetting(arg.key, std::to_string(intVal));
}
break;
} else if (arg.type == SoapySDR::ArgInfo::FLOAT) {
}
else if (arg.type == SoapySDR::ArgInfo::FLOAT) {
wxString floatVal = wxGetTextFromUser(arg.description, arg.name, wxGetApp().getSDRThread()->readSetting(arg.key));
try {
wxGetApp().getSDRThread()->writeSetting(arg.key, floatVal.ToStdString());
} catch (std::invalid_argument e) {
}
catch (std::invalid_argument e) {
// ...
}
break;
} else {
menuIdx++;
}
} else {
else {
menuIdx++;
}
}
else {
menuIdx++;
}
} //end for
return true;
}
return false;
}
bool AppFrame::actionOnMenuAGC(wxCommandEvent& event) {
if (event.GetId() == wxID_AGC_CONTROL) {
if (wxGetApp().getDevice() == NULL) {
agcMenuItem->Check(true);
return true;
}
if (!wxGetApp().getAGCMode()) {
wxGetApp().setAGCMode(true);
gainSpacerItem->Show(false);
gainSizerItem->Show(false);
demodTray->Layout();
}
else {
wxGetApp().setAGCMode(false);
gainSpacerItem->Show(true);
gainSizerItem->Show(true);
gainSizerItem->SetMinSize(wxGetApp().getDevice()->getSoapyDevice()->listGains(SOAPY_SDR_RX, 0).size() * 40, 0);
demodTray->Layout();
gainCanvas->updateGainUI();
}
//full Refresh, some graphical elements has changed
Refresh();
return true;
}
return false;
}
bool AppFrame::actionOnMenuSampleRate(wxCommandEvent& event) {
if (event.GetId() == wxID_BANDWIDTH_MANUAL) {
wxGetApp().setSampleRate(manualSampleRate);
return true;
}
else if (event.GetId() == wxID_BANDWIDTH_MANUAL_DIALOG) {
@ -1234,13 +1204,22 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
wxGetApp().setSampleRate(manualSampleRate);
}
}
return true;
}
else if (event.GetId() >= wxID_BANDWIDTH_BASE && event.GetId() < wxID_BANDWIDTH_BASE + (int)sampleRates.size()) {
wxGetApp().setSampleRate(sampleRates[event.GetId() - wxID_BANDWIDTH_BASE]);
return true;
}
return false;
}
bool AppFrame::actionOnMenuAudioSampleRate(wxCommandEvent& event) {
if (event.GetId() >= wxID_AUDIO_BANDWIDTH_BASE) {
int evId = event.GetId();
std::vector<RtAudio::DeviceInfo>::iterator devices_i;
std::map<int, RtAudio::DeviceInfo>::iterator mdevices_i;
@ -1263,8 +1242,56 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
}
i++;
}
return true;
}
return false;
}
bool AppFrame::actionOnMenuLoadSave(wxCommandEvent& event) {
if (event.GetId() == wxID_SAVE) {
if (!currentSessionFile.empty()) {
saveSession(currentSessionFile);
}
else {
wxFileDialog saveFileDialog(this, _("Save XML Session file"), "", "", "XML files (*.xml)|*.xml", wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
if (saveFileDialog.ShowModal() == wxID_CANCEL) {
return true;
}
saveSession(saveFileDialog.GetPath().ToStdString());
}
return true;
}
else if (event.GetId() == wxID_OPEN) {
wxFileDialog openFileDialog(this, _("Open XML Session file"), "", "", "XML files (*.xml)|*.xml", wxFD_OPEN | wxFD_FILE_MUST_EXIST);
if (openFileDialog.ShowModal() == wxID_CANCEL) {
return true;
}
loadSession(openFileDialog.GetPath().ToStdString());
return true;
}
else if (event.GetId() == wxID_SAVEAS) {
wxFileDialog saveFileDialog(this, _("Save XML Session file"), "", "", "XML files (*.xml)|*.xml", wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
if (saveFileDialog.ShowModal() == wxID_CANCEL) {
return true;
}
saveSession(saveFileDialog.GetPath().ToStdString());
return true;
}
return false;
}
bool AppFrame::actionOnMenuRig(wxCommandEvent& event) {
bool bManaged = false;
#ifdef USE_HAMLIB
bool resetRig = false;
@ -1278,19 +1305,24 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
rigSDRIF = devConfig->getRigIF(rigModel);
if (rigSDRIF) {
wxGetApp().lockFrequency(rigSDRIF);
} else {
}
else {
wxGetApp().unlockFrequency();
}
} else {
}
else {
wxGetApp().unlockFrequency();
}
resetRig = true;
bManaged = true;
}
if (event.GetId() >= wxID_RIG_SERIAL_BASE && event.GetId() < wxID_RIG_SERIAL_BASE + rigSerialRates.size()) {
int serialIdx = event.GetId() - wxID_RIG_SERIAL_BASE;
rigSerialRate = rigSerialRates[serialIdx];
resetRig = true;
bManaged = true;
}
if (event.GetId() == wxID_RIG_PORT) {
@ -1300,15 +1332,19 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
rigPort = rigPortStr;
resetRig = true;
}
bManaged = true;
}
if (event.GetId() == wxID_RIG_TOGGLE) {
resetRig = false;
if (!wxGetApp().rigIsActive()) {
enableRig();
} else {
}
else {
disableRig();
}
bManaged = true;
}
if (event.GetId() == wxID_RIG_SDR_IF) {
@ -1322,10 +1358,12 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
}
if (rigSDRIF && wxGetApp().rigIsActive()) {
wxGetApp().lockFrequency(rigSDRIF);
} else {
}
else {
wxGetApp().unlockFrequency();
}
}
bManaged = true;
}
if (event.GetId() == wxID_RIG_CONTROL) {
@ -1334,9 +1372,11 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
rt->setControlMode(!rt->getControlMode());
rigControlMenuItem->Check(rt->getControlMode());
wxGetApp().getConfig()->setRigControlMode(rt->getControlMode());
} else {
}
else {
wxGetApp().getConfig()->setRigControlMode(rigControlMenuItem->IsChecked());
}
bManaged = true;
}
if (event.GetId() == wxID_RIG_FOLLOW) {
@ -1345,9 +1385,12 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
rt->setFollowMode(!rt->getFollowMode());
rigFollowMenuItem->Check(rt->getFollowMode());
wxGetApp().getConfig()->setRigFollowMode(rt->getFollowMode());
} else {
}
else {
wxGetApp().getConfig()->setRigFollowMode(rigFollowMenuItem->IsChecked());
}
bManaged = true;
}
if (event.GetId() == wxID_RIG_CENTERLOCK) {
@ -1356,9 +1399,12 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
rt->setCenterLock(!rt->getCenterLock());
rigCenterLockMenuItem->Check(rt->getCenterLock());
wxGetApp().getConfig()->setRigCenterLock(rt->getCenterLock());
} else {
}
else {
wxGetApp().getConfig()->setRigCenterLock(rigCenterLockMenuItem->IsChecked());
}
bManaged = true;
}
if (event.GetId() == wxID_RIG_FOLLOW_MODEM) {
@ -1367,9 +1413,12 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
rt->setFollowModem(!rt->getFollowModem());
rigFollowModemMenuItem->Check(rt->getFollowModem());
wxGetApp().getConfig()->setRigFollowModem(rt->getFollowModem());
} else {
}
else {
wxGetApp().getConfig()->setRigFollowModem(rigFollowModemMenuItem->IsChecked());
}
bManaged = true;
}
if (wxGetApp().rigIsActive() && resetRig) {
@ -1378,6 +1427,90 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
}
#endif
return bManaged;
}
void AppFrame::OnMenu(wxCommandEvent& event) {
if (actionOnMenuAbout(event)) {
return;
}
else if (event.GetId() == wxID_SDR_START_STOP) {
if (!wxGetApp().getSDRThread()->isTerminated()) {
wxGetApp().stopDevice(true, 2000);
} else {
SDRDeviceInfo *dev = wxGetApp().getDevice();
if (dev != nullptr) {
wxGetApp().setDevice(dev, 0);
}
}
}
else if (event.GetId() == wxID_LOW_PERF) {
lowPerfMode = lowPerfMenuItem->IsChecked();
wxGetApp().getConfig()->setLowPerfMode(lowPerfMode);
}
else if (event.GetId() == wxID_SET_TIPS ) {
if (wxGetApp().getConfig()->getShowTips()) {
wxGetApp().getConfig()->setShowTips(false);
} else {
wxGetApp().getConfig()->setShowTips(true);
}
}
else if (event.GetId() == wxID_SET_IQSWAP) {
wxGetApp().getSDRThread()->setIQSwap(!wxGetApp().getSDRThread()->getIQSwap());
}
else if (event.GetId() == wxID_SET_FREQ_OFFSET) {
long ofs = wxGetNumberFromUser("Shift the displayed frequency by this amount.\ni.e. -125000000 for -125 MHz", "Frequency (Hz)",
"Frequency Offset", wxGetApp().getOffset(), -2000000000, 2000000000, this);
if (ofs != -1) {
wxGetApp().setOffset(ofs);
}
}
else if (event.GetId() == wxID_SET_DB_OFFSET) {
long ofs = wxGetNumberFromUser("Shift the displayed RF power level by this amount.\ni.e. -30 for -30 dB", "Decibels (dB)",
"Power Level Offset", wxGetApp().getConfig()->getDBOffset(), -1000, 1000, this);
if (ofs != -1) {
wxGetApp().getConfig()->setDBOffset(ofs);
}
}
else if (actionOnMenuAGC(event)) {
return;
}
else if (event.GetId() == wxID_SDR_DEVICES) {
wxGetApp().deviceSelector();
}
else if (event.GetId() == wxID_SET_PPM) {
long ofs = wxGetNumberFromUser("Frequency correction for device in PPM.\ni.e. -51 for -51 PPM\n\nNote: you can adjust PPM interactively\nby holding ALT over the frequency tuning bar.\n", "Parts per million (PPM)",
"Frequency Correction", wxGetApp().getPPM(), -1000, 1000, this);
wxGetApp().setPPM(ofs);
}
else if (actionOnMenuLoadSave(event)) {
return;
}
else if (actionOnMenuReset(event)) {
return;
}
else if (event.GetId() == wxID_CLOSE || event.GetId() == wxID_EXIT) {
Close(false);
}
else if (actionOnMenuSettings(event)) {
return;
}
else if (actionOnMenuSampleRate(event)) {
return;
}
else if (actionOnMenuAudioSampleRate(event)) {
return;
}
else if (actionOnMenuDisplay(event)) {
return;
}
//Optional : Rig
else if (actionOnMenuRig(event)) {
return;
}
}
void AppFrame::OnClose(wxCloseEvent& event) {

View File

@ -139,9 +139,17 @@ private:
void OnUnSplit(wxSplitterEvent& event);
void OnAboutDialogClose(wxCommandEvent& event);
//manage Display menu actions, return true if the event has been
//actionXXXX manage menu actions, return true if the event has been
//treated.
bool actionOnMenuAbout(wxCommandEvent& event);
bool actionOnMenuReset(wxCommandEvent& event);
bool actionOnMenuSettings(wxCommandEvent& event);
bool actionOnMenuAGC(wxCommandEvent& event);
bool actionOnMenuSampleRate(wxCommandEvent& event);
bool actionOnMenuAudioSampleRate(wxCommandEvent& event);
bool actionOnMenuDisplay(wxCommandEvent& event);
bool actionOnMenuLoadSave(wxCommandEvent& event);
bool actionOnMenuRig(wxCommandEvent& event);
ScopeCanvas *scopeCanvas;
SpectrumCanvas *spectrumCanvas;

View File

@ -69,7 +69,7 @@ DefaultColorTheme::DefaultColorTheme() {
RadarColorTheme::RadarColorTheme() {
name = "Rad";
name = "Radar";
waterfallGradient.addColor(GradientColor(5.0f / 255.0f, 45.0f / 255.0f, 10.0f / 255.0f));
waterfallGradient.addColor(GradientColor(30.0f / 255.0f, 150.0f / 255.0f, 40.0f / 255.0f));
waterfallGradient.addColor(GradientColor(40.0f / 255.0f, 240.0f / 255.0f, 60.0f / 255.0f));