mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-06 02:16:04 +08:00
Audio setup component deferred init,
because in a distributed swift system it takes a moment until the settings are sychronized this is leading to undesired "save settings" messages and played sounds
This commit is contained in:
committed by
Mat Sutcliffe
parent
341f2db406
commit
365c52613a
@@ -20,6 +20,7 @@
|
|||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
using namespace BlackCore;
|
using namespace BlackCore;
|
||||||
using namespace BlackCore::Context;
|
using namespace BlackCore::Context;
|
||||||
@@ -38,6 +39,19 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
// deferred init, because in a distributed swift system
|
||||||
|
// it takes a moment until the settings are sychronized
|
||||||
|
// this is leading to undesired "save settings" messages and played sounds
|
||||||
|
QPointer<CAudioSetupComponent> myself(this);
|
||||||
|
QTimer::singleShot(2500, this, [ = ]
|
||||||
|
{
|
||||||
|
if (!myself || !sGui || sGui->isShuttingDown()) { return; }
|
||||||
|
this->init();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAudioSetupComponent::init()
|
||||||
|
{
|
||||||
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui");
|
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui");
|
||||||
Q_ASSERT_X(sGui->getIContextAudio(), Q_FUNC_INFO, "Missing Audio context");
|
Q_ASSERT_X(sGui->getIContextAudio(), Q_FUNC_INFO, "Missing Audio context");
|
||||||
|
|
||||||
@@ -141,14 +155,14 @@ namespace BlackGui
|
|||||||
const QObject *sender = QObject::sender();
|
const QObject *sender = QObject::sender();
|
||||||
if (sender == ui->cb_SetupAudioInputDevice)
|
if (sender == ui->cb_SetupAudioInputDevice)
|
||||||
{
|
{
|
||||||
CAudioDeviceInfoList inputDevices = devices.getInputDevices();
|
const CAudioDeviceInfoList inputDevices = devices.getInputDevices();
|
||||||
if (index >= inputDevices.size()) { return; }
|
if (index >= inputDevices.size()) { return; }
|
||||||
selectedDevice = inputDevices[index];
|
selectedDevice = inputDevices[index];
|
||||||
sGui->getIContextAudio()->setCurrentAudioDevice(selectedDevice);
|
sGui->getIContextAudio()->setCurrentAudioDevice(selectedDevice);
|
||||||
}
|
}
|
||||||
else if (sender == ui->cb_SetupAudioOutputDevice)
|
else if (sender == ui->cb_SetupAudioOutputDevice)
|
||||||
{
|
{
|
||||||
CAudioDeviceInfoList outputDevices = devices.getOutputDevices();
|
const CAudioDeviceInfoList outputDevices = devices.getOutputDevices();
|
||||||
if (index >= outputDevices.size()) { return; }
|
if (index >= outputDevices.size()) { return; }
|
||||||
selectedDevice = outputDevices[index];
|
selectedDevice = outputDevices[index];
|
||||||
sGui->getIContextAudio()->setCurrentAudioDevice(selectedDevice);
|
sGui->getIContextAudio()->setCurrentAudioDevice(selectedDevice);
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ namespace BlackGui
|
|||||||
bool playNotificationSounds() const;
|
bool playNotificationSounds() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//! Init
|
||||||
|
void init();
|
||||||
|
|
||||||
//! Reload settings
|
//! Reload settings
|
||||||
void reloadSettings();
|
void reloadSettings();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user