mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 08:36:52 +08:00
refs #335, made audio setup a component so it can be used in settings and cockpit
This commit is contained in:
committed by
Roland Winklmeier
parent
ccf308eda1
commit
73eee7af1e
29
src/blackgui/components/audiocomponent.cpp
Normal file
29
src/blackgui/components/audiocomponent.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "audiocomponent.h"
|
||||
#include "ui_audiocomponent.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
|
||||
CAudioComponent::CAudioComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CAudioComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
CAudioComponent::~CAudioComponent()
|
||||
{ }
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
44
src/blackgui/components/audiocomponent.h
Normal file
44
src/blackgui/components/audiocomponent.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_AUDIOCOMPONENT_H
|
||||
#define BLACKGUI_AUDIOCOMPONENT_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CAudioComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
//! Audio component, volume, ...
|
||||
class CAudioComponent : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CAudioComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CAudioComponent();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CAudioComponent> ui;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
|
||||
#endif // guard
|
||||
239
src/blackgui/components/audiosetup.cpp
Normal file
239
src/blackgui/components/audiosetup.cpp
Normal file
@@ -0,0 +1,239 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "audiosetup.h"
|
||||
#include "ui_audiosetup.h"
|
||||
#include "blackmisc/setaudio.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
using namespace BlackCore;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Audio;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Settings;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CAudioSetup::CAudioSetup(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
CEnableForRuntime(nullptr, false),
|
||||
ui(new Ui::CAudioSetup)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->ui->prb_SetupAudioTestProgress->hide();
|
||||
this->m_timerAudioTests = new QTimer(this);
|
||||
}
|
||||
|
||||
CAudioSetup::~CAudioSetup()
|
||||
{ }
|
||||
|
||||
/*
|
||||
* Runtime set
|
||||
*/
|
||||
void CAudioSetup::runtimeHasBeenSet()
|
||||
{
|
||||
if (!this->getIContextSettings()) qFatal("Settings missing");
|
||||
this->connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &CAudioSetup::ps_changedSettings);
|
||||
this->connect(this->m_timerAudioTests, &QTimer::timeout, this, &CAudioSetup::ps_audioTestUpdate);
|
||||
|
||||
// based on audio context
|
||||
Q_ASSERT(this->getIContextAudio());
|
||||
bool connected = false;
|
||||
if (this->getIContextAudio())
|
||||
{
|
||||
this->initAudioDeviceLists();
|
||||
connected = this->connect(this->getIContextAudio(), &IContextAudio::audioTestCompleted, this, &CAudioSetup::ps_audioTestUpdate);
|
||||
Q_ASSERT(connected);
|
||||
connected = this->connect(this->ui->cb_SetupAudioInputDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_audioDeviceSelected(int)));
|
||||
Q_ASSERT(connected);
|
||||
connected = this->connect(this->ui->cb_SetupAudioOutputDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_audioDeviceSelected(int)));
|
||||
Q_ASSERT(connected);
|
||||
this->connect(this->ui->pb_SetupAudioMicrophoneTest, &QPushButton::clicked, this, &CAudioSetup::ps_startAudioTest);
|
||||
this->connect(this->ui->pb_SetupAudioSquelchTest, &QPushButton::clicked, this, &CAudioSetup::ps_startAudioTest);
|
||||
}
|
||||
this->reloadSettings();
|
||||
}
|
||||
|
||||
void CAudioSetup::ps_changedSettings(uint typeValue)
|
||||
{
|
||||
IContextSettings::SettingsType type = static_cast<IContextSettings::SettingsType>(typeValue);
|
||||
this->reloadSettings();
|
||||
Q_UNUSED(type);
|
||||
}
|
||||
|
||||
/*
|
||||
* Reload settings
|
||||
*/
|
||||
void CAudioSetup::reloadSettings()
|
||||
{
|
||||
// local copy
|
||||
CSettingsAudio as = this->getIContextSettings()->getAudioSettings();
|
||||
|
||||
// fake setting for sound notifications
|
||||
this->ui->cb_SetupAudioPlayNotificationSounds->setChecked(true);
|
||||
this->ui->cb_SetupAudioNotificationTextMessage->setChecked(as.getNotificationFlag(BlackSound::CNotificationSounds::NotificationTextMessagePrivate));
|
||||
this->ui->cb_SetupAudioNotificationVoiceRoom->setChecked(as.getNotificationFlag(BlackSound::CNotificationSounds::NotificationVoiceRoomJoined));
|
||||
}
|
||||
|
||||
/*
|
||||
* Set audio device lists
|
||||
*/
|
||||
void CAudioSetup::initAudioDeviceLists()
|
||||
{
|
||||
if (!this->getIContextAudio()) return;
|
||||
this->ui->cb_SetupAudioOutputDevice->clear();
|
||||
this->ui->cb_SetupAudioInputDevice->clear();
|
||||
|
||||
foreach(CAudioDevice device, this->getIContextAudio()->getAudioDevices())
|
||||
{
|
||||
if (device.getType() == CAudioDevice::InputDevice)
|
||||
{
|
||||
this->ui->cb_SetupAudioInputDevice->addItem(device.toQString(true));
|
||||
}
|
||||
else if (device.getType() == CAudioDevice::OutputDevice)
|
||||
{
|
||||
this->ui->cb_SetupAudioOutputDevice->addItem(device.toQString(true));
|
||||
}
|
||||
}
|
||||
|
||||
foreach(CAudioDevice device, this->getIContextAudio()->getCurrentAudioDevices())
|
||||
{
|
||||
if (device.getType() == CAudioDevice::InputDevice)
|
||||
{
|
||||
this->ui->cb_SetupAudioInputDevice->setCurrentText(device.toQString(true));
|
||||
}
|
||||
else if (device.getType() == CAudioDevice::OutputDevice)
|
||||
{
|
||||
this->ui->cb_SetupAudioOutputDevice->setCurrentText(device.toQString(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Notification sounds
|
||||
*/
|
||||
bool CAudioSetup::playNotificationSounds() const
|
||||
{
|
||||
return this->ui->cb_SetupAudioPlayNotificationSounds->isChecked();
|
||||
}
|
||||
|
||||
/*
|
||||
* Start the voice tests
|
||||
*/
|
||||
void CAudioSetup::ps_startAudioTest()
|
||||
{
|
||||
if (!this->getIContextAudio())
|
||||
{
|
||||
CLogMessage(this).error("voice context not available");
|
||||
return;
|
||||
}
|
||||
if (this->m_timerAudioTests->isActive())
|
||||
{
|
||||
CLogMessage(this).error("test running, wait until completed");
|
||||
return;
|
||||
}
|
||||
|
||||
QObject *sender = QObject::sender();
|
||||
this->m_timerAudioTests->start(600); // I let this run for <x>ms, so there is enough overhead to really complete it
|
||||
this->ui->prb_SetupAudioTestProgress->setValue(0);
|
||||
this->ui->pte_SetupAudioTestActionAndResult->clear();
|
||||
if (sender == this->ui->pb_SetupAudioMicrophoneTest)
|
||||
{
|
||||
this->m_audioTestRunning = MicrophoneTest;
|
||||
this->getIContextAudio()->runMicrophoneTest();
|
||||
this->ui->pte_SetupAudioTestActionAndResult->appendPlainText("Speak normally for 5 seconds");
|
||||
}
|
||||
else if (sender == this->ui->pb_SetupAudioSquelchTest)
|
||||
{
|
||||
this->m_audioTestRunning = SquelchTest;
|
||||
this->getIContextAudio()->runSquelchTest();
|
||||
this->ui->pte_SetupAudioTestActionAndResult->appendPlainText("Silence for 5 seconds");
|
||||
}
|
||||
this->ui->prb_SetupAudioTestProgress->setVisible(true);
|
||||
this->ui->pb_SetupAudioMicrophoneTest->setEnabled(false);
|
||||
this->ui->pb_SetupAudioSquelchTest->setEnabled(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Start the voice tests
|
||||
*/
|
||||
void CAudioSetup::ps_audioTestUpdate()
|
||||
{
|
||||
Q_ASSERT(this->getIContextAudio());
|
||||
if (!this->getIContextAudio()) return;
|
||||
int v = this->ui->prb_SetupAudioTestProgress->value();
|
||||
QObject *sender = this->sender();
|
||||
|
||||
if (v < 100 && (sender == m_timerAudioTests))
|
||||
{
|
||||
// timer update, increasing progress
|
||||
this->ui->prb_SetupAudioTestProgress->setValue(v + 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_timerAudioTests->stop();
|
||||
this->ui->prb_SetupAudioTestProgress->setValue(100);
|
||||
if (sender == m_timerAudioTests) return; // just timer update
|
||||
|
||||
// getting here we assume the audio test finished signal
|
||||
// fetch results
|
||||
this->ui->pte_SetupAudioTestActionAndResult->clear();
|
||||
if (this->m_audioTestRunning == SquelchTest)
|
||||
{
|
||||
double s = this->getIContextAudio()->getSquelchValue();
|
||||
this->ui->pte_SetupAudioTestActionAndResult->appendPlainText(QString::number(s));
|
||||
}
|
||||
else if (this->m_audioTestRunning == MicrophoneTest)
|
||||
{
|
||||
QString m = this->getIContextAudio()->getMicrophoneTestResult();
|
||||
this->ui->pte_SetupAudioTestActionAndResult->appendPlainText(m);
|
||||
}
|
||||
this->m_audioTestRunning = NoAudioTest;
|
||||
this->m_timerAudioTests->stop();
|
||||
this->ui->pb_SetupAudioMicrophoneTest->setEnabled(true);
|
||||
this->ui->pb_SetupAudioSquelchTest->setEnabled(true);
|
||||
this->ui->prb_SetupAudioTestProgress->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Select audio device
|
||||
*/
|
||||
void CAudioSetup::ps_audioDeviceSelected(int index)
|
||||
{
|
||||
if (!this->getIContextAudio()) return;
|
||||
if (index < 0)return;
|
||||
|
||||
CAudioDeviceList devices = this->getIContextAudio()->getAudioDevices();
|
||||
if (devices.isEmpty()) return;
|
||||
CAudioDevice selectedDevice;
|
||||
QObject *sender = QObject::sender();
|
||||
if (sender == this->ui->cb_SetupAudioInputDevice)
|
||||
{
|
||||
CAudioDeviceList inputDevices = devices.getInputDevices();
|
||||
if (index >= inputDevices.size()) return;
|
||||
selectedDevice = inputDevices[index];
|
||||
this->getIContextAudio()->setCurrentAudioDevice(selectedDevice);
|
||||
}
|
||||
else if (sender == this->ui->cb_SetupAudioOutputDevice)
|
||||
{
|
||||
CAudioDeviceList outputDevices = devices.getOutputDevices();
|
||||
if (index >= outputDevices.size()) return;
|
||||
selectedDevice = outputDevices[index];
|
||||
this->getIContextAudio()->setCurrentAudioDevice(selectedDevice);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
86
src/blackgui/components/audiosetup.h
Normal file
86
src/blackgui/components/audiosetup.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_AUDIOSETUP_H
|
||||
#define BLACKGUI_AUDIOSETUP_H
|
||||
|
||||
#include "enableforruntime.h"
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CAudioSetup; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
//! Audio setup such as input / output devices
|
||||
class CAudioSetup :
|
||||
public QFrame,
|
||||
public CEnableForRuntime
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CAudioSetup(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CAudioSetup();
|
||||
|
||||
//! Play notification sounds (at all)
|
||||
bool playNotificationSounds() const;
|
||||
|
||||
public slots:
|
||||
//! Reload settings
|
||||
void reloadSettings();
|
||||
|
||||
protected:
|
||||
//! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet
|
||||
virtual void runtimeHasBeenSet() override;
|
||||
|
||||
private slots:
|
||||
|
||||
//! Settings have been changed
|
||||
void ps_changedSettings(uint typeValue);
|
||||
|
||||
//! start the MIC tests (Squelch)
|
||||
void ps_startAudioTest();
|
||||
|
||||
//! Audio test updates (timer) for progressbar and fetching results
|
||||
void ps_audioTestUpdate();
|
||||
|
||||
/*!
|
||||
* \brief Audio device selected
|
||||
* \param index audio device index (COM1, COM2)
|
||||
*/
|
||||
void ps_audioDeviceSelected(int index);
|
||||
|
||||
private:
|
||||
//! Audio test modes
|
||||
enum AudioTest
|
||||
{
|
||||
NoAudioTest,
|
||||
SquelchTest,
|
||||
MicrophoneTest
|
||||
};
|
||||
|
||||
//! Audio device lists from settings
|
||||
void initAudioDeviceLists();
|
||||
|
||||
QScopedPointer<Ui::CAudioSetup> ui;
|
||||
QTimer *m_timerAudioTests; //!< audio tests: progress bar, disable/enable buttons
|
||||
AudioTest m_audioTestRunning = NoAudioTest;
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "blackcore/context_settings.h"
|
||||
#include "blackcore/context_audio.h"
|
||||
#include "blackmisc/hwkeyboardkeylist.h"
|
||||
#include "blackmisc/setaudio.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/settingsblackmiscclasses.h"
|
||||
#include <QColorDialog>
|
||||
@@ -36,28 +35,23 @@ namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
CSettingsComponent::CSettingsComponent(QWidget *parent) :
|
||||
QTabWidget(parent),
|
||||
CEnableForRuntime(nullptr, false),
|
||||
ui(new Ui::CSettingsComponent),
|
||||
m_audioTestRunning(NoAudioTest)
|
||||
ui(new Ui::CSettingsComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->tabBar()->setExpanding(false);
|
||||
this->ui->prb_SettingsAudioTestProgress->setVisible(false);
|
||||
this->m_timerAudioTests = new QTimer(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* Destructor
|
||||
*/
|
||||
CSettingsComponent::~CSettingsComponent()
|
||||
{ }
|
||||
|
||||
bool CSettingsComponent::playNotificationSounds() const
|
||||
{
|
||||
return ui->comp_AudioSetup->playNotificationSounds();
|
||||
}
|
||||
|
||||
/*
|
||||
* Update own ICAO data from GUI
|
||||
*/
|
||||
@@ -68,65 +62,36 @@ namespace BlackGui
|
||||
icao.setAircraftCombinedType(this->ui->le_SettingsIcaoCombinedType->text());
|
||||
}
|
||||
|
||||
/*
|
||||
* Opacity
|
||||
*/
|
||||
void CSettingsComponent::setGuiOpacity(double value)
|
||||
{
|
||||
this->ui->hs_SettingsGuiOpacity->setValue(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Login as observer
|
||||
*/
|
||||
bool CSettingsComponent::loginAsObserver() const
|
||||
{
|
||||
return this->ui->rb_SettingsLoginStealthMode->isChecked();
|
||||
}
|
||||
|
||||
/*
|
||||
* Stealth
|
||||
*/
|
||||
bool CSettingsComponent::loginStealth() const
|
||||
{
|
||||
return this->ui->rb_SettingsLoginStealthMode->isChecked();
|
||||
}
|
||||
|
||||
/*
|
||||
* Notification sounds
|
||||
*/
|
||||
bool CSettingsComponent::playNotificationSounds() const
|
||||
{
|
||||
return this->ui->cb_SettingsAudioPlayNotificationSounds->isChecked();
|
||||
}
|
||||
|
||||
/*
|
||||
* Update interval
|
||||
*/
|
||||
int CSettingsComponent::getAtcUpdateIntervalSeconds() const
|
||||
{
|
||||
return this->ui->hs_SettingsGuiAtcRefreshTime->value();
|
||||
}
|
||||
|
||||
/*
|
||||
* Update interval
|
||||
*/
|
||||
int CSettingsComponent::getAircraftUpdateIntervalSeconds() const
|
||||
{
|
||||
return this->ui->hs_SettingsGuiAircraftRefreshTime->value();
|
||||
}
|
||||
|
||||
/*
|
||||
* Update interval
|
||||
*/
|
||||
int CSettingsComponent::getUsersUpdateIntervalSeconds() const
|
||||
{
|
||||
return this->ui->hs_SettingsGuiUserRefreshTime->value();
|
||||
}
|
||||
|
||||
/*
|
||||
* Own callsign
|
||||
*/
|
||||
QString CSettingsComponent::getOwnCallsignFromGui() const
|
||||
{
|
||||
return this->ui->le_SettingsAircraftCallsign->text();
|
||||
@@ -139,7 +104,6 @@ namespace BlackGui
|
||||
{
|
||||
// local copy
|
||||
CSettingsNetwork nws = this->getIContextSettings()->getNetworkSettings();
|
||||
CSettingsAudio as = this->getIContextSettings()->getAudioSettings();
|
||||
|
||||
// update servers
|
||||
this->ui->tvp_SettingsTnServers->setSelectedServer(nws.getCurrentTrafficNetworkServer());
|
||||
@@ -147,11 +111,6 @@ namespace BlackGui
|
||||
|
||||
// update hot keys
|
||||
this->ui->tvp_SettingsMiscHotkeys->updateContainer(this->getIContextSettings()->getHotkeys());
|
||||
|
||||
// fake setting for sound notifications
|
||||
this->ui->cb_SettingsAudioPlayNotificationSounds->setChecked(true);
|
||||
this->ui->cb_SettingsAudioNotificationTextMessage->setChecked(as.getNotificationFlag(BlackSound::CNotificationSounds::NotificationTextMessagePrivate));
|
||||
this->ui->cb_SettingsAudioNotificationVoiceRoom->setChecked(as.getNotificationFlag(BlackSound::CNotificationSounds::NotificationVoiceRoomJoined));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -168,27 +127,10 @@ namespace BlackGui
|
||||
void CSettingsComponent::runtimeHasBeenSet()
|
||||
{
|
||||
if (!this->getIContextSettings()) qFatal("Settings missing");
|
||||
|
||||
this->connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &CSettingsComponent::ps_changedSettings);
|
||||
this->connect(this->m_timerAudioTests, &QTimer::timeout, this, &CSettingsComponent::ps_audioTestUpdate);
|
||||
|
||||
// based on audio context
|
||||
Q_ASSERT(this->getIContextAudio());
|
||||
bool connected = false;
|
||||
if (this->getIContextAudio())
|
||||
{
|
||||
this->initAudioDeviceLists();
|
||||
connected = this->connect(this->getIContextAudio(), &IContextAudio::audioTestCompleted, this, &CSettingsComponent::ps_audioTestUpdate);
|
||||
Q_ASSERT(connected);
|
||||
connected = this->connect(this->ui->cb_SettingsAudioInputDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_audioDeviceSelected(int)));
|
||||
Q_ASSERT(connected);
|
||||
connected = this->connect(this->ui->cb_SettingsAudioOutputDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_audioDeviceSelected(int)));
|
||||
Q_ASSERT(connected);
|
||||
this->connect(this->ui->pb_SettingsAudioMicrophoneTest, &QPushButton::clicked, this, &CSettingsComponent::ps_startAudioTest);
|
||||
this->connect(this->ui->pb_SettingsAudioSquelchTest, &QPushButton::clicked, this, &CSettingsComponent::ps_startAudioTest);
|
||||
}
|
||||
|
||||
// Opacity, intervals
|
||||
bool connected = false;
|
||||
this->connect(this->ui->hs_SettingsGuiOpacity, &QSlider::valueChanged, this, &CSettingsComponent::changedWindowsOpacity);
|
||||
this->connect(this->ui->hs_SettingsGuiAircraftRefreshTime, &QSlider::valueChanged, this, &CSettingsComponent::changedAircraftsUpdateInterval);
|
||||
this->connect(this->ui->hs_SettingsGuiAtcRefreshTime, &QSlider::valueChanged, this, &CSettingsComponent::changedAtcStationsUpdateInterval);
|
||||
@@ -259,7 +201,7 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
/*
|
||||
* Settings did changed
|
||||
* Settings did change
|
||||
*/
|
||||
void CSettingsComponent::ps_changedSettings(uint typeValue)
|
||||
{
|
||||
@@ -326,40 +268,6 @@ namespace BlackGui
|
||||
this->ui->tvp_SettingsMiscHotkeys->derivedModel()->update(i, defaultHotkey);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set audio device lists
|
||||
*/
|
||||
void CSettingsComponent::initAudioDeviceLists()
|
||||
{
|
||||
if (!this->getIContextAudio()) return;
|
||||
this->ui->cb_SettingsAudioOutputDevice->clear();
|
||||
this->ui->cb_SettingsAudioInputDevice->clear();
|
||||
|
||||
foreach(CAudioDevice device, this->getIContextAudio()->getAudioDevices())
|
||||
{
|
||||
if (device.getType() == CAudioDevice::InputDevice)
|
||||
{
|
||||
this->ui->cb_SettingsAudioInputDevice->addItem(device.toQString(true));
|
||||
}
|
||||
else if (device.getType() == CAudioDevice::OutputDevice)
|
||||
{
|
||||
this->ui->cb_SettingsAudioOutputDevice->addItem(device.toQString(true));
|
||||
}
|
||||
}
|
||||
|
||||
foreach(CAudioDevice device, this->getIContextAudio()->getCurrentAudioDevices())
|
||||
{
|
||||
if (device.getType() == CAudioDevice::InputDevice)
|
||||
{
|
||||
this->ui->cb_SettingsAudioInputDevice->setCurrentText(device.toQString(true));
|
||||
}
|
||||
else if (device.getType() == CAudioDevice::OutputDevice)
|
||||
{
|
||||
this->ui->cb_SettingsAudioOutputDevice->setCurrentText(device.toQString(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Font has been changed
|
||||
*/
|
||||
@@ -396,112 +304,5 @@ namespace BlackGui
|
||||
this->ui->le_SettingsGuiFontColor->setText(this->m_fontColor.name());
|
||||
this->ps_fontChanged();
|
||||
}
|
||||
|
||||
/*
|
||||
* Start the voice tests
|
||||
*/
|
||||
void CSettingsComponent::ps_startAudioTest()
|
||||
{
|
||||
if (!this->getIContextAudio())
|
||||
{
|
||||
CLogMessage(this).error("voice context not available");
|
||||
return;
|
||||
}
|
||||
if (this->m_timerAudioTests->isActive())
|
||||
{
|
||||
CLogMessage(this).error("test running, wait until completed");
|
||||
return;
|
||||
}
|
||||
|
||||
QObject *sender = QObject::sender();
|
||||
this->m_timerAudioTests->start(600); // I let this run for <x>ms, so there is enough overhead to really complete it
|
||||
this->ui->prb_SettingsAudioTestProgress->setValue(0);
|
||||
this->ui->pte_SettingsAudioTestActionAndResult->clear();
|
||||
if (sender == this->ui->pb_SettingsAudioMicrophoneTest)
|
||||
{
|
||||
this->m_audioTestRunning = MicrophoneTest;
|
||||
this->getIContextAudio()->runMicrophoneTest();
|
||||
this->ui->pte_SettingsAudioTestActionAndResult->appendPlainText("Speak normally for 5 seconds");
|
||||
}
|
||||
else if (sender == this->ui->pb_SettingsAudioSquelchTest)
|
||||
{
|
||||
this->m_audioTestRunning = SquelchTest;
|
||||
this->getIContextAudio()->runSquelchTest();
|
||||
this->ui->pte_SettingsAudioTestActionAndResult->appendPlainText("Silence for 5 seconds");
|
||||
}
|
||||
this->ui->prb_SettingsAudioTestProgress->setVisible(true);
|
||||
this->ui->pb_SettingsAudioMicrophoneTest->setEnabled(false);
|
||||
this->ui->pb_SettingsAudioSquelchTest->setEnabled(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Start the voice tests
|
||||
*/
|
||||
void CSettingsComponent::ps_audioTestUpdate()
|
||||
{
|
||||
Q_ASSERT(this->getIContextAudio());
|
||||
if (!this->getIContextAudio()) return;
|
||||
int v = this->ui->prb_SettingsAudioTestProgress->value();
|
||||
QObject *sender = this->sender();
|
||||
|
||||
if (v < 100 && (sender == m_timerAudioTests))
|
||||
{
|
||||
// timer update, increasing progress
|
||||
this->ui->prb_SettingsAudioTestProgress->setValue(v + 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_timerAudioTests->stop();
|
||||
this->ui->prb_SettingsAudioTestProgress->setValue(100);
|
||||
if (sender == m_timerAudioTests) return; // just timer update
|
||||
|
||||
// getting here we assume the audio test finished signal
|
||||
// fetch results
|
||||
this->ui->pte_SettingsAudioTestActionAndResult->clear();
|
||||
if (this->m_audioTestRunning == SquelchTest)
|
||||
{
|
||||
double s = this->getIContextAudio()->getSquelchValue();
|
||||
this->ui->pte_SettingsAudioTestActionAndResult->appendPlainText(QString::number(s));
|
||||
}
|
||||
else if (this->m_audioTestRunning == MicrophoneTest)
|
||||
{
|
||||
QString m = this->getIContextAudio()->getMicrophoneTestResult();
|
||||
this->ui->pte_SettingsAudioTestActionAndResult->appendPlainText(m);
|
||||
}
|
||||
this->m_audioTestRunning = NoAudioTest;
|
||||
this->m_timerAudioTests->stop();
|
||||
this->ui->pb_SettingsAudioMicrophoneTest->setEnabled(true);
|
||||
this->ui->pb_SettingsAudioSquelchTest->setEnabled(true);
|
||||
this->ui->prb_SettingsAudioTestProgress->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Select audio device
|
||||
*/
|
||||
void CSettingsComponent::ps_audioDeviceSelected(int index)
|
||||
{
|
||||
if (!this->getIContextAudio()) return;
|
||||
if (index < 0)return;
|
||||
|
||||
CAudioDeviceList devices = this->getIContextAudio()->getAudioDevices();
|
||||
if (devices.isEmpty()) return;
|
||||
CAudioDevice selectedDevice;
|
||||
QObject *sender = QObject::sender();
|
||||
if (sender == this->ui->cb_SettingsAudioInputDevice)
|
||||
{
|
||||
CAudioDeviceList inputDevices = devices.getInputDevices();
|
||||
if (index >= inputDevices.size()) return;
|
||||
selectedDevice = inputDevices[index];
|
||||
this->getIContextAudio()->setCurrentAudioDevice(selectedDevice);
|
||||
}
|
||||
else if (sender == this->ui->cb_SettingsAudioOutputDevice)
|
||||
{
|
||||
CAudioDeviceList outputDevices = devices.getOutputDevices();
|
||||
if (index >= outputDevices.size()) return;
|
||||
selectedDevice = outputDevices[index];
|
||||
this->getIContextAudio()->setCurrentAudioDevice(selectedDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -53,6 +53,9 @@ namespace BlackGui
|
||||
//! Destructor
|
||||
~CSettingsComponent();
|
||||
|
||||
//! \copydoc CAudioSetupComponent::playNotificationSounds
|
||||
bool playNotificationSounds() const;
|
||||
|
||||
//! ICAO data from GUI
|
||||
void setOwnAircraftIcaoDataFromGui(BlackMisc::Aviation::CAircraftIcao &icao) const;
|
||||
|
||||
@@ -65,9 +68,6 @@ namespace BlackGui
|
||||
//! Login as observer
|
||||
bool loginStealth() const;
|
||||
|
||||
//! Play notification sounds (at all)
|
||||
bool playNotificationSounds() const;
|
||||
|
||||
//! ATC refresh time
|
||||
int getAtcUpdateIntervalSeconds() const;
|
||||
|
||||
@@ -130,18 +130,6 @@ namespace BlackGui
|
||||
//! Clear single hotkey
|
||||
void ps_clearHotkey();
|
||||
|
||||
//! start the MIC tests (Squelch)
|
||||
void ps_startAudioTest();
|
||||
|
||||
//! Audio test updates (timer) for progressbar and fetching results
|
||||
void ps_audioTestUpdate();
|
||||
|
||||
/*!
|
||||
* \brief Audio device selected
|
||||
* \param index audio device index (COM1, COM2)
|
||||
*/
|
||||
void ps_audioDeviceSelected(int index);
|
||||
|
||||
//! Font has been changed
|
||||
void ps_fontChanged();
|
||||
|
||||
@@ -149,22 +137,8 @@ namespace BlackGui
|
||||
void ps_fontColorDialog();
|
||||
|
||||
private:
|
||||
//! Audio test modes
|
||||
enum AudioTest
|
||||
{
|
||||
NoAudioTest,
|
||||
SquelchTest,
|
||||
MicrophoneTest
|
||||
};
|
||||
|
||||
QScopedPointer<Ui::CSettingsComponent> ui;
|
||||
QTimer *m_timerAudioTests; //!< audio tests: progress bar, disable/enable buttons
|
||||
AudioTest m_audioTestRunning;
|
||||
QColor m_fontColor;
|
||||
|
||||
//! Audio device lists from settings
|
||||
void initAudioDeviceLists();
|
||||
|
||||
QColor m_fontColor;
|
||||
};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -372,7 +372,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CAudioSetup" name="comp_AudioSetup">
|
||||
<widget class="BlackGui::Components::CAudioSetupComponent" name="comp_AudioSetup">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
@@ -468,9 +468,12 @@
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_SettingsGuiAircraftRefreshTime">
|
||||
<property name="text">
|
||||
<property name="toolTip">
|
||||
<string>Aircraft refresh time (5-30s)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Aircraft rt (5-30s)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
@@ -506,9 +509,12 @@
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_SettingsGuiAtcRefreshTime">
|
||||
<property name="text">
|
||||
<property name="toolTip">
|
||||
<string>ATC refresh time (5-30s)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ATC rt (5-30s)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
@@ -541,9 +547,12 @@
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_SettingsGuiUserRefreshTime">
|
||||
<property name="text">
|
||||
<property name="toolTip">
|
||||
<string>User refresh time (5-30s)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>User rt (5-30s)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
@@ -589,6 +598,9 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
@@ -792,6 +804,12 @@
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CAudioSetupComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/audiosetupcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Views::CKeyboardKeyView</class>
|
||||
<extends>QTableView</extends>
|
||||
@@ -808,12 +826,6 @@
|
||||
<header>blackgui/components/settingssimulatorcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CAudioSetup</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/audiosetup.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
Reference in New Issue
Block a user