From d65d3f896ebeac1182e4280e2fad098fb24a81c4 Mon Sep 17 00:00:00 2001 From: "michal.szwaj" Date: Sun, 11 Mar 2018 15:14:44 +0100 Subject: [PATCH] Add configuration for audio channels --- .../autoapp/Configuration/Configuration.hpp | 10 +++++++ .../autoapp/Configuration/IConfiguration.hpp | 5 ++++ src/autoapp/Configuration/Configuration.cpp | 29 +++++++++++++++++++ src/autoapp/UI/SettingsWindow.cpp | 6 ++++ src/autoapp/UI/settingswindow.ui | 8 ++--- 5 files changed, 54 insertions(+), 4 deletions(-) diff --git a/include/f1x/openauto/autoapp/Configuration/Configuration.hpp b/include/f1x/openauto/autoapp/Configuration/Configuration.hpp index 59c60b0..2498977 100644 --- a/include/f1x/openauto/autoapp/Configuration/Configuration.hpp +++ b/include/f1x/openauto/autoapp/Configuration/Configuration.hpp @@ -63,6 +63,11 @@ public: std::string getBluetoothRemoteAdapterAddress() const override; void setBluetoothRemoteAdapterAddress(const std::string& value) override; + bool musicAudioChannelEnabled() const override; + void setMusicAudioChannelEnabled(bool value) override; + bool speechAudioChannelEnabled() const override; + void setSpeechAudioChannelEnabled(bool value) override; + private: void readButtonCodes(boost::property_tree::ptree& iniConfig); void insertButtonCode(boost::property_tree::ptree& iniConfig, const std::string& buttonCodeKey, aasdk::proto::enums::ButtonCode::Enum buttonCode); @@ -78,6 +83,8 @@ private: ButtonCodes buttonCodes_; BluetoothAdapterType bluetoothAdapterType_; std::string bluetoothRemoteAdapterAddress_; + bool musicAudioChannelEnabled_; + bool speechAudiochannelEnabled_; static const std::string cConfigFileName; @@ -89,6 +96,9 @@ private: static const std::string cVideoScreenDPIKey; static const std::string cVideoOMXLayerIndexKey; + static const std::string cAudioMusicAudioChannelEnabled; + static const std::string cAudioSpeechAudioChannelEnabled; + static const std::string cBluetoothAdapterTypeKey; static const std::string cBluetoothRemoteAdapterAddressKey; diff --git a/include/f1x/openauto/autoapp/Configuration/IConfiguration.hpp b/include/f1x/openauto/autoapp/Configuration/IConfiguration.hpp index e3bd23f..48437f6 100644 --- a/include/f1x/openauto/autoapp/Configuration/IConfiguration.hpp +++ b/include/f1x/openauto/autoapp/Configuration/IConfiguration.hpp @@ -69,6 +69,11 @@ public: virtual void setBluetoothAdapterType(BluetoothAdapterType value) = 0; virtual std::string getBluetoothRemoteAdapterAddress() const = 0; virtual void setBluetoothRemoteAdapterAddress(const std::string& value) = 0; + + virtual bool musicAudioChannelEnabled() const = 0; + virtual void setMusicAudioChannelEnabled(bool value) = 0; + virtual bool speechAudioChannelEnabled() const = 0; + virtual void setSpeechAudioChannelEnabled(bool value) = 0; }; } diff --git a/src/autoapp/Configuration/Configuration.cpp b/src/autoapp/Configuration/Configuration.cpp index 1d14954..90b083b 100644 --- a/src/autoapp/Configuration/Configuration.cpp +++ b/src/autoapp/Configuration/Configuration.cpp @@ -38,6 +38,9 @@ const std::string Configuration::cVideoResolutionKey = "Video.Resolution"; const std::string Configuration::cVideoScreenDPIKey = "Video.ScreenDPI"; const std::string Configuration::cVideoOMXLayerIndexKey = "Video.OMXLayerIndex"; +const std::string Configuration::cAudioMusicAudioChannelEnabled = "Audio.MusicAudioChannelEnabled"; +const std::string Configuration::cAudioSpeechAudioChannelEnabled = "Audio.SpeechAudioChannelEnabled"; + const std::string Configuration::cBluetoothAdapterTypeKey = "Bluetooth.AdapterType"; const std::string Configuration::cBluetoothRemoteAdapterAddressKey = "Bluetooth.RemoteAdapterAddress"; @@ -92,6 +95,9 @@ void Configuration::load() static_cast(BluetoothAdapterType::NONE))); bluetoothRemoteAdapterAddress_ = iniConfig.get(cBluetoothRemoteAdapterAddressKey, ""); + + musicAudioChannelEnabled_ = iniConfig.get(cAudioMusicAudioChannelEnabled, true); + speechAudiochannelEnabled_ = iniConfig.get(cAudioSpeechAudioChannelEnabled, true); } catch(const boost::property_tree::ini_parser_error& e) { @@ -131,6 +137,9 @@ void Configuration::save() iniConfig.put(cBluetoothAdapterTypeKey, static_cast(bluetoothAdapterType_)); iniConfig.put(cBluetoothRemoteAdapterAddressKey, bluetoothRemoteAdapterAddress_); + + iniConfig.put(cAudioMusicAudioChannelEnabled, musicAudioChannelEnabled_); + iniConfig.put(cAudioSpeechAudioChannelEnabled, speechAudiochannelEnabled_); boost::property_tree::ini_parser::write_ini(cConfigFileName, iniConfig); } @@ -234,6 +243,26 @@ void Configuration::setBluetoothRemoteAdapterAddress(const std::string& value) bluetoothRemoteAdapterAddress_ = value; } +bool Configuration::musicAudioChannelEnabled() const +{ + return musicAudioChannelEnabled_; +} + +void Configuration::setMusicAudioChannelEnabled(bool value) +{ + musicAudioChannelEnabled_ = value; +} + +bool Configuration::speechAudioChannelEnabled() const +{ + return speechAudiochannelEnabled_; +} + +void Configuration::setSpeechAudioChannelEnabled(bool value) +{ + speechAudiochannelEnabled_ = value; +} + void Configuration::readButtonCodes(boost::property_tree::ptree& iniConfig) { this->insertButtonCode(iniConfig, cInputPlayButtonKey, aasdk::proto::enums::ButtonCode::PLAY); diff --git a/src/autoapp/UI/SettingsWindow.cpp b/src/autoapp/UI/SettingsWindow.cpp index c520398..dd55a57 100644 --- a/src/autoapp/UI/SettingsWindow.cpp +++ b/src/autoapp/UI/SettingsWindow.cpp @@ -91,6 +91,9 @@ void SettingsWindow::onSave() configuration_->setBluetoothRemoteAdapterAddress(ui_->lineEditExternalBluetoothAdapterAddress->text().toStdString()); + configuration_->setMusicAudioChannelEnabled(ui_->checkBoxMusicAudioChannel->isChecked()); + configuration_->setSpeechAudioChannelEnabled(ui_->checkBoxSpeechAudioChannel->isChecked()); + configuration_->save(); this->close(); } @@ -135,6 +138,9 @@ void SettingsWindow::load() ui_->radioButtonUseExternalBluetoothAdapter->setChecked(configuration_->getBluetoothAdapterType() == configuration::BluetoothAdapterType::REMOTE); ui_->lineEditExternalBluetoothAdapterAddress->setEnabled(configuration_->getBluetoothAdapterType() == configuration::BluetoothAdapterType::REMOTE); ui_->lineEditExternalBluetoothAdapterAddress->setText(QString::fromStdString(configuration_->getBluetoothRemoteAdapterAddress())); + + ui_->checkBoxMusicAudioChannel->setChecked(configuration_->musicAudioChannelEnabled()); + ui_->checkBoxSpeechAudioChannel->setChecked(configuration_->speechAudioChannelEnabled()); } void SettingsWindow::loadButtonCheckBoxes() diff --git a/src/autoapp/UI/settingswindow.ui b/src/autoapp/UI/settingswindow.ui index cfff6c5..11e6ad4 100644 --- a/src/autoapp/UI/settingswindow.ui +++ b/src/autoapp/UI/settingswindow.ui @@ -381,7 +381,7 @@ color: rgb(238, 238, 236); Audio channels - + 10 @@ -394,7 +394,7 @@ color: rgb(238, 238, 236); Music channel - + 160 @@ -913,8 +913,8 @@ color: rgb(238, 238, 236); radioButton1080p spinBoxOmxLayerIndex horizontalSliderScreenDPI - checkBoxMusicChannel - checkBoxSpeechChannel + checkBoxMusicAudioChannel + checkBoxSpeechAudioChannel checkBoxEnableTouchscreen listWidgetButtons checkBoxPlayButton