Add configuration for audio channels

pull/53/head
michal.szwaj 2018-03-11 15:14:44 +01:00
parent f8d8349082
commit d65d3f896e
5 changed files with 54 additions and 4 deletions

View File

@ -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;

View File

@ -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;
};
}

View File

@ -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<uint32_t>(BluetoothAdapterType::NONE)));
bluetoothRemoteAdapterAddress_ = iniConfig.get<std::string>(cBluetoothRemoteAdapterAddressKey, "");
musicAudioChannelEnabled_ = iniConfig.get<bool>(cAudioMusicAudioChannelEnabled, true);
speechAudiochannelEnabled_ = iniConfig.get<bool>(cAudioSpeechAudioChannelEnabled, true);
}
catch(const boost::property_tree::ini_parser_error& e)
{
@ -131,6 +137,9 @@ void Configuration::save()
iniConfig.put<uint32_t>(cBluetoothAdapterTypeKey, static_cast<uint32_t>(bluetoothAdapterType_));
iniConfig.put<std::string>(cBluetoothRemoteAdapterAddressKey, bluetoothRemoteAdapterAddress_);
iniConfig.put<bool>(cAudioMusicAudioChannelEnabled, musicAudioChannelEnabled_);
iniConfig.put<bool>(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);

View File

@ -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()

View File

@ -381,7 +381,7 @@ color: rgb(238, 238, 236);</string>
<property name="title">
<string>Audio channels</string>
</property>
<widget class="QCheckBox" name="checkBoxMusicChannel">
<widget class="QCheckBox" name="checkBoxMusicAudioChannel">
<property name="geometry">
<rect>
<x>10</x>
@ -394,7 +394,7 @@ color: rgb(238, 238, 236);</string>
<string>Music channel</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxSpeechChannel">
<widget class="QCheckBox" name="checkBoxSpeechAudioChannel">
<property name="geometry">
<rect>
<x>160</x>
@ -913,8 +913,8 @@ color: rgb(238, 238, 236);</string>
<tabstop>radioButton1080p</tabstop>
<tabstop>spinBoxOmxLayerIndex</tabstop>
<tabstop>horizontalSliderScreenDPI</tabstop>
<tabstop>checkBoxMusicChannel</tabstop>
<tabstop>checkBoxSpeechChannel</tabstop>
<tabstop>checkBoxMusicAudioChannel</tabstop>
<tabstop>checkBoxSpeechAudioChannel</tabstop>
<tabstop>checkBoxEnableTouchscreen</tabstop>
<tabstop>listWidgetButtons</tabstop>
<tabstop>checkBoxPlayButton</tabstop>