mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-08-24 10:14:13 -05:00
UI: Track recording state in OBSBasic
Avoid using controls dock buttons for recording states. Use signals and OBSBasic member variables instead.
This commit is contained in:
+55
-15
@@ -340,6 +340,30 @@ OBSBasic::OBSBasic(QWidget *parent)
|
||||
connect(ui->modeSwitch, &QAbstractButton::clicked, this,
|
||||
&OBSBasic::TogglePreviewProgramMode);
|
||||
|
||||
/* Set up recording connections */
|
||||
connect(
|
||||
this, &OBSBasic::RecordingStarted, this,
|
||||
[this]() {
|
||||
this->recordingStarted = true;
|
||||
this->recordingPaused = false;
|
||||
},
|
||||
Qt::DirectConnection);
|
||||
connect(
|
||||
this, &OBSBasic::RecordingPaused, this,
|
||||
[this]() { this->recordingPaused = true; },
|
||||
Qt::DirectConnection);
|
||||
connect(
|
||||
this, &OBSBasic::RecordingUnpaused, this,
|
||||
[this]() { this->recordingPaused = false; },
|
||||
Qt::DirectConnection);
|
||||
connect(
|
||||
this, &OBSBasic::RecordingStopped, this,
|
||||
[this]() {
|
||||
this->recordingStarted = false;
|
||||
this->recordingPaused = false;
|
||||
},
|
||||
Qt::DirectConnection);
|
||||
|
||||
startingDockLayout = saveState();
|
||||
|
||||
statsDock = new OBSDock();
|
||||
@@ -1994,6 +2018,8 @@ void OBSBasic::ResetOutputs()
|
||||
if (sysTrayReplayBuffer)
|
||||
sysTrayReplayBuffer->setEnabled(
|
||||
!!outputHandler->replayBuffer);
|
||||
|
||||
UpdateIsRecordingPausable();
|
||||
} else {
|
||||
outputHandler->Update();
|
||||
}
|
||||
@@ -2802,10 +2828,10 @@ void OBSBasic::CreateHotkeys()
|
||||
"OBSBasic.StartRecording", Str("Basic.Main.StartRecording"),
|
||||
"OBSBasic.StopRecording", Str("Basic.Main.StopRecording"),
|
||||
MAKE_CALLBACK(!basic.outputHandler->RecordingActive() &&
|
||||
!basic.ui->recordButton->isChecked(),
|
||||
!basic.recordingStarted,
|
||||
basic.StartRecording, "Starting recording"),
|
||||
MAKE_CALLBACK(basic.outputHandler->RecordingActive() &&
|
||||
basic.ui->recordButton->isChecked(),
|
||||
basic.recordingStarted,
|
||||
basic.StopRecording, "Stopping recording"),
|
||||
this, this);
|
||||
LoadHotkeyPair(recordingHotkeys, "OBSBasic.StartRecording",
|
||||
@@ -2814,9 +2840,11 @@ void OBSBasic::CreateHotkeys()
|
||||
pauseHotkeys = obs_hotkey_pair_register_frontend(
|
||||
"OBSBasic.PauseRecording", Str("Basic.Main.PauseRecording"),
|
||||
"OBSBasic.UnpauseRecording", Str("Basic.Main.UnpauseRecording"),
|
||||
MAKE_CALLBACK(basic.pause && !basic.pause->isChecked(),
|
||||
MAKE_CALLBACK(basic.isRecordingPausable &&
|
||||
!basic.recordingPaused,
|
||||
basic.PauseRecording, "Pausing recording"),
|
||||
MAKE_CALLBACK(basic.pause && basic.pause->isChecked(),
|
||||
MAKE_CALLBACK(basic.isRecordingPausable &&
|
||||
basic.recordingPaused,
|
||||
basic.UnpauseRecording, "Unpausing recording"),
|
||||
this, this);
|
||||
LoadHotkeyPair(pauseHotkeys, "OBSBasic.PauseRecording",
|
||||
@@ -7795,6 +7823,7 @@ void OBSBasic::StopRecording()
|
||||
void OBSBasic::RecordingStart()
|
||||
{
|
||||
ui->statusbar->RecordingStarted(outputHandler->fileOutput);
|
||||
emit RecordingStarted();
|
||||
ui->recordButton->setText(QTStr("Basic.Main.StopRecording"));
|
||||
ui->recordButton->setChecked(true);
|
||||
|
||||
@@ -7817,6 +7846,7 @@ void OBSBasic::RecordingStart()
|
||||
void OBSBasic::RecordingStop(int code, QString last_error)
|
||||
{
|
||||
ui->statusbar->RecordingStopped();
|
||||
emit RecordingStopped();
|
||||
ui->recordButton->setText(QTStr("Basic.Main.StartRecording"));
|
||||
ui->recordButton->setChecked(false);
|
||||
|
||||
@@ -10793,7 +10823,8 @@ void OBSBasic::UpdatePatronJson(const QString &text, const QString &error)
|
||||
|
||||
void OBSBasic::PauseRecording()
|
||||
{
|
||||
if (!pause || !outputHandler || !outputHandler->fileOutput ||
|
||||
if (!isRecordingPausable || !outputHandler ||
|
||||
!outputHandler->fileOutput ||
|
||||
os_atomic_load_bool(&recording_paused))
|
||||
return;
|
||||
|
||||
@@ -10802,6 +10833,7 @@ void OBSBasic::PauseRecording()
|
||||
if (obs_output_pause(output, true)) {
|
||||
os_atomic_set_bool(&recording_paused, true);
|
||||
|
||||
emit RecordingPaused();
|
||||
pause->setAccessibleName(QTStr("Basic.Main.UnpauseRecording"));
|
||||
pause->setToolTip(QTStr("Basic.Main.UnpauseRecording"));
|
||||
pause->blockSignals(true);
|
||||
@@ -10839,7 +10871,8 @@ void OBSBasic::PauseRecording()
|
||||
|
||||
void OBSBasic::UnpauseRecording()
|
||||
{
|
||||
if (!pause || !outputHandler || !outputHandler->fileOutput ||
|
||||
if (!isRecordingPausable || !outputHandler ||
|
||||
!outputHandler->fileOutput ||
|
||||
!os_atomic_load_bool(&recording_paused))
|
||||
return;
|
||||
|
||||
@@ -10848,6 +10881,7 @@ void OBSBasic::UnpauseRecording()
|
||||
if (obs_output_pause(output, false)) {
|
||||
os_atomic_set_bool(&recording_paused, false);
|
||||
|
||||
emit RecordingUnpaused();
|
||||
pause->setAccessibleName(QTStr("Basic.Main.PauseRecording"));
|
||||
pause->setToolTip(QTStr("Basic.Main.PauseRecording"));
|
||||
pause->blockSignals(true);
|
||||
@@ -10882,7 +10916,8 @@ void OBSBasic::UnpauseRecording()
|
||||
|
||||
void OBSBasic::PauseToggled()
|
||||
{
|
||||
if (!pause || !outputHandler || !outputHandler->fileOutput)
|
||||
if (!isRecordingPausable || !outputHandler ||
|
||||
!outputHandler->fileOutput)
|
||||
return;
|
||||
|
||||
obs_output_t *output = outputHandler->fileOutput;
|
||||
@@ -10894,16 +10929,11 @@ void OBSBasic::PauseToggled()
|
||||
UnpauseRecording();
|
||||
}
|
||||
|
||||
void OBSBasic::UpdatePause(bool activate)
|
||||
void OBSBasic::UpdateIsRecordingPausable()
|
||||
{
|
||||
if (!activate || !outputHandler || !outputHandler->RecordingActive()) {
|
||||
pause.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
const char *mode = config_get_string(basicConfig, "Output", "Mode");
|
||||
bool adv = astrcmpi(mode, "Advanced") == 0;
|
||||
bool shared;
|
||||
bool shared = true;
|
||||
|
||||
if (adv) {
|
||||
const char *recType =
|
||||
@@ -10923,7 +10953,17 @@ void OBSBasic::UpdatePause(bool activate)
|
||||
shared = strcmp(quality, "Stream") == 0;
|
||||
}
|
||||
|
||||
if (!shared) {
|
||||
isRecordingPausable = !shared;
|
||||
}
|
||||
|
||||
void OBSBasic::UpdatePause(bool activate)
|
||||
{
|
||||
if (!activate || !outputHandler || !outputHandler->RecordingActive()) {
|
||||
pause.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
if (isRecordingPausable) {
|
||||
pause.reset(new QPushButton());
|
||||
pause->setAccessibleName(QTStr("Basic.Main.PauseRecording"));
|
||||
pause->setToolTip(QTStr("Basic.Main.PauseRecording"));
|
||||
|
||||
@@ -677,6 +677,10 @@ private:
|
||||
|
||||
void UpdatePreviewOverflowSettings();
|
||||
|
||||
bool recordingStarted = false;
|
||||
bool isRecordingPausable = false;
|
||||
bool recordingPaused = false;
|
||||
|
||||
bool restartingVCam = false;
|
||||
|
||||
public slots:
|
||||
@@ -881,6 +885,7 @@ private:
|
||||
|
||||
void AutoRemux(QString input, bool no_show = false);
|
||||
|
||||
void UpdateIsRecordingPausable();
|
||||
void UpdatePause(bool activate = true);
|
||||
void UpdateReplayBuffer(bool activate = true);
|
||||
|
||||
@@ -1251,6 +1256,12 @@ public slots:
|
||||
void UpdateContextBarVisibility();
|
||||
|
||||
signals:
|
||||
/* Recording signals */
|
||||
void RecordingStarted();
|
||||
void RecordingPaused();
|
||||
void RecordingUnpaused();
|
||||
void RecordingStopped();
|
||||
|
||||
/* Studio Mode signal */
|
||||
void PreviewProgramModeChanged(bool enabled);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user