mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
[AFV] Ref T739, adv. UI component to start/stop audio and distributed audio
This commit is contained in:
committed by
Mat Sutcliffe
parent
767b999330
commit
b9acf794d8
@@ -9,6 +9,13 @@
|
||||
#include "audioadvanceddistributedcomponent.h"
|
||||
#include "ui_audioadvanceddistributedcomponent.h"
|
||||
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackcore/context/contextaudio.h"
|
||||
#include "blackcore/afv/clients/afvclient.h"
|
||||
|
||||
using namespace BlackMisc::Audio;
|
||||
using namespace BlackCore::Context;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
@@ -18,9 +25,55 @@ namespace BlackGui
|
||||
ui(new Ui::CAudioAdvancedDistributedComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(sGui->getCContextAudioBase(), &CContextAudioBase::startedAudio, this, &CAudioAdvancedDistributedComponent::onAudioStarted, Qt::QueuedConnection);
|
||||
connect(sGui->getCContextAudioBase(), &CContextAudioBase::stoppedAudio, this, &CAudioAdvancedDistributedComponent::onAudioStoppend, Qt::QueuedConnection);
|
||||
connect(ui->pb_StartStop, &QPushButton::released, this, &CAudioAdvancedDistributedComponent::toggleAudioStartStop, Qt::QueuedConnection);
|
||||
|
||||
this->setStartButton();
|
||||
}
|
||||
|
||||
CAudioAdvancedDistributedComponent::~CAudioAdvancedDistributedComponent()
|
||||
{ }
|
||||
|
||||
void CAudioAdvancedDistributedComponent::toggleAudioStartStop()
|
||||
{
|
||||
if (!hasContexts()) { return; }
|
||||
const bool started = sGui->getCContextAudioBase()->isAudioStarted();
|
||||
if (started)
|
||||
{
|
||||
sGui->getCContextAudioBase()->afvClient()->stopAudio();
|
||||
}
|
||||
else
|
||||
{
|
||||
sGui->getCContextAudioBase()->afvClient()->startAudio();
|
||||
}
|
||||
}
|
||||
|
||||
void CAudioAdvancedDistributedComponent::setStartButton()
|
||||
{
|
||||
if (!hasContexts()) { return; }
|
||||
const bool started = sGui->getCContextAudioBase()->isAudioStarted();
|
||||
ui->pb_StartStop->setText(started ? "stop" : "start");
|
||||
}
|
||||
|
||||
void CAudioAdvancedDistributedComponent::onAudioStarted(const CAudioDeviceInfo &inputDevice, const CAudioDeviceInfo &outputDevice)
|
||||
{
|
||||
Q_UNUSED(inputDevice)
|
||||
Q_UNUSED(outputDevice)
|
||||
this->setStartButton();
|
||||
}
|
||||
|
||||
void CAudioAdvancedDistributedComponent::onAudioStoppend()
|
||||
{
|
||||
this->setStartButton();
|
||||
}
|
||||
|
||||
bool CAudioAdvancedDistributedComponent::hasContexts()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->getCContextAudioBase()) { return false; }
|
||||
if (!sGui->getCContextAudioBase()->afvClient()) { return false; }
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#ifndef BLACKGUI_COMPONENTS_AUDIOADVANCEDDISTRIBUTEDCOMPONENT_H
|
||||
#define BLACKGUI_COMPONENTS_AUDIOADVANCEDDISTRIBUTEDCOMPONENT_H
|
||||
|
||||
#include "blackmisc/audio/audiodeviceinfo.h"
|
||||
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
|
||||
@@ -33,8 +35,20 @@ namespace BlackGui
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CAudioAdvancedDistributedComponent> ui;
|
||||
|
||||
//! Audio start/stop
|
||||
void toggleAudioStartStop();
|
||||
|
||||
//! Start/stop button
|
||||
void setStartButton();
|
||||
|
||||
void onAudioStarted(const BlackMisc::Audio::CAudioDeviceInfo &inputDevice, const BlackMisc::Audio::CAudioDeviceInfo &outputDevice);
|
||||
void onAudioStoppend();
|
||||
|
||||
//! Contexts
|
||||
static bool hasContexts();
|
||||
};
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version='1.0'?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CAudioAdvancedDistributedComponent</class>
|
||||
<widget class="QFrame" name="CAudioAdvancedDistributedComponent">
|
||||
@@ -6,12 +6,30 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>640</width>
|
||||
<height>480</height>
|
||||
<width>166</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_StartStop">
|
||||
<property name="text">
|
||||
<string>Start/stop audio:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="pb_StartStop">
|
||||
<property name="text">
|
||||
<string>stop</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -235,8 +235,8 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CAudioAdvancedDistributedComponent" name="compAudioAdv">
|
||||
<item alignment="Qt::AlignTop">
|
||||
<widget class="BlackGui::Components::CAudioAdvancedDistributedComponent" name="comp_AudioAdv">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
|
||||
Reference in New Issue
Block a user