📄 fdrmdialog.cpp
字号:
/******************************************************************************\
* Technische Universitaet Darmstadt, Institut fuer Nachrichtentechnik
* Copyright (c) 2001
*
* Author(s):
* Volker Fischer
*
* Description:
*
*
******************************************************************************
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
\******************************************************************************/
#include "fdrmdialog.h"
/* Implementation *************************************************************/
FDRMDialog::FDRMDialog(CDRMReceiver* pNDRMR, QWidget* parent, const char* name,
bool modal, WFlags f) : pDRMRec(pNDRMR),
FDRMDialogBase(parent, name, modal, f)
{
/* Set help text for the controls */
AddWhatsThisHelp();
#ifdef _WIN32 /* This works only reliable under Windows :-( */
/* Get window geometry data from DRMReceiver module and apply it */
const QRect WinGeom(pDRMRec->GeomFdrmdialog.iXPos,
pDRMRec->GeomFdrmdialog.iYPos,
pDRMRec->GeomFdrmdialog.iWSize,
pDRMRec->GeomFdrmdialog.iHSize);
if (WinGeom.isValid() && !WinGeom.isEmpty() && !WinGeom.isNull())
setGeometry(WinGeom);
#else /* Under Linux only restore the size */
resize(pDRMRec->GeomFdrmdialog.iWSize,
pDRMRec->GeomFdrmdialog.iHSize);
#endif
/* Set Menu ***************************************************************/
/* View menu ------------------------------------------------------------ */
QPopupMenu* EvalWinMenu = new QPopupMenu(this);
CHECK_PTR(EvalWinMenu);
EvalWinMenu->insertItem(tr("&Evaluation Dialog..."), this,
SLOT(OnViewEvalDlg()), CTRL+Key_E);
EvalWinMenu->insertItem(tr("M&ultimedia Dialog..."), this,
SLOT(OnViewMultiMediaDlg()), CTRL+Key_U);
EvalWinMenu->insertItem(tr("S&tations Dialog..."), this,
SLOT(OnViewStationsDlg()), CTRL+Key_T);
EvalWinMenu->insertSeparator();
EvalWinMenu->insertItem(tr("E&xit"), this, SLOT(close()), CTRL+Key_Q);
/* Settings menu ------------------------------------------------------- */
pSettingsMenu = new QPopupMenu(this);
CHECK_PTR(pSettingsMenu);
pSettingsMenu->insertItem(tr("&Sound Card Selection"),
new CSoundCardSelMenu(pDRMRec->GetSoundInterface(), this));
pSettingsMenu->insertItem(tr("&AM (analog)"), this,
SLOT(OnSwitchToAM()), CTRL+Key_A);
pSettingsMenu->insertItem(tr("New &DRM Acquisition"), this,
SLOT(OnSwitchToDRM()), CTRL+Key_D);
/* Main menu bar -------------------------------------------------------- */
pMenu = new QMenuBar(this);
CHECK_PTR(pMenu);
pMenu->insertItem(tr("&View"), EvalWinMenu);
pMenu->insertItem(tr("&Settings"), pSettingsMenu);
pMenu->insertItem(tr("&?"), new CDreamHelpMenu(this));
pMenu->setSeparator(QMenuBar::InWindowsStyle);
/* Now tell the layout about the menu */
FDRMDialogBaseLayout->setMenuBar(pMenu);
/* Digi controls */
/* Reset text */
TextServiceIDRate->setText("");
TextServiceLabel->setText("");
TextServiceAudio->setText("");
/* Init progress bar for input signal level */
ProgrInputLevel->setRange(-50.0, 0.0);
ProgrInputLevel->setOrientation(QwtThermo::Vertical, QwtThermo::Left);
ProgrInputLevel->setFillColor(QColor(0, 190, 0));
ProgrInputLevel->setAlarmLevel(-12.5);
ProgrInputLevel->setAlarmColor(QColor(255, 0, 0));
/* Stations window */
pStationsDlg = new StationsDlg(pDRMRec, this, tr("Stations"), FALSE,
Qt::WStyle_MinMax);
if (pDRMRec->GeomStationsDlg.bVisible == TRUE)
pStationsDlg->show();
else
pStationsDlg->hide();
/* Evaluation window */
pSysEvalDlg = new systemevalDlg(pDRMRec, this, tr("System Evaluation"),
FALSE, Qt::WStyle_MinMax);
if (pDRMRec->GeomSystemEvalDlg.bVisible == TRUE)
{
pSysEvalDlg->show();
bSysEvalDlgWasVis = TRUE;
}
else
{
pSysEvalDlg->hide();
bSysEvalDlgWasVis = FALSE;
}
/* Multimedia window */
pMultiMediaDlg = new MultimediaDlg(pDRMRec, this, tr("Multimedia"), FALSE,
Qt::WStyle_MinMax);
if (pDRMRec->GeomMultimediaDlg.bVisible == TRUE)
{
pMultiMediaDlg->show();
bMultMedDlgWasVis = TRUE;
}
else
{
pMultiMediaDlg->hide();
bMultMedDlgWasVis = FALSE;
}
/* Analog demodulation window */
pAnalogDemDlg = new AnalogDemDlg(pDRMRec, NULL, tr("Analog Demodulation"),
FALSE, Qt::WStyle_MinMax);
if (pDRMRec->GeomAnalogDemDlg.bVisible == TRUE)
SetReceiverMode(CDRMReceiver::RM_AM);
else
SetReceiverMode(CDRMReceiver::RM_DRM);
/* Enable multimedia */
pDRMRec->GetParameters()->EnableMultimedia(TRUE);
/* Init current selected service */
pDRMRec->GetParameters()->ResetCurSelAudDatServ();
iCurSelServiceGUI = 0;
iOldNoServicesGUI = 0;
PushButtonService1->setOn(TRUE);
PushButtonService1->setEnabled(FALSE);
PushButtonService2->setEnabled(FALSE);
PushButtonService3->setEnabled(FALSE);
PushButtonService4->setEnabled(FALSE);
/* Update times for color LEDs */
CLED_FAC->SetUpdateTime(1500);
CLED_SDC->SetUpdateTime(1500);
CLED_MSC->SetUpdateTime(600);
/* Connect buttons */
connect(PushButtonService1, SIGNAL(clicked()),
this, SLOT(OnButtonService1()));
connect(PushButtonService2, SIGNAL(clicked()),
this, SLOT(OnButtonService2()));
connect(PushButtonService3, SIGNAL(clicked()),
this, SLOT(OnButtonService3()));
connect(PushButtonService4, SIGNAL(clicked()),
this, SLOT(OnButtonService4()));
connect(pAnalogDemDlg, SIGNAL(SwitchToDRM()),
this, SLOT(OnSwitchToDRM()));
connect(pAnalogDemDlg, SIGNAL(ViewStationsDlg()),
this, SLOT(OnViewStationsDlg()));
connect(pAnalogDemDlg, SIGNAL(Closed()),
this, SLOT(close()));
connect(&Timer, SIGNAL(timeout()),
this, SLOT(OnTimer()));
/* Disable text message label */
TextTextMessage->setText("");
TextTextMessage->hide();
/* Set timer for real-time controls */
Timer.start(GUI_CONTROL_UPDATE_TIME);
/* Update window */
OnTimer();
}
FDRMDialog::~FDRMDialog()
{
/* Set window geometry data in DRMReceiver module */
QRect WinGeom = geometry();
pDRMRec->GeomFdrmdialog.iXPos = WinGeom.x();
pDRMRec->GeomFdrmdialog.iYPos = WinGeom.y();
pDRMRec->GeomFdrmdialog.iHSize = WinGeom.height();
pDRMRec->GeomFdrmdialog.iWSize = WinGeom.width();
/* Set "visible" flags for settings */
pDRMRec->GeomAnalogDemDlg.bVisible = pAnalogDemDlg->isVisible();
pDRMRec->GeomStationsDlg.bVisible = pStationsDlg->isVisible();
/* Special treatment for multimedia and systen evaluation dialog since these
windows are not used for AM demodulation */
if (pDRMRec->GetReceiverMode() == CDRMReceiver::RM_AM)
{
pDRMRec->GeomSystemEvalDlg.bVisible = bSysEvalDlgWasVis;
pDRMRec->GeomMultimediaDlg.bVisible = bMultMedDlgWasVis;
}
else
{
pDRMRec->GeomSystemEvalDlg.bVisible = pSysEvalDlg->isVisible();
pDRMRec->GeomMultimediaDlg.bVisible = pMultiMediaDlg->isVisible();
}
}
void FDRMDialog::OnTimer()
{
/* Input level meter */
ProgrInputLevel->setValue(pDRMRec->GetReceiver()->GetLevelMeter());
/* Check if receiver does receive a DRM signal */
if ((pDRMRec->GetReceiverState() == CDRMReceiver::AS_WITH_SIGNAL) &&
(pDRMRec->GetReceiverMode() == CDRMReceiver::RM_DRM))
{
/* Receiver does receive a DRM signal ------------------------------- */
/* First get current selected services */
const int iCurSelAudioServ =
pDRMRec->GetParameters()->GetCurSelAudioService();
const int iCurSelDataServ =
pDRMRec->GetParameters()->GetCurSelDataService();
/* If selected service is audio and text message is true */
if ((pDRMRec->GetParameters()->Service[iCurSelAudioServ].
eAudDataFlag == CParameter::SF_AUDIO) &&
(pDRMRec->GetParameters()->Service[iCurSelAudioServ].
AudioParam.bTextflag == TRUE))
{
/* Activate text window */
TextTextMessage->show();
/* Text message of current selected audio service
(UTF-8 decoding) */
TextTextMessage->setText(QString().fromUtf8(QCString(
pDRMRec->GetParameters()->Service[iCurSelAudioServ].AudioParam.
strTextMessage.c_str())));
}
else
{
/* Deactivate text window */
TextTextMessage->hide();
/* Clear Text */
TextTextMessage->setText("");
}
/* Check whether service parameters were not transmitted yet */
if (pDRMRec->GetParameters()->Service[iCurSelAudioServ].IsActive())
{
/* Service label (UTF-8 encoded string -> convert) */
TextServiceLabel->setText(QString().fromUtf8(QCString(
pDRMRec->GetParameters()->Service[iCurSelAudioServ].
strLabel.c_str())));
TextServiceIDRate->setText(SetBitrIDStr(iCurSelAudioServ));
/* Audio informations digi-string */
TextServiceAudio->setText(SetServParamStr(iCurSelAudioServ));
}
else
{
TextServiceLabel->setText(tr("No Service"));
TextServiceIDRate->setText("");
TextServiceAudio->setText("");
}
/* Update service selector ------------------------------------------ */
/* Make sure a possible service was selected. If not, correct */
if ((!pDRMRec->GetParameters()->Service[iCurSelServiceGUI].IsActive()) ||
(!((iCurSelServiceGUI == iCurSelAudioServ) ||
(iCurSelServiceGUI == iCurSelDataServ))))
{
/* Reset checks */
PushButtonService1->setOn(FALSE);
PushButtonService2->setOn(FALSE);
PushButtonService3->setOn(FALSE);
PushButtonService4->setOn(FALSE);
/* Set right flag */
switch (iCurSelAudioServ)
{
case 0:
PushButtonService1->setOn(TRUE);
iCurSelServiceGUI = 0;
break;
case 1:
PushButtonService2->setOn(TRUE);
iCurSelServiceGUI = 1;
break;
case 2:
PushButtonService3->setOn(TRUE);
iCurSelServiceGUI = 2;
break;
case 3:
PushButtonService4->setOn(TRUE);
iCurSelServiceGUI = 3;
break;
}
}
/* Service selector ------------------------------------------------- */
QString strSpace = " | ";
/* Enable only so many number of channel switches as present in the
stream */
const int iNumServices = pDRMRec->GetParameters()->GetTotNumServices();
QString m_StaticService[MAX_NUM_SERVICES] = {"", "", "", ""};
/* Reset all buttons only if number of services has changed */
if (iOldNoServicesGUI != iNumServices)
{
PushButtonService1->setEnabled(FALSE);
PushButtonService2->setEnabled(FALSE);
PushButtonService3->setEnabled(FALSE);
PushButtonService4->setEnabled(FALSE);
}
iOldNoServicesGUI = iNumServices;
for (int i = 0; i < MAX_NUM_SERVICES; i++)
{
/* Check, if service is used */
if (pDRMRec->GetParameters()->Service[i].IsActive())
{
/* Do UTF-8 to string converion with the label strings */
QString strLabel = QString().fromUtf8(QCString(pDRMRec->
GetParameters()->Service[i].strLabel.c_str()));
/* Print out label in bold letters (rich text). Problem, if
html tags are used in the label: FIXME */
m_StaticService[i] = "<b>" + strLabel +
"</b>" + strSpace + SetServParamStr(i);
/* Bit-rate (only show if greater than 0) */
const _REAL rBitRate =
pDRMRec->GetParameters()->GetBitRateKbps(i, FALSE);
if (rBitRate > (_REAL) 0.0)
{
m_StaticService[i] += " (" +
QString().setNum(rBitRate, 'f', 2) + " kbps)";
}
/* Show, if a multimedia stream is connected to this service */
if ((pDRMRec->GetParameters()->Service[i].
eAudDataFlag == CParameter::SF_AUDIO) &&
(pDRMRec->GetParameters()->Service[i].
DataParam.iStreamID != STREAM_ID_NOT_USED))
{
m_StaticService[i] += tr(" + MM");
/* Bit-rate of connected data stream */
m_StaticService[i] += " (" + QString().setNum(pDRMRec->
GetParameters()->GetBitRateKbps(i, TRUE), 'f', 2) +
" kbps)";
}
switch (i)
{
case 0:
PushButtonService1->setEnabled(TRUE);
break;
case 1:
PushButtonService2->setEnabled(TRUE);
break;
case 2:
PushButtonService3->setEnabled(TRUE);
break;
case 3:
PushButtonService4->setEnabled(TRUE);
break;
}
}
}
/* Set texts */
TextMiniService1->setText(m_StaticService[0]);
TextMiniService2->setText(m_StaticService[1]);
TextMiniService3->setText(m_StaticService[2]);
TextMiniService4->setText(m_StaticService[3]);
}
else
{
/* No signal is currently received ---------------------------------- */
/* Disable service buttons and associated labels */
PushButtonService1->setEnabled(FALSE);
PushButtonService2->setEnabled(FALSE);
PushButtonService3->setEnabled(FALSE);
PushButtonService4->setEnabled(FALSE);
TextMiniService1->setText("");
TextMiniService2->setText("");
TextMiniService3->setText("");
TextMiniService4->setText("");
/* Main text labels */
TextServiceAudio->setText("");
TextServiceIDRate->setText("");
/* Hide text message label */
TextTextMessage->hide();
TextTextMessage->setText("");
TextServiceLabel->setText(tr("Scanning..."));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -