mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-01 21:54:55 -04:00
Multi device support: moved DSPDeviceEngine start/stop actions and status from main window to each source plugin GUI
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
#include <QDateTime>
|
||||
#include <QString>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "ui_filesourcegui.h"
|
||||
#include "plugin/pluginapi.h"
|
||||
#include "gui/colormapper.h"
|
||||
@@ -42,15 +44,20 @@ FileSourceGui::FileSourceGui(PluginAPI* pluginAPI, QWidget* parent) :
|
||||
m_startingTimeStamp(0),
|
||||
m_samplesCount(0),
|
||||
m_tickCount(0),
|
||||
m_enableNavTime(false)
|
||||
m_enableNavTime(false),
|
||||
m_lastEngineState((DSPDeviceEngine::State)-1)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
|
||||
ui->centerFrequency->setValueRange(7, 0, pow(10,7));
|
||||
ui->fileNameText->setText(m_fileName);
|
||||
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
|
||||
|
||||
connect(&(m_pluginAPI->getMainWindow()->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick()));
|
||||
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
||||
m_statusTimer.start(500);
|
||||
|
||||
displaySettings();
|
||||
|
||||
ui->navTimeSlider->setEnabled(false);
|
||||
ui->playLoop->setChecked(true); // FIXME: always play in a loop
|
||||
ui->playLoop->setEnabled(false);
|
||||
@@ -168,15 +175,57 @@ void FileSourceGui::sendSettings()
|
||||
{
|
||||
}
|
||||
|
||||
void FileSourceGui::updateHardware()
|
||||
{
|
||||
}
|
||||
|
||||
void FileSourceGui::on_playLoop_toggled(bool checked)
|
||||
{
|
||||
// TODO: do something about it!
|
||||
}
|
||||
|
||||
void FileSourceGui::on_startStop_toggled(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
if (m_pluginAPI->initAcquisition())
|
||||
{
|
||||
m_pluginAPI->startAcquisition();
|
||||
DSPEngine::instance()->startAudio();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pluginAPI->stopAcquistion();
|
||||
DSPEngine::instance()->stopAudio();
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceGui::updateStatus()
|
||||
{
|
||||
int state = m_pluginAPI->state();
|
||||
|
||||
if(m_lastEngineState != state)
|
||||
{
|
||||
switch(state)
|
||||
{
|
||||
case DSPDeviceEngine::StNotStarted:
|
||||
ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
||||
break;
|
||||
case DSPDeviceEngine::StIdle:
|
||||
ui->startStop->setStyleSheet("QToolButton { background-color : cyan; }");
|
||||
break;
|
||||
case DSPDeviceEngine::StRunning:
|
||||
ui->startStop->setStyleSheet("QToolButton { background-color : green; }");
|
||||
break;
|
||||
case DSPDeviceEngine::StError:
|
||||
ui->startStop->setStyleSheet("QToolButton { background-color : red; }");
|
||||
QMessageBox::information(this, tr("Message"), m_pluginAPI->errorMessage());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_lastEngineState = state;
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceGui::on_play_toggled(bool checked)
|
||||
{
|
||||
FileSourceInput::MsgConfigureFileSourceWork* message = FileSourceInput::MsgConfigureFileSourceWork::create(checked);
|
||||
|
||||
@@ -51,7 +51,7 @@ private:
|
||||
|
||||
PluginAPI* m_pluginAPI;
|
||||
FileSourceInput::Settings m_settings;
|
||||
QTimer m_updateTimer;
|
||||
QTimer m_statusTimer;
|
||||
std::vector<int> m_gains;
|
||||
SampleSource* m_sampleSource;
|
||||
bool m_acquisition;
|
||||
@@ -63,11 +63,11 @@ private:
|
||||
int m_samplesCount;
|
||||
std::size_t m_tickCount;
|
||||
bool m_enableNavTime;
|
||||
int m_lastEngineState;
|
||||
|
||||
void displaySettings();
|
||||
void displayTime();
|
||||
void sendSettings();
|
||||
void updateHardware();
|
||||
void configureFileName();
|
||||
void updateWithAcquisition();
|
||||
void updateWithStreamData();
|
||||
@@ -75,10 +75,12 @@ private:
|
||||
|
||||
private slots:
|
||||
void handleSourceMessages();
|
||||
void on_startStop_toggled(bool checked);
|
||||
void on_playLoop_toggled(bool checked);
|
||||
void on_play_toggled(bool checked);
|
||||
void on_navTimeSlider_valueChanged(int value);
|
||||
void on_showFileDialog_clicked(bool checked);
|
||||
void updateStatus();
|
||||
void tick();
|
||||
};
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_freq">
|
||||
<item>
|
||||
<widget class="ButtonSwitch" name="startStopButton">
|
||||
<widget class="ButtonSwitch" name="startStop">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
||||
Reference in New Issue
Block a user