mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +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 "audioadvanceddistributedcomponent.h"
|
||||||
#include "ui_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 BlackGui
|
||||||
{
|
{
|
||||||
namespace Components
|
namespace Components
|
||||||
@@ -18,9 +25,55 @@ namespace BlackGui
|
|||||||
ui(new Ui::CAudioAdvancedDistributedComponent)
|
ui(new Ui::CAudioAdvancedDistributedComponent)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
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()
|
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
|
#ifndef BLACKGUI_COMPONENTS_AUDIOADVANCEDDISTRIBUTEDCOMPONENT_H
|
||||||
#define BLACKGUI_COMPONENTS_AUDIOADVANCEDDISTRIBUTEDCOMPONENT_H
|
#define BLACKGUI_COMPONENTS_AUDIOADVANCEDDISTRIBUTEDCOMPONENT_H
|
||||||
|
|
||||||
|
#include "blackmisc/audio/audiodeviceinfo.h"
|
||||||
|
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
|
|
||||||
@@ -33,8 +35,20 @@ namespace BlackGui
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CAudioAdvancedDistributedComponent> ui;
|
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
|
#endif // guard
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version='1.0'?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>CAudioAdvancedDistributedComponent</class>
|
<class>CAudioAdvancedDistributedComponent</class>
|
||||||
<widget class="QFrame" name="CAudioAdvancedDistributedComponent">
|
<widget class="QFrame" name="CAudioAdvancedDistributedComponent">
|
||||||
@@ -6,12 +6,30 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>640</width>
|
<width>166</width>
|
||||||
<height>480</height>
|
<height>32</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Frame</string>
|
<string>Frame</string>
|
||||||
</property>
|
</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>
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
@@ -235,8 +235,8 @@
|
|||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item alignment="Qt::AlignTop">
|
||||||
<widget class="BlackGui::Components::CAudioAdvancedDistributedComponent" name="compAudioAdv">
|
<widget class="BlackGui::Components::CAudioAdvancedDistributedComponent" name="comp_AudioAdv">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
Reference in New Issue
Block a user