void Viewer::SettingsChanged() { Reg::Save(cg_SettingsLocation, m_cfg); m_cacher.WrapAround(m_cfg.View.BrowseWrapAround); m_keys.SetBindings(m_cfg.Keyboard); m_statusBar->Show(m_cfg.View.ShowStatusBar && ViewportMode() != SM_Fullscreen); UpdateViewportConfig(); UpdateMemoryLimits(); m_viewPort.Refresh(); AlwaysOnTop(m_cfg.View.AlwaysOnTop); ImageChanged(); }
bool Viewer::Init(const std::string params) { m_dropTarget = new DropTarget(this); m_normalRect = wxToRect(GetRect()); Bind(wxEVT_CLOSE_WINDOW, [&](wxCloseEvent& evt) { PerformOnClose(); evt.Skip(); }); ViewportBuilder b; b.BuildViewport(m_viewPort, this, m_cfg); m_adjust = std::make_shared<Adjust>(this); m_adjust->OnChange.connect([this](int a, int b, int c) { AdjustChange(a, b, c); }); m_mouseMap.AddAction(MouseFullscreen, [this](Win::MouseEvent) { ToggleFullscreenMode(); }); m_mouseMap.AddAction(MouseToggleFullSizeDefaultZoom, [&](Win::MouseEvent) { ZoomToggleFullSizeDefaultZoom(); }); m_mouseMap.AddAction(MouseNextImage, [this](Win::MouseEvent) { ImageNext(1); }); m_mouseMap.AddAction(MousePrevImage, [this](Win::MouseEvent) { ImagePrev(1); }); m_mouseMap.AddAction(MouseZoomIn, [this](Win::MouseEvent) { ZoomIn(); }); m_mouseMap.AddAction(MouseZoomOut, [this](Win::MouseEvent) { ZoomOut(); }); m_mouseMap.AddAction(MouseContext, [this](Win::MouseEvent e) { ShowContextMenu(e); }); m_mouseMap.AddAction(MouseRotateLeft, [this](Win::MouseEvent) { RotateLeft(); }); m_mouseMap.AddAction(MouseRotateRight, [this](Win::MouseEvent) { RotateRight(); }); m_contextMenu.Construct(this); m_keys.Construct(this); m_keys.SetBindings(m_cfg.Keyboard); m_lang = Intl::OnLanguageChanged.connect([&]() { UpdateImageInformation(); }); m_cacher.SetCodecFactoryStore(m_codecs); UpdateViewportConfig(); // Apply some settings that can't be set automatically UpdateMemoryLimits(); m_cacher.MessageTarget(this); // TODO: FIXME: This is very wrong, should be set to something that isn't hardcoded. m_cacher.SetMaximumResolutionHint(Geom::SizeInt(25600, 25600)); m_folderMonitor.OnEvent.connect([this](IO::FileEvent e) { AddNotification(e); }); m_cacher.WrapAround(m_cfg.View.BrowseWrapAround); AlwaysOnTop(m_cfg.View.AlwaysOnTop); ZoomMode(m_cfg.View.DefaultZoomMode); if (m_cfg.View.Maximized) { m_doMaximize = true; } m_viewPort.Init(); m_statusBar = CreateStatusBar(7); int widths[] = { StatFieldZoomWidth, -1, StatFieldImageDimWidth, StatFieldPosWidth, StatFieldTimeWidth, StatFieldFileSizeWidth, StatFieldLastModified }; m_statusBar->SetStatusWidths(7, widths); m_statusBar->Show(m_cfg.View.ShowStatusBar); SetImageLocation(params); SetDropTarget(m_dropTarget); return true; }
///////////////////////////////////////////////////////////////////// // Constructor/Destructor ///////////////////////////////////////////////////////////////////// MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); setWindowTitle(PROGRAM_TITLE_VERSION); //create SDR interface class m_pSdrInterface = new CSdrInterface; //give GUI plotter access to the sdr interface object ui->framePlot->SetSdrInterface(m_pSdrInterface); //create the global Testbench object if(!g_pTestBench) g_pTestBench = new CTestBench(this); readSettings(); //read persistent settings ui->actionAlwaysOnTop->setChecked(m_AlwaysOnTop); AlwaysOnTop(); //create Demod setup menu for non-modal use(can leave up and still access rest of program) m_pDemodSetupDlg = new CDemodSetupDlg(this); m_pTimer = new QTimer(this); //connect a bunch of signals to the GUI objects connect(m_pTimer, SIGNAL(timeout()), this, SLOT(OnTimer())); connect(ui->frameFreqCtrl, SIGNAL(NewFrequency(qint64)), this, SLOT(OnNewCenterFrequency(qint64))); connect(ui->frameDemodFreqCtrl, SIGNAL(NewFrequency(qint64)), this, SLOT(OnNewDemodFrequency(qint64))); connect(m_pSdrInterface, SIGNAL(NewStatus(int)), this, SLOT( OnStatus(int) ) ); connect(m_pSdrInterface, SIGNAL(NewInfoData()), this, SLOT( OnNewInfoData() ) ); connect(m_pSdrInterface, SIGNAL(NewFftData()), this, SLOT( OnNewFftData() ) ); connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(OnExit())); connect(ui->actionNetwork, SIGNAL(triggered()), this, SLOT(OnNetworkDlg())); connect(ui->actionSoundCard, SIGNAL(triggered()), this, SLOT(OnSoundCardDlg())); connect(ui->actionSDR, SIGNAL(triggered()), this, SLOT(OnSdrDlg())); connect(ui->actionDisplay, SIGNAL(triggered()), this, SLOT(OnDisplayDlg())); connect(ui->actionAlwaysOnTop, SIGNAL(triggered()), this, SLOT(AlwaysOnTop())); connect(ui->actionDemod_Setup, SIGNAL(triggered()), this, SLOT(OnDemodDlg())); connect(ui->actionNoise_Processing, SIGNAL(triggered()), this, SLOT(OnNoiseProcDlg())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(OnAbout())); connect(ui->framePlot, SIGNAL(NewDemodFreq(qint64)), this, SLOT( OnNewScreenDemodFreq(qint64) ) ); connect(ui->framePlot, SIGNAL(NewCenterFreq(qint64)), this, SLOT( OnNewScreenCenterFreq(qint64) ) ); connect(ui->framePlot, SIGNAL(NewLowCutFreq(int)), this, SLOT( OnNewLowCutFreq(int) ) ); connect(ui->framePlot, SIGNAL(NewHighCutFreq(int)), this, SLOT( OnNewHighCutFreq(int) ) ); m_pTimer->start(200); //start up status timer m_pSdrInterface->SetRadioType(m_RadioType); quint32 maxspan = m_pSdrInterface->GetMaxBWFromIndex(m_BandwidthIndex); ui->framePlot->SetPercent2DScreen(m_Percent2DScreen); //initialize controls and limits qint32 tmpspan = m_SpanFrequency; //save since setting range triggers control to update ui->SpanspinBox->setMaximum(maxspan/1000); m_SpanFrequency = tmpspan; if(m_SpanFrequency>maxspan) m_SpanFrequency = maxspan; ui->SpanspinBox->setValue(m_SpanFrequency/1000); m_LastSpanKhz = m_SpanFrequency/1000; //tmp save demod freq since gets set to center freq by center freq control inititalization qint64 tmpdemod = m_DemodFrequency; ui->frameFreqCtrl->Setup(9, 100U, 500000000U, 1, UNITS_KHZ ); ui->frameFreqCtrl->SetBkColor(Qt::darkBlue); ui->frameFreqCtrl->SetDigitColor(Qt::cyan); ui->frameFreqCtrl->SetUnitsColor(Qt::lightGray); ui->frameFreqCtrl->SetHighlightColor(Qt::darkGray); ui->frameFreqCtrl->SetFrequency(m_CenterFrequency); m_DemodFrequency = tmpdemod; ui->frameDemodFreqCtrl->Setup(9, 100U, 500000000U, 1, UNITS_KHZ ); ui->frameDemodFreqCtrl->SetBkColor(Qt::darkBlue); ui->frameDemodFreqCtrl->SetDigitColor(Qt::white); ui->frameDemodFreqCtrl->SetUnitsColor(Qt::lightGray); ui->frameDemodFreqCtrl->SetHighlightColor(Qt::darkGray); //limit demod frequency to Center Frequency +/-span frequency ui->frameDemodFreqCtrl->Setup(9, m_CenterFrequency-m_SpanFrequency/2, m_CenterFrequency+m_SpanFrequency/2, 1, UNITS_KHZ ); ui->frameDemodFreqCtrl->SetFrequency(m_DemodFrequency); ui->framePlot->SetSpanFreq( m_SpanFrequency ); ui->framePlot->SetCenterFreq( m_CenterFrequency ); ui->framePlot->SetClickResolution(m_ClickResolution); m_FreqChanged = false; ui->horizontalSliderVol->setValue(m_Volume); m_pSdrInterface->SetVolume(m_Volume); ui->ScalecomboBox->addItem("10 dB/Div", 10); ui->ScalecomboBox->addItem("5 dB/Div", 5); ui->ScalecomboBox->addItem("3 dB/Div", 3); ui->ScalecomboBox->addItem("1 dB/Div", 1); m_dBStepSize = (int)ui->ScalecomboBox->itemData(m_VertScaleIndex).toInt(); ui->ScalecomboBox->setCurrentIndex(m_VertScaleIndex); ui->framePlot->SetdBStepSize(m_dBStepSize); ui->MaxdBspinBox->setValue(m_MaxdB); ui->MaxdBspinBox->setSingleStep(m_dBStepSize); ui->MaxdBspinBox->setMinimum(MIN_FFTDB+VERT_DIVS*m_dBStepSize); ui->MaxdBspinBox->setMaximum(MAX_FFTDB); ui->framePlot->SetMaxdB(m_MaxdB); m_pSdrInterface->SetFftSize( m_FftSize); m_pSdrInterface->SetFftAve( m_FftAve); m_pSdrInterface->SetMaxDisplayRate(m_MaxDisplayRate); m_pSdrInterface->SetSdrBandwidthIndex(m_BandwidthIndex); m_pSdrInterface->SetSdrRfGain( m_RfGain ); m_pSdrInterface->ManageNCOSpurOffsets(CSdrInterface::NCOSPUR_CMD_SET, &m_NCOSpurOffsetI, &m_NCOSpurOffsetQ); m_pSdrInterface->SetSoundCardSelection(m_SoundInIndex, m_SoundOutIndex, m_StereoOut); m_pSdrInterface->SetSpectrumInversion(m_InvertSpectrum); m_pSdrInterface->SetUSFmVersion(m_USFm); InitDemodSettings(); ui->framePlot->SetDemodCenterFreq( m_DemodFrequency ); SetupDemod(m_DemodMode); m_RdsDecode.DecodeReset(m_USFm); SetupNoiseProc(); UpdateInfoBox(); m_ActiveDevice = ""; m_pSdrInterface->SetupNetwork(m_IPAdr,m_Port); m_Status = CSdrInterface::NOT_CONNECTED; m_LastStatus = m_Status; m_pSdrInterface->StartIO(); m_KeepAliveTimer = 0; if(m_UseTestBench) { //make sure top of dialog is visable(0,0 doesn't include menu bar.Qt bug?) if(m_TestBenchRect.top()<30) m_TestBenchRect.setTop(30); g_pTestBench->setGeometry(m_TestBenchRect); g_pTestBench->show(); g_pTestBench->Init(); } }