From 64598732a65a877755510ac5edaf823127e8555a Mon Sep 17 00:00:00 2001 From: Clayton Groeneveld Date: Tue, 16 Jul 2019 23:53:38 -0500 Subject: [PATCH] frontend-tools: Add option to pause output timer when rec is paused --- .../frontend-tools/data/locale/en-US.ini | 1 + .../frontend-tools/forms/output-timer.ui | 438 +++++++++--------- .../frontend-tools/output-timer.cpp | 38 +- .../frontend-tools/output-timer.hpp | 4 + 4 files changed, 269 insertions(+), 212 deletions(-) diff --git a/UI/frontend-plugins/frontend-tools/data/locale/en-US.ini b/UI/frontend-plugins/frontend-tools/data/locale/en-US.ini index c3ab60876..39414356a 100644 --- a/UI/frontend-plugins/frontend-tools/data/locale/en-US.ini +++ b/UI/frontend-plugins/frontend-tools/data/locale/en-US.ini @@ -24,6 +24,7 @@ OutputTimer.Stream.StoppingIn="Streaming stopping in:" OutputTimer.Record.StoppingIn="Recording stopping in:" OutputTimer.Stream.EnableEverytime="Enable streaming timer every time" OutputTimer.Record.EnableEverytime="Enable recording timer every time" +OutputTimer.Record.PauseTimer="Pause timer when recording is paused" Scripts="Scripts" LoadedScripts="Loaded Scripts" diff --git a/UI/frontend-plugins/frontend-tools/forms/output-timer.ui b/UI/frontend-plugins/frontend-tools/forms/output-timer.ui index e56ae421b..cc9b63eaa 100644 --- a/UI/frontend-plugins/frontend-tools/forms/output-timer.ui +++ b/UI/frontend-plugins/frontend-tools/forms/output-timer.ui @@ -1,215 +1,231 @@ OutputTimer - - - - 0 - 0 - 600 - 200 - - - - OutputTimer - - - - - - OutputTimer.Stream - - - - - - - 0 - - - 24 - - - 0 - - - - - - - Hours - - - - - - - 59 - - - 0 - - - - - - - Minutes - - - - - - - 0 - - - 59 - - - 30 - - - - - - - Seconds - - - - - - - Start - - - - - - - OutputTimer.Stream.StoppingIn - - - - - - - 00:00:00 - - - - - - - OutputTimer.Record - - - - - - - 0 - - - 24 - - - 0 - - - - - - - Hours - - - - - - - 0 - - - 59 - - - 0 - - - - - - - Minutes - - - - - - - 0 - - - 59 - - - 30 - - - - - - - Seconds - - - - - - - Start - - - - - - - OutputTimer.Record.StoppingIn - - - - - - - 00:00:00 - - - - - - - OutputTimer.Stream.EnableEverytime - - - - - - - OutputTimer.Record.EnableEverytime - - - - - - - QDialogButtonBox::Close - - - - - - - + + + + 0 + 0 + 697 + 240 + + + + OutputTimer + + + + + + Hours + + + + + + + 0 + + + 24 + + + 0 + + + + + + + 0 + + + 59 + + + 30 + + + + + + + Start + + + + + + + 0 + + + 59 + + + 0 + + + + + + + OutputTimer.Stream + + + + + + + 59 + + + 0 + + + + + + + Start + + + + + + + OutputTimer.Record.StoppingIn + + + + + + + Seconds + + + + + + + 00:00:00 + + + + + + + Minutes + + + + + + + 0 + + + 24 + + + 0 + + + + + + + 00:00:00 + + + + + + + Minutes + + + + + + + OutputTimer.Record + + + + + + + 0 + + + 59 + + + 30 + + + + + + + OutputTimer.Stream.EnableEverytime + + + + + + + OutputTimer.Stream.StoppingIn + + + + + + + OutputTimer.Record.EnableEverytime + + + + + + + QDialogButtonBox::Close + + + + + + + Hours + + + + + + + Seconds + + + + + + + + 0 + 0 + + + + OutputTimer.Record.PauseTimer + + + true + + + + + + + diff --git a/UI/frontend-plugins/frontend-tools/output-timer.cpp b/UI/frontend-plugins/frontend-tools/output-timer.cpp index 5d2f06c8e..207cfd172 100644 --- a/UI/frontend-plugins/frontend-tools/output-timer.cpp +++ b/UI/frontend-plugins/frontend-tools/output-timer.cpp @@ -181,7 +181,13 @@ void OutputTimer::UpdateStreamTimerDisplay() void OutputTimer::UpdateRecordTimerDisplay() { - int remainingTime = recordingTimer->remainingTime() / 1000; + int remainingTime = 0; + + if (obs_frontend_recording_paused() && + ui->pauseRecordTimer->isChecked()) + remainingTime = recordingTimeLeft / 1000; + else + remainingTime = recordingTimer->remainingTime() / 1000; int seconds = remainingTime % 60; int minutes = (remainingTime % 3600) / 60; @@ -192,6 +198,26 @@ void OutputTimer::UpdateRecordTimerDisplay() ui->recordTime->setText(text); } +void OutputTimer::PauseRecordingTimer() +{ + if (!ui->pauseRecordTimer->isChecked()) + return; + + if (recordingTimer->isActive()) { + recordingTimeLeft = recordingTimer->remainingTime(); + recordingTimer->stop(); + } +} + +void OutputTimer::UnpauseRecordingTimer() +{ + if (!ui->pauseRecordTimer->isChecked()) + return; + + if (!recordingTimer->isActive()) + recordingTimer->start(recordingTimeLeft); +} + void OutputTimer::ShowHideDialog() { if (!isVisible()) { @@ -239,6 +265,9 @@ static void SaveOutputTimer(obs_data_t *save_data, bool saving, void *) obs_data_set_bool(obj, "autoStartRecordTimer", ot->ui->autoStartRecordTimer->isChecked()); + obs_data_set_bool(obj, "pauseRecordTimer", + ot->ui->pauseRecordTimer->isChecked()); + obs_data_set_obj(save_data, "output-timer", obj); obs_data_release(obj); @@ -267,6 +296,9 @@ static void SaveOutputTimer(obs_data_t *save_data, bool saving, void *) ot->ui->autoStartRecordTimer->setChecked( obs_data_get_bool(obj, "autoStartRecordTimer")); + ot->ui->pauseRecordTimer->setChecked( + obs_data_get_bool(obj, "pauseRecordTimer")); + obs_data_release(obj); } } @@ -286,6 +318,10 @@ static void OBSEvent(enum obs_frontend_event event, void *) ot->RecordTimerStart(); } else if (event == OBS_FRONTEND_EVENT_RECORDING_STOPPING) { ot->RecordTimerStop(); + } else if (event == OBS_FRONTEND_EVENT_RECORDING_PAUSED) { + ot->PauseRecordingTimer(); + } else if (event == OBS_FRONTEND_EVENT_RECORDING_UNPAUSED) { + ot->UnpauseRecordingTimer(); } } diff --git a/UI/frontend-plugins/frontend-tools/output-timer.hpp b/UI/frontend-plugins/frontend-tools/output-timer.hpp index ff3b733dc..97867b8f7 100644 --- a/UI/frontend-plugins/frontend-tools/output-timer.hpp +++ b/UI/frontend-plugins/frontend-tools/output-timer.hpp @@ -15,6 +15,8 @@ public: OutputTimer(QWidget *parent); void closeEvent(QCloseEvent *event) override; + void PauseRecordingTimer(); + void UnpauseRecordingTimer(); public slots: void StreamingTimerButton(); @@ -37,4 +39,6 @@ private: QTimer *recordingTimer; QTimer *streamingTimerDisplay; QTimer *recordingTimerDisplay; + + int recordingTimeLeft; };