UI: Show remaining reconnect timeout duration

When a reconnect is occurring, the user doesn't really know that the
program is waiting to reconnect to the server or not, nor does the user
know how many seconds are remaining until that next attempt.  This will
show the reconnect timeout countdown as it's occurring.
This commit is contained in:
jp9000 2015-05-10 16:18:11 -07:00
parent c1e8d28548
commit 83df87c552
3 changed files with 21 additions and 7 deletions

View File

@ -137,7 +137,8 @@ Basic.PropertiesWindow.NoProperties="No properties available"
Basic.InteractionWindow="Interacting with '%1'"
# status bar
Basic.StatusBar.Reconnecting="Disconnected, reconnecting (attempt %1)"
Basic.StatusBar.Reconnecting="Disconnected, reconnecting in %2 second(s) (attempt %1)"
Basic.StatusBar.AttemptingReconnect="Attempting to reconnect... (attempt %1)"
Basic.StatusBar.ReconnectSuccessful="Reconnection successful"
# filters window

View File

@ -106,6 +106,17 @@ void OBSBasicStatusBar::UpdateSessionTime()
text.sprintf("%02d:%02d:%02d", hours, minutes, seconds);
sessionTime->setText(text);
sessionTime->setMinimumWidth(sessionTime->width());
if (reconnectTimeout > 0) {
QString msg = QTStr("Basic.StatusBar.Reconnecting");
showMessage(msg.arg(QString::number(retries),
QString::number(reconnectTimeout)));
reconnectTimeout--;
} else if (retries > 0) {
QString msg = QTStr("Basic.StatusBar.AttemptingReconnect");
showMessage(msg.arg(QString::number(retries)));
}
}
void OBSBasicStatusBar::UpdateDroppedFrames()
@ -132,7 +143,8 @@ void OBSBasicStatusBar::OBSOutputReconnect(void *data, calldata_t *params)
OBSBasicStatusBar *statusBar =
reinterpret_cast<OBSBasicStatusBar*>(data);
QMetaObject::invokeMethod(statusBar, "Reconnect");
int seconds = (int)calldata_int(params, "timeout_sec");
QMetaObject::invokeMethod(statusBar, "Reconnect", Q_ARG(int, seconds));
UNUSED_PARAMETER(params);
}
@ -145,18 +157,17 @@ void OBSBasicStatusBar::OBSOutputReconnectSuccess(void *data, calldata_t *params
UNUSED_PARAMETER(params);
}
void OBSBasicStatusBar::Reconnect()
void OBSBasicStatusBar::Reconnect(int seconds)
{
retries++;
QString reconnectMsg = QTStr("Basic.StatusBar.Reconnecting");
showMessage(reconnectMsg.arg(QString::number(retries)));
reconnectTimeout = seconds;
}
void OBSBasicStatusBar::ReconnectSuccess()
{
showMessage(QTStr("Basic.StatusBar.ReconnectSuccessful"), 4000);
retries = 0;
reconnectTimeout = 0;
bitrateUpdateSeconds = -1;
lastBytesSent = 0;
lastBytesSentTime = os_gettime_ns();

View File

@ -24,6 +24,8 @@ private:
int activeRefs = 0;
int totalSeconds = 0;
int reconnectTimeout = 0;
int bitrateUpdateSeconds = 0;
uint64_t lastBytesSent = 0;
uint64_t lastBytesSentTime = 0;
@ -43,7 +45,7 @@ private:
static void OBSOutputReconnectSuccess(void *data, calldata_t *params);
private slots:
void Reconnect();
void Reconnect(int seconds);
void ReconnectSuccess();
void UpdateStatusBar();
void UpdateCPUUsage();