mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-24 23:31:36 +08:00
UI: Track streaming state in OBSBasic
Avoid using controls dock buttons for streaming state. Use signals and OBSBasic member variables instead.
This commit is contained in:
@@ -340,6 +340,20 @@ OBSBasic::OBSBasic(QWidget *parent)
|
||||
connect(ui->modeSwitch, &QAbstractButton::clicked, this,
|
||||
&OBSBasic::TogglePreviewProgramMode);
|
||||
|
||||
/* Set up streaming connections */
|
||||
connect(
|
||||
this, &OBSBasic::StreamingStarting, this,
|
||||
[this] { this->streamingStarting = true; },
|
||||
Qt::DirectConnection);
|
||||
connect(
|
||||
this, &OBSBasic::StreamingStarted, this,
|
||||
[this] { this->streamingStarting = false; },
|
||||
Qt::DirectConnection);
|
||||
connect(
|
||||
this, &OBSBasic::StreamingStopped, this,
|
||||
[this] { this->streamingStarting = false; },
|
||||
Qt::DirectConnection);
|
||||
|
||||
/* Set up recording connections */
|
||||
connect(
|
||||
this, &OBSBasic::RecordingStarted, this,
|
||||
@@ -2803,10 +2817,10 @@ void OBSBasic::CreateHotkeys()
|
||||
"OBSBasic.StartStreaming", Str("Basic.Main.StartStreaming"),
|
||||
"OBSBasic.StopStreaming", Str("Basic.Main.StopStreaming"),
|
||||
MAKE_CALLBACK(!basic.outputHandler->StreamingActive() &&
|
||||
basic.ui->streamButton->isEnabled(),
|
||||
!basic.streamingStarting,
|
||||
basic.StartStreaming, "Starting stream"),
|
||||
MAKE_CALLBACK(basic.outputHandler->StreamingActive() &&
|
||||
basic.ui->streamButton->isEnabled(),
|
||||
!basic.streamingStarting,
|
||||
basic.StopStreaming, "Stopping stream"),
|
||||
this, this);
|
||||
LoadHotkeyPair(streamingHotkeys, "OBSBasic.StartStreaming",
|
||||
@@ -6929,6 +6943,8 @@ void OBSBasic::DisplayStreamStartError()
|
||||
QString message = !outputHandler->lastError.empty()
|
||||
? QTStr(outputHandler->lastError.c_str())
|
||||
: QTStr("Output.StartFailedGeneric");
|
||||
|
||||
emit StreamingStopped();
|
||||
ui->streamButton->setText(QTStr("Basic.Main.StartStreaming"));
|
||||
ui->streamButton->setEnabled(true);
|
||||
ui->streamButton->setChecked(false);
|
||||
@@ -7089,6 +7105,7 @@ void OBSBasic::StartStreaming()
|
||||
sysTrayStream->setText(text);
|
||||
};
|
||||
|
||||
emit StreamingStarting();
|
||||
ui->streamButton->setEnabled(false);
|
||||
ui->streamButton->setChecked(false);
|
||||
ui->broadcastButton->setChecked(false);
|
||||
@@ -7481,6 +7498,7 @@ void OBSBasic::ForceStopStreaming()
|
||||
|
||||
void OBSBasic::StreamDelayStarting(int sec)
|
||||
{
|
||||
emit StreamingStarted();
|
||||
ui->streamButton->setText(QTStr("Basic.Main.StopStreaming"));
|
||||
ui->streamButton->setEnabled(true);
|
||||
ui->streamButton->setChecked(true);
|
||||
@@ -7507,6 +7525,7 @@ void OBSBasic::StreamDelayStarting(int sec)
|
||||
|
||||
void OBSBasic::StreamDelayStopping(int sec)
|
||||
{
|
||||
emit StreamingStopped();
|
||||
ui->streamButton->setText(QTStr("Basic.Main.StartStreaming"));
|
||||
ui->streamButton->setEnabled(true);
|
||||
ui->streamButton->setChecked(false);
|
||||
@@ -7534,6 +7553,7 @@ void OBSBasic::StreamDelayStopping(int sec)
|
||||
|
||||
void OBSBasic::StreamingStart()
|
||||
{
|
||||
emit StreamingStarted();
|
||||
OBSOutputAutoRelease output = obs_frontend_get_streaming_output();
|
||||
|
||||
ui->streamButton->setText(QTStr("Basic.Main.StopStreaming"));
|
||||
@@ -7638,6 +7658,7 @@ void OBSBasic::StreamingStop(int code, QString last_error)
|
||||
|
||||
ui->statusbar->StreamStopped();
|
||||
|
||||
emit StreamingStopped();
|
||||
ui->streamButton->setText(QTStr("Basic.Main.StartStreaming"));
|
||||
ui->streamButton->setEnabled(true);
|
||||
ui->streamButton->setChecked(false);
|
||||
|
||||
Reference in New Issue
Block a user