From 16bee441e11232cdc15865c8f9c522fabf1dcd3c Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 9 Feb 2015 19:54:36 +0100 Subject: [PATCH] refs #381, adjust GUI for new voice vatlib * Only 1 volume * No tests (squelch ...) * loopback * required backed functions in context --- src/blackcore/context_audio.h | 8 +- src/blackcore/context_audio_impl.cpp | 27 +- src/blackcore/context_audio_impl.h | 12 +- src/blackcore/context_audio_proxy.cpp | 17 +- src/blackcore/context_audio_proxy.h | 6 + .../components/audiosetupcomponent.cpp | 141 +++-------- src/blackgui/components/audiosetupcomponent.h | 22 +- .../components/audiosetupcomponent.ui | 233 ++++++++---------- .../components/audiovolumecomponent.cpp | 76 ++++-- .../components/audiovolumecomponent.h | 7 +- .../components/audiovolumecomponent.ui | 73 +++--- src/blackgui/qss/mainwindow.qss | 4 + src/blackmisc/blackmisc.qrc | 4 + 13 files changed, 306 insertions(+), 324 deletions(-) diff --git a/src/blackcore/context_audio.h b/src/blackcore/context_audio.h index 12c9743dc..65a6aeb05 100644 --- a/src/blackcore/context_audio.h +++ b/src/blackcore/context_audio.h @@ -73,7 +73,7 @@ namespace BlackCore virtual QString getPathAndContextId() const { return this->buildPathAndContextId(ObjectPath()); } //! Factory method - static IContextAudio *create(CRuntime *parent, CRuntimeConfig::ContextMode mode, CDBusServer *server, QDBusConnection &conn); + static IContextAudio *create(CRuntime *runtime, CRuntimeConfig::ContextMode mode, CDBusServer *server, QDBusConnection &conn); //! \brief Destructor virtual ~IContextAudio() {} @@ -137,6 +137,9 @@ namespace BlackCore //! Set voice output volume (0..300) virtual void setVoiceOutputVolume(int volume) = 0; + //! Voice output volume (0..300) + virtual int getVoiceOutputVolume() const = 0; + //! Set mute state virtual void setMute(bool mute) = 0; @@ -156,6 +159,9 @@ namespace BlackCore //! Enable audio loopback virtual void enableAudioLoopback(bool enable = true) = 0; + //! Is loobback enabled? + virtual bool isAudioLoopbackEnabled() const = 0; + //! Command line was entered virtual bool parseCommandLine(const QString &commandLine) = 0; }; diff --git a/src/blackcore/context_audio_impl.cpp b/src/blackcore/context_audio_impl.cpp index 0cbbab778..d7479a045 100644 --- a/src/blackcore/context_audio_impl.cpp +++ b/src/blackcore/context_audio_impl.cpp @@ -211,11 +211,18 @@ namespace BlackCore void CContextAudio::setVoiceOutputVolume(int volume) { + Q_ASSERT(m_voiceOutputDevice); m_outDeviceVolume = volume; - if (!isMuted()) m_voiceOutputDevice->setOutputVolume(m_outDeviceVolume); + if (!isMuted()) { m_voiceOutputDevice->setOutputVolume(m_outDeviceVolume); } emit changedAudioVolume(volume); } + int CContextAudio::getVoiceOutputVolume() const + { + Q_ASSERT(m_voiceOutputDevice); + return m_voiceOutputDevice->getOutputVolume(); + } + void CContextAudio::setMute(bool muted) { if (this->isMuted() == muted) { return; } // avoid roundtrips / unnecessary signals @@ -407,12 +414,23 @@ namespace BlackCore */ void CContextAudio::enableAudioLoopback(bool enable) { - Q_ASSERT(this->m_voice); + Q_ASSERT(this->m_audioMixer); CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; if (enable) + { m_audioMixer->makeMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputOutputDevice1); + } else + { m_audioMixer->removeMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputOutputDevice1); + } + } + + bool CContextAudio::isAudioLoopbackEnabled() const + { + Q_ASSERT(this->m_audioMixer); + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; + return this->m_audioMixer->hasMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputOutputDevice1); } bool CContextAudio::parseCommandLine(const QString &commandLine) @@ -439,10 +457,11 @@ namespace BlackCore } else if (parser.commandStartsWith("vol") && parser.countParts() > 1) { - qint32 v = parser.toInt(1); + int v = parser.toInt(1); if (v >= 0 && v <= 300) { setVoiceOutputVolume(v); + return true; } } return false; @@ -473,7 +492,7 @@ namespace BlackCore break; case IVoiceChannel::ConnectingFailed: case IVoiceChannel::DisconnectedError: - qWarning() << "Voice room COM1 error"; + CLogMessage(this).warning("Voice channel disconnecting error"); // intentional fall-through case IVoiceChannel::Disconnected: if (this->getIContextOwnAircraft()) diff --git a/src/blackcore/context_audio_impl.h b/src/blackcore/context_audio_impl.h index 2e12caa00..6f9ecea1c 100644 --- a/src/blackcore/context_audio_impl.h +++ b/src/blackcore/context_audio_impl.h @@ -78,9 +78,12 @@ namespace BlackCore //! \copydoc IContextAudio::setCurrentAudioDevice() virtual void setCurrentAudioDevice(const BlackMisc::Audio::CAudioDeviceInfo &audioDevice) override; - //!\copydoc IContext::setVoiceOutputVolume + //! \copydoc IContext::setVoiceOutputVolume virtual void setVoiceOutputVolume(int volume) override; + //! \copydoc IContext::getVoiceOutputVolume + virtual int getVoiceOutputVolume() const override; + //! \copydoc ICOntext::setMute virtual void setMute(bool muted) override; @@ -96,14 +99,15 @@ namespace BlackCore //! \copydoc IContextAudio::enableAudioLoopback() virtual void enableAudioLoopback(bool enable = true) override; + //! \copydoc ICOntextAudio::isAudioLoopbackEnabled + virtual bool isAudioLoopbackEnabled() const override; + //! \addtogroup commandline //! @{ //!
         //! .mute                          mute             CContextAudio
         //! .unmute                        unmute           CContextAudio
