wfview/bandbuttons.cpp

346 wiersze
8.2 KiB
C++
Czysty Zwykły widok Historia

2023-02-09 06:14:55 +00:00
#include "bandbuttons.h"
#include "ui_bandbuttons.h"
bandbuttons::bandbuttons(QWidget *parent) :
QWidget(parent),
ui(new Ui::bandbuttons)
{
ui->setupUi(this);
ui->bandStkLastUsedBtn->setVisible(false);
ui->bandStkVoiceBtn->setVisible(false);
ui->bandStkDataBtn->setVisible(false);
ui->bandStkCWBtn->setVisible(false);
2023-02-12 02:39:02 +00:00
this->setWindowTitle("Band Switcher");
2023-05-27 19:26:53 +00:00
this->setObjectName("bandButtons");
queue = cachingQueue::getInstance(this);
2023-02-09 06:14:55 +00:00
}
bandbuttons::~bandbuttons()
{
delete ui;
}
2023-02-10 21:03:37 +00:00
int bandbuttons::getBSRNumber()
2023-02-09 06:14:55 +00:00
{
2023-02-10 21:03:37 +00:00
return ui->bandStkPopdown->currentIndex()+1;
}
2023-02-09 06:14:55 +00:00
2023-02-10 21:03:37 +00:00
void bandbuttons::acceptRigCaps(rigCapabilities rc)
{
this->rigCaps = rc;
qDebug(logGui()) << "Accepting new rigcaps into band buttons.";
if(haveRigCaps)
qDebug(logGui()) << "Accepting additional rigcaps into band buttons.";
qDebug(logGui()) << "Bands in this rigcaps: ";
for(size_t i=0; i < rigCaps.bands.size(); i++)
{
qDebug(logGui()) << "band[" << i << "]: " << (unsigned char)rigCaps.bands.at(i).band;
}
for(size_t i=0; i < 20; i++)
{
qDebug(logGui()) << "bsr[" << i << "]: " << (unsigned char)rigCaps.bsr[i];
}
setUIToRig();
haveRigCaps = true;
2023-02-09 06:14:55 +00:00
}
2023-02-10 21:03:37 +00:00
void bandbuttons::setUIToRig()
2023-02-09 06:14:55 +00:00
{
2023-02-10 21:03:37 +00:00
// Turn off each button first:
2023-07-22 15:22:19 +00:00
hideButton(ui->band3cmbtn);
hideButton(ui->band6cmbtn);
hideButton(ui->band13cmbtn);
2023-02-10 21:03:37 +00:00
hideButton(ui->band23cmbtn);
hideButton(ui->band70cmbtn);
hideButton(ui->band2mbtn);
hideButton(ui->bandAirbtn);
hideButton(ui->bandWFMbtn);
hideButton(ui->band4mbtn);
hideButton(ui->band6mbtn);
hideButton(ui->band10mbtn);
hideButton(ui->band12mbtn);
hideButton(ui->band15mbtn);
hideButton(ui->band17mbtn);
hideButton(ui->band20mbtn);
hideButton(ui->band30mbtn);
hideButton(ui->band40mbtn);
hideButton(ui->band60mbtn);
hideButton(ui->band80mbtn);
hideButton(ui->band160mbtn);
hideButton(ui->band630mbtn);
hideButton(ui->band2200mbtn);
hideButton(ui->bandGenbtn);
2023-05-27 19:26:53 +00:00
foreach (auto band, rigCaps.bands)
2023-02-10 21:03:37 +00:00
{
2023-05-27 19:26:53 +00:00
switch(band.band)
2023-02-10 21:03:37 +00:00
{
2023-07-22 15:22:19 +00:00
case(band3cm):
showButton(ui->band3cmbtn);
break;
case(band6cm):
showButton(ui->band6cmbtn);
break;
case(band13cm):
showButton(ui->band13cmbtn);
break;
2023-02-10 21:03:37 +00:00
case(band23cm):
showButton(ui->band23cmbtn);
break;
case(band70cm):
showButton(ui->band70cmbtn);
break;
case(band2m):
showButton(ui->band2mbtn);
break;
case(bandAir):
showButton(ui->bandAirbtn);
break;
case(bandWFM):
showButton(ui->bandWFMbtn);
break;
case(band4m):
showButton(ui->band4mbtn);
break;
case(band6m):
showButton(ui->band6mbtn);
break;
case(band10m):
showButton(ui->band10mbtn);
break;
case(band12m):
showButton(ui->band12mbtn);
break;
case(band15m):
showButton(ui->band15mbtn);
break;
case(band17m):
showButton(ui->band17mbtn);
break;
case(band20m):
showButton(ui->band20mbtn);
break;
case(band30m):
showButton(ui->band30mbtn);
break;
case(band40m):
showButton(ui->band40mbtn);
break;
case(band60m):
showButton(ui->band60mbtn);
break;
case(band80m):
showButton(ui->band80mbtn);
break;
case(band160m):
showButton(ui->band160mbtn);
break;
case(band630m):
showButton(ui->band630mbtn);
break;
case(band2200m):
showButton(ui->band2200mbtn);
break;
case(bandGen):
showButton(ui->bandGenbtn);
break;
default:
break;
}
}
}
2023-02-09 06:14:55 +00:00
2023-02-10 21:03:37 +00:00
void bandbuttons::showButton(QPushButton *b)
{
b->setVisible(true);
2023-02-09 06:14:55 +00:00
}
2023-02-10 21:03:37 +00:00
void bandbuttons::hideButton(QPushButton *b)
2023-02-09 06:14:55 +00:00
{
2023-02-10 21:03:37 +00:00
b->setHidden(true);
}
2023-02-09 06:14:55 +00:00
2023-02-10 21:03:37 +00:00
void bandbuttons::receiveBandStackReg(freqt freqGo, char mode, char filter, bool dataOn)
{
// This function is not currently used, but perhaps it should be?
// Issue: wfmain is also waiting for a BSR and acts upon it.
if(waitingForBSR)
{
qDebug(logGui()) << "Received band stack register and was waiting for one.";
emit issueCmdF(cmdSetFreq, freqGo);
emit issueCmd(cmdSetMode, mode);
//emit issueCmd(cmdSetFilter, filter); // TODO
if(dataOn)
emit issueDelayedCommand(cmdSetDataModeOn);
else
emit issueDelayedCommand(cmdSetDataModeOff);
waitingForBSR = false;
} else {
qWarning(logGui()) << "Received a BSR but did not expect one.";
}
(void)filter;
2023-02-09 06:14:55 +00:00
}
2023-02-10 21:03:37 +00:00
void bandbuttons::bandStackBtnClick(availableBands band)
{
if(haveRigCaps)
{
2023-05-27 19:26:53 +00:00
foreach (auto b, rigCaps.bands)
2023-02-10 21:03:37 +00:00
{
2023-05-27 19:26:53 +00:00
if (b.band == band)
{
if(b.bsr == 0)
{
qDebug(logGui()) << "requested to drop to band that does not have a BSR.";
jumpToBandWithoutBSR(band);
} else {
queue->add(priorityImmediate,queueItem(funcBandStackReg,
2023-06-05 08:27:37 +00:00
QVariant::fromValue<bandStackType>(bandStackType(b.bsr,ui->bandStkPopdown->currentIndex()+1)),false,false));
2023-05-27 19:26:53 +00:00
}
break;
}
2023-02-10 21:03:37 +00:00
}
} else {
qWarning(logGui()) << "bandbuttons, Asked to go to a band but do not have rigCaps yet.";
}
}
void bandbuttons::jumpToBandWithoutBSR(availableBands band)
2023-02-09 06:14:55 +00:00
{
2023-02-10 21:03:37 +00:00
// Sometimes we do not have a BSR for these bands:
2023-05-27 19:26:53 +00:00
foreach (auto b, rigCaps.bands)
2023-02-10 21:03:37 +00:00
{
2023-05-27 19:26:53 +00:00
if (b.band == band)
{
freqt f;
f.Hz = (b.lowFreq+b.highFreq)/2.0;
f.MHzDouble = f.Hz/1000000.0;
f.VFO = activeVFO;
2023-06-05 08:27:37 +00:00
queue->add(priorityImmediate,queueItem(funcSelectedFreq,QVariant::fromValue<freqt>(f),false,false));
2023-05-27 19:26:53 +00:00
break;
}
2023-02-10 21:03:37 +00:00
}
}
2023-02-09 06:14:55 +00:00
2023-02-10 21:03:37 +00:00
void bandbuttons::on_band2200mbtn_clicked()
{
bandStackBtnClick(band2200m);
2023-02-09 06:14:55 +00:00
}
2023-02-10 21:03:37 +00:00
void bandbuttons::on_band630mbtn_clicked()
2023-02-09 06:14:55 +00:00
{
2023-02-10 21:03:37 +00:00
bandStackBtnClick(band630m);
}
2023-02-09 06:14:55 +00:00
2023-02-10 21:03:37 +00:00
void bandbuttons::on_band160mbtn_clicked()
{
bandStackBtnClick(band160m);
2023-02-09 06:14:55 +00:00
}
2023-02-10 21:03:37 +00:00
void bandbuttons::on_band80mbtn_clicked()
2023-02-09 06:14:55 +00:00
{
2023-02-10 21:03:37 +00:00
bandStackBtnClick(band80m);
}
2023-02-09 06:14:55 +00:00
2023-02-10 21:03:37 +00:00
void bandbuttons::on_band60mbtn_clicked()
{
bandStackBtnClick(band60m);
2023-02-09 06:14:55 +00:00
}
2023-02-10 21:03:37 +00:00
void bandbuttons::on_band40mbtn_clicked()
2023-02-09 06:14:55 +00:00
{
2023-02-10 21:03:37 +00:00
bandStackBtnClick(band40m);
}
2023-02-09 06:14:55 +00:00
2023-02-10 21:03:37 +00:00
void bandbuttons::on_band30mbtn_clicked()
{
bandStackBtnClick(band30m);
2023-02-09 06:14:55 +00:00
}
void bandbuttons::on_band20mbtn_clicked()
{
2023-02-10 21:03:37 +00:00
bandStackBtnClick(band20m);
2023-02-09 06:14:55 +00:00
}
void bandbuttons::on_band17mbtn_clicked()
{
2023-02-10 21:03:37 +00:00
bandStackBtnClick(band17m);
2023-02-09 06:14:55 +00:00
}
void bandbuttons::on_band15mbtn_clicked()
{
2023-02-10 21:03:37 +00:00
bandStackBtnClick(band15m);
2023-02-09 06:14:55 +00:00
}
void bandbuttons::on_band12mbtn_clicked()
{
2023-02-10 21:03:37 +00:00
bandStackBtnClick(band12m);
2023-02-09 06:14:55 +00:00
}
void bandbuttons::on_band10mbtn_clicked()
{
2023-02-10 21:03:37 +00:00
bandStackBtnClick(band10m);
2023-02-09 06:14:55 +00:00
}
void bandbuttons::on_band6mbtn_clicked()
{
2023-02-10 21:03:37 +00:00
bandStackBtnClick(band6m);
2023-02-09 06:14:55 +00:00
}
void bandbuttons::on_band4mbtn_clicked()
{
2023-02-10 21:03:37 +00:00
bandStackBtnClick(band4m);
2023-02-09 06:14:55 +00:00
}
void bandbuttons::on_band2mbtn_clicked()
{
2023-02-10 21:03:37 +00:00
bandStackBtnClick(band2m);
2023-02-09 06:14:55 +00:00
}
void bandbuttons::on_band70cmbtn_clicked()
{
2023-02-10 21:03:37 +00:00
bandStackBtnClick(band70cm);
2023-02-09 06:14:55 +00:00
}
void bandbuttons::on_band23cmbtn_clicked()
{
2023-02-10 21:03:37 +00:00
bandStackBtnClick(band23cm);
2023-02-09 06:14:55 +00:00
}
2023-07-22 15:22:19 +00:00
void bandbuttons::on_band13cmbtn_clicked()
{
bandStackBtnClick(band13cm);
}
void bandbuttons::on_band6cmbtn_clicked()
{
bandStackBtnClick(band6cm);
}
void bandbuttons::on_band3cmbtn_clicked()
{
bandStackBtnClick(band3cm);
}
2023-02-09 06:14:55 +00:00
void bandbuttons::on_bandWFMbtn_clicked()
{
2023-02-10 21:03:37 +00:00
bandStackBtnClick(bandWFM);
2023-02-09 06:14:55 +00:00
}
void bandbuttons::on_bandAirbtn_clicked()
{
2023-02-10 21:03:37 +00:00
bandStackBtnClick(bandAir);
2023-02-09 06:14:55 +00:00
}
void bandbuttons::on_bandGenbtn_clicked()
{
2023-02-10 21:03:37 +00:00
bandStackBtnClick(bandGen);
2023-02-09 06:14:55 +00:00
}