Add preference and tweak connection warning

This commit is contained in:
Cameron Gutman 2019-03-18 20:21:52 -07:00
parent 202a643e5a
commit f624a1817e
5 changed files with 31 additions and 2 deletions

View file

@ -476,6 +476,16 @@ Flickable {
prefs.startWindowed = !checked
}
}
CheckBox {
id: connectionWarningsCheck
text: "Show connection quality warnings"
font.pointSize: 12
checked: prefs.connectionWarnings
onCheckedChanged: {
prefs.connectionWarnings = checked
}
}
}
}
}

View file

@ -24,6 +24,7 @@
#define SER_MOUSEACCELERATION "mouseacceleration"
#define SER_STARTWINDOWED "startwindowed"
#define SER_FRAMEPACING "framepacing"
#define SER_CONNWARNINGS "connwarnings"
StreamingPreferences::StreamingPreferences(QObject *parent)
: QObject(parent)
@ -49,6 +50,7 @@ void StreamingPreferences::reload()
mouseAcceleration = settings.value(SER_MOUSEACCELERATION, false).toBool();
startWindowed = settings.value(SER_STARTWINDOWED, false).toBool();
framePacing = settings.value(SER_FRAMEPACING, false).toBool();
connectionWarnings = settings.value(SER_CONNWARNINGS, true).toBool();
audioConfig = static_cast<AudioConfig>(settings.value(SER_AUDIOCFG,
static_cast<int>(AudioConfig::AC_STEREO)).toInt());
videoCodecConfig = static_cast<VideoCodecConfig>(settings.value(SER_VIDEOCFG,
@ -79,6 +81,7 @@ void StreamingPreferences::save()
settings.setValue(SER_MOUSEACCELERATION, mouseAcceleration);
settings.setValue(SER_STARTWINDOWED, startWindowed);
settings.setValue(SER_FRAMEPACING, framePacing);
settings.setValue(SER_CONNWARNINGS, connectionWarnings);
settings.setValue(SER_AUDIOCFG, static_cast<int>(audioConfig));
settings.setValue(SER_VIDEOCFG, static_cast<int>(videoCodecConfig));
settings.setValue(SER_VIDEODEC, static_cast<int>(videoDecoderSelection));

View file

@ -77,6 +77,7 @@ public:
Q_PROPERTY(bool mouseAcceleration MEMBER mouseAcceleration NOTIFY mouseAccelerationChanged)
Q_PROPERTY(bool startWindowed MEMBER startWindowed NOTIFY startWindowedChanged)
Q_PROPERTY(bool framePacing MEMBER framePacing NOTIFY framePacingChanged)
Q_PROPERTY(bool connectionWarnings MEMBER connectionWarnings NOTIFY connectionWarningsChanged)
Q_PROPERTY(AudioConfig audioConfig MEMBER audioConfig NOTIFY audioConfigChanged)
Q_PROPERTY(VideoCodecConfig videoCodecConfig MEMBER videoCodecConfig NOTIFY videoCodecConfigChanged)
Q_PROPERTY(VideoDecoderSelection videoDecoderSelection MEMBER videoDecoderSelection NOTIFY videoDecoderSelectionChanged)
@ -97,6 +98,7 @@ public:
bool mouseAcceleration;
bool startWindowed;
bool framePacing;
bool connectionWarnings;
AudioConfig audioConfig;
VideoCodecConfig videoCodecConfig;
VideoDecoderSelection videoDecoderSelection;
@ -119,5 +121,6 @@ signals:
void windowModeChanged();
void startWindowedChanged();
void framePacingChanged();
void connectionWarningsChanged();
};

View file

@ -117,10 +117,23 @@ void Session::clRumble(unsigned short controllerNumber, unsigned short lowFreqMo
void Session::clConnectionStatusUpdate(int connectionStatus)
{
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
"Connection status update: %d",
connectionStatus);
if (!s_ActiveSession->m_Preferences->connectionWarnings) {
return;
}
switch (connectionStatus)
{
case CONN_STATUS_POOR:
strcpy(s_ActiveSession->m_OverlayManager.getOverlayText(Overlay::OverlayStatusUpdate), "Poor network connection");
if (s_ActiveSession->m_StreamConfig.bitrate > 5000) {
strcpy(s_ActiveSession->m_OverlayManager.getOverlayText(Overlay::OverlayStatusUpdate), "Slow connection to PC\nReduce bitrate");
}
else {
strcpy(s_ActiveSession->m_OverlayManager.getOverlayText(Overlay::OverlayStatusUpdate), "Poor connection to PC");
}
s_ActiveSession->m_OverlayManager.setOverlayTextUpdated(Overlay::OverlayStatusUpdate);
s_ActiveSession->m_OverlayManager.setOverlayState(Overlay::OverlayStatusUpdate, true);
break;

@ -1 +1 @@
Subproject commit c9745855fd3d0eb2f5c4c4546a30c849b7453a7c
Subproject commit e9bc1070b716e1cd79646cba9e02293f1ffb4c3b