Skip to content

Commit

Permalink
Add settings option to allow aircraft radio stack volume knobs to con…
Browse files Browse the repository at this point in the history
…trol radio volume
  • Loading branch information
justinshannon committed Jan 2, 2022
1 parent 81c7498 commit ad90f93
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
21 changes: 18 additions & 3 deletions client/Resources/Views/SettingsWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import AppConfig 1.0
Window {
id: formSettings
title: "Settings"
width: 650
height: 560
width: 670
height: 580
minimumHeight: height
minimumWidth: width
maximumHeight: height
Expand Down Expand Up @@ -73,6 +73,7 @@ Window {
switchAlertSelcal.checked = AppConfig.AlertSelcal;
switchAlertDisconnect.checked = AppConfig.AlertDisconnect;
switchKeepWindowVisible.checked = AppConfig.KeepWindowVisible
switchAircraftVolumeKnobs.checked = AppConfig.AircraftRadioStackControlsVolume
}

onAfterRendering: {
Expand Down Expand Up @@ -517,7 +518,7 @@ Window {
onLinkActivated: Qt.openUrlExternally(link)
renderType: Text.NativeRendering
wrapMode: Text.WordWrap
Layout.maximumWidth: 600
Layout.maximumWidth: 300
linkColor: "#0164AD"
font.pixelSize: 13
color: "#333333"
Expand Down Expand Up @@ -564,6 +565,20 @@ Window {
audio.setCom2Volume(volume)
}
}

CustomSwitch {
id: switchAircraftVolumeKnobs
text: "Allow aircraft radio stack volume knobs to control radio volume"
font.pixelSize: 13
clip: false
Layout.preferredHeight: 35
Layout.preferredWidth: 300
leftPadding: 0
topPadding: 20
onCheckedChanged: {
AppConfig.AircraftRadioStackControlsVolume = switchAircraftVolumeKnobs.checked
}
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions client/src/audio/afv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ namespace xpilot
m_client->setTxRadio(1);
}

m_client->setRadioGain(0, ScaleVolume(m_radioStackState.Com1Volume / 100.0f));
m_client->setRadioGain(1, ScaleVolume(m_radioStackState.Com2Volume / 100.0f));
if(AppConfig::getInstance()->AircraftRadioStackControlsVolume) {
m_client->setRadioGain(0, ScaleVolume(m_radioStackState.Com1Volume / 100.0f));
m_client->setRadioGain(1, ScaleVolume(m_radioStackState.Com2Volume / 100.0f));
}

updateTransceivers();
}
Expand Down
3 changes: 3 additions & 0 deletions client/src/config/appconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void AppConfig::loadConfig()
XplaneUdpPort = XPLANE_UDP_PORT;
SilenceModelInstall = false;
KeepWindowVisible = false;
AircraftRadioStackControlsVolume = true;

saveConfig();
loadConfig();
Expand Down Expand Up @@ -111,6 +112,7 @@ void AppConfig::loadConfig()
SilenceModelInstall = jsonMap["SilenceModelInstall"].toBool();
VisualMachines = jsonMap["VisualMachines"].toStringList();
KeepWindowVisible = jsonMap["KeepWindowVisible"].toBool();
AircraftRadioStackControlsVolume = jsonMap["AircraftRadioStackControlsVolume"].toBool();

QJsonArray cachedServers = jsonMap["CachedServers"].toJsonArray();
for(const auto & value : cachedServers) {
Expand Down Expand Up @@ -186,6 +188,7 @@ void AppConfig::saveConfig()
jsonObj["XplaneUdpPort"] = XplaneUdpPort == 0 ? XPLANE_UDP_PORT : XplaneUdpPort;
jsonObj["SilenceModelInstall"] = SilenceModelInstall;
jsonObj["KeepWindowVisible"] = KeepWindowVisible;
jsonObj["AircraftRadioStackControlsVolume"] = AircraftRadioStackControlsVolume;

QJsonArray cachedServers;
for(auto & server : CachedServers) {
Expand Down
2 changes: 2 additions & 0 deletions client/src/config/appconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ namespace xpilot
bool SilenceModelInstall;
QStringList VisualMachines;
bool KeepWindowVisible;
bool AircraftRadioStackControlsVolume;
bool VelocityEnabled;

QString NameWithHomeAirport() const
Expand Down Expand Up @@ -119,6 +120,7 @@ namespace xpilot
Q_PROPERTY(bool SilenceModelInstall MEMBER SilenceModelInstall)
Q_PROPERTY(QStringList VisualMachines MEMBER VisualMachines)
Q_PROPERTY(bool KeepWindowVisible MEMBER KeepWindowVisible)
Q_PROPERTY(bool AircraftRadioStackControlsVolume MEMBER AircraftRadioStackControlsVolume)
Q_PROPERTY(bool VelocityEnabled MEMBER VelocityEnabled)

signals:
Expand Down

0 comments on commit ad90f93

Please sign in to comment.