2017-10-22 13:12:43 -04:00
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
// written by Christian Daniel //
// //
// 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 as version 3 of the License, or //
2019-04-11 08:43:33 -04:00
// (at your option) any later version. //
2017-10-22 13:12:43 -04:00
// //
// 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 V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
# include <QInputDialog>
# include <QMessageBox>
# include <QLabel>
# include <QFile>
# include <QFileInfo>
# include <QFileDialog>
# include <QTextStream>
# include <QDateTime>
# include <QSysInfo>
2018-01-04 23:05:12 -05:00
# include <QKeyEvent>
2018-02-18 17:01:02 -05:00
# include <QResource>
2018-05-06 21:14:18 -04:00
# include <QFontDatabase>
2017-10-22 13:12:43 -04:00
2020-10-09 02:52:30 -04:00
# include "device/devicegui.h"
2019-05-08 16:11:53 -04:00
# include "device/deviceapi.h"
2017-10-24 12:34:39 -04:00
# include "device/deviceuiset.h"
2020-10-11 02:27:58 -04:00
# include "device/deviceset.h"
2017-11-01 22:30:54 -04:00
# include "device/deviceenumerator.h"
2020-10-02 23:16:19 -04:00
# include "channel/channelapi.h"
2020-10-04 00:16:15 -04:00
# include "channel/channelgui.h"
2020-09-19 19:06:34 -04:00
# include "feature/featureuiset.h"
2020-10-10 18:22:42 -04:00
# include "feature/featureset.h"
2020-10-02 23:26:07 -04:00
# include "feature/feature.h"
2020-10-09 02:52:30 -04:00
# include "gui/commandkeyreceiver.h"
2017-10-22 13:12:43 -04:00
# include "gui/indicator.h"
# include "gui/presetitem.h"
2018-01-04 05:11:53 -05:00
# include "gui/commanditem.h"
2017-10-22 13:12:43 -04:00
# include "gui/addpresetdialog.h"
2018-01-04 05:11:53 -05:00
# include "gui/editcommanddialog.h"
2018-01-04 14:15:33 -05:00
# include "gui/commandoutputdialog.h"
2017-10-22 13:12:43 -04:00
# include "gui/pluginsdialog.h"
# include "gui/aboutdialog.h"
# include "gui/rollupwidget.h"
# include "gui/channelwindow.h"
2020-09-19 19:06:34 -04:00
# include "gui/featurewindow.h"
2017-10-22 13:12:43 -04:00
# include "gui/audiodialog.h"
2017-11-11 13:26:23 -05:00
# include "gui/loggingdialog.h"
2019-06-12 12:50:53 -04:00
# include "gui/deviceuserargsdialog.h"
2019-05-14 13:23:13 -04:00
# include "gui/sdrangelsplash.h"
2017-10-22 13:12:43 -04:00
# include "gui/mypositiondialog.h"
2019-07-19 12:38:03 -04:00
# include "gui/ambedevicesdialog.h"
2017-10-22 13:12:43 -04:00
# include "dsp/dspengine.h"
# include "dsp/spectrumvis.h"
# include "dsp/dspcommands.h"
# include "dsp/devicesamplesource.h"
# include "dsp/devicesamplesink.h"
2019-05-18 05:59:56 -04:00
# include "dsp/devicesamplemimo.h"
2019-05-08 16:11:53 -04:00
# include "dsp/dspdevicesourceengine.h"
# include "dsp/dspdevicesinkengine.h"
2019-05-18 05:59:56 -04:00
# include "dsp/dspdevicemimoengine.h"
2017-10-22 13:12:43 -04:00
# include "plugin/pluginapi.h"
# include "gui/glspectrum.h"
# include "gui/glspectrumgui.h"
2017-11-11 20:23:55 -05:00
# include "loggerwithfile.h"
2017-11-17 02:52:15 -05:00
# include "webapi/webapirequestmapper.h"
# include "webapi/webapiserver.h"
2020-10-11 06:39:30 -04:00
# include "webapi/webapiadapter.h"
2018-01-04 05:11:53 -05:00
# include "commands/command.h"
2017-10-22 13:12:43 -04:00
2017-10-24 12:34:39 -04:00
# include "mainwindow.h"
2018-03-23 13:08:38 -04:00
# include <audio/audiodevicemanager.h>
2017-10-24 12:34:39 -04:00
# include "ui_mainwindow.h"
2017-10-22 13:12:43 -04:00
# include <string>
# include <QDebug>
2019-05-14 13:23:13 -04:00
# include <QSplashScreen>
2017-10-22 13:12:43 -04:00
2020-01-24 17:05:16 -05:00
# if defined(HAS_LIMERFEUSB)
2020-01-11 19:10:51 -05:00
# include "limerfegui/limerfeusbdialog.h"
# endif
2017-10-24 07:45:10 -04:00
MainWindow * MainWindow : : m_instance = 0 ;
2017-11-17 23:06:43 -05:00
MainWindow : : MainWindow ( qtwebapp : : LoggerWithFile * logger , const MainParser & parser , QWidget * parent ) :
2017-10-22 13:12:43 -04:00
QMainWindow ( parent ) ,
ui ( new Ui : : MainWindow ) ,
2020-10-10 14:08:11 -04:00
m_mainCore ( MainCore : : instance ( ) ) ,
2017-10-22 13:12:43 -04:00
m_dspEngine ( DSPEngine : : instance ( ) ) ,
2019-05-08 16:11:53 -04:00
m_lastEngineState ( DeviceAPI : : StNotStarted ) ,
2017-10-22 13:12:43 -04:00
m_inputGUI ( 0 ) ,
m_sampleRate ( 0 ) ,
m_centerFrequency ( 0 ) ,
2020-10-10 14:08:11 -04:00
m_sampleFileName ( std : : string ( " ./test.sdriq " ) )
2017-10-22 13:12:43 -04:00
{
qDebug ( ) < < " MainWindow::MainWindow: start " ;
2017-10-24 07:45:10 -04:00
m_instance = this ;
2020-10-10 14:08:11 -04:00
m_mainCore - > m_logger = logger ;
m_mainCore - > m_masterTabIndex = 0 ;
m_mainCore - > m_mainMessageQueue = & m_inputMessageQueue ;
m_mainCore - > m_settings . setAudioDeviceManager ( m_dspEngine - > getAudioDeviceManager ( ) ) ;
m_mainCore - > m_settings . setAMBEEngine ( m_dspEngine - > getAMBEEngine ( ) ) ;
2017-10-22 13:12:43 -04:00
2018-05-06 21:14:18 -04:00
QFontDatabase : : addApplicationFont ( " :/LiberationSans-Regular.ttf " ) ;
QFontDatabase : : addApplicationFont ( " :/LiberationMono-Regular.ttf " ) ;
QFont font ( " Liberation Sans " ) ;
font . setPointSize ( 9 ) ;
qApp - > setFont ( font ) ;
2019-05-14 13:23:13 -04:00
QPixmap logoPixmap ( " :/sdrangel_logo.png " ) ;
SDRangelSplash * splash = new SDRangelSplash ( logoPixmap ) ;
2019-06-09 17:10:12 -04:00
splash - > setMessageRect ( QRect ( 10 , 80 , 350 , 16 ) ) ;
2019-05-14 13:23:13 -04:00
splash - > show ( ) ;
2019-08-11 19:46:27 -04:00
splash - > showStatusMessage ( " starting... " , Qt : : white ) ;
2019-05-14 13:23:13 -04:00
splash - > showStatusMessage ( " starting... " , Qt : : white ) ;
2017-10-22 13:12:43 -04:00
ui - > setupUi ( this ) ;
createStatusBar ( ) ;
setCorner ( Qt : : TopLeftCorner , Qt : : LeftDockWidgetArea ) ;
setCorner ( Qt : : BottomLeftCorner , Qt : : LeftDockWidgetArea ) ;
setCorner ( Qt : : TopRightCorner , Qt : : RightDockWidgetArea ) ;
setCorner ( Qt : : BottomRightCorner , Qt : : RightDockWidgetArea ) ;
// work around broken Qt dock widget ordering
removeDockWidget ( ui - > inputViewDock ) ;
removeDockWidget ( ui - > spectraDisplayDock ) ;
removeDockWidget ( ui - > presetDock ) ;
2018-01-03 06:25:58 -05:00
removeDockWidget ( ui - > commandsDock ) ;
2017-10-22 13:12:43 -04:00
removeDockWidget ( ui - > channelDock ) ;
2020-09-19 19:06:34 -04:00
removeDockWidget ( ui - > featureDock ) ;
2017-10-22 13:12:43 -04:00
addDockWidget ( Qt : : LeftDockWidgetArea , ui - > inputViewDock ) ;
addDockWidget ( Qt : : LeftDockWidgetArea , ui - > spectraDisplayDock ) ;
addDockWidget ( Qt : : LeftDockWidgetArea , ui - > presetDock ) ;
2018-01-03 06:25:58 -05:00
addDockWidget ( Qt : : LeftDockWidgetArea , ui - > commandsDock ) ;
tabifyDockWidget ( ui - > presetDock , ui - > commandsDock ) ;
2017-10-22 13:12:43 -04:00
addDockWidget ( Qt : : RightDockWidgetArea , ui - > channelDock ) ;
2020-09-19 19:06:34 -04:00
addDockWidget ( Qt : : RightDockWidgetArea , ui - > featureDock ) ;
2017-10-22 13:12:43 -04:00
ui - > inputViewDock - > show ( ) ;
ui - > spectraDisplayDock - > show ( ) ;
ui - > presetDock - > show ( ) ;
2018-01-03 06:25:58 -05:00
ui - > commandsDock - > show ( ) ;
2017-10-22 13:12:43 -04:00
ui - > channelDock - > show ( ) ;
2020-09-19 19:06:34 -04:00
ui - > featureDock - > show ( ) ;
2017-10-22 13:12:43 -04:00
ui - > menu_Window - > addAction ( ui - > inputViewDock - > toggleViewAction ( ) ) ;
ui - > menu_Window - > addAction ( ui - > spectraDisplayDock - > toggleViewAction ( ) ) ;
ui - > menu_Window - > addAction ( ui - > presetDock - > toggleViewAction ( ) ) ;
2018-01-03 06:25:58 -05:00
ui - > menu_Window - > addAction ( ui - > commandsDock - > toggleViewAction ( ) ) ;
2017-10-22 13:12:43 -04:00
ui - > menu_Window - > addAction ( ui - > channelDock - > toggleViewAction ( ) ) ;
2020-09-19 19:06:34 -04:00
ui - > menu_Window - > addAction ( ui - > featureDock - > toggleViewAction ( ) ) ;
2017-10-22 13:12:43 -04:00
2020-11-24 14:59:33 -05:00
ui - > spectraDisplayDock - > setStyleSheet ( " QAbstractButton#qt_dockwidget_closebutton{qproperty-toolTip: \" Close \" ;} " ) ;
ui - > spectraDisplayDock - > setStyleSheet ( " QAbstractButton#qt_dockwidget_floatbutton{qproperty-toolTip: \" Dock/undock \" ;} " ) ;
ui - > presetDock - > setStyleSheet ( " QAbstractButton#qt_dockwidget_closebutton{qproperty-toolTip: \" Close \" ;} " ) ;
ui - > presetDock - > setStyleSheet ( " QAbstractButton#qt_dockwidget_floatbutton{qproperty-toolTip: \" Dock/undock \" ;} " ) ;
2017-10-22 13:12:43 -04:00
ui - > tabInputsView - > setStyleSheet ( " QWidget { background: rgb(50,50,50); } "
" QToolButton::checked { background: rgb(128,70,0); } "
" QComboBox::item:selected { color: rgb(255,140,0); } "
" QTabWidget::pane { border: 1px solid #C06900; } "
" QTabBar::tab:selected { background: rgb(128,70,0); } " ) ;
connect ( & m_inputMessageQueue , SIGNAL ( messageEnqueued ( ) ) , this , SLOT ( handleMessages ( ) ) , Qt : : QueuedConnection ) ;
connect ( & m_statusTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( updateStatus ( ) ) ) ;
m_statusTimer . start ( 1000 ) ;
2020-03-12 01:27:38 -04:00
splash - > showStatusMessage ( " allocate FFTs... " , Qt : : white ) ;
splash - > showStatusMessage ( " allocate FFTs... " , Qt : : white ) ;
m_dspEngine - > createFFTFactory ( parser . getFFTWFWisdomFileName ( ) ) ;
m_dspEngine - > preAllocateFFTs ( ) ;
2019-05-14 13:23:13 -04:00
splash - > showStatusMessage ( " load settings... " , Qt : : white ) ;
2017-10-22 13:12:43 -04:00
qDebug ( ) < < " MainWindow::MainWindow: load settings... " ;
2020-09-19 19:06:34 -04:00
loadSettings ( ) ;
2019-05-14 13:23:13 -04:00
splash - > showStatusMessage ( " load plugins... " , Qt : : white ) ;
2018-02-22 00:42:41 -05:00
qDebug ( ) < < " MainWindow::MainWindow: load plugins... " ;
m_pluginManager = new PluginManager ( this ) ;
2020-10-11 02:27:58 -04:00
m_mainCore - > m_pluginManager = m_pluginManager ;
2018-02-22 00:42:41 -05:00
m_pluginManager - > loadPlugins ( QString ( " plugins " ) ) ;
2020-10-10 14:08:11 -04:00
m_pluginManager - > loadPluginsNonDiscoverable ( m_mainCore - > m_settings . getDeviceUserArgs ( ) ) ;
2018-02-22 00:42:41 -05:00
2020-09-19 19:06:34 -04:00
splash - > showStatusMessage ( " load initial feature set... " , Qt : : white ) ;
QStringList featureNames ;
m_pluginManager - > listFeatures ( featureNames ) ;
ui - > featureDock - > addAvailableFeatures ( featureNames ) ;
addFeatureSet ( ) ;
2020-09-23 23:38:05 -04:00
ui - > featureDock - > setFeatureUISet ( m_featureUIs [ 0 ] ) ;
2020-10-10 14:08:11 -04:00
ui - > featureDock - > setPresets ( m_mainCore - > m_settings . getFeatureSetPresets ( ) ) ;
2020-09-23 23:38:05 -04:00
ui - > featureDock - > setPluginAPI ( m_pluginManager - > getPluginAPI ( ) ) ;
2020-09-08 10:47:20 -04:00
2019-07-07 18:59:04 -04:00
splash - > showStatusMessage ( " load file input... " , Qt : : white ) ;
qDebug ( ) < < " MainWindow::MainWindow: select SampleSource from settings or default (file input)... " ;
2017-10-22 13:12:43 -04:00
2020-10-10 14:08:11 -04:00
int deviceIndex = DeviceEnumerator : : instance ( ) - > getRxSamplingDeviceIndex ( m_mainCore - > m_settings . getSourceDeviceId ( ) , m_mainCore - > m_settings . getSourceIndex ( ) ) ;
2019-07-07 18:59:04 -04:00
addSourceDevice ( deviceIndex ) ; // add the first device set with file input device as default if device in settings is not enumerated
2019-05-08 16:11:53 -04:00
m_deviceUIs . back ( ) - > m_deviceAPI - > setBuddyLeader ( true ) ; // the first device is always the leader
2020-09-12 04:37:16 -04:00
tabChannelsIndexChanged ( ) ; // force channel selection list update
2017-10-22 13:12:43 -04:00
2019-05-14 13:23:13 -04:00
splash - > showStatusMessage ( " load current preset settings... " , Qt : : white ) ;
2017-10-22 13:12:43 -04:00
qDebug ( ) < < " MainWindow::MainWindow: load current preset settings... " ;
2020-10-10 14:08:11 -04:00
loadPresetSettings ( m_mainCore - > m_settings . getWorkingPreset ( ) , 0 ) ;
2020-10-11 06:39:30 -04:00
m_apiAdapter = new WebAPIAdapter ( ) ;
2020-10-10 14:08:11 -04:00
loadFeatureSetPresetSettings ( m_mainCore - > m_settings . getWorkingFeatureSetPreset ( ) , 0 ) ;
2017-10-22 13:12:43 -04:00
2019-05-14 13:23:13 -04:00
splash - > showStatusMessage ( " update preset controls... " , Qt : : white ) ;
2017-10-22 13:12:43 -04:00
qDebug ( ) < < " MainWindow::MainWindow: update preset controls... " ;
updatePresetControls ( ) ;
2019-05-14 13:23:13 -04:00
splash - > showStatusMessage ( " finishing... " , Qt : : white ) ;
2017-10-22 13:12:43 -04:00
connect ( ui - > tabInputsView , SIGNAL ( currentChanged ( int ) ) , this , SLOT ( tabInputViewIndexChanged ( ) ) ) ;
2020-09-12 04:37:16 -04:00
connect ( ui - > tabChannels , SIGNAL ( currentChanged ( int ) ) , this , SLOT ( tabChannelsIndexChanged ( ) ) ) ;
connect ( ui - > channelDock , SIGNAL ( addChannel ( int ) ) , this , SLOT ( channelAddClicked ( int ) ) ) ;
2020-09-13 11:50:24 -04:00
connect ( ui - > inputViewDock , SIGNAL ( deviceChanged ( int , int , int ) ) , this , SLOT ( samplingDeviceChanged ( int , int , int ) ) ) ;
2020-09-19 19:06:34 -04:00
connect ( ui - > featureDock , SIGNAL ( addFeature ( int ) ) , this , SLOT ( featureAddClicked ( int ) ) ) ;
2017-10-22 13:12:43 -04:00
2018-02-18 17:01:02 -05:00
QString applicationDirPath = qApp - > applicationDirPath ( ) ;
2019-06-02 14:34:49 -04:00
# ifdef _MSC_VER
if ( QResource : : registerResource ( applicationDirPath + " /sdrbase.rcc " ) ) {
qDebug ( " MainWindow::MainWindow: registered resource file %s/%s " , qPrintable ( applicationDirPath ) , " sdrbase.rcc " ) ;
} else {
qWarning ( " MainWindow::MainWindow: could not register resource file %s/%s " , qPrintable ( applicationDirPath ) , " sdrbase.rcc " ) ;
}
# endif
2020-09-23 23:38:05 -04:00
ui - > featureDock - > setWebAPIAdapter ( m_apiAdapter ) ;
2017-12-17 18:00:21 -05:00
m_requestMapper = new WebAPIRequestMapper ( this ) ;
2017-11-18 13:34:47 -05:00
m_requestMapper - > setAdapter ( m_apiAdapter ) ;
2018-01-11 18:57:05 -05:00
m_apiHost = parser . getServerAddress ( ) ;
m_apiPort = parser . getServerPort ( ) ;
m_apiServer = new WebAPIServer ( m_apiHost , m_apiPort , m_requestMapper ) ;
2017-11-17 02:52:15 -05:00
m_apiServer - > start ( ) ;
2018-01-04 23:05:12 -05:00
m_commandKeyReceiver = new CommandKeyReceiver ( ) ;
m_commandKeyReceiver - > setRelease ( true ) ;
this - > installEventFilter ( m_commandKeyReceiver ) ;
2019-05-12 04:25:55 -04:00
m_dspEngine - > setMIMOSupport ( parser . getMIMOSupport ( ) ) ;
2019-12-21 17:19:17 -05:00
if ( ! parser . getMIMOSupport ( ) ) {
ui - > menu_Devices - > removeAction ( ui - > action_addMIMODevice ) ;
}
# ifdef __APPLE__
ui - > menuPreferences - > removeAction ( ui - > action_AMBE ) ;
# endif
2020-01-24 17:05:16 -05:00
# if not defined(HAS_LIMERFEUSB)
2020-01-11 19:10:51 -05:00
ui - > menuPreferences - > removeAction ( ui - > action_LimeRFE ) ;
# endif
2019-12-21 17:19:17 -05:00
2019-05-14 13:23:13 -04:00
delete splash ;
2021-07-01 10:28:43 -04:00
// Restore window size and position
QSettings s ;
2021-07-01 11:07:25 -04:00
restoreGeometry ( qUncompress ( QByteArray : : fromBase64 ( s . value ( " mainWindowGeometry " ) . toByteArray ( ) ) ) ) ;
restoreState ( qUncompress ( QByteArray : : fromBase64 ( s . value ( " mainWindowState " ) . toByteArray ( ) ) ) ) ;
2021-07-01 10:28:43 -04:00
2017-10-22 13:12:43 -04:00
qDebug ( ) < < " MainWindow::MainWindow: end " ;
}
MainWindow : : ~ MainWindow ( )
{
2017-11-17 02:52:15 -05:00
m_apiServer - > stop ( ) ;
delete m_apiServer ;
delete m_requestMapper ;
2017-11-18 13:34:47 -05:00
delete m_apiAdapter ;
2017-11-17 02:52:15 -05:00
2017-10-22 13:12:43 -04:00
delete m_pluginManager ;
delete m_dateTimeWidget ;
delete m_showSystemWidget ;
2020-09-19 19:06:34 -04:00
removeAllFeatureSets ( ) ;
2017-10-22 13:12:43 -04:00
delete ui ;
2017-11-11 04:29:32 -05:00
qDebug ( ) < < " MainWindow::~MainWindow: end " ;
2018-02-15 04:52:34 -05:00
delete m_commandKeyReceiver ;
2017-10-22 13:12:43 -04:00
}
2017-12-25 03:10:19 -05:00
void MainWindow : : addSourceDevice ( int deviceIndex )
2017-10-22 13:12:43 -04:00
{
DSPDeviceSourceEngine * dspDeviceSourceEngine = m_dspEngine - > addDeviceSourceEngine ( ) ;
dspDeviceSourceEngine - > start ( ) ;
uint dspDeviceSourceEngineUID = dspDeviceSourceEngine - > getUID ( ) ;
char uidCStr [ 16 ] ;
sprintf ( uidCStr , " UID:%d " , dspDeviceSourceEngineUID ) ;
2017-11-01 15:06:33 -04:00
int deviceTabIndex = m_deviceUIs . size ( ) ;
2020-09-13 11:50:24 -04:00
ui - > inputViewDock - > addDevice ( 0 , deviceTabIndex ) ;
2020-10-11 02:27:58 -04:00
m_mainCore - > appendDeviceSet ( 0 ) ;
2021-02-11 18:53:18 -05:00
m_deviceUIs . push_back ( new DeviceUISet ( deviceTabIndex , m_mainCore - > m_deviceSets . back ( ) ) ) ;
2017-10-22 13:12:43 -04:00
m_deviceUIs . back ( ) - > m_deviceSourceEngine = dspDeviceSourceEngine ;
2020-10-11 02:27:58 -04:00
m_mainCore - > m_deviceSets . back ( ) - > m_deviceSourceEngine = dspDeviceSourceEngine ;
2019-12-14 12:45:25 -05:00
m_deviceUIs . back ( ) - > m_deviceSinkEngine = nullptr ;
2020-10-11 02:27:58 -04:00
m_mainCore - > m_deviceSets . back ( ) - > m_deviceSinkEngine = nullptr ;
2019-12-14 12:45:25 -05:00
m_deviceUIs . back ( ) - > m_deviceMIMOEngine = nullptr ;
2020-10-11 02:27:58 -04:00
m_mainCore - > m_deviceSets . back ( ) - > m_deviceMIMOEngine = nullptr ;
2017-10-22 13:12:43 -04:00
char tabNameCStr [ 16 ] ;
sprintf ( tabNameCStr , " R%d " , deviceTabIndex ) ;
2019-05-18 00:30:37 -04:00
DeviceAPI * deviceAPI = new DeviceAPI ( DeviceAPI : : StreamSingleRx , deviceTabIndex , dspDeviceSourceEngine , nullptr , nullptr ) ;
2017-10-22 13:12:43 -04:00
2019-05-08 16:11:53 -04:00
m_deviceUIs . back ( ) - > m_deviceAPI = deviceAPI ;
2020-10-11 02:27:58 -04:00
m_mainCore - > m_deviceSets . back ( ) - > m_deviceAPI = deviceAPI ;
2017-11-01 03:32:44 -04:00
QList < QString > channelNames ;
m_pluginManager - > listRxChannels ( channelNames ) ;
2020-09-12 04:37:16 -04:00
m_deviceUIs . back ( ) - > setNumberOfAvailableRxChannels ( channelNames . size ( ) ) ;
2017-10-22 13:12:43 -04:00
dspDeviceSourceEngine - > addSink ( m_deviceUIs . back ( ) - > m_spectrumVis ) ;
ui - > tabSpectra - > addTab ( m_deviceUIs . back ( ) - > m_spectrum , tabNameCStr ) ;
ui - > tabSpectraGUI - > addTab ( m_deviceUIs . back ( ) - > m_spectrumGUI , tabNameCStr ) ;
ui - > tabChannels - > addTab ( m_deviceUIs . back ( ) - > m_channelWindow , tabNameCStr ) ;
2017-12-25 03:10:19 -05:00
// Create a file source instance by default if requested device was not enumerated (index = -1)
if ( deviceIndex < 0 ) {
2019-07-07 18:59:04 -04:00
deviceIndex = DeviceEnumerator : : instance ( ) - > getFileInputDeviceIndex ( ) ;
2017-12-25 03:10:19 -05:00
}
2019-05-08 19:12:40 -04:00
const PluginInterface : : SamplingDevice * samplingDevice = DeviceEnumerator : : instance ( ) - > getRxSamplingDevice ( deviceIndex ) ;
2020-10-11 02:27:58 -04:00
deviceAPI - > setSamplingDeviceSequence ( samplingDevice - > sequence ) ;
deviceAPI - > setDeviceNbItems ( samplingDevice - > deviceNbItems ) ;
deviceAPI - > setDeviceItemIndex ( samplingDevice - > deviceItemIndex ) ;
deviceAPI - > setHardwareId ( samplingDevice - > hardwareId ) ;
deviceAPI - > setSamplingDeviceId ( samplingDevice - > id ) ;
deviceAPI - > setSamplingDeviceSerial ( samplingDevice - > serial ) ;
deviceAPI - > setSamplingDeviceDisplayName ( samplingDevice - > displayedName ) ;
deviceAPI - > setSamplingDevicePluginInterface ( DeviceEnumerator : : instance ( ) - > getRxPluginInterface ( deviceIndex ) ) ;
2017-11-01 22:30:54 -04:00
2020-10-10 14:08:11 -04:00
QString userArgs = m_mainCore - > m_settings . getDeviceUserArgs ( ) . findUserArgs ( samplingDevice - > hardwareId , samplingDevice - > sequence ) ;
2019-06-13 12:43:06 -04:00
if ( userArgs . size ( ) > 0 ) {
2020-10-11 02:27:58 -04:00
deviceAPI - > setHardwareUserArguments ( userArgs ) ;
2019-06-13 12:43:06 -04:00
}
2020-09-13 11:50:24 -04:00
ui - > inputViewDock - > setSelectedDeviceIndex ( deviceTabIndex , deviceIndex ) ;
2017-10-29 21:15:59 -04:00
2020-10-03 01:24:56 -04:00
// delete previous plugin GUI if it exists
if ( m_deviceUIs . back ( ) - > m_deviceGUI ) {
m_deviceUIs . back ( ) - > m_deviceGUI - > destroy ( ) ;
}
2017-11-01 22:30:54 -04:00
2020-10-11 02:27:58 -04:00
DeviceSampleSource * source = deviceAPI - > getPluginInterface ( ) - > createSampleSourcePluginInstance (
deviceAPI - > getSamplingDeviceId ( ) , deviceAPI ) ;
deviceAPI - > setSampleSource ( source ) ;
2017-10-22 13:12:43 -04:00
QWidget * gui ;
2020-10-11 02:27:58 -04:00
DeviceGUI * pluginGUI = deviceAPI - > getPluginInterface ( ) - > createSampleSourcePluginInstanceGUI (
deviceAPI - > getSamplingDeviceId ( ) ,
2017-10-29 19:02:28 -04:00
& gui ,
m_deviceUIs . back ( ) ) ;
2020-10-11 02:27:58 -04:00
deviceAPI - > getSampleSource ( ) - > setMessageQueueToGUI ( pluginGUI - > getInputMessageQueue ( ) ) ;
2020-10-03 00:58:57 -04:00
m_deviceUIs . back ( ) - > m_deviceGUI = pluginGUI ;
2019-05-08 16:11:53 -04:00
m_deviceUIs . back ( ) - > m_deviceAPI - > getSampleSource ( ) - > init ( ) ;
2020-10-11 02:27:58 -04:00
setDeviceGUI ( deviceTabIndex , gui , deviceAPI - > getSamplingDeviceDisplayName ( ) ) ;
2017-10-22 13:12:43 -04:00
}
void MainWindow : : addSinkDevice ( )
{
DSPDeviceSinkEngine * dspDeviceSinkEngine = m_dspEngine - > addDeviceSinkEngine ( ) ;
dspDeviceSinkEngine - > start ( ) ;
uint dspDeviceSinkEngineUID = dspDeviceSinkEngine - > getUID ( ) ;
char uidCStr [ 16 ] ;
sprintf ( uidCStr , " UID:%d " , dspDeviceSinkEngineUID ) ;
2017-11-01 15:06:33 -04:00
int deviceTabIndex = m_deviceUIs . size ( ) ;
2020-09-13 11:50:24 -04:00
ui - > inputViewDock - > addDevice ( 1 , deviceTabIndex ) ;
2020-10-11 02:27:58 -04:00
m_mainCore - > appendDeviceSet ( 1 ) ;
2021-02-11 18:53:18 -05:00
m_deviceUIs . push_back ( new DeviceUISet ( deviceTabIndex , m_mainCore - > m_deviceSets . back ( ) ) ) ;
2019-12-14 12:45:25 -05:00
m_deviceUIs . back ( ) - > m_deviceSourceEngine = nullptr ;
2020-10-11 02:27:58 -04:00
m_mainCore - > m_deviceSets . back ( ) - > m_deviceSourceEngine = nullptr ;
2017-10-22 13:12:43 -04:00
m_deviceUIs . back ( ) - > m_deviceSinkEngine = dspDeviceSinkEngine ;
2020-10-11 02:27:58 -04:00
m_mainCore - > m_deviceSets . back ( ) - > m_deviceSinkEngine = dspDeviceSinkEngine ;
2019-12-14 12:45:25 -05:00
m_deviceUIs . back ( ) - > m_deviceMIMOEngine = nullptr ;
2020-10-11 02:27:58 -04:00
m_mainCore - > m_deviceSets . back ( ) - > m_deviceMIMOEngine = nullptr ;
2017-10-22 13:12:43 -04:00
char tabNameCStr [ 16 ] ;
sprintf ( tabNameCStr , " T%d " , deviceTabIndex ) ;
2019-05-18 00:30:37 -04:00
DeviceAPI * deviceAPI = new DeviceAPI ( DeviceAPI : : StreamSingleTx , deviceTabIndex , nullptr , dspDeviceSinkEngine , nullptr ) ;
2017-10-22 13:12:43 -04:00
2019-05-08 16:11:53 -04:00
m_deviceUIs . back ( ) - > m_deviceAPI = deviceAPI ;
2020-10-11 02:27:58 -04:00
m_mainCore - > m_deviceSets . back ( ) - > m_deviceAPI = deviceAPI ;
2017-11-01 03:32:44 -04:00
QList < QString > channelNames ;
m_pluginManager - > listTxChannels ( channelNames ) ;
2020-09-12 04:37:16 -04:00
m_deviceUIs . back ( ) - > setNumberOfAvailableTxChannels ( channelNames . size ( ) ) ;
2017-10-22 13:12:43 -04:00
dspDeviceSinkEngine - > addSpectrumSink ( m_deviceUIs . back ( ) - > m_spectrumVis ) ;
2019-05-30 12:38:10 -04:00
m_deviceUIs . back ( ) - > m_spectrum - > setDisplayedStream ( false , 0 ) ;
2017-10-22 13:12:43 -04:00
ui - > tabSpectra - > addTab ( m_deviceUIs . back ( ) - > m_spectrum , tabNameCStr ) ;
ui - > tabSpectraGUI - > addTab ( m_deviceUIs . back ( ) - > m_spectrumGUI , tabNameCStr ) ;
ui - > tabChannels - > addTab ( m_deviceUIs . back ( ) - > m_channelWindow , tabNameCStr ) ;
// create a file sink by default
2020-08-03 18:53:34 -04:00
int fileSinkDeviceIndex = DeviceEnumerator : : instance ( ) - > getFileOutputDeviceIndex ( ) ;
2019-05-08 19:12:40 -04:00
const PluginInterface : : SamplingDevice * samplingDevice = DeviceEnumerator : : instance ( ) - > getTxSamplingDevice ( fileSinkDeviceIndex ) ;
2020-10-11 02:27:58 -04:00
deviceAPI - > setSamplingDeviceSequence ( samplingDevice - > sequence ) ;
deviceAPI - > setDeviceNbItems ( samplingDevice - > deviceNbItems ) ;
deviceAPI - > setDeviceItemIndex ( samplingDevice - > deviceItemIndex ) ;
deviceAPI - > setHardwareId ( samplingDevice - > hardwareId ) ;
deviceAPI - > setSamplingDeviceId ( samplingDevice - > id ) ;
deviceAPI - > setSamplingDeviceSerial ( samplingDevice - > serial ) ;
deviceAPI - > setSamplingDeviceDisplayName ( samplingDevice - > displayedName ) ;
deviceAPI - > setSamplingDevicePluginInterface ( DeviceEnumerator : : instance ( ) - > getTxPluginInterface ( fileSinkDeviceIndex ) ) ;
2017-11-01 22:30:54 -04:00
2020-10-10 14:08:11 -04:00
QString userArgs = m_mainCore - > m_settings . getDeviceUserArgs ( ) . findUserArgs ( samplingDevice - > hardwareId , samplingDevice - > sequence ) ;
2019-06-13 12:43:06 -04:00
if ( userArgs . size ( ) > 0 ) {
2020-10-11 02:27:58 -04:00
deviceAPI - > setHardwareUserArguments ( userArgs ) ;
2019-06-13 12:43:06 -04:00
}
2020-09-13 11:50:24 -04:00
ui - > inputViewDock - > setSelectedDeviceIndex ( deviceTabIndex , fileSinkDeviceIndex ) ;
2017-10-29 21:23:06 -04:00
// delete previous plugin GUI if it exists
2020-10-03 01:24:56 -04:00
if ( m_deviceUIs . back ( ) - > m_deviceGUI ) {
m_deviceUIs . back ( ) - > m_deviceGUI - > destroy ( ) ;
}
2017-10-29 21:23:06 -04:00
2020-10-11 02:27:58 -04:00
DeviceSampleSink * sink = deviceAPI - > getPluginInterface ( ) - > createSampleSinkPluginInstance (
deviceAPI - > getSamplingDeviceId ( ) , deviceAPI ) ;
deviceAPI - > setSampleSink ( sink ) ;
2017-10-22 13:12:43 -04:00
QWidget * gui ;
2020-10-11 02:27:58 -04:00
DeviceGUI * pluginGUI = deviceAPI - > getPluginInterface ( ) - > createSampleSinkPluginInstanceGUI (
deviceAPI - > getSamplingDeviceId ( ) ,
2017-10-29 20:11:35 -04:00
& gui ,
m_deviceUIs . back ( ) ) ;
2020-10-11 02:27:58 -04:00
deviceAPI - > getSampleSink ( ) - > setMessageQueueToGUI ( pluginGUI - > getInputMessageQueue ( ) ) ;
2020-10-03 00:58:57 -04:00
m_deviceUIs . back ( ) - > m_deviceGUI = pluginGUI ;
2019-05-08 16:11:53 -04:00
m_deviceUIs . back ( ) - > m_deviceAPI - > getSampleSink ( ) - > init ( ) ;
2020-10-11 02:27:58 -04:00
setDeviceGUI ( deviceTabIndex , gui , deviceAPI - > getSamplingDeviceDisplayName ( ) , 1 ) ;
2017-10-22 13:12:43 -04:00
}
2020-11-10 06:08:58 -05:00
void MainWindow : : addMIMODevice ( )
{
DSPDeviceMIMOEngine * dspDeviceMIMOEngine = m_dspEngine - > addDeviceMIMOEngine ( ) ;
dspDeviceMIMOEngine - > start ( ) ;
uint dspDeviceMIMOEngineUID = dspDeviceMIMOEngine - > getUID ( ) ;
char uidCStr [ 16 ] ;
sprintf ( uidCStr , " UID:%d " , dspDeviceMIMOEngineUID ) ;
int deviceTabIndex = m_deviceUIs . size ( ) ;
ui - > inputViewDock - > addDevice ( 2 , deviceTabIndex ) ;
m_mainCore - > appendDeviceSet ( 2 ) ;
2021-02-11 18:53:18 -05:00
m_deviceUIs . push_back ( new DeviceUISet ( deviceTabIndex , m_mainCore - > m_deviceSets . back ( ) ) ) ;
2020-11-10 06:08:58 -05:00
m_deviceUIs . back ( ) - > m_deviceSourceEngine = nullptr ;
m_mainCore - > m_deviceSets . back ( ) - > m_deviceSourceEngine = nullptr ;
m_deviceUIs . back ( ) - > m_deviceSinkEngine = nullptr ;
m_mainCore - > m_deviceSets . back ( ) - > m_deviceSinkEngine = nullptr ;
m_deviceUIs . back ( ) - > m_deviceMIMOEngine = dspDeviceMIMOEngine ;
m_mainCore - > m_deviceSets . back ( ) - > m_deviceMIMOEngine = dspDeviceMIMOEngine ;
char tabNameCStr [ 16 ] ;
sprintf ( tabNameCStr , " M%d " , deviceTabIndex ) ;
DeviceAPI * deviceAPI = new DeviceAPI ( DeviceAPI : : StreamMIMO , deviceTabIndex , nullptr , nullptr , dspDeviceMIMOEngine ) ;
m_deviceUIs . back ( ) - > m_deviceAPI = deviceAPI ;
m_mainCore - > m_deviceSets . back ( ) - > m_deviceAPI = deviceAPI ;
// add MIMO channels
QList < QString > mimoChannelNames ;
m_pluginManager - > listMIMOChannels ( mimoChannelNames ) ;
m_deviceUIs . back ( ) - > setNumberOfAvailableMIMOChannels ( mimoChannelNames . size ( ) ) ;
// Add Rx channels
QList < QString > rxChannelNames ;
m_pluginManager - > listRxChannels ( rxChannelNames ) ;
m_deviceUIs . back ( ) - > setNumberOfAvailableRxChannels ( rxChannelNames . size ( ) ) ;
// Add Tx channels
QList < QString > txChannelNames ;
m_pluginManager - > listTxChannels ( txChannelNames ) ;
m_deviceUIs . back ( ) - > setNumberOfAvailableTxChannels ( txChannelNames . size ( ) ) ;
dspDeviceMIMOEngine - > addSpectrumSink ( m_deviceUIs . back ( ) - > m_spectrumVis ) ;
ui - > tabSpectra - > addTab ( m_deviceUIs . back ( ) - > m_spectrum , tabNameCStr ) ;
ui - > tabSpectraGUI - > addTab ( m_deviceUIs . back ( ) - > m_spectrumGUI , tabNameCStr ) ;
ui - > tabChannels - > addTab ( m_deviceUIs . back ( ) - > m_channelWindow , tabNameCStr ) ;
// create a test MIMO by default
int testMIMODeviceIndex = DeviceEnumerator : : instance ( ) - > getTestMIMODeviceIndex ( ) ;
const PluginInterface : : SamplingDevice * samplingDevice = DeviceEnumerator : : instance ( ) - > getMIMOSamplingDevice ( testMIMODeviceIndex ) ;
deviceAPI - > setSamplingDeviceSequence ( samplingDevice - > sequence ) ;
deviceAPI - > setDeviceNbItems ( samplingDevice - > deviceNbItems ) ;
deviceAPI - > setDeviceItemIndex ( samplingDevice - > deviceItemIndex ) ;
deviceAPI - > setHardwareId ( samplingDevice - > hardwareId ) ;
deviceAPI - > setSamplingDeviceId ( samplingDevice - > id ) ;
deviceAPI - > setSamplingDeviceSerial ( samplingDevice - > serial ) ;
deviceAPI - > setSamplingDeviceDisplayName ( samplingDevice - > displayedName ) ;
deviceAPI - > setSamplingDevicePluginInterface ( DeviceEnumerator : : instance ( ) - > getMIMOPluginInterface ( testMIMODeviceIndex ) ) ;
QString userArgs = m_mainCore - > m_settings . getDeviceUserArgs ( ) . findUserArgs ( samplingDevice - > hardwareId , samplingDevice - > sequence ) ;
if ( userArgs . size ( ) > 0 ) {
deviceAPI - > setHardwareUserArguments ( userArgs ) ;
}
ui - > inputViewDock - > setSelectedDeviceIndex ( deviceTabIndex , testMIMODeviceIndex ) ;
// delete previous plugin GUI if it exists
if ( m_deviceUIs . back ( ) - > m_deviceGUI ) {
m_deviceUIs . back ( ) - > m_deviceGUI - > destroy ( ) ;
}
DeviceSampleMIMO * mimo = deviceAPI - > getPluginInterface ( ) - > createSampleMIMOPluginInstance (
deviceAPI - > getSamplingDeviceId ( ) , deviceAPI ) ;
deviceAPI - > setSampleMIMO ( mimo ) ;
QWidget * gui ;
DeviceGUI * pluginGUI = deviceAPI - > getPluginInterface ( ) - > createSampleMIMOPluginInstanceGUI (
deviceAPI - > getSamplingDeviceId ( ) ,
& gui ,
m_deviceUIs . back ( ) ) ;
deviceAPI - > getSampleMIMO ( ) - > setMessageQueueToGUI ( pluginGUI - > getInputMessageQueue ( ) ) ;
m_deviceUIs . back ( ) - > m_deviceGUI = pluginGUI ;
m_deviceUIs . back ( ) - > m_deviceAPI - > getSampleMIMO ( ) - > init ( ) ;
setDeviceGUI ( deviceTabIndex , gui , deviceAPI - > getSamplingDeviceDisplayName ( ) , 2 ) ;
}
2017-10-22 13:12:43 -04:00
void MainWindow : : removeLastDevice ( )
{
if ( m_deviceUIs . back ( ) - > m_deviceSourceEngine ) // source tab
{
DSPDeviceSourceEngine * lastDeviceEngine = m_deviceUIs . back ( ) - > m_deviceSourceEngine ;
lastDeviceEngine - > stopAcquistion ( ) ;
lastDeviceEngine - > removeSink ( m_deviceUIs . back ( ) - > m_spectrumVis ) ;
ui - > tabSpectraGUI - > removeTab ( ui - > tabSpectraGUI - > count ( ) - 1 ) ;
ui - > tabSpectra - > removeTab ( ui - > tabSpectra - > count ( ) - 1 ) ;
2020-09-13 12:32:33 -04:00
ui - > inputViewDock - > removeLastDevice ( ) ;
2017-10-22 13:12:43 -04:00
// deletes old UI and input object
2019-09-07 18:44:56 -04:00
m_deviceUIs . back ( ) - > freeChannels ( ) ; // destroys the channel instances
2020-10-03 01:24:56 -04:00
m_deviceUIs . back ( ) - > m_deviceAPI - > getSampleSource ( ) - > setMessageQueueToGUI ( nullptr ) ; // have source stop sending messages to the GUI
m_deviceUIs . back ( ) - > m_deviceGUI - > destroy ( ) ;
2019-05-08 16:11:53 -04:00
m_deviceUIs . back ( ) - > m_deviceAPI - > resetSamplingDeviceId ( ) ;
m_deviceUIs . back ( ) - > m_deviceAPI - > getPluginInterface ( ) - > deleteSampleSourcePluginInstanceInput (
m_deviceUIs . back ( ) - > m_deviceAPI - > getSampleSource ( ) ) ;
m_deviceUIs . back ( ) - > m_deviceAPI - > clearBuddiesLists ( ) ; // clear old API buddies lists
2017-10-22 13:12:43 -04:00
ui - > tabChannels - > removeTab ( ui - > tabChannels - > count ( ) - 1 ) ;
m_deviceWidgetTabs . removeLast ( ) ;
2020-11-02 02:29:21 -05:00
restoreDeviceTabs ( ) ;
2017-10-22 13:12:43 -04:00
2019-05-08 16:11:53 -04:00
DeviceAPI * sourceAPI = m_deviceUIs . back ( ) - > m_deviceAPI ;
2017-10-22 13:12:43 -04:00
delete m_deviceUIs . back ( ) ;
lastDeviceEngine - > stop ( ) ;
m_dspEngine - > removeLastDeviceSourceEngine ( ) ;
2018-02-14 18:25:50 -05:00
delete sourceAPI ;
2017-10-22 13:12:43 -04:00
}
else if ( m_deviceUIs . back ( ) - > m_deviceSinkEngine ) // sink tab
{
DSPDeviceSinkEngine * lastDeviceEngine = m_deviceUIs . back ( ) - > m_deviceSinkEngine ;
lastDeviceEngine - > stopGeneration ( ) ;
lastDeviceEngine - > removeSpectrumSink ( m_deviceUIs . back ( ) - > m_spectrumVis ) ;
ui - > tabSpectraGUI - > removeTab ( ui - > tabSpectraGUI - > count ( ) - 1 ) ;
ui - > tabSpectra - > removeTab ( ui - > tabSpectra - > count ( ) - 1 ) ;
2020-09-13 12:32:33 -04:00
ui - > inputViewDock - > removeLastDevice ( ) ;
2017-10-22 13:12:43 -04:00
// deletes old UI and output object
2019-09-07 18:44:56 -04:00
m_deviceUIs . back ( ) - > freeChannels ( ) ;
2020-10-03 01:24:56 -04:00
m_deviceUIs . back ( ) - > m_deviceAPI - > getSampleSink ( ) - > setMessageQueueToGUI ( nullptr ) ; // have sink stop sending messages to the GUI
m_deviceUIs . back ( ) - > m_deviceGUI - > destroy ( ) ;
2019-05-08 16:11:53 -04:00
m_deviceUIs . back ( ) - > m_deviceAPI - > resetSamplingDeviceId ( ) ;
m_deviceUIs . back ( ) - > m_deviceAPI - > getPluginInterface ( ) - > deleteSampleSinkPluginInstanceOutput (
m_deviceUIs . back ( ) - > m_deviceAPI - > getSampleSink ( ) ) ;
m_deviceUIs . back ( ) - > m_deviceAPI - > clearBuddiesLists ( ) ; // clear old API buddies lists
2017-10-22 13:12:43 -04:00
ui - > tabChannels - > removeTab ( ui - > tabChannels - > count ( ) - 1 ) ;
m_deviceWidgetTabs . removeLast ( ) ;
2020-11-02 02:29:21 -05:00
restoreDeviceTabs ( ) ;
2017-10-22 13:12:43 -04:00
2019-05-08 16:11:53 -04:00
DeviceAPI * sinkAPI = m_deviceUIs . back ( ) - > m_deviceAPI ;
2017-10-22 13:12:43 -04:00
delete m_deviceUIs . back ( ) ;
lastDeviceEngine - > stop ( ) ;
m_dspEngine - > removeLastDeviceSinkEngine ( ) ;
2018-02-14 18:25:50 -05:00
delete sinkAPI ;
2017-10-22 13:12:43 -04:00
}
2019-05-18 05:59:56 -04:00
else if ( m_deviceUIs . back ( ) - > m_deviceMIMOEngine ) // MIMO tab
{
DSPDeviceMIMOEngine * lastDeviceEngine = m_deviceUIs . back ( ) - > m_deviceMIMOEngine ;
2019-10-20 14:05:01 -04:00
lastDeviceEngine - > stopProcess ( 1 ) ; // Tx side
lastDeviceEngine - > stopProcess ( 0 ) ; // Rx side
2019-05-18 05:59:56 -04:00
lastDeviceEngine - > removeSpectrumSink ( m_deviceUIs . back ( ) - > m_spectrumVis ) ;
ui - > tabSpectraGUI - > removeTab ( ui - > tabSpectraGUI - > count ( ) - 1 ) ;
ui - > tabSpectra - > removeTab ( ui - > tabSpectra - > count ( ) - 1 ) ;
2020-09-13 12:32:33 -04:00
ui - > inputViewDock - > removeLastDevice ( ) ;
2019-05-18 05:59:56 -04:00
// deletes old UI and output object
2019-09-07 18:44:56 -04:00
m_deviceUIs . back ( ) - > freeChannels ( ) ;
2019-05-18 05:59:56 -04:00
m_deviceUIs . back ( ) - > m_deviceAPI - > getSampleMIMO ( ) - > setMessageQueueToGUI ( nullptr ) ; // have sink stop sending messages to the GUI
2020-10-03 01:24:56 -04:00
m_deviceUIs . back ( ) - > m_deviceGUI - > destroy ( ) ;
2019-05-18 05:59:56 -04:00
m_deviceUIs . back ( ) - > m_deviceAPI - > resetSamplingDeviceId ( ) ;
m_deviceUIs . back ( ) - > m_deviceAPI - > getPluginInterface ( ) - > deleteSampleMIMOPluginInstanceMIMO (
m_deviceUIs . back ( ) - > m_deviceAPI - > getSampleMIMO ( ) ) ;
ui - > tabChannels - > removeTab ( ui - > tabChannels - > count ( ) - 1 ) ;
m_deviceWidgetTabs . removeLast ( ) ;
2020-11-02 02:29:21 -05:00
restoreDeviceTabs ( ) ;
2019-05-18 05:59:56 -04:00
DeviceAPI * mimoAPI = m_deviceUIs . back ( ) - > m_deviceAPI ;
delete m_deviceUIs . back ( ) ;
lastDeviceEngine - > stop ( ) ;
m_dspEngine - > removeLastDeviceMIMOEngine ( ) ;
delete mimoAPI ;
}
2017-10-22 13:12:43 -04:00
m_deviceUIs . pop_back ( ) ;
2020-10-11 02:27:58 -04:00
m_mainCore - > removeLastDeviceSet ( ) ;
2017-10-22 13:12:43 -04:00
}
2020-09-19 19:06:34 -04:00
void MainWindow : : addFeatureSet ( )
{
int tabIndex = m_featureUIs . size ( ) ;
2020-10-10 18:22:42 -04:00
m_mainCore - > appendFeatureSet ( ) ;
m_featureUIs . push_back ( new FeatureUISet ( tabIndex , m_mainCore - > m_featureSets [ tabIndex ] ) ) ;
2020-09-19 19:06:34 -04:00
ui - > tabFeatures - > addTab ( m_featureUIs . back ( ) - > m_featureWindow , QString ( " F%1 " ) . arg ( tabIndex ) ) ;
}
2020-11-14 16:08:06 -05:00
void MainWindow : : removeFeatureSet ( unsigned int tabIndex )
2020-09-19 19:06:34 -04:00
{
if ( tabIndex < m_featureUIs . size ( ) )
{
delete m_featureUIs [ tabIndex ] ;
m_featureUIs . erase ( m_featureUIs . begin ( ) + tabIndex ) ;
2020-10-10 18:22:42 -04:00
m_mainCore - > removeFeatureSet ( tabIndex ) ;
2020-09-19 19:06:34 -04:00
}
}
void MainWindow : : removeAllFeatureSets ( )
{
while ( m_featureUIs . size ( ) > 0 )
{
delete m_featureUIs . back ( ) ;
m_featureUIs . erase ( std : : prev ( m_featureUIs . end ( ) ) ) ;
}
}
2017-12-23 17:41:37 -05:00
void MainWindow : : deleteChannel ( int deviceSetIndex , int channelIndex )
{
if ( ( deviceSetIndex > = 0 ) & & ( deviceSetIndex < ( int ) m_deviceUIs . size ( ) ) )
{
DeviceUISet * deviceSet = m_deviceUIs [ deviceSetIndex ] ;
2019-09-07 18:44:56 -04:00
deviceSet - > deleteChannel ( channelIndex ) ;
2020-10-10 18:22:42 -04:00
m_mainCore - > removeLastFeatureSet ( ) ;
2017-12-23 17:41:37 -05:00
}
}
2017-10-22 13:12:43 -04:00
void MainWindow : : addViewAction ( QAction * action )
{
ui - > menu_Window - > addAction ( action ) ;
}
2019-05-18 05:59:56 -04:00
void MainWindow : : setDeviceGUI ( int deviceTabIndex , QWidget * gui , const QString & deviceDisplayName , int deviceType )
2017-10-22 13:12:43 -04:00
{
2020-11-02 02:29:21 -05:00
QString tabName ;
2017-10-22 13:12:43 -04:00
2019-05-18 05:59:56 -04:00
if ( deviceType = = 0 ) {
2020-11-02 02:29:21 -05:00
tabName = tr ( " R%1 " ) . arg ( deviceTabIndex ) ;
2019-05-18 05:59:56 -04:00
} else if ( deviceType = = 1 ) {
2020-11-02 02:29:21 -05:00
tabName = tr ( " T%1 " ) . arg ( deviceTabIndex ) ;
2019-05-18 05:59:56 -04:00
} else if ( deviceType = = 2 ) {
2020-11-02 02:29:21 -05:00
tabName = tr ( " M%1 " ) . arg ( deviceTabIndex ) ;
2017-10-22 13:12:43 -04:00
}
2019-05-18 05:59:56 -04:00
qDebug ( " MainWindow::setDeviceGUI: insert device type %d tab at %d " , deviceType , deviceTabIndex ) ;
2017-10-22 13:12:43 -04:00
2019-05-18 05:59:56 -04:00
if ( deviceTabIndex < m_deviceWidgetTabs . size ( ) ) {
2020-11-02 02:29:21 -05:00
m_deviceWidgetTabs [ deviceTabIndex ] = { gui , deviceDisplayName , tabName } ;
2019-05-18 05:59:56 -04:00
} else {
2020-11-02 02:29:21 -05:00
m_deviceWidgetTabs . append ( { gui , deviceDisplayName , tabName } ) ;
2017-10-22 13:12:43 -04:00
}
2020-11-02 02:29:21 -05:00
restoreDeviceTabs ( ) ;
2017-10-22 13:12:43 -04:00
ui - > tabInputsView - > setCurrentIndex ( deviceTabIndex ) ;
}
void MainWindow : : loadSettings ( )
{
qDebug ( ) < < " MainWindow::loadSettings " ;
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . load ( ) ;
m_mainCore - > m_settings . sortPresets ( ) ;
int middleIndex = m_mainCore - > m_settings . getPresetCount ( ) / 2 ;
2017-11-25 05:14:52 -05:00
QTreeWidgetItem * treeItem ;
2017-10-22 13:12:43 -04:00
2020-10-10 14:08:11 -04:00
for ( int i = 0 ; i < m_mainCore - > m_settings . getPresetCount ( ) ; + + i )
2017-10-22 13:12:43 -04:00
{
2020-10-10 14:08:11 -04:00
treeItem = addPresetToTree ( m_mainCore - > m_settings . getPreset ( i ) ) ;
2017-11-25 05:14:52 -05:00
if ( i = = middleIndex ) {
ui - > presetTree - > setCurrentItem ( treeItem ) ;
}
2017-10-22 13:12:43 -04:00
}
2017-11-11 13:26:23 -05:00
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . sortCommands ( ) ;
2018-01-04 05:11:53 -05:00
2020-10-10 14:08:11 -04:00
for ( int i = 0 ; i < m_mainCore - > m_settings . getCommandCount ( ) ; + + i )
2018-01-04 05:11:53 -05:00
{
2020-10-10 14:08:11 -04:00
treeItem = addCommandToTree ( m_mainCore - > m_settings . getCommand ( i ) ) ;
2018-01-04 05:11:53 -05:00
}
2020-10-10 14:08:11 -04:00
m_mainCore - > setLoggingOptions ( ) ;
2017-10-22 13:12:43 -04:00
}
void MainWindow : : loadPresetSettings ( const Preset * preset , int tabIndex )
{
qDebug ( " MainWindow::loadPresetSettings: preset [%s | %s] " ,
qPrintable ( preset - > getGroup ( ) ) ,
qPrintable ( preset - > getDescription ( ) ) ) ;
if ( tabIndex > = 0 )
{
DeviceUISet * deviceUI = m_deviceUIs [ tabIndex ] ;
2019-08-10 19:27:19 -04:00
deviceUI - > m_spectrumGUI - > deserialize ( preset - > getSpectrumConfig ( ) ) ;
deviceUI - > m_deviceAPI - > loadSamplingDeviceSettings ( preset ) ;
2017-10-22 13:12:43 -04:00
2019-08-10 19:27:19 -04:00
if ( deviceUI - > m_deviceSourceEngine ) { // source device
2017-10-31 17:37:57 -04:00
deviceUI - > loadRxChannelSettings ( preset , m_pluginManager - > getPluginAPI ( ) ) ;
2019-08-10 19:27:19 -04:00
} else if ( deviceUI - > m_deviceSinkEngine ) { // sink device
2017-10-31 19:00:03 -04:00
deviceUI - > loadTxChannelSettings ( preset , m_pluginManager - > getPluginAPI ( ) ) ;
2019-09-13 07:40:31 -04:00
} else if ( deviceUI - > m_deviceMIMOEngine ) { // MIMO device
deviceUI - > loadMIMOChannelSettings ( preset , m_pluginManager - > getPluginAPI ( ) ) ;
2017-10-22 13:12:43 -04:00
}
}
// has to be last step
2019-08-12 03:34:59 -04:00
if ( ! preset - > getLayout ( ) . isEmpty ( ) ) {
restoreState ( preset - > getLayout ( ) ) ;
}
2018-01-05 20:44:45 -05:00
tabifyDockWidget ( ui - > presetDock , ui - > commandsDock ) ; // override this setting
ui - > presetDock - > raise ( ) ;
2017-10-22 13:12:43 -04:00
}
void MainWindow : : savePresetSettings ( Preset * preset , int tabIndex )
{
qDebug ( " MainWindow::savePresetSettings: preset [%s | %s] " ,
qPrintable ( preset - > getGroup ( ) ) ,
qPrintable ( preset - > getDescription ( ) ) ) ;
// Save from currently selected source tab
//int currentSourceTabIndex = ui->tabInputsView->currentIndex();
DeviceUISet * deviceUI = m_deviceUIs [ tabIndex ] ;
if ( deviceUI - > m_deviceSourceEngine ) // source device
{
preset - > setSpectrumConfig ( deviceUI - > m_spectrumGUI - > serialize ( ) ) ;
preset - > clearChannels ( ) ;
2019-09-13 07:40:31 -04:00
preset - > setSourcePreset ( ) ;
2017-10-31 17:37:57 -04:00
deviceUI - > saveRxChannelSettings ( preset ) ;
2019-05-08 16:11:53 -04:00
deviceUI - > m_deviceAPI - > saveSamplingDeviceSettings ( preset ) ;
2017-10-22 13:12:43 -04:00
}
else if ( deviceUI - > m_deviceSinkEngine ) // sink device
{
preset - > setSpectrumConfig ( deviceUI - > m_spectrumGUI - > serialize ( ) ) ;
preset - > clearChannels ( ) ;
2019-09-13 07:40:31 -04:00
preset - > setSinkPreset ( ) ;
2017-10-31 19:00:03 -04:00
deviceUI - > saveTxChannelSettings ( preset ) ;
2019-05-08 16:11:53 -04:00
deviceUI - > m_deviceAPI - > saveSamplingDeviceSettings ( preset ) ;
2017-10-22 13:12:43 -04:00
}
2019-09-13 07:40:31 -04:00
else if ( deviceUI - > m_deviceMIMOEngine ) // MIMO device
{
preset - > setSpectrumConfig ( deviceUI - > m_spectrumGUI - > serialize ( ) ) ;
preset - > clearChannels ( ) ;
preset - > setMIMOPreset ( ) ;
deviceUI - > saveMIMOChannelSettings ( preset ) ;
deviceUI - > m_deviceAPI - > saveSamplingDeviceSettings ( preset ) ;
}
2017-10-22 13:12:43 -04:00
preset - > setLayout ( saveState ( ) ) ;
}
2020-09-23 23:38:05 -04:00
void MainWindow : : loadFeatureSetPresetSettings ( const FeatureSetPreset * preset , int featureSetIndex )
{
qDebug ( " MainWindow::loadFeatureSetPresetSettings: preset [%s | %s] " ,
qPrintable ( preset - > getGroup ( ) ) ,
qPrintable ( preset - > getDescription ( ) ) ) ;
if ( featureSetIndex > = 0 )
{
FeatureUISet * featureSetUI = m_featureUIs [ featureSetIndex ] ;
2020-09-27 18:20:37 -04:00
qDebug ( " MainWindow::loadFeatureSetPresetSettings: m_apiAdapter: %p " , m_apiAdapter ) ;
2020-09-23 23:38:05 -04:00
featureSetUI - > loadFeatureSetSettings ( preset , m_pluginManager - > getPluginAPI ( ) , m_apiAdapter ) ;
}
}
void MainWindow : : saveFeatureSetPresetSettings ( FeatureSetPreset * preset , int featureSetIndex )
{
qDebug ( " MainWindow::saveFeatureSetPresetSettings: preset [%s | %s] " ,
qPrintable ( preset - > getGroup ( ) ) ,
qPrintable ( preset - > getDescription ( ) ) ) ;
// Save from currently selected source tab
//int currentSourceTabIndex = ui->tabInputsView->currentIndex();
FeatureUISet * featureUI = m_featureUIs [ featureSetIndex ] ;
preset - > clearFeatures ( ) ;
featureUI - > saveFeatureSetSettings ( preset ) ;
}
2018-01-05 05:54:05 -05:00
void MainWindow : : saveCommandSettings ( )
{
}
2017-10-22 13:12:43 -04:00
void MainWindow : : createStatusBar ( )
{
QString qtVersionStr = QString ( " Qt %1 " ) . arg ( QT_VERSION_STR ) ;
2020-11-04 16:52:15 -05:00
# if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
2019-04-13 04:30:16 -04:00
m_showSystemWidget = new QLabel ( " SDRangel " + qApp - > applicationVersion ( ) + " " + qtVersionStr
2018-01-06 19:33:57 -05:00
+ QSysInfo : : currentCpuArchitecture ( ) + " " + QSysInfo : : prettyProductName ( ) , this ) ;
2017-10-22 13:12:43 -04:00
# else
2019-04-13 04:30:16 -04:00
m_showSystemWidget = new QLabel ( " SDRangel " + qApp - > applicationVersion ( ) + " " + qtVersionStr , this ) ;
2017-10-22 13:12:43 -04:00
# endif
statusBar ( ) - > addPermanentWidget ( m_showSystemWidget ) ;
m_dateTimeWidget = new QLabel ( tr ( " Date " ) , this ) ;
m_dateTimeWidget - > setToolTip ( tr ( " Current date/time " ) ) ;
statusBar ( ) - > addPermanentWidget ( m_dateTimeWidget ) ;
}
2019-07-22 12:49:24 -04:00
void MainWindow : : closeEvent ( QCloseEvent * closeEvent )
2017-10-22 13:12:43 -04:00
{
2019-07-22 12:49:24 -04:00
qDebug ( " MainWindow::closeEvent " ) ;
2021-07-01 10:28:43 -04:00
// Save window size and position
QSettings s ;
2021-07-01 11:07:25 -04:00
s . setValue ( " mainWindowGeometry " , qCompress ( saveGeometry ( ) ) . toBase64 ( ) ) ;
s . setValue ( " mainWindowState " , qCompress ( saveState ( ) ) . toBase64 ( ) ) ;
2021-07-01 10:28:43 -04:00
2020-10-10 14:08:11 -04:00
savePresetSettings ( m_mainCore - > m_settings . getWorkingPreset ( ) , 0 ) ;
saveFeatureSetPresetSettings ( m_mainCore - > m_settings . getWorkingFeatureSetPreset ( ) , 0 ) ;
m_mainCore - > m_settings . save ( ) ;
2019-07-22 12:49:24 -04:00
while ( m_deviceUIs . size ( ) > 0 )
{
removeLastDevice ( ) ;
}
closeEvent - > accept ( ) ;
2017-10-22 13:12:43 -04:00
}
void MainWindow : : updatePresetControls ( )
{
ui - > presetTree - > resizeColumnToContents ( 0 ) ;
if ( ui - > presetTree - > currentItem ( ) ! = 0 )
{
ui - > presetDelete - > setEnabled ( true ) ;
ui - > presetLoad - > setEnabled ( true ) ;
}
else
{
ui - > presetDelete - > setEnabled ( false ) ;
ui - > presetLoad - > setEnabled ( false ) ;
}
}
QTreeWidgetItem * MainWindow : : addPresetToTree ( const Preset * preset )
{
QTreeWidgetItem * group = 0 ;
for ( int i = 0 ; i < ui - > presetTree - > topLevelItemCount ( ) ; i + + )
{
if ( ui - > presetTree - > topLevelItem ( i ) - > text ( 0 ) = = preset - > getGroup ( ) )
{
group = ui - > presetTree - > topLevelItem ( i ) ;
break ;
}
}
if ( group = = 0 )
{
QStringList sl ;
sl . append ( preset - > getGroup ( ) ) ;
group = new QTreeWidgetItem ( ui - > presetTree , sl , PGroup ) ;
group - > setFirstColumnSpanned ( true ) ;
group - > setExpanded ( true ) ;
ui - > presetTree - > sortByColumn ( 0 , Qt : : AscendingOrder ) ;
}
QStringList sl ;
sl . append ( QString ( " %1 " ) . arg ( preset - > getCenterFrequency ( ) / 1e6 f , 0 , ' f ' , 3 ) ) ; // frequency column
2019-09-13 07:40:31 -04:00
sl . append ( QString ( " %1 " ) . arg ( preset - > isSourcePreset ( ) ? ' R ' : preset - > isSinkPreset ( ) ? ' T ' : preset - > isMIMOPreset ( ) ? ' M ' : ' X ' ) ) ; // mode column
2017-10-22 13:12:43 -04:00
sl . append ( preset - > getDescription ( ) ) ; // description column
PresetItem * item = new PresetItem ( group , sl , preset - > getCenterFrequency ( ) , PItem ) ;
item - > setTextAlignment ( 0 , Qt : : AlignRight ) ;
2020-04-19 00:13:32 -04:00
item - > setData ( 0 , Qt : : UserRole , QVariant : : fromValue ( preset ) ) ;
2017-10-22 13:12:43 -04:00
ui - > presetTree - > resizeColumnToContents ( 0 ) ; // Resize frequency column to minimum
ui - > presetTree - > resizeColumnToContents ( 1 ) ; // Resize mode column to minimum
updatePresetControls ( ) ;
return item ;
}
2018-01-04 05:11:53 -05:00
QTreeWidgetItem * MainWindow : : addCommandToTree ( const Command * command )
{
QTreeWidgetItem * group = 0 ;
for ( int i = 0 ; i < ui - > commandTree - > topLevelItemCount ( ) ; i + + )
{
if ( ui - > commandTree - > topLevelItem ( i ) - > text ( 0 ) = = command - > getGroup ( ) )
{
group = ui - > commandTree - > topLevelItem ( i ) ;
break ;
}
}
if ( group = = 0 )
{
QStringList sl ;
sl . append ( command - > getGroup ( ) ) ;
group = new QTreeWidgetItem ( ui - > commandTree , sl , PGroup ) ;
group - > setFirstColumnSpanned ( true ) ;
group - > setExpanded ( true ) ;
ui - > commandTree - > sortByColumn ( 0 , Qt : : AscendingOrder ) ;
}
QStringList sl ;
sl . append ( QString ( " %1 " ) . arg ( command - > getDescription ( ) ) ) ; // Descriptions column
2018-01-06 00:26:00 -05:00
sl . append ( QString ( " %1 " ) . arg ( command - > getAssociateKey ( ) ? command - > getRelease ( ) ? " R " : " P " : " - " ) ) ; // key press/release column
2018-01-04 17:10:05 -05:00
sl . append ( QString ( " %1 " ) . arg ( command - > getKeyLabel ( ) ) ) ; // key column
2018-01-04 05:11:53 -05:00
CommandItem * item = new CommandItem ( group , sl , command - > getDescription ( ) , PItem ) ;
2020-04-19 00:13:32 -04:00
item - > setData ( 0 , Qt : : UserRole , QVariant : : fromValue ( command ) ) ;
2018-01-04 05:11:53 -05:00
item - > setTextAlignment ( 0 , Qt : : AlignLeft ) ;
2018-01-04 17:10:05 -05:00
ui - > commandTree - > resizeColumnToContents ( 0 ) ; // Resize description column to minimum
ui - > commandTree - > resizeColumnToContents ( 1 ) ; // Resize key column to minimum
ui - > commandTree - > resizeColumnToContents ( 2 ) ; // Resize key press/release column to minimum
2018-01-04 05:11:53 -05:00
//updatePresetControls();
return item ;
}
2017-10-22 13:12:43 -04:00
void MainWindow : : applySettings ( )
{
2020-10-10 14:08:11 -04:00
loadPresetSettings ( m_mainCore - > m_settings . getWorkingPreset ( ) , 0 ) ;
loadFeatureSetPresetSettings ( m_mainCore - > m_settings . getWorkingFeatureSetPreset ( ) , 0 ) ;
2019-08-11 19:46:27 -04:00
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . sortPresets ( ) ;
int middleIndex = m_mainCore - > m_settings . getPresetCount ( ) / 2 ;
2019-08-11 19:46:27 -04:00
QTreeWidgetItem * treeItem ;
ui - > presetTree - > clear ( ) ;
2020-10-10 14:08:11 -04:00
for ( int i = 0 ; i < m_mainCore - > m_settings . getPresetCount ( ) ; + + i )
2019-08-11 19:46:27 -04:00
{
2020-10-10 14:08:11 -04:00
treeItem = addPresetToTree ( m_mainCore - > m_settings . getPreset ( i ) ) ;
2019-08-11 19:46:27 -04:00
if ( i = = middleIndex ) {
ui - > presetTree - > setCurrentItem ( treeItem ) ;
}
}
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . sortCommands ( ) ;
2019-08-11 19:46:27 -04:00
ui - > commandTree - > clear ( ) ;
2020-10-10 14:08:11 -04:00
for ( int i = 0 ; i < m_mainCore - > m_settings . getCommandCount ( ) ; + + i ) {
treeItem = addCommandToTree ( m_mainCore - > m_settings . getCommand ( i ) ) ;
2019-08-11 19:46:27 -04:00
}
2020-10-10 14:08:11 -04:00
m_mainCore - > setLoggingOptions ( ) ;
2017-10-22 13:12:43 -04:00
}
2017-11-25 10:08:18 -05:00
bool MainWindow : : handleMessage ( const Message & cmd )
{
2020-10-10 14:08:11 -04:00
if ( MainCore : : MsgLoadPreset : : match ( cmd ) )
2017-11-25 10:08:18 -05:00
{
2020-10-10 14:08:11 -04:00
MainCore : : MsgLoadPreset & notif = ( MainCore : : MsgLoadPreset & ) cmd ;
2017-11-25 10:08:18 -05:00
loadPresetSettings ( notif . getPreset ( ) , notif . getDeviceSetIndex ( ) ) ;
return true ;
}
2020-10-10 14:08:11 -04:00
else if ( MainCore : : MsgSavePreset : : match ( cmd ) )
2017-11-25 10:47:13 -05:00
{
2020-10-10 14:08:11 -04:00
MainCore : : MsgSavePreset & notif = ( MainCore : : MsgSavePreset & ) cmd ;
2017-11-25 10:47:13 -05:00
savePresetSettings ( notif . getPreset ( ) , notif . getDeviceSetIndex ( ) ) ;
if ( notif . isNewPreset ( ) ) { ui - > presetTree - > setCurrentItem ( addPresetToTree ( notif . getPreset ( ) ) ) ; }
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . sortPresets ( ) ;
m_mainCore - > m_settings . save ( ) ;
2020-09-23 23:38:05 -04:00
return true ;
}
2020-10-10 14:08:11 -04:00
else if ( MainCore : : MsgLoadFeatureSetPreset : : match ( cmd ) )
2020-09-23 23:38:05 -04:00
{
2020-10-10 14:08:11 -04:00
MainCore : : MsgLoadFeatureSetPreset & notif = ( MainCore : : MsgLoadFeatureSetPreset & ) cmd ;
2020-09-23 23:38:05 -04:00
loadFeatureSetPresetSettings ( notif . getPreset ( ) , notif . getFeatureSetIndex ( ) ) ;
return true ;
}
2020-10-10 14:08:11 -04:00
else if ( MainCore : : MsgSaveFeatureSetPreset : : match ( cmd ) )
2020-09-23 23:38:05 -04:00
{
2020-10-10 14:08:11 -04:00
MainCore : : MsgSaveFeatureSetPreset & notif = ( MainCore : : MsgSaveFeatureSetPreset & ) cmd ;
2020-09-23 23:38:05 -04:00
saveFeatureSetPresetSettings ( notif . getPreset ( ) , notif . getFeatureSetIndex ( ) ) ;
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . sortFeatureSetPresets ( ) ;
m_mainCore - > m_settings . save ( ) ;
2017-11-25 10:47:13 -05:00
return true ;
}
2020-10-10 14:08:11 -04:00
else if ( MainCore : : MsgDeletePreset : : match ( cmd ) )
2017-11-25 13:42:56 -05:00
{
2020-10-10 14:08:11 -04:00
MainCore : : MsgDeletePreset & notif = ( MainCore : : MsgDeletePreset & ) cmd ;
2017-11-25 13:42:56 -05:00
const Preset * presetToDelete = notif . getPreset ( ) ;
// remove preset from tree
for ( int ig = 0 ; ig < ui - > presetTree - > topLevelItemCount ( ) ; ig + + )
{
QTreeWidgetItem * groupItem = ui - > presetTree - > topLevelItem ( ig ) ;
if ( groupItem - > text ( 0 ) = = presetToDelete - > getGroup ( ) )
{
for ( int ip = 0 ; ip < groupItem - > childCount ( ) ; ip + + )
{
QTreeWidgetItem * presetItem = groupItem - > child ( ip ) ;
const Preset * preset = qvariant_cast < const Preset * > ( presetItem - > data ( 0 , Qt : : UserRole ) ) ;
if ( ( preset - > getGroup ( ) = = presetToDelete - > getGroup ( ) ) & &
( preset - > getCenterFrequency ( ) = = presetToDelete - > getCenterFrequency ( ) ) & &
( preset - > getDescription ( ) = = presetToDelete - > getDescription ( ) ) & &
2019-09-13 07:40:31 -04:00
( preset - > getPresetType ( ) = = presetToDelete - > getPresetType ( ) ) )
2017-11-25 13:42:56 -05:00
{
groupItem - > takeChild ( ip ) ;
}
}
}
}
// remove preset from settings
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . deletePreset ( presetToDelete ) ;
2017-11-25 13:42:56 -05:00
return true ;
}
2021-09-03 23:58:06 -04:00
else if ( MainCore : : MsgDeleteFeatureSetPreset : : match ( cmd ) )
{
MainCore : : MsgDeleteFeatureSetPreset & notif = ( MainCore : : MsgDeleteFeatureSetPreset & ) cmd ;
const FeatureSetPreset * presetToDelete = notif . getPreset ( ) ;
// remove preset from settings
m_mainCore - > m_settings . deleteFeatureSetPreset ( presetToDelete ) ;
return true ;
}
2020-10-10 14:08:11 -04:00
else if ( MainCore : : MsgAddDeviceSet : : match ( cmd ) )
2017-11-25 16:52:24 -05:00
{
2020-10-10 14:08:11 -04:00
MainCore : : MsgAddDeviceSet & notif = ( MainCore : : MsgAddDeviceSet & ) cmd ;
2019-05-08 19:12:40 -04:00
int direction = notif . getDirection ( ) ;
2017-11-25 16:52:24 -05:00
2019-05-08 19:12:40 -04:00
if ( direction = = 1 ) { // Single stream Tx
2017-11-25 16:52:24 -05:00
addSinkDevice ( ) ;
2019-05-08 19:12:40 -04:00
} else if ( direction = = 0 ) { // Single stream Rx
2017-12-25 03:10:19 -05:00
addSourceDevice ( - 1 ) ; // create with file source device by default
2020-11-10 06:08:58 -05:00
} else if ( direction = = 2 ) { // MIMO
addMIMODevice ( ) ;
2019-05-18 05:59:56 -04:00
}
2017-11-25 16:52:24 -05:00
return true ;
}
2020-10-10 14:08:11 -04:00
else if ( MainCore : : MsgRemoveLastDeviceSet : : match ( cmd ) )
2017-11-25 16:52:24 -05:00
{
if ( m_deviceUIs . size ( ) > 1 ) {
removeLastDevice ( ) ;
}
return true ;
}
2020-10-10 14:08:11 -04:00
else if ( MainCore : : MsgSetDevice : : match ( cmd ) )
2017-11-27 02:14:07 -05:00
{
2020-10-10 14:08:11 -04:00
MainCore : : MsgSetDevice & notif = ( MainCore : : MsgSetDevice & ) cmd ;
2020-09-13 12:32:33 -04:00
ui - > tabInputsView - > setCurrentIndex ( notif . getDeviceSetIndex ( ) ) ;
2020-09-13 11:50:24 -04:00
ui - > inputViewDock - > setSelectedDeviceIndex ( notif . getDeviceSetIndex ( ) , notif . getDeviceIndex ( ) ) ;
2020-09-13 12:32:33 -04:00
samplingDeviceChanged ( notif . getDeviceType ( ) , notif . getDeviceSetIndex ( ) , notif . getDeviceIndex ( ) ) ;
2017-11-27 02:14:07 -05:00
return true ;
}
2021-08-21 14:09:57 -04:00
else if ( MainCore : : MsgAddFeatureSet : : match ( cmd ) )
{
addFeatureSet ( ) ;
return true ;
}
else if ( MainCore : : MsgRemoveLastFeatureSet : : match ( cmd ) )
{
if ( m_mainCore - > m_featureSets . size ( ) ! = 0 ) {
removeFeatureSet ( m_mainCore - > m_featureSets . size ( ) - 1 ) ;
}
return true ;
}
2020-10-10 14:08:11 -04:00
else if ( MainCore : : MsgAddChannel : : match ( cmd ) )
2017-12-10 19:18:10 -05:00
{
2020-10-10 14:08:11 -04:00
MainCore : : MsgAddChannel & notif = ( MainCore : : MsgAddChannel & ) cmd ;
2020-09-13 12:32:33 -04:00
ui - > tabInputsView - > setCurrentIndex ( notif . getDeviceSetIndex ( ) ) ;
2020-09-12 04:37:16 -04:00
channelAddClicked ( notif . getChannelRegistrationIndex ( ) ) ;
2017-12-10 19:18:10 -05:00
return true ;
}
2020-10-10 14:08:11 -04:00
else if ( MainCore : : MsgDeleteChannel : : match ( cmd ) )
2017-12-23 17:41:37 -05:00
{
2020-10-10 14:08:11 -04:00
MainCore : : MsgDeleteChannel & notif = ( MainCore : : MsgDeleteChannel & ) cmd ;
2017-12-23 17:41:37 -05:00
deleteChannel ( notif . getDeviceSetIndex ( ) , notif . getChannelIndex ( ) ) ;
return true ;
}
2020-10-10 14:08:11 -04:00
else if ( MainCore : : MsgDeviceSetFocus : : match ( cmd ) )
2018-01-05 21:46:53 -05:00
{
2020-10-10 14:08:11 -04:00
MainCore : : MsgDeviceSetFocus & notif = ( MainCore : : MsgDeviceSetFocus & ) cmd ;
2018-01-05 21:46:53 -05:00
int index = notif . getDeviceSetIndex ( ) ;
if ( ( index > = 0 ) & & ( index < ( int ) m_deviceUIs . size ( ) ) ) {
ui - > tabInputsView - > setCurrentIndex ( index ) ;
}
}
2020-10-10 14:08:11 -04:00
else if ( MainCore : : MsgAddFeature : : match ( cmd ) )
2020-09-20 21:13:36 -04:00
{
2020-10-10 14:08:11 -04:00
MainCore : : MsgAddFeature & notif = ( MainCore : : MsgAddFeature & ) cmd ;
2020-09-20 21:13:36 -04:00
ui - > tabFeatures - > setCurrentIndex ( notif . getFeatureSetIndex ( ) ) ;
featureAddClicked ( notif . getFeatureRegistrationIndex ( ) ) ;
return true ;
}
2020-10-10 14:08:11 -04:00
else if ( MainCore : : MsgDeleteFeature : : match ( cmd ) )
2020-09-20 21:13:36 -04:00
{
2020-10-10 14:08:11 -04:00
MainCore : : MsgDeleteFeature & notif = ( MainCore : : MsgDeleteFeature & ) cmd ;
2020-09-20 21:13:36 -04:00
deleteFeature ( notif . getFeatureSetIndex ( ) , notif . getFeatureIndex ( ) ) ;
return true ;
}
2020-10-10 14:08:11 -04:00
else if ( MainCore : : MsgApplySettings : : match ( cmd ) )
2019-08-10 19:27:19 -04:00
{
applySettings ( ) ;
return true ;
}
2020-10-10 14:08:11 -04:00
else if ( MainCore : : MsgDVSerial : : match ( cmd ) )
{
MainCore : : MsgDVSerial & notif = ( MainCore : : MsgDVSerial & ) cmd ;
ui - > action_DV_Serial - > setChecked ( notif . getActive ( ) ) ;
return true ;
}
2017-11-25 10:08:18 -05:00
return false ;
}
2017-10-22 13:12:43 -04:00
void MainWindow : : handleMessages ( )
{
Message * message ;
while ( ( message = m_inputMessageQueue . pop ( ) ) ! = 0 )
{
qDebug ( " MainWindow::handleMessages: message: %s " , message - > getIdentifier ( ) ) ;
2017-11-25 10:08:18 -05:00
handleMessage ( * message ) ;
2017-10-22 13:12:43 -04:00
delete message ;
}
}
void MainWindow : : on_action_View_Fullscreen_toggled ( bool checked )
{
2018-01-04 17:10:05 -05:00
if ( checked ) {
2017-10-22 13:12:43 -04:00
showFullScreen ( ) ;
2018-01-04 17:10:05 -05:00
} else {
showNormal ( ) ;
}
2017-10-22 13:12:43 -04:00
}
2018-01-04 05:11:53 -05:00
void MainWindow : : on_commandNew_clicked ( )
{
QStringList groups ;
QString group = " " ;
QString description = " " ;
for ( int i = 0 ; i < ui - > commandTree - > topLevelItemCount ( ) ; i + + ) {
groups . append ( ui - > commandTree - > topLevelItem ( i ) - > text ( 0 ) ) ;
}
QTreeWidgetItem * item = ui - > commandTree - > currentItem ( ) ;
if ( item ! = 0 )
{
if ( item - > type ( ) = = PGroup ) {
group = item - > text ( 0 ) ;
} else if ( item - > type ( ) = = PItem ) {
group = item - > parent ( ) - > text ( 0 ) ;
description = item - > text ( 0 ) ;
}
}
Command * command = new Command ( ) ;
command - > setGroup ( group ) ;
command - > setDescription ( description ) ;
EditCommandDialog editCommandDialog ( groups , group , this ) ;
editCommandDialog . fromCommand ( * command ) ;
if ( editCommandDialog . exec ( ) = = QDialog : : Accepted )
{
editCommandDialog . toCommand ( * command ) ;
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . addCommand ( command ) ;
2018-01-04 05:11:53 -05:00
ui - > commandTree - > setCurrentItem ( addCommandToTree ( command ) ) ;
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . sortCommands ( ) ;
2018-01-04 05:11:53 -05:00
}
}
void MainWindow : : on_commandDuplicate_clicked ( )
{
QTreeWidgetItem * item = ui - > commandTree - > currentItem ( ) ;
const Command * command = qvariant_cast < const Command * > ( item - > data ( 0 , Qt : : UserRole ) ) ;
Command * commandCopy = new Command ( * command ) ;
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . addCommand ( commandCopy ) ;
2018-01-04 05:11:53 -05:00
ui - > commandTree - > setCurrentItem ( addCommandToTree ( commandCopy ) ) ;
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . sortCommands ( ) ;
2018-01-04 05:11:53 -05:00
}
void MainWindow : : on_commandEdit_clicked ( )
{
QTreeWidgetItem * item = ui - > commandTree - > currentItem ( ) ;
2018-01-05 05:45:20 -05:00
bool change = false ;
const Command * changedCommand = 0 ;
QString newGroupName ;
QStringList groups ;
for ( int i = 0 ; i < ui - > commandTree - > topLevelItemCount ( ) ; i + + ) {
groups . append ( ui - > commandTree - > topLevelItem ( i ) - > text ( 0 ) ) ;
}
2018-01-04 05:11:53 -05:00
if ( item ! = 0 )
{
2018-01-05 05:45:20 -05:00
if ( item - > type ( ) = = PItem )
2018-01-04 05:11:53 -05:00
{
const Command * command = qvariant_cast < const Command * > ( item - > data ( 0 , Qt : : UserRole ) ) ;
if ( command ! = 0 )
{
EditCommandDialog editCommandDialog ( groups , command - > getGroup ( ) , this ) ;
editCommandDialog . fromCommand ( * command ) ;
if ( editCommandDialog . exec ( ) = = QDialog : : Accepted )
{
Command * command_mod = const_cast < Command * > ( command ) ;
editCommandDialog . toCommand ( * command_mod ) ;
2018-01-05 05:45:20 -05:00
change = true ;
changedCommand = command ;
}
}
}
else if ( item - > type ( ) = = PGroup )
{
AddPresetDialog dlg ( groups , item - > text ( 0 ) , this ) ;
dlg . showGroupOnly ( ) ;
dlg . setDialogTitle ( " Edit command group " ) ;
dlg . setDescriptionBoxTitle ( " Command details " ) ;
if ( dlg . exec ( ) = = QDialog : : Accepted )
{
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . renameCommandGroup ( item - > text ( 0 ) , dlg . group ( ) ) ;
2018-01-05 05:45:20 -05:00
newGroupName = dlg . group ( ) ;
change = true ;
}
}
}
2018-01-04 05:11:53 -05:00
2018-01-05 05:45:20 -05:00
if ( change )
{
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . sortCommands ( ) ;
2018-01-05 05:45:20 -05:00
ui - > commandTree - > clear ( ) ;
2018-01-04 05:11:53 -05:00
2020-10-10 14:08:11 -04:00
for ( int i = 0 ; i < m_mainCore - > m_settings . getCommandCount ( ) ; + + i )
2018-01-05 05:45:20 -05:00
{
2020-10-10 14:08:11 -04:00
QTreeWidgetItem * item_x = addCommandToTree ( m_mainCore - > m_settings . getCommand ( i ) ) ;
2018-01-05 05:45:20 -05:00
const Command * command_x = qvariant_cast < const Command * > ( item_x - > data ( 0 , Qt : : UserRole ) ) ;
if ( changedCommand & & ( command_x = = changedCommand ) ) { // set cursor on changed command
ui - > commandTree - > setCurrentItem ( item_x ) ;
}
}
if ( ! changedCommand ) // on group name change set cursor on the group that has been changed
{
for ( int i = 0 ; i < ui - > commandTree - > topLevelItemCount ( ) ; i + + )
{
QTreeWidgetItem * item = ui - > commandTree - > topLevelItem ( i ) ;
if ( item - > text ( 0 ) = = newGroupName ) {
ui - > commandTree - > setCurrentItem ( item ) ;
2018-01-04 05:11:53 -05:00
}
}
}
}
}
void MainWindow : : on_commandDelete_clicked ( )
{
QTreeWidgetItem * item = ui - > commandTree - > currentItem ( ) ;
2018-01-06 14:02:08 -05:00
if ( item ! = 0 )
{
if ( item - > type ( ) = = PItem ) // delete individual command
{
const Command * command = qvariant_cast < const Command * > ( item - > data ( 0 , Qt : : UserRole ) ) ;
2018-01-04 05:11:53 -05:00
2018-01-06 14:02:08 -05:00
if ( command )
{
if ( QMessageBox : : question ( this ,
tr ( " Delete command " ) ,
tr ( " Do you want to delete command '%1'? " )
. arg ( command - > getDescription ( ) ) , QMessageBox : : No | QMessageBox : : Yes , QMessageBox : : No ) = = QMessageBox : : Yes )
{
delete item ;
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . deleteCommand ( command ) ;
2018-01-06 14:02:08 -05:00
}
}
}
else if ( item - > type ( ) = = PGroup ) // delete all commands in this group
{
if ( QMessageBox : : question ( this ,
tr ( " Delete command group " ) ,
tr ( " Do you want to delete command group '%1'? " )
. arg ( item - > text ( 0 ) ) , QMessageBox : : No | QMessageBox : : Yes , QMessageBox : : No ) = = QMessageBox : : Yes )
{
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . deleteCommandGroup ( item - > text ( 0 ) ) ;
2018-01-04 05:11:53 -05:00
2018-01-06 14:02:08 -05:00
ui - > commandTree - > clear ( ) ;
2018-01-04 05:11:53 -05:00
2020-10-10 14:08:11 -04:00
for ( int i = 0 ; i < m_mainCore - > m_settings . getCommandCount ( ) ; + + i ) {
addCommandToTree ( m_mainCore - > m_settings . getCommand ( i ) ) ;
2018-01-06 14:02:08 -05:00
}
}
}
2018-01-04 05:11:53 -05:00
}
}
2018-01-04 14:15:33 -05:00
void MainWindow : : on_commandRun_clicked ( )
{
QTreeWidgetItem * item = ui - > commandTree - > currentItem ( ) ;
2018-01-06 14:02:08 -05:00
if ( item ! = 0 )
2018-01-04 14:15:33 -05:00
{
2020-09-13 12:32:33 -04:00
int currentDeviceSetIndex = ui - > tabInputsView - > currentIndex ( ) ;
2018-01-06 14:02:08 -05:00
if ( item - > type ( ) = = PItem ) // run individual command
{
const Command * command = qvariant_cast < const Command * > ( item - > data ( 0 , Qt : : UserRole ) ) ;
Command * command_mod = const_cast < Command * > ( command ) ;
command_mod - > run ( m_apiServer - > getHost ( ) , m_apiServer - > getPort ( ) , currentDeviceSetIndex ) ;
}
else if ( item - > type ( ) = = PGroup ) // run all commands in this group
{
QString group = item - > text ( 0 ) ;
2020-10-10 14:08:11 -04:00
for ( int i = 0 ; i < m_mainCore - > m_settings . getCommandCount ( ) ; + + i )
2018-01-06 14:02:08 -05:00
{
2020-10-10 14:08:11 -04:00
Command * command_mod = const_cast < Command * > ( m_mainCore - > m_settings . getCommand ( i ) ) ;
2018-01-06 14:02:08 -05:00
if ( command_mod - > getGroup ( ) = = group ) {
command_mod - > run ( m_apiServer - > getHost ( ) , m_apiServer - > getPort ( ) , currentDeviceSetIndex ) ;
}
}
}
2018-01-04 14:15:33 -05:00
}
}
void MainWindow : : on_commandOutput_clicked ( )
{
QTreeWidgetItem * item = ui - > commandTree - > currentItem ( ) ;
if ( ( item ! = 0 ) & & ( item - > type ( ) = = PItem ) )
{
const Command * command = qvariant_cast < const Command * > ( item - > data ( 0 , Qt : : UserRole ) ) ;
Command * command_mod = const_cast < Command * > ( command ) ;
CommandOutputDialog commandOutputDialog ( * command_mod ) ;
commandOutputDialog . exec ( ) ;
}
}
2018-01-05 05:54:05 -05:00
void MainWindow : : on_commandsSave_clicked ( )
{
saveCommandSettings ( ) ;
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . save ( ) ;
2018-01-05 05:54:05 -05:00
}
2019-07-29 12:54:50 -04:00
void MainWindow : : commandKeysConnect ( QObject * object , const char * slot )
{
setFocus ( ) ;
connect ( m_commandKeyReceiver , SIGNAL ( capturedKey ( Qt : : Key , Qt : : KeyboardModifiers , bool ) ) ,
object , slot ) ;
}
void MainWindow : : commandKeysDisconnect ( QObject * object , const char * slot )
{
disconnect ( m_commandKeyReceiver , SIGNAL ( capturedKey ( Qt : : Key , Qt : : KeyboardModifiers , bool ) ) ,
object , slot ) ;
}
2018-01-04 23:05:12 -05:00
void MainWindow : : on_commandKeyboardConnect_toggled ( bool checked )
{
qDebug ( " on_commandKeyboardConnect_toggled: %s " , checked ? " true " : " false " ) ;
if ( checked )
{
2019-07-29 12:54:50 -04:00
commandKeysConnect ( this , SLOT ( commandKeyPressed ( Qt : : Key , Qt : : KeyboardModifiers , bool ) ) ) ;
2018-01-04 23:05:12 -05:00
}
else
{
2019-07-29 12:54:50 -04:00
commandKeysDisconnect ( this , SLOT ( commandKeyPressed ( Qt : : Key , Qt : : KeyboardModifiers , bool ) ) ) ;
2018-01-04 23:05:12 -05:00
}
}
2017-10-22 13:12:43 -04:00
void MainWindow : : on_presetSave_clicked ( )
{
2018-01-04 05:11:53 -05:00
QStringList groups ;
QString group ;
QString description = " " ;
2017-10-22 13:12:43 -04:00
2018-01-04 05:11:53 -05:00
for ( int i = 0 ; i < ui - > presetTree - > topLevelItemCount ( ) ; i + + ) {
groups . append ( ui - > presetTree - > topLevelItem ( i ) - > text ( 0 ) ) ;
}
2017-10-22 13:12:43 -04:00
2018-01-04 05:11:53 -05:00
QTreeWidgetItem * item = ui - > presetTree - > currentItem ( ) ;
2017-10-22 13:12:43 -04:00
2018-01-04 05:11:53 -05:00
if ( item ! = 0 )
{
if ( item - > type ( ) = = PGroup ) {
group = item - > text ( 0 ) ;
} else if ( item - > type ( ) = = PItem ) {
group = item - > parent ( ) - > text ( 0 ) ;
description = item - > text ( 0 ) ;
}
}
2017-10-22 13:12:43 -04:00
2018-01-04 05:11:53 -05:00
AddPresetDialog dlg ( groups , group , this ) ;
2017-10-22 13:12:43 -04:00
2018-01-04 05:11:53 -05:00
if ( description . length ( ) > 0 ) {
dlg . setDescription ( description ) ;
}
2017-11-25 05:14:52 -05:00
2018-01-04 05:11:53 -05:00
if ( dlg . exec ( ) = = QDialog : : Accepted ) {
2020-10-10 14:08:11 -04:00
Preset * preset = m_mainCore - > m_settings . newPreset ( dlg . group ( ) , dlg . description ( ) ) ;
2018-01-04 05:11:53 -05:00
savePresetSettings ( preset , ui - > tabInputsView - > currentIndex ( ) ) ;
ui - > presetTree - > setCurrentItem ( addPresetToTree ( preset ) ) ;
}
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . sortPresets ( ) ;
2017-10-22 13:12:43 -04:00
}
void MainWindow : : on_presetUpdate_clicked ( )
{
QTreeWidgetItem * item = ui - > presetTree - > currentItem ( ) ;
2018-01-05 20:44:45 -05:00
const Preset * changedPreset = 0 ;
2017-10-22 13:12:43 -04:00
2018-01-04 05:11:53 -05:00
if ( item ! = 0 )
{
if ( item - > type ( ) = = PItem )
{
2017-10-22 13:12:43 -04:00
const Preset * preset = qvariant_cast < const Preset * > ( item - > data ( 0 , Qt : : UserRole ) ) ;
2018-01-04 05:11:53 -05:00
if ( preset ! = 0 )
{
2017-10-22 13:12:43 -04:00
Preset * preset_mod = const_cast < Preset * > ( preset ) ;
savePresetSettings ( preset_mod , ui - > tabInputsView - > currentIndex ( ) ) ;
2018-01-05 12:39:37 -05:00
changedPreset = preset ;
2017-10-22 13:12:43 -04:00
}
}
}
2017-11-25 05:14:52 -05:00
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . sortPresets ( ) ;
2018-01-05 12:39:37 -05:00
ui - > presetTree - > clear ( ) ;
2020-10-10 14:08:11 -04:00
for ( int i = 0 ; i < m_mainCore - > m_settings . getPresetCount ( ) ; + + i )
2018-01-05 12:39:37 -05:00
{
2020-10-10 14:08:11 -04:00
QTreeWidgetItem * item_x = addPresetToTree ( m_mainCore - > m_settings . getPreset ( i ) ) ;
2018-01-05 12:39:37 -05:00
const Preset * preset_x = qvariant_cast < const Preset * > ( item_x - > data ( 0 , Qt : : UserRole ) ) ;
if ( changedPreset & & ( preset_x = = changedPreset ) ) { // set cursor on changed preset
ui - > presetTree - > setCurrentItem ( item_x ) ;
}
}
2017-10-22 13:12:43 -04:00
}
2018-01-05 05:45:20 -05:00
void MainWindow : : on_presetEdit_clicked ( )
{
QTreeWidgetItem * item = ui - > presetTree - > currentItem ( ) ;
QStringList groups ;
bool change = false ;
const Preset * changedPreset = 0 ;
QString newGroupName ;
for ( int i = 0 ; i < ui - > presetTree - > topLevelItemCount ( ) ; i + + ) {
groups . append ( ui - > presetTree - > topLevelItem ( i ) - > text ( 0 ) ) ;
}
if ( item ! = 0 )
{
if ( item - > type ( ) = = PItem )
{
const Preset * preset = qvariant_cast < const Preset * > ( item - > data ( 0 , Qt : : UserRole ) ) ;
AddPresetDialog dlg ( groups , preset - > getGroup ( ) , this ) ;
dlg . setDescription ( preset - > getDescription ( ) ) ;
if ( dlg . exec ( ) = = QDialog : : Accepted )
{
Preset * preset_mod = const_cast < Preset * > ( preset ) ;
preset_mod - > setGroup ( dlg . group ( ) ) ;
preset_mod - > setDescription ( dlg . description ( ) ) ;
change = true ;
changedPreset = preset ;
}
}
else if ( item - > type ( ) = = PGroup )
{
AddPresetDialog dlg ( groups , item - > text ( 0 ) , this ) ;
dlg . showGroupOnly ( ) ;
dlg . setDialogTitle ( " Edit preset group " ) ;
if ( dlg . exec ( ) = = QDialog : : Accepted )
{
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . renamePresetGroup ( item - > text ( 0 ) , dlg . group ( ) ) ;
2018-01-05 05:45:20 -05:00
newGroupName = dlg . group ( ) ;
change = true ;
}
}
}
if ( change )
{
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . sortPresets ( ) ;
2018-01-05 05:45:20 -05:00
ui - > presetTree - > clear ( ) ;
2020-10-10 14:08:11 -04:00
for ( int i = 0 ; i < m_mainCore - > m_settings . getPresetCount ( ) ; + + i )
2018-01-05 05:45:20 -05:00
{
2020-10-10 14:08:11 -04:00
QTreeWidgetItem * item_x = addPresetToTree ( m_mainCore - > m_settings . getPreset ( i ) ) ;
2018-01-05 05:45:20 -05:00
const Preset * preset_x = qvariant_cast < const Preset * > ( item_x - > data ( 0 , Qt : : UserRole ) ) ;
if ( changedPreset & & ( preset_x = = changedPreset ) ) { // set cursor on changed preset
ui - > presetTree - > setCurrentItem ( item_x ) ;
}
}
if ( ! changedPreset ) // on group name change set cursor on the group that has been changed
{
for ( int i = 0 ; i < ui - > presetTree - > topLevelItemCount ( ) ; i + + )
{
QTreeWidgetItem * item = ui - > presetTree - > topLevelItem ( i ) ;
if ( item - > text ( 0 ) = = newGroupName ) {
ui - > presetTree - > setCurrentItem ( item ) ;
}
}
}
}
}
2017-10-22 13:12:43 -04:00
void MainWindow : : on_presetExport_clicked ( )
{
QTreeWidgetItem * item = ui - > presetTree - > currentItem ( ) ;
if ( item ! = 0 ) {
if ( item - > type ( ) = = PItem )
{
const Preset * preset = qvariant_cast < const Preset * > ( item - > data ( 0 , Qt : : UserRole ) ) ;
QString base64Str = preset - > serialize ( ) . toBase64 ( ) ;
QString fileName = QFileDialog : : getSaveFileName ( this ,
2018-05-10 18:00:15 -04:00
tr ( " Open preset export file " ) , " . " , tr ( " Preset export files (*.prex) " ) , 0 , QFileDialog : : DontUseNativeDialog ) ;
2017-10-22 13:12:43 -04:00
if ( fileName ! = " " )
{
QFileInfo fileInfo ( fileName ) ;
if ( fileInfo . suffix ( ) ! = " prex " ) {
fileName + = " .prex " ;
}
QFile exportFile ( fileName ) ;
if ( exportFile . open ( QIODevice : : WriteOnly | QIODevice : : Text ) )
{
QTextStream outstream ( & exportFile ) ;
outstream < < base64Str ;
exportFile . close ( ) ;
}
else
{
QMessageBox : : information ( this , tr ( " Message " ) , tr ( " Cannot open file for writing " ) ) ;
}
}
}
}
}
void MainWindow : : on_presetImport_clicked ( )
{
QTreeWidgetItem * item = ui - > presetTree - > currentItem ( ) ;
if ( item ! = 0 )
{
QString group ;
if ( item - > type ( ) = = PGroup ) {
group = item - > text ( 0 ) ;
} else if ( item - > type ( ) = = PItem ) {
group = item - > parent ( ) - > text ( 0 ) ;
} else {
return ;
}
QString fileName = QFileDialog : : getOpenFileName ( this ,
2018-05-10 18:00:15 -04:00
tr ( " Open preset export file " ) , " . " , tr ( " Preset export files (*.prex) " ) , 0 , QFileDialog : : DontUseNativeDialog ) ;
2017-10-22 13:12:43 -04:00
if ( fileName ! = " " )
{
QFile exportFile ( fileName ) ;
if ( exportFile . open ( QIODevice : : ReadOnly | QIODevice : : Text ) )
{
QByteArray base64Str ;
QTextStream instream ( & exportFile ) ;
instream > > base64Str ;
exportFile . close ( ) ;
2020-10-10 14:08:11 -04:00
Preset * preset = m_mainCore - > m_settings . newPreset ( " " , " " ) ;
2017-10-22 13:12:43 -04:00
preset - > deserialize ( QByteArray : : fromBase64 ( base64Str ) ) ;
preset - > setGroup ( group ) ; // override with current group
ui - > presetTree - > setCurrentItem ( addPresetToTree ( preset ) ) ;
}
else
{
QMessageBox : : information ( this , tr ( " Message " ) , tr ( " Cannot open file for reading " ) ) ;
}
}
}
}
void MainWindow : : on_settingsSave_clicked ( )
{
2020-10-10 14:08:11 -04:00
savePresetSettings ( m_mainCore - > m_settings . getWorkingPreset ( ) , ui - > tabInputsView - > currentIndex ( ) ) ;
saveFeatureSetPresetSettings ( m_mainCore - > m_settings . getWorkingFeatureSetPreset ( ) , ui - > tabFeatures - > currentIndex ( ) ) ;
m_mainCore - > m_settings . save ( ) ;
2017-10-22 13:12:43 -04:00
}
void MainWindow : : on_presetLoad_clicked ( )
{
qDebug ( ) < < " MainWindow::on_presetLoad_clicked " ;
QTreeWidgetItem * item = ui - > presetTree - > currentItem ( ) ;
if ( item = = 0 )
{
qDebug ( " MainWindow::on_presetLoad_clicked: item null " ) ;
updatePresetControls ( ) ;
return ;
}
const Preset * preset = qvariant_cast < const Preset * > ( item - > data ( 0 , Qt : : UserRole ) ) ;
if ( preset = = 0 )
{
qDebug ( " MainWindow::on_presetLoad_clicked: preset null " ) ;
return ;
}
loadPresetSettings ( preset , ui - > tabInputsView - > currentIndex ( ) ) ;
}
void MainWindow : : on_presetDelete_clicked ( )
{
QTreeWidgetItem * item = ui - > presetTree - > currentItem ( ) ;
2018-01-06 14:02:08 -05:00
if ( item = = 0 )
{
2017-10-22 13:12:43 -04:00
updatePresetControls ( ) ;
return ;
}
2018-01-06 14:02:08 -05:00
else
{
if ( item - > type ( ) = = PItem )
{
const Preset * preset = qvariant_cast < const Preset * > ( item - > data ( 0 , Qt : : UserRole ) ) ;
2017-10-22 13:12:43 -04:00
2018-01-06 14:02:08 -05:00
if ( preset )
{
if ( QMessageBox : : question ( this , tr ( " Delete Preset " ) , tr ( " Do you want to delete preset '%1'? " ) . arg ( preset - > getDescription ( ) ) , QMessageBox : : No | QMessageBox : : Yes , QMessageBox : : No ) = = QMessageBox : : Yes ) {
delete item ;
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . deletePreset ( preset ) ;
2018-01-06 14:02:08 -05:00
}
}
}
else if ( item - > type ( ) = = PGroup )
{
if ( QMessageBox : : question ( this ,
tr ( " Delete preset group " ) ,
tr ( " Do you want to delete preset group '%1'? " )
. arg ( item - > text ( 0 ) ) , QMessageBox : : No | QMessageBox : : Yes , QMessageBox : : No ) = = QMessageBox : : Yes )
{
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . deletePresetGroup ( item - > text ( 0 ) ) ;
2018-01-06 14:02:08 -05:00
2018-07-18 02:36:28 -04:00
ui - > presetTree - > clear ( ) ;
2018-01-06 14:02:08 -05:00
2020-10-10 14:08:11 -04:00
for ( int i = 0 ; i < m_mainCore - > m_settings . getPresetCount ( ) ; + + i ) {
addPresetToTree ( m_mainCore - > m_settings . getPreset ( i ) ) ;
2018-01-06 14:02:08 -05:00
}
}
}
2017-10-22 13:12:43 -04:00
}
}
2018-11-12 12:36:27 -05:00
void MainWindow : : on_presetTree_currentItemChanged ( QTreeWidgetItem * current , QTreeWidgetItem * previous )
2017-10-22 13:12:43 -04:00
{
2018-11-12 12:36:27 -05:00
( void ) current ;
( void ) previous ;
2017-10-22 13:12:43 -04:00
updatePresetControls ( ) ;
}
2018-11-12 12:36:27 -05:00
void MainWindow : : on_presetTree_itemActivated ( QTreeWidgetItem * item , int column )
2017-10-22 13:12:43 -04:00
{
2018-11-12 12:36:27 -05:00
( void ) item ;
( void ) column ;
2017-10-22 13:12:43 -04:00
on_presetLoad_clicked ( ) ;
}
void MainWindow : : on_action_Loaded_Plugins_triggered ( )
{
PluginsDialog pluginsDialog ( m_pluginManager , this ) ;
pluginsDialog . exec ( ) ;
}
void MainWindow : : on_action_Audio_triggered ( )
{
2018-03-25 07:36:09 -04:00
AudioDialogX audioDialog ( m_dspEngine - > getAudioDeviceManager ( ) , this ) ;
2017-10-22 13:12:43 -04:00
audioDialog . exec ( ) ;
}
2017-11-11 13:26:23 -05:00
void MainWindow : : on_action_Logging_triggered ( )
{
2020-10-10 14:08:11 -04:00
LoggingDialog loggingDialog ( m_mainCore - > m_settings , this ) ;
2017-11-11 13:26:23 -05:00
loggingDialog . exec ( ) ;
2020-10-10 14:08:11 -04:00
m_mainCore - > setLoggingOptions ( ) ;
2017-11-11 13:26:23 -05:00
}
2017-10-22 13:12:43 -04:00
void MainWindow : : on_action_My_Position_triggered ( )
{
2020-10-10 14:08:11 -04:00
MyPositionDialog myPositionDialog ( m_mainCore - > m_settings , this ) ;
2017-10-22 13:12:43 -04:00
myPositionDialog . exec ( ) ;
}
2019-06-12 12:50:53 -04:00
void MainWindow : : on_action_DeviceUserArguments_triggered ( )
{
qDebug ( " MainWindow::on_action_DeviceUserArguments_triggered " ) ;
2020-10-10 14:08:11 -04:00
DeviceUserArgsDialog deviceUserArgsDialog ( DeviceEnumerator : : instance ( ) , m_mainCore - > m_settings . getDeviceUserArgs ( ) , this ) ;
2019-06-12 12:50:53 -04:00
deviceUserArgsDialog . exec ( ) ;
}
2019-07-19 12:38:03 -04:00
void MainWindow : : on_action_AMBE_triggered ( )
{
qDebug ( " MainWindow::on_action_AMBE_triggered " ) ;
2019-10-11 23:39:41 -04:00
# ifndef __APPLE__
2019-07-19 12:38:03 -04:00
AMBEDevicesDialog ambeDevicesDialog ( m_dspEngine - > getAMBEEngine ( ) , this ) ;
ambeDevicesDialog . exec ( ) ;
2019-10-11 23:39:41 -04:00
# endif
2019-07-19 12:38:03 -04:00
}
2020-01-11 19:10:51 -05:00
void MainWindow : : on_action_LimeRFE_triggered ( )
{
qDebug ( " MainWindow::on_action_LimeRFE_triggered " ) ;
2020-01-24 17:05:16 -05:00
# if defined(HAS_LIMERFEUSB)
2020-01-11 19:10:51 -05:00
qDebug ( " MainWindow::on_action_LimeRFE_triggered: activated " ) ;
2020-10-10 14:08:11 -04:00
LimeRFEUSBDialog * limeRFEUSBDialog = new LimeRFEUSBDialog ( m_mainCore - > m_settings . getLimeRFEUSBCalib ( ) , this ) ;
2020-01-11 19:10:51 -05:00
limeRFEUSBDialog - > setModal ( false ) ;
limeRFEUSBDialog - > show ( ) ;
# endif
}
2020-09-13 11:50:24 -04:00
void MainWindow : : samplingDeviceChanged ( int deviceType , int tabIndex , int newDeviceIndex )
{
qDebug ( " MainWindow::samplingDeviceChanged: deviceType: %d tabIndex: %d newDeviceIndex: %d " ,
deviceType , tabIndex , newDeviceIndex ) ;
if ( deviceType = = 0 ) {
sampleSourceChanged ( tabIndex , newDeviceIndex ) ;
} else if ( deviceType = = 1 ) {
sampleSinkChanged ( tabIndex , newDeviceIndex ) ;
2020-11-10 06:08:58 -05:00
} else if ( deviceType = = 2 ) {
sampleMIMOChanged ( tabIndex , newDeviceIndex ) ;
2020-09-13 11:50:24 -04:00
}
}
void MainWindow : : sampleSourceChanged ( int tabIndex , int newDeviceIndex )
{
if ( tabIndex > = 0 )
{
qDebug ( " MainWindow::sampleSourceChanged: tab at %d " , tabIndex ) ;
DeviceUISet * deviceUI = m_deviceUIs [ tabIndex ] ;
2020-10-10 14:08:11 -04:00
deviceUI - > m_deviceAPI - > saveSamplingDeviceSettings ( m_mainCore - > m_settings . getWorkingPreset ( ) ) ; // save old API settings
2020-09-13 11:50:24 -04:00
deviceUI - > m_deviceAPI - > stopDeviceEngine ( ) ;
// deletes old UI and input object
deviceUI - > m_deviceAPI - > getSampleSource ( ) - > setMessageQueueToGUI ( nullptr ) ; // have source stop sending messages to the GUI
2020-11-02 02:29:21 -05:00
m_deviceUIs [ tabIndex ] - > m_deviceGUI - > destroy ( ) ;
2020-09-13 11:50:24 -04:00
deviceUI - > m_deviceAPI - > resetSamplingDeviceId ( ) ;
2020-10-03 00:58:57 -04:00
deviceUI - > m_deviceAPI - > getPluginInterface ( ) - > deleteSampleSourcePluginInstanceInput ( deviceUI - > m_deviceAPI - > getSampleSource ( ) ) ;
2020-09-13 11:50:24 -04:00
deviceUI - > m_deviceAPI - > clearBuddiesLists ( ) ; // clear old API buddies lists
const PluginInterface : : SamplingDevice * samplingDevice = DeviceEnumerator : : instance ( ) - > getRxSamplingDevice ( newDeviceIndex ) ;
qDebug ( " MainWindow::sampleSourceChanged: %s " , qPrintable ( samplingDevice - > hardwareId ) ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceSequence ( samplingDevice - > sequence ) ;
deviceUI - > m_deviceAPI - > setDeviceNbItems ( samplingDevice - > deviceNbItems ) ;
deviceUI - > m_deviceAPI - > setDeviceItemIndex ( samplingDevice - > deviceItemIndex ) ;
deviceUI - > m_deviceAPI - > setHardwareId ( samplingDevice - > hardwareId ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceId ( samplingDevice - > id ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceSerial ( samplingDevice - > serial ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceDisplayName ( samplingDevice - > displayedName ) ;
deviceUI - > m_deviceAPI - > setSamplingDevicePluginInterface ( DeviceEnumerator : : instance ( ) - > getRxPluginInterface ( newDeviceIndex ) ) ;
2021-05-02 07:06:10 -04:00
qDebug ( ) < < " MainWindow::sampleSourceChanged: "
< < " newDeviceIndex: " < < newDeviceIndex
< < " hardwareId: " < < samplingDevice - > hardwareId
< < " sequence: " < < samplingDevice - > sequence
< < " id: " < < samplingDevice - > id
< < " serial: " < < samplingDevice - > serial
< < " displayedName: " < < samplingDevice - > displayedName ;
2020-09-13 11:50:24 -04:00
if ( deviceUI - > m_deviceAPI - > getSamplingDeviceId ( ) . size ( ) = = 0 ) // non existent device => replace by default
{
qDebug ( " MainWindow::sampleSourceChanged: non existent device replaced by File Input " ) ;
int fileInputDeviceIndex = DeviceEnumerator : : instance ( ) - > getFileInputDeviceIndex ( ) ;
samplingDevice = DeviceEnumerator : : instance ( ) - > getRxSamplingDevice ( fileInputDeviceIndex ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceSequence ( samplingDevice - > sequence ) ;
deviceUI - > m_deviceAPI - > setDeviceNbItems ( samplingDevice - > deviceNbItems ) ;
deviceUI - > m_deviceAPI - > setDeviceItemIndex ( samplingDevice - > deviceItemIndex ) ;
deviceUI - > m_deviceAPI - > setHardwareId ( samplingDevice - > hardwareId ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceId ( samplingDevice - > id ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceSerial ( samplingDevice - > serial ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceDisplayName ( samplingDevice - > displayedName ) ;
deviceUI - > m_deviceAPI - > setSamplingDevicePluginInterface ( DeviceEnumerator : : instance ( ) - > getRxPluginInterface ( fileInputDeviceIndex ) ) ;
}
2020-10-10 14:08:11 -04:00
QString userArgs = m_mainCore - > m_settings . getDeviceUserArgs ( ) . findUserArgs ( samplingDevice - > hardwareId , samplingDevice - > sequence ) ;
2020-09-13 11:50:24 -04:00
if ( userArgs . size ( ) > 0 ) {
deviceUI - > m_deviceAPI - > setHardwareUserArguments ( userArgs ) ;
}
// add to buddies list
std : : vector < DeviceUISet * > : : iterator it = m_deviceUIs . begin ( ) ;
int nbOfBuddies = 0 ;
for ( ; it ! = m_deviceUIs . end ( ) ; + + it )
{
if ( * it ! = deviceUI ) // do not add to itself
{
if ( ( * it ) - > m_deviceSourceEngine ) // it is a source device
{
if ( ( deviceUI - > m_deviceAPI - > getHardwareId ( ) = = ( * it ) - > m_deviceAPI - > getHardwareId ( ) ) & &
( deviceUI - > m_deviceAPI - > getSamplingDeviceSerial ( ) = = ( * it ) - > m_deviceAPI - > getSamplingDeviceSerial ( ) ) )
{
( * it ) - > m_deviceAPI - > addSourceBuddy ( deviceUI - > m_deviceAPI ) ;
nbOfBuddies + + ;
}
}
if ( ( * it ) - > m_deviceSinkEngine ) // it is a sink device
{
if ( ( deviceUI - > m_deviceAPI - > getHardwareId ( ) = = ( * it ) - > m_deviceAPI - > getHardwareId ( ) ) & &
( deviceUI - > m_deviceAPI - > getSamplingDeviceSerial ( ) = = ( * it ) - > m_deviceAPI - > getSamplingDeviceSerial ( ) ) )
{
( * it ) - > m_deviceAPI - > addSourceBuddy ( deviceUI - > m_deviceAPI ) ;
nbOfBuddies + + ;
}
}
}
}
if ( nbOfBuddies = = 0 ) {
deviceUI - > m_deviceAPI - > setBuddyLeader ( true ) ;
}
// constructs new GUI and input object
DeviceSampleSource * source = deviceUI - > m_deviceAPI - > getPluginInterface ( ) - > createSampleSourcePluginInstance (
deviceUI - > m_deviceAPI - > getSamplingDeviceId ( ) , deviceUI - > m_deviceAPI ) ;
deviceUI - > m_deviceAPI - > setSampleSource ( source ) ;
QWidget * gui ;
2020-10-05 13:23:13 -04:00
DeviceGUI * pluginGUI = deviceUI - > m_deviceAPI - > getPluginInterface ( ) - > createSampleSourcePluginInstanceGUI (
2020-09-13 11:50:24 -04:00
deviceUI - > m_deviceAPI - > getSamplingDeviceId ( ) ,
& gui ,
deviceUI ) ;
2020-10-03 00:58:57 -04:00
deviceUI - > m_deviceAPI - > getSampleSource ( ) - > setMessageQueueToGUI ( pluginGUI - > getInputMessageQueue ( ) ) ;
deviceUI - > m_deviceGUI = pluginGUI ;
2020-09-13 11:50:24 -04:00
setDeviceGUI ( tabIndex , gui , deviceUI - > m_deviceAPI - > getSamplingDeviceDisplayName ( ) ) ;
deviceUI - > m_deviceAPI - > getSampleSource ( ) - > init ( ) ;
2020-10-10 14:08:11 -04:00
deviceUI - > m_deviceAPI - > loadSamplingDeviceSettings ( m_mainCore - > m_settings . getWorkingPreset ( ) ) ; // load new API settings
2020-09-13 11:50:24 -04:00
if ( tabIndex = = 0 ) // save as default starting device
{
2020-10-10 14:08:11 -04:00
m_mainCore - > m_settings . setSourceIndex ( samplingDevice - > sequence ) ;
m_mainCore - > m_settings . setSourceDeviceId ( samplingDevice - > id ) ;
2020-09-13 11:50:24 -04:00
}
}
}
void MainWindow : : sampleSinkChanged ( int tabIndex , int newDeviceIndex )
{
if ( tabIndex > = 0 )
{
qDebug ( " MainWindow::sampleSinkChanged: tab at %d " , tabIndex ) ;
DeviceUISet * deviceUI = m_deviceUIs [ tabIndex ] ;
2020-10-10 14:08:11 -04:00
deviceUI - > m_deviceAPI - > saveSamplingDeviceSettings ( m_mainCore - > m_settings . getWorkingPreset ( ) ) ; // save old API settings
2020-09-13 11:50:24 -04:00
deviceUI - > m_deviceAPI - > stopDeviceEngine ( ) ;
// deletes old UI and output object
2020-10-03 01:24:56 -04:00
deviceUI - > m_deviceAPI - > getSampleSink ( ) - > setMessageQueueToGUI ( nullptr ) ; // have sink stop sending messages to the GUI
2020-11-02 02:29:21 -05:00
m_deviceUIs [ tabIndex ] - > m_deviceGUI - > destroy ( ) ;
2020-09-13 11:50:24 -04:00
deviceUI - > m_deviceAPI - > resetSamplingDeviceId ( ) ;
2020-10-03 00:58:57 -04:00
deviceUI - > m_deviceAPI - > getPluginInterface ( ) - > deleteSampleSinkPluginInstanceOutput ( deviceUI - > m_deviceAPI - > getSampleSink ( ) ) ;
2020-09-13 11:50:24 -04:00
deviceUI - > m_deviceAPI - > clearBuddiesLists ( ) ; // clear old API buddies lists
const PluginInterface : : SamplingDevice * samplingDevice = DeviceEnumerator : : instance ( ) - > getTxSamplingDevice ( newDeviceIndex ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceSequence ( samplingDevice - > sequence ) ;
deviceUI - > m_deviceAPI - > setDeviceNbItems ( samplingDevice - > deviceNbItems ) ;
deviceUI - > m_deviceAPI - > setDeviceItemIndex ( samplingDevice - > deviceItemIndex ) ;
deviceUI - > m_deviceAPI - > setHardwareId ( samplingDevice - > hardwareId ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceId ( samplingDevice - > id ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceSerial ( samplingDevice - > serial ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceDisplayName ( samplingDevice - > displayedName ) ;
deviceUI - > m_deviceAPI - > setSamplingDevicePluginInterface ( DeviceEnumerator : : instance ( ) - > getTxPluginInterface ( newDeviceIndex ) ) ;
2021-05-02 07:06:10 -04:00
qDebug ( ) < < " MainWindow::sampleSinkChanged: "
< < " newDeviceIndex: " < < newDeviceIndex
< < " hardwareId: " < < samplingDevice - > hardwareId
< < " sequence: " < < samplingDevice - > sequence
< < " id: " < < samplingDevice - > id
< < " serial: " < < samplingDevice - > serial
< < " displayedName: " < < samplingDevice - > displayedName ;
2020-09-13 11:50:24 -04:00
if ( deviceUI - > m_deviceAPI - > getSamplingDeviceId ( ) . size ( ) = = 0 ) // non existent device => replace by default
{
qDebug ( " MainWindow::sampleSinkChanged: non existent device replaced by File Sink " ) ;
int fileSinkDeviceIndex = DeviceEnumerator : : instance ( ) - > getFileOutputDeviceIndex ( ) ;
const PluginInterface : : SamplingDevice * samplingDevice = DeviceEnumerator : : instance ( ) - > getTxSamplingDevice ( fileSinkDeviceIndex ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceSequence ( samplingDevice - > sequence ) ;
deviceUI - > m_deviceAPI - > setDeviceNbItems ( samplingDevice - > deviceNbItems ) ;
deviceUI - > m_deviceAPI - > setDeviceItemIndex ( samplingDevice - > deviceItemIndex ) ;
deviceUI - > m_deviceAPI - > setHardwareId ( samplingDevice - > hardwareId ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceId ( samplingDevice - > id ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceSerial ( samplingDevice - > serial ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceDisplayName ( samplingDevice - > displayedName ) ;
deviceUI - > m_deviceAPI - > setSamplingDevicePluginInterface ( DeviceEnumerator : : instance ( ) - > getTxPluginInterface ( fileSinkDeviceIndex ) ) ;
}
2020-10-10 14:08:11 -04:00
QString userArgs = m_mainCore - > m_settings . getDeviceUserArgs ( ) . findUserArgs ( samplingDevice - > hardwareId , samplingDevice - > sequence ) ;
2020-09-13 11:50:24 -04:00
if ( userArgs . size ( ) > 0 ) {
deviceUI - > m_deviceAPI - > setHardwareUserArguments ( userArgs ) ;
}
// add to buddies list
std : : vector < DeviceUISet * > : : iterator it = m_deviceUIs . begin ( ) ;
int nbOfBuddies = 0 ;
for ( ; it ! = m_deviceUIs . end ( ) ; + + it )
{
if ( * it ! = deviceUI ) // do not add to itself
{
if ( ( * it ) - > m_deviceSourceEngine ) // it is a source device
{
if ( ( deviceUI - > m_deviceAPI - > getHardwareId ( ) = = ( * it ) - > m_deviceAPI - > getHardwareId ( ) ) & &
( deviceUI - > m_deviceAPI - > getSamplingDeviceSerial ( ) = = ( * it ) - > m_deviceAPI - > getSamplingDeviceSerial ( ) ) )
{
( * it ) - > m_deviceAPI - > addSinkBuddy ( deviceUI - > m_deviceAPI ) ;
nbOfBuddies + + ;
}
}
if ( ( * it ) - > m_deviceSinkEngine ) // it is a sink device
{
if ( ( deviceUI - > m_deviceAPI - > getHardwareId ( ) = = ( * it ) - > m_deviceAPI - > getHardwareId ( ) ) & &
( deviceUI - > m_deviceAPI - > getSamplingDeviceSerial ( ) = = ( * it ) - > m_deviceAPI - > getSamplingDeviceSerial ( ) ) )
{
( * it ) - > m_deviceAPI - > addSinkBuddy ( deviceUI - > m_deviceAPI ) ;
nbOfBuddies + + ;
}
}
}
}
if ( nbOfBuddies = = 0 ) {
deviceUI - > m_deviceAPI - > setBuddyLeader ( true ) ;
}
// constructs new GUI and output object
DeviceSampleSink * sink = deviceUI - > m_deviceAPI - > getPluginInterface ( ) - > createSampleSinkPluginInstance (
deviceUI - > m_deviceAPI - > getSamplingDeviceId ( ) , deviceUI - > m_deviceAPI ) ;
deviceUI - > m_deviceAPI - > setSampleSink ( sink ) ;
QWidget * gui ;
2020-10-05 13:23:13 -04:00
DeviceGUI * pluginGUI = deviceUI - > m_deviceAPI - > getPluginInterface ( ) - > createSampleSinkPluginInstanceGUI (
2020-09-13 11:50:24 -04:00
deviceUI - > m_deviceAPI - > getSamplingDeviceId ( ) ,
& gui ,
deviceUI ) ;
2020-10-03 00:58:57 -04:00
deviceUI - > m_deviceAPI - > getSampleSink ( ) - > setMessageQueueToGUI ( pluginGUI - > getInputMessageQueue ( ) ) ;
deviceUI - > m_deviceGUI = pluginGUI ;
2020-09-13 11:50:24 -04:00
setDeviceGUI ( tabIndex , gui , deviceUI - > m_deviceAPI - > getSamplingDeviceDisplayName ( ) , 1 ) ;
deviceUI - > m_deviceAPI - > getSampleSink ( ) - > init ( ) ;
2020-10-10 14:08:11 -04:00
deviceUI - > m_deviceAPI - > loadSamplingDeviceSettings ( m_mainCore - > m_settings . getWorkingPreset ( ) ) ; // load new API settings
2020-09-13 11:50:24 -04:00
}
}
2020-11-10 06:08:58 -05:00
void MainWindow : : sampleMIMOChanged ( int tabIndex , int newDeviceIndex )
{
if ( tabIndex > = 0 )
{
qDebug ( " MainWindow::sampleMIMOChanged: tab at %d " , tabIndex ) ;
DeviceUISet * deviceUI = m_deviceUIs [ tabIndex ] ;
deviceUI - > m_deviceAPI - > saveSamplingDeviceSettings ( m_mainCore - > m_settings . getWorkingPreset ( ) ) ; // save old API settings
deviceUI - > m_deviceAPI - > stopDeviceEngine ( ) ;
// deletes old UI and output object
deviceUI - > m_deviceAPI - > getSampleMIMO ( ) - > setMessageQueueToGUI ( nullptr ) ; // have sink stop sending messages to the GUI
m_deviceUIs [ tabIndex ] - > m_deviceGUI - > destroy ( ) ;
deviceUI - > m_deviceAPI - > resetSamplingDeviceId ( ) ;
deviceUI - > m_deviceAPI - > getPluginInterface ( ) - > deleteSampleMIMOPluginInstanceMIMO ( deviceUI - > m_deviceAPI - > getSampleMIMO ( ) ) ;
const PluginInterface : : SamplingDevice * samplingDevice = DeviceEnumerator : : instance ( ) - > getMIMOSamplingDevice ( newDeviceIndex ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceSequence ( samplingDevice - > sequence ) ;
deviceUI - > m_deviceAPI - > setDeviceNbItems ( samplingDevice - > deviceNbItems ) ;
deviceUI - > m_deviceAPI - > setDeviceItemIndex ( samplingDevice - > deviceItemIndex ) ;
deviceUI - > m_deviceAPI - > setHardwareId ( samplingDevice - > hardwareId ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceId ( samplingDevice - > id ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceSerial ( samplingDevice - > serial ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceDisplayName ( samplingDevice - > displayedName ) ;
deviceUI - > m_deviceAPI - > setSamplingDevicePluginInterface ( DeviceEnumerator : : instance ( ) - > getMIMOPluginInterface ( newDeviceIndex ) ) ;
2021-05-02 07:06:10 -04:00
qDebug ( ) < < " MainWindow::sampleMIMOChanged: "
< < " newDeviceIndex: " < < newDeviceIndex
< < " hardwareId: " < < samplingDevice - > hardwareId
< < " sequence: " < < samplingDevice - > sequence
< < " id: " < < samplingDevice - > id
< < " serial: " < < samplingDevice - > serial
< < " displayedName: " < < samplingDevice - > displayedName ;
2020-11-10 06:08:58 -05:00
if ( deviceUI - > m_deviceAPI - > getSamplingDeviceId ( ) . size ( ) = = 0 ) // non existent device => replace by default
{
qDebug ( " MainWindow::sampleMIMOChanged: non existent device replaced by Test MIMO " ) ;
int testMIMODeviceIndex = DeviceEnumerator : : instance ( ) - > getTestMIMODeviceIndex ( ) ;
const PluginInterface : : SamplingDevice * samplingDevice = DeviceEnumerator : : instance ( ) - > getMIMOSamplingDevice ( testMIMODeviceIndex ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceSequence ( samplingDevice - > sequence ) ;
deviceUI - > m_deviceAPI - > setDeviceNbItems ( samplingDevice - > deviceNbItems ) ;
deviceUI - > m_deviceAPI - > setDeviceItemIndex ( samplingDevice - > deviceItemIndex ) ;
deviceUI - > m_deviceAPI - > setHardwareId ( samplingDevice - > hardwareId ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceId ( samplingDevice - > id ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceSerial ( samplingDevice - > serial ) ;
deviceUI - > m_deviceAPI - > setSamplingDeviceDisplayName ( samplingDevice - > displayedName ) ;
deviceUI - > m_deviceAPI - > setSamplingDevicePluginInterface ( DeviceEnumerator : : instance ( ) - > getMIMOPluginInterface ( testMIMODeviceIndex ) ) ;
}
QString userArgs = m_mainCore - > m_settings . getDeviceUserArgs ( ) . findUserArgs ( samplingDevice - > hardwareId , samplingDevice - > sequence ) ;
if ( userArgs . size ( ) > 0 ) {
deviceUI - > m_deviceAPI - > setHardwareUserArguments ( userArgs ) ;
}
// constructs new GUI and MIMO object
DeviceSampleMIMO * mimo = deviceUI - > m_deviceAPI - > getPluginInterface ( ) - > createSampleMIMOPluginInstance (
deviceUI - > m_deviceAPI - > getSamplingDeviceId ( ) , deviceUI - > m_deviceAPI ) ;
deviceUI - > m_deviceAPI - > setSampleMIMO ( mimo ) ;
QWidget * gui ;
DeviceGUI * pluginGUI = deviceUI - > m_deviceAPI - > getPluginInterface ( ) - > createSampleMIMOPluginInstanceGUI (
deviceUI - > m_deviceAPI - > getSamplingDeviceId ( ) ,
& gui ,
deviceUI ) ;
deviceUI - > m_deviceAPI - > getSampleMIMO ( ) - > setMessageQueueToGUI ( pluginGUI - > getInputMessageQueue ( ) ) ;
deviceUI - > m_deviceGUI = pluginGUI ;
setDeviceGUI ( tabIndex , gui , deviceUI - > m_deviceAPI - > getSamplingDeviceDisplayName ( ) , 2 ) ;
deviceUI - > m_deviceAPI - > getSampleMIMO ( ) - > init ( ) ;
deviceUI - > m_deviceAPI - > loadSamplingDeviceSettings ( m_mainCore - > m_settings . getWorkingPreset ( ) ) ; // load new API settings
}
}
2020-09-12 04:37:16 -04:00
void MainWindow : : channelAddClicked ( int channelIndex )
2017-10-22 13:12:43 -04:00
{
// Do it in the currently selected source tab
2020-09-24 17:23:54 -04:00
int currentChannelTabIndex = ui - > tabChannels - > currentIndex ( ) ;
2017-10-22 13:12:43 -04:00
2020-09-24 17:23:54 -04:00
if ( currentChannelTabIndex > = 0 )
2017-10-22 13:12:43 -04:00
{
2020-09-24 17:23:54 -04:00
DeviceUISet * deviceUI = m_deviceUIs [ currentChannelTabIndex ] ;
2017-10-22 13:12:43 -04:00
if ( deviceUI - > m_deviceSourceEngine ) // source device => Rx channels
{
2020-09-30 07:24:26 -04:00
PluginAPI : : ChannelRegistrations * channelRegistrations = m_pluginManager - > getRxChannelRegistrations ( ) ; // Available channel plugins
PluginInterface * pluginInterface = ( * channelRegistrations ) [ channelIndex ] . m_plugin ;
2020-10-02 21:09:36 -04:00
ChannelAPI * channelAPI ;
2020-10-01 16:47:30 -04:00
BasebandSampleSink * rxChannel ;
2020-10-02 21:09:36 -04:00
pluginInterface - > createRxChannel ( deviceUI - > m_deviceAPI , & rxChannel , & channelAPI ) ;
2020-10-04 00:16:15 -04:00
ChannelGUI * gui = pluginInterface - > createRxChannelGUI ( deviceUI , rxChannel ) ;
2020-10-15 02:52:30 -04:00
deviceUI - > registerRxChannelInstance ( channelAPI , gui ) ;
2017-10-22 13:12:43 -04:00
}
else if ( deviceUI - > m_deviceSinkEngine ) // sink device => Tx channels
{
2020-09-30 07:24:26 -04:00
PluginAPI : : ChannelRegistrations * channelRegistrations = m_pluginManager - > getTxChannelRegistrations ( ) ; // Available channel plugins
PluginInterface * pluginInterface = ( * channelRegistrations ) [ channelIndex ] . m_plugin ;
2020-10-02 21:09:36 -04:00
ChannelAPI * channelAPI ;
2020-10-01 16:47:30 -04:00
BasebandSampleSource * txChannel ;
2020-10-02 21:09:36 -04:00
pluginInterface - > createTxChannel ( deviceUI - > m_deviceAPI , & txChannel , & channelAPI ) ;
2020-10-04 00:16:15 -04:00
ChannelGUI * gui = pluginInterface - > createTxChannelGUI ( deviceUI , txChannel ) ;
2020-10-15 02:52:30 -04:00
deviceUI - > registerTxChannelInstance ( channelAPI , gui ) ;
2017-10-22 13:12:43 -04:00
}
2019-05-18 09:40:00 -04:00
else if ( deviceUI - > m_deviceMIMOEngine ) // MIMO device => all possible channels. Depends on index range
{
2020-11-10 06:08:58 -05:00
int nbMIMOChannels = deviceUI - > getNumberOfAvailableMIMOChannels ( ) ;
2019-05-18 09:40:00 -04:00
int nbRxChannels = deviceUI - > getNumberOfAvailableRxChannels ( ) ;
int nbTxChannels = deviceUI - > getNumberOfAvailableTxChannels ( ) ;
2020-11-10 06:08:58 -05:00
qDebug ( " MainWindow::channelAddClicked: MIMO: tab: nbMIMO: %d %d nbRx: %d nbTx: %d selected: %d " ,
currentChannelTabIndex , nbMIMOChannels , nbRxChannels , nbTxChannels , channelIndex ) ;
2019-05-18 09:40:00 -04:00
2020-11-10 06:08:58 -05:00
if ( channelIndex < nbMIMOChannels )
2020-09-30 07:24:26 -04:00
{
2020-11-10 06:08:58 -05:00
PluginAPI : : ChannelRegistrations * channelRegistrations = m_pluginManager - > getMIMOChannelRegistrations ( ) ; // Available channel plugins
2020-09-30 07:24:26 -04:00
PluginInterface * pluginInterface = ( * channelRegistrations ) [ channelIndex ] . m_plugin ;
2020-10-02 21:09:36 -04:00
ChannelAPI * channelAPI ;
2020-11-10 06:08:58 -05:00
MIMOChannel * mimoChannel ;
pluginInterface - > createMIMOChannel ( deviceUI - > m_deviceAPI , & mimoChannel , & channelAPI ) ;
ChannelGUI * gui = pluginInterface - > createMIMOChannelGUI ( deviceUI , mimoChannel ) ;
deviceUI - > registerChannelInstance ( channelAPI , gui ) ;
}
else if ( channelIndex < nbMIMOChannels + nbRxChannels ) // Rx
{
PluginAPI : : ChannelRegistrations * channelRegistrations = m_pluginManager - > getRxChannelRegistrations ( ) ; // Available channel plugins
PluginInterface * pluginInterface = ( * channelRegistrations ) [ channelIndex - nbMIMOChannels ] . m_plugin ;
ChannelAPI * channelAPI ;
2020-10-01 16:47:30 -04:00
BasebandSampleSink * rxChannel ;
2020-10-02 21:09:36 -04:00
pluginInterface - > createRxChannel ( deviceUI - > m_deviceAPI , & rxChannel , & channelAPI ) ;
2020-10-04 00:16:15 -04:00
ChannelGUI * gui = pluginInterface - > createRxChannelGUI ( deviceUI , rxChannel ) ;
2020-10-15 02:52:30 -04:00
deviceUI - > registerRxChannelInstance ( channelAPI , gui ) ;
2020-09-30 07:24:26 -04:00
}
2020-11-10 06:08:58 -05:00
else if ( channelIndex < nbMIMOChannels + nbRxChannels + nbTxChannels )
2020-09-30 07:24:26 -04:00
{
PluginAPI : : ChannelRegistrations * channelRegistrations = m_pluginManager - > getTxChannelRegistrations ( ) ; // Available channel plugins
2020-11-10 06:08:58 -05:00
PluginInterface * pluginInterface = ( * channelRegistrations ) [ channelIndex - nbMIMOChannels - nbRxChannels ] . m_plugin ;
2020-10-02 21:09:36 -04:00
ChannelAPI * channelAPI ;
2020-10-01 16:47:30 -04:00
BasebandSampleSource * txChannel ;
2020-10-02 21:09:36 -04:00
pluginInterface - > createTxChannel ( deviceUI - > m_deviceAPI , & txChannel , & channelAPI ) ;
2020-10-04 00:16:15 -04:00
ChannelGUI * gui = pluginInterface - > createTxChannelGUI ( deviceUI , txChannel ) ;
2020-10-15 02:52:30 -04:00
deviceUI - > registerTxChannelInstance ( channelAPI , gui ) ;
2019-05-18 09:40:00 -04:00
}
}
2017-10-22 13:12:43 -04:00
}
}
2020-09-19 19:06:34 -04:00
void MainWindow : : featureAddClicked ( int featureIndex )
{
// Do it in the currently selected source tab
int currentFeatureTabIndex = ui - > tabFeatures - > currentIndex ( ) ;
qDebug ( " MainWindow::featureAddClicked: tab: %d index: %d " , currentFeatureTabIndex , featureIndex ) ;
if ( currentFeatureTabIndex > = 0 )
{
FeatureUISet * featureUISet = m_featureUIs [ currentFeatureTabIndex ] ;
2020-09-27 18:20:37 -04:00
qDebug ( " MainWindow::featureAddClicked: m_apiAdapter: %p " , m_apiAdapter ) ;
2020-09-30 07:24:26 -04:00
PluginAPI : : FeatureRegistrations * featureRegistrations = m_pluginManager - > getFeatureRegistrations ( ) ; // Available feature plugins
PluginInterface * pluginInterface = ( * featureRegistrations ) [ featureIndex ] . m_plugin ;
Feature * feature = pluginInterface - > createFeature ( m_apiAdapter ) ;
2020-10-03 17:55:24 -04:00
FeatureGUI * gui = pluginInterface - > createFeatureGUI ( featureUISet , feature ) ;
2020-10-16 02:35:06 -04:00
featureUISet - > registerFeatureInstance ( gui , feature ) ;
2020-09-19 19:06:34 -04:00
}
}
2020-09-20 21:13:36 -04:00
void MainWindow : : deleteFeature ( int featureSetIndex , int featureIndex )
{
if ( ( featureSetIndex > = 0 ) & & ( featureSetIndex < ( int ) m_featureUIs . size ( ) ) )
{
FeatureUISet * featureSet = m_featureUIs [ featureSetIndex ] ;
featureSet - > deleteFeature ( featureIndex ) ;
}
}
2017-10-22 13:12:43 -04:00
void MainWindow : : on_action_About_triggered ( )
{
2020-10-10 14:08:11 -04:00
AboutDialog dlg ( m_apiHost , m_apiPort , m_mainCore - > m_settings , this ) ;
2017-10-22 13:12:43 -04:00
dlg . exec ( ) ;
}
void MainWindow : : on_action_addSourceDevice_triggered ( )
{
2017-12-25 03:10:19 -05:00
addSourceDevice ( - 1 ) ; // create with file source device by default
2017-10-22 13:12:43 -04:00
}
void MainWindow : : on_action_addSinkDevice_triggered ( )
{
addSinkDevice ( ) ;
}
2019-05-18 05:59:56 -04:00
void MainWindow : : on_action_addMIMODevice_triggered ( )
{
2020-11-10 06:08:58 -05:00
if ( m_dspEngine - > getMIMOSupport ( ) ) {
addMIMODevice ( ) ;
} else {
QMessageBox : : information ( this , tr ( " Message " ) , tr ( " MIMO not supported in this version " ) ) ;
}
2019-05-18 05:59:56 -04:00
}
2017-10-22 13:12:43 -04:00
void MainWindow : : on_action_removeLastDevice_triggered ( )
{
if ( m_deviceUIs . size ( ) > 1 )
{
removeLastDevice ( ) ;
}
}
2021-08-21 16:05:05 -04:00
void MainWindow : : on_action_addFeatureSet_triggered ( )
{
addFeatureSet ( ) ;
}
void MainWindow : : on_action_removeLastFeatureSet_triggered ( )
{
if ( m_featureUIs . size ( ) > 1 ) {
removeFeatureSet ( m_featureUIs . size ( ) - 1 ) ;
}
}
2017-10-22 13:12:43 -04:00
void MainWindow : : tabInputViewIndexChanged ( )
{
int inputViewIndex = ui - > tabInputsView - > currentIndex ( ) ;
2020-09-13 11:50:24 -04:00
if ( inputViewIndex > = 0 ) {
ui - > inputViewDock - > setCurrentTabIndex ( inputViewIndex ) ;
}
2020-10-10 14:08:11 -04:00
if ( ( inputViewIndex > = 0 ) & & ( m_mainCore - > m_masterTabIndex > = 0 ) & & ( inputViewIndex ! = m_mainCore - > m_masterTabIndex ) )
2017-10-22 13:12:43 -04:00
{
DeviceUISet * deviceUI = m_deviceUIs [ inputViewIndex ] ;
2020-10-10 14:08:11 -04:00
DeviceUISet * lastdeviceUI = m_deviceUIs [ m_mainCore - > m_masterTabIndex ] ;
2017-10-22 13:12:43 -04:00
lastdeviceUI - > m_mainWindowState = saveState ( ) ;
restoreState ( deviceUI - > m_mainWindowState ) ;
2020-10-10 14:08:11 -04:00
m_mainCore - > m_masterTabIndex = inputViewIndex ;
2017-10-22 13:12:43 -04:00
}
ui - > tabSpectra - > setCurrentIndex ( inputViewIndex ) ;
ui - > tabChannels - > setCurrentIndex ( inputViewIndex ) ;
ui - > tabSpectraGUI - > setCurrentIndex ( inputViewIndex ) ;
}
2020-09-12 04:37:16 -04:00
void MainWindow : : tabChannelsIndexChanged ( )
{
int channelsTabIndex = ui - > tabChannels - > currentIndex ( ) ;
if ( channelsTabIndex > = 0 )
{
DeviceUISet * deviceUI = m_deviceUIs [ channelsTabIndex ] ;
QList < QString > channelNames ;
ui - > channelDock - > resetAvailableChannels ( ) ;
if ( deviceUI - > m_deviceSourceEngine ) // source device
{
m_pluginManager - > listRxChannels ( channelNames ) ;
ui - > channelDock - > addAvailableChannels ( channelNames ) ;
}
else if ( deviceUI - > m_deviceSinkEngine ) // sink device
{
m_pluginManager - > listTxChannels ( channelNames ) ;
ui - > channelDock - > addAvailableChannels ( channelNames ) ;
}
else if ( deviceUI - > m_deviceMIMOEngine ) // MIMO device
{
m_pluginManager - > listMIMOChannels ( channelNames ) ;
ui - > channelDock - > addAvailableChannels ( channelNames ) ;
m_pluginManager - > listRxChannels ( channelNames ) ;
ui - > channelDock - > addAvailableChannels ( channelNames ) ;
m_pluginManager - > listTxChannels ( channelNames ) ;
ui - > channelDock - > addAvailableChannels ( channelNames ) ;
}
}
}
2017-10-22 13:12:43 -04:00
void MainWindow : : updateStatus ( )
{
2018-05-11 05:00:08 -04:00
m_dateTimeWidget - > setText ( QDateTime : : currentDateTime ( ) . toString ( " yyyy-MM-dd HH:mm:ss t " ) ) ;
2017-10-22 13:12:43 -04:00
}
2017-11-11 13:26:23 -05:00
2018-01-04 23:05:12 -05:00
void MainWindow : : commandKeyPressed ( Qt : : Key key , Qt : : KeyboardModifiers keyModifiers , bool release )
{
2018-01-05 04:28:32 -05:00
//qDebug("MainWindow::commandKeyPressed: key: %x mod: %x %s", (int) key, (int) keyModifiers, release ? "release" : "press");
2020-09-13 12:32:33 -04:00
int currentDeviceSetIndex = ui - > tabInputsView - > currentIndex ( ) ;
2018-01-05 04:28:32 -05:00
2020-10-10 14:08:11 -04:00
for ( int i = 0 ; i < m_mainCore - > m_settings . getCommandCount ( ) ; + + i )
2018-01-05 04:28:32 -05:00
{
2020-10-10 14:08:11 -04:00
const Command * command = m_mainCore - > m_settings . getCommand ( i ) ;
2018-01-05 04:28:32 -05:00
if ( command - > getAssociateKey ( )
& & ( command - > getRelease ( ) = = release )
& & ( command - > getKey ( ) = = key )
& & ( command - > getKeyModifiers ( ) = = keyModifiers ) )
{
Command * command_mod = const_cast < Command * > ( command ) ;
command_mod - > run ( m_apiServer - > getHost ( ) , m_apiServer - > getPort ( ) , currentDeviceSetIndex ) ;
}
}
2018-01-04 23:05:12 -05:00
}
2020-11-02 02:29:21 -05:00
void MainWindow : : restoreDeviceTabs ( )
{
ui - > tabInputsView - > clear ( ) ;
for ( int i = 0 ; i < m_deviceWidgetTabs . size ( ) ; i + + )
{
qDebug ( " MainWindow::restoreDeviceTabs: adding tab for %s " , qPrintable ( m_deviceWidgetTabs [ i ] . displayName ) ) ;
ui - > tabInputsView - > addTab ( m_deviceWidgetTabs [ i ] . gui , m_deviceWidgetTabs [ i ] . tabName ) ;
ui - > tabInputsView - > setTabToolTip ( i , m_deviceWidgetTabs [ i ] . displayName ) ;
}
}