-        //! .vol .volume   volume 0..100   set volume       CContextAudio
-        //! .vol1 .volume1 volume 0..100   set volume COM1  CContextAudio
-        //! .vol2 .volume2 volume 0..100   set volume COM2  CContextAudio
+        //! .vol .volume   volume 0..300   set volume       CContextAudio
         //! 
//! @} //! \copydoc IContextAudio::parseCommandLine diff --git a/src/blackcore/context_audio_proxy.cpp b/src/blackcore/context_audio_proxy.cpp index b3cf22cff..97cd8e8c6 100644 --- a/src/blackcore/context_audio_proxy.cpp +++ b/src/blackcore/context_audio_proxy.cpp @@ -33,7 +33,7 @@ namespace BlackCore void CContextAudioProxy::relaySignals(const QString &serviceName, QDBusConnection &connection) { bool s = connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(), - "changedVoiceRooms", this, SIGNAL(changedVoiceRooms(BlackMisc::Audio::CVoiceRoomList, bool))); + "changedVoiceRooms", this, SIGNAL(changedVoiceRooms(BlackMisc::Audio::CVoiceRoomList, bool))); Q_ASSERT(s); s = connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(), "changedAudioVolume", this, SIGNAL(changedAudioVolume(int))); @@ -151,6 +151,11 @@ namespace BlackCore this->m_dBusInterface->callDBus(QLatin1Literal("setVoiceOutputVolume"), volume); } + int CContextAudioProxy::getVoiceOutputVolume() const + { + return this->m_dBusInterface->callDBusRet(QLatin1Literal("getVoiceOutputVolume")); + } + /* * Toggle mute */ @@ -172,7 +177,15 @@ namespace BlackCore */ void CContextAudioProxy::enableAudioLoopback(bool enable) { - return this->m_dBusInterface->callDBus(QLatin1Literal("enableAudioLoopback"), enable); + this->m_dBusInterface->callDBus(QLatin1Literal("enableAudioLoopback"), enable); + } + + /* + * Loopback + */ + bool CContextAudioProxy::isAudioLoopbackEnabled() const + { + return this->m_dBusInterface->callDBusRet(QLatin1Literal("isAudioLoopbackEnabled")); } /* diff --git a/src/blackcore/context_audio_proxy.h b/src/blackcore/context_audio_proxy.h index 7704fbe7c..719e428ac 100644 --- a/src/blackcore/context_audio_proxy.h +++ b/src/blackcore/context_audio_proxy.h @@ -84,6 +84,9 @@ namespace BlackCore //!\copydoc IContext::setVoiceOutputVolume virtual void setVoiceOutputVolume(int volume) override; + //! \copydoc IContext::getVoiceOutputVolume + virtual int getVoiceOutputVolume() const override; + //! \copydoc IContextAudio::setMute virtual void setMute(bool muted) override; @@ -99,6 +102,9 @@ namespace BlackCore //! \copydoc IContextAudio::enableAudioLoopback() virtual void enableAudioLoopback(bool enable = true) override; + //! \copydoc IContextAudio::isAudioLoopbackEnabled() + virtual bool isAudioLoopbackEnabled() const override; + //! \copydoc IContextOwnAircraft::parseCommandLine virtual bool parseCommandLine(const QString &commandLine) override; diff --git a/src/blackgui/components/audiosetupcomponent.cpp b/src/blackgui/components/audiosetupcomponent.cpp index 21eea15ec..69e43d274 100644 --- a/src/blackgui/components/audiosetupcomponent.cpp +++ b/src/blackgui/components/audiosetupcomponent.cpp @@ -32,21 +32,21 @@ namespace BlackGui ui(new Ui::CAudioSetupComponent) { ui->setupUi(this); - this->ui->prb_SetupAudioTestProgress->hide(); - this->m_timerAudioTests = new QTimer(this); + + bool c = connect(this->ui->tb_ExpandNotificationSounds, &QToolButton::toggled, this, &CAudioSetupComponent::ps_onToggleNotificationSoundsVisibility); + Q_ASSERT(c); + c = connect(this->ui->cb_SetupAudioLoopback, &QCheckBox::toggled, this, &CAudioSetupComponent::ps_onLoopbackToggled); + Q_ASSERT(c); + Q_UNUSED(c); } CAudioSetupComponent::~CAudioSetupComponent() { } - /* - * Runtime set - */ void CAudioSetupComponent::runtimeHasBeenSet() { if (!this->getIContextSettings()) qFatal("Settings missing"); this->connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &CAudioSetupComponent::ps_changedSettings); - this->connect(this->m_timerAudioTests, &QTimer::timeout, this, &CAudioSetupComponent::ps_audioTestUpdate); // based on audio context Q_ASSERT(this->getIContextAudio()); @@ -54,22 +54,22 @@ namespace BlackGui { this->initAudioDeviceLists(); + // default + this->ui->cb_SetupAudioLoopback->setChecked(this->getIContextAudio()->isAudioLoopbackEnabled()); + // the connects depend on initAudioDeviceLists - bool connected = this->connect(this->ui->cb_SetupAudioInputDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_audioDeviceSelected(int))); + bool connected = this->connect(this->ui->cb_SetupAudioInputDevice, static_cast (&QComboBox::currentIndexChanged), this, &CAudioSetupComponent::ps_audioDeviceSelected); Q_ASSERT(connected); - connected = this->connect(this->ui->cb_SetupAudioOutputDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_audioDeviceSelected(int))); + connected = this->connect(this->ui->cb_SetupAudioOutputDevice, static_cast (&QComboBox::currentIndexChanged), this, &CAudioSetupComponent::ps_audioDeviceSelected); Q_ASSERT(connected); Q_UNUSED(connected); - this->connect(this->ui->pb_SetupAudioMicrophoneTest, &QPushButton::clicked, this, &CAudioSetupComponent::ps_startAudioTest); - this->connect(this->ui->pb_SetupAudioSquelchTest, &QPushButton::clicked, this, &CAudioSetupComponent::ps_startAudioTest); - // context -// this->connect(this->getIContextAudio(), &IContextAudio::audioTestCompleted, this, &CAudioSetupComponent::ps_audioTestUpdate); this->connect(this->getIContextAudio(), &IContextAudio::changedAudioDevices, this, &CAudioSetupComponent::ps_onAudioDevicesChanged); this->connect(this->getIContextAudio(), &IContextAudio::changedSelectedAudioDevices, this, &CAudioSetupComponent::ps_onCurrentAudioDevicesChanged); } this->reloadSettings(); + this->ui->tb_ExpandNotificationSounds->setChecked(false); // collapse } void CAudioSetupComponent::ps_changedSettings(uint typeValue) @@ -79,9 +79,6 @@ namespace BlackGui Q_UNUSED(type); } - /* - * Reload settings - */ void CAudioSetupComponent::reloadSettings() { // local copy @@ -93,9 +90,11 @@ namespace BlackGui this->ui->cb_SetupAudioNotificationVoiceRoom->setChecked(as.getNotificationFlag(BlackSound::CNotificationSounds::NotificationVoiceRoomJoined)); } - /* - * Set audio device lists - */ + void CAudioSetupComponent::ps_onToggleNotificationSoundsVisibility(bool checked) + { + this->ui->fr_NotificationSoundsInner->setVisible(checked); + } + void CAudioSetupComponent::initAudioDeviceLists() { if (!this->getIContextAudio()) { return; } @@ -103,118 +102,31 @@ namespace BlackGui this->ps_onCurrentAudioDevicesChanged(this->getIContextAudio()->getCurrentAudioDevices()); } - /* - * Notification sounds - */ bool CAudioSetupComponent::playNotificationSounds() const { return this->ui->cb_SetupAudioPlayNotificationSounds->isChecked(); } - /* - * Start the voice tests - */ - void CAudioSetupComponent::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 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 CAudioSetupComponent::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(); - double s = 0.0; - this->ui->pte_SetupAudioTestActionAndResult->appendPlainText(QString::number(s)); - } - else if (this->m_audioTestRunning == MicrophoneTest) - { -// QString m = this->getIContextAudio()->getMicrophoneTestResult(); - QString m; - 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 CAudioSetupComponent::ps_audioDeviceSelected(int index) { if (!this->getIContextAudio()) return; - if (index < 0)return; + if (index < 0) { return; } CAudioDeviceInfoList devices = this->getIContextAudio()->getAudioDevices(); - if (devices.isEmpty()) return; + if (devices.isEmpty()) { return; } CAudioDeviceInfo selectedDevice; QObject *sender = QObject::sender(); if (sender == this->ui->cb_SetupAudioInputDevice) { CAudioDeviceInfoList inputDevices = devices.getInputDevices(); - if (index >= inputDevices.size()) return; + if (index >= inputDevices.size()) { return; } selectedDevice = inputDevices[index]; this->getIContextAudio()->setCurrentAudioDevice(selectedDevice); } else if (sender == this->ui->cb_SetupAudioOutputDevice) { CAudioDeviceInfoList outputDevices = devices.getOutputDevices(); - if (index >= outputDevices.size()) return; + if (index >= outputDevices.size()) { return; } selectedDevice = outputDevices[index]; this->getIContextAudio()->setCurrentAudioDevice(selectedDevice); } @@ -222,7 +134,7 @@ namespace BlackGui void CAudioSetupComponent::ps_onCurrentAudioDevicesChanged(const CAudioDeviceInfoList &devices) { - for(auto &device : devices) + for (auto &device : devices) { if (device.getType() == CAudioDeviceInfo::InputDevice) { @@ -240,7 +152,7 @@ namespace BlackGui this->ui->cb_SetupAudioOutputDevice->clear(); this->ui->cb_SetupAudioInputDevice->clear(); - for(auto &device : devices) + for (auto &device : devices) { if (device.getType() == CAudioDeviceInfo::InputDevice) { @@ -253,5 +165,12 @@ namespace BlackGui } } + void CAudioSetupComponent::ps_onLoopbackToggled(bool loopback) + { + Q_ASSERT(this->getIContextAudio()); + if (this->getIContextAudio()->isAudioLoopbackEnabled() == loopback) { return; } + this->getIContextAudio()->enableAudioLoopback(loopback); + } + } // namespace } // namespace diff --git a/src/blackgui/components/audiosetupcomponent.h b/src/blackgui/components/audiosetupcomponent.h index 6d5e8f087..c7e9b2937 100644 --- a/src/blackgui/components/audiosetupcomponent.h +++ b/src/blackgui/components/audiosetupcomponent.h @@ -53,12 +53,6 @@ namespace BlackGui //! 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) @@ -71,21 +65,17 @@ namespace BlackGui //! Audio devices changed void ps_onAudioDevicesChanged(const BlackMisc::Audio::CAudioDeviceInfoList &devices); - private: - //! Audio test modes - enum AudioTest - { - NoAudioTest, - SquelchTest, - MicrophoneTest - }; + //! Loopback toggled + void ps_onLoopbackToggled(bool loopback); + //! Visibilty (show/hide buttons) + void ps_onToggleNotificationSoundsVisibility(bool checked); + + private: //! Audio device lists from settings void initAudioDeviceLists(); QScopedPointer ui; - QTimer *m_timerAudioTests; //!< audio tests: progress bar, disable/enable buttons - AudioTest m_audioTestRunning = NoAudioTest; }; } // namespace } // namespace diff --git a/src/blackgui/components/audiosetupcomponent.ui b/src/blackgui/components/audiosetupcomponent.ui index 3b6a2e744..318bed65d 100644 --- a/src/blackgui/components/audiosetupcomponent.ui +++ b/src/blackgui/components/audiosetupcomponent.ui @@ -20,23 +20,23 @@ QFrame::Raised - - 3 - - 0 + 2 - 0 + 2 - 0 + 2 - 0 + 2 + + QLayout::SetDefaultConstraint + QFormLayout::AllNonFixedFieldsGrow @@ -96,143 +96,112 @@ - + - Tests + Test - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - false - - - Squelch test - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Mic. test - - - - - - - - - - + - Result - - - - - - - - 16777215 - 40 - - - - true - - - - - - - - 0 - 0 - - - - 0 - - - - - - - Notification sounds - - - - - - - play notification sounds - - - - - - - notification for text messages - - - - - - - notification for join/leave voice room + Loopback, test sound input to output loop + + + + + + Notification sounds + + + + + + + + 18 + 18 + + + + Toggle visibility + + + ... + + + + :/diagona/icons/diagona/icons/toggle-expand.png + :/diagona/icons/diagona/icons/toggle.png:/diagona/icons/diagona/icons/toggle-expand.png + + + true + + + true + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + notification for join/leave voice room + + + + + + + play notification sounds + + + false + + + + + + + notification for text messages + + + + + + + + + + + + Qt::Vertical + + + + 20 + 143 + + + + - + + + diff --git a/src/blackgui/components/audiovolumecomponent.cpp b/src/blackgui/components/audiovolumecomponent.cpp index 94f0ab6c9..f670c7dbe 100644 --- a/src/blackgui/components/audiovolumecomponent.cpp +++ b/src/blackgui/components/audiovolumecomponent.cpp @@ -25,13 +25,10 @@ namespace BlackGui ui->setupUi(this); bool c = connect(this->ui->pb_ShowWinMixer, &QPushButton::pressed, this, &CAudioVolumeComponent::ps_onWindowsMixerRequested); Q_ASSERT(c); - - c = connect(this->ui->hs_VolumeCom1, &QSlider::sliderReleased, this, &CAudioVolumeComponent::ps_changeVolume); + c = connect(this->ui->hs_Volume, &QSlider::valueChanged, this, &CAudioVolumeComponent::ps_changeOutputVolumeFromSlider); Q_ASSERT(c); - - c = connect(this->ui->hs_VolumeCom2, &QSlider::sliderReleased, this, &CAudioVolumeComponent::ps_changeVolume); + c = connect(this->ui->sb_Volume, static_cast (&QSpinBox::valueChanged), this, &CAudioVolumeComponent::ps_changeOutputVolumeFromSpinBox); Q_ASSERT(c); - Q_UNUSED(c); } @@ -43,13 +40,22 @@ namespace BlackGui // from audio context bool c = connect(this->getIContextAudio(), &IContextAudio::changedMute, this, &CAudioVolumeComponent::ps_onMuteChanged); Q_ASSERT(c); -// connect(this->getIContextAudio(), &IContextAudio::changedAudioVolumes, this, &CAudioVolumeComponent::ps_onVolumesChanged); + connect(this->getIContextAudio(), &IContextAudio::changedAudioVolume, this, &CAudioVolumeComponent::ps_onOutputVolumeChanged); Q_ASSERT(c); // to audio audio context c = connect(this->ui->pb_Mute, &QPushButton::toggled, this->getIContextAudio(), &IContextAudio::setMute); Q_ASSERT(c); Q_UNUSED(c); + + if (this->getIContextAudio()->isUsingImplementingObject()) + { + this->ui->lbl_ContextLocation->setText("local"); + } + else + { + this->ui->lbl_ContextLocation->setText("remote"); + } } void CAudioVolumeComponent::ps_onMuteChanged(bool muted) @@ -58,21 +64,57 @@ namespace BlackGui this->ui->pb_Mute->setChecked(muted); } - void CAudioVolumeComponent::ps_onVolumesChanged(qint32 com1Volume, qint32 com2Volume) + void CAudioVolumeComponent::ps_onOutputVolumeChanged(int volume) { - this->ui->hs_VolumeCom1->setValue(com1Volume); - this->ui->hs_VolumeCom2->setValue(com2Volume); - this->ui->hs_VolumeCom1->setToolTip(QString::number(com1Volume)); - this->ui->hs_VolumeCom2->setToolTip(QString::number(com2Volume)); + this->ui->hs_Volume->setToolTip(QString::number(volume)); + + // comparisons to avoid rountrips + QString v = QString::number(volume); + if (volume != this->ui->sb_Volume->value()) + { + this->ui->sb_Volume->setValue(volume); + this->ui->sb_Volume->setToolTip(v); + } + + + if (volume > 100) + { + int v = volume - 100; + volume = 100 + v / 5; + } + + if (volume != this->ui->hs_Volume->value()) + { + this->ui->hs_Volume->setValue(volume); + this->ui->hs_Volume->setToolTip(v); + } } - void CAudioVolumeComponent::ps_changeVolume() + void CAudioVolumeComponent::ps_changeOutputVolumeFromSlider(int volume) { - qint32 v1 = this->ui->hs_VolumeCom1->value(); - qint32 v2 = this->ui->hs_VolumeCom2->value(); - this->ui->hs_VolumeCom1->setToolTip(QString::number(v1)); - this->ui->hs_VolumeCom2->setToolTip(QString::number(v2)); -// this->getIContextAudio()->setVolumes(v1, v2); + if (volume > 100) + { + // 100 -> 100, 120 -> 200, 140 -> 300 + int v = volume - 100; + volume = 100 + v * 5; + } + this->ui->hs_Volume->setToolTip(QString::number(volume)); + + Q_ASSERT(this->getIContextAudio()); + if (this->getIContextAudio()->getVoiceOutputVolume() != volume) + { + this->getIContextAudio()->setVoiceOutputVolume(volume); + } + } + + void CAudioVolumeComponent::ps_changeOutputVolumeFromSpinBox(int volume) + { + this->ui->sb_Volume->setToolTip(QString::number(volume)); + Q_ASSERT(this->getIContextAudio()); + if (this->getIContextAudio()->getVoiceOutputVolume() != volume) + { + this->getIContextAudio()->setVoiceOutputVolume(volume); + } } void CAudioVolumeComponent::ps_onWindowsMixerRequested() diff --git a/src/blackgui/components/audiovolumecomponent.h b/src/blackgui/components/audiovolumecomponent.h index c2337d5e8..a01315d4f 100644 --- a/src/blackgui/components/audiovolumecomponent.h +++ b/src/blackgui/components/audiovolumecomponent.h @@ -45,10 +45,13 @@ namespace BlackGui void ps_onMuteChanged(bool muted); //! Volumes changed (elsewhere) - void ps_onVolumesChanged(qint32 com1Volume, qint32 com2Volume); + void ps_onOutputVolumeChanged(int volume); //! Change values because of volume GUI controls - void ps_changeVolume(); + void ps_changeOutputVolumeFromSlider(int volume); + + //! Change values because of volume GUI controls + void ps_changeOutputVolumeFromSpinBox(int volume); //! Requested windows mixer void ps_onWindowsMixerRequested(); diff --git a/src/blackgui/components/audiovolumecomponent.ui b/src/blackgui/components/audiovolumecomponent.ui index f04a907bf..476baea58 100644 --- a/src/blackgui/components/audiovolumecomponent.ui +++ b/src/blackgui/components/audiovolumecomponent.ui @@ -6,8 +6,8 @@ 0 0 - 400 - 300 + 275 + 58 @@ -36,10 +36,7 @@ 0 - - - QFormLayout::AllNonFixedFieldsGrow - + 10 @@ -56,50 +53,36 @@ - - - - Volume COM1 - - - - - - - 100 - - - 5 - - - 50 - - - Qt::Horizontal - - - - + - Volume COM2 + Volume - + - 100 + 140 5 + + 90 + - 50 + 90 Qt::Horizontal + + QSlider::TicksAbove + + + 100 + @@ -174,7 +157,7 @@ - + Qt::Horizontal @@ -189,6 +172,26 @@ + + + + local + + + + + + + 300 + + + 5 + + + 90 + + + diff --git a/src/blackgui/qss/mainwindow.qss b/src/blackgui/qss/mainwindow.qss index 3828cb56b..7da802ab2 100644 --- a/src/blackgui/qss/mainwindow.qss +++ b/src/blackgui/qss/mainwindow.qss @@ -225,6 +225,10 @@ QLabel { background: transparent; } +QToolButton { + background-color: transparent; /* transparent tool buttons */ +} + QLineEdit { background: transparent; border: 1px solid green; diff --git a/src/blackmisc/blackmisc.qrc b/src/blackmisc/blackmisc.qrc index 8017b5005..3fd514987 100644 --- a/src/blackmisc/blackmisc.qrc +++ b/src/blackmisc/blackmisc.qrc @@ -308,6 +308,10 @@ icons/diagona/icons/speaker-network.png icons/diagona/icons/speaker--pencil.png icons/diagona/icons/speaker--plus.png + icons/diagona/icons/toggle.png + icons/diagona/icons/toggle-expand.png + icons/diagona/icons/toggle-small.png + icons/diagona/icons/toggle-small-expand.png icons/own/app.jpg