Skip to content

Commit bad7b78

Browse files
AleksbgbgLain-B
authored andcommitted
UI: Fix text stacking in paused indicator
Currently, the paused indicator is never undone, instead relying on the update timer to eventually erase it away when the recording duration is updated. If the user spams pause fast enough, the indicator will stack several times before it is erased - especially if the unpaused branch in the update timer never has a chance to run. Instead of mutating the recordTime text on pause and requiring an undo, extract the UI update to a separate function which computes the full text based on the current state. Call this function when pause is toggled, thereby forcing an accurate UI update that either does or does not incude the paused text. An added benefit is that the paused indicator now disappears immediately.
1 parent ec31c7e commit bad7b78

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

UI/window-basic-status-bar.cpp

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,6 @@ void OBSBasicStatusBar::UpdateRecordTime()
304304
if (!paused) {
305305
totalRecordSeconds++;
306306

307-
int seconds = totalRecordSeconds % 60;
308-
int totalMinutes = totalRecordSeconds / 60;
309-
int minutes = totalMinutes % 60;
310-
int hours = totalMinutes / 60;
311-
312-
QString text = QString::asprintf("%02d:%02d:%02d", hours,
313-
minutes, seconds);
314-
315-
statusWidget->ui->recordTime->setText(text);
316307
if (recordOutput && !statusWidget->ui->recordTime->isEnabled())
317308
statusWidget->ui->recordTime->setDisabled(false);
318309
} else {
@@ -322,6 +313,24 @@ void OBSBasicStatusBar::UpdateRecordTime()
322313

323314
streamPauseIconToggle = !streamPauseIconToggle;
324315
}
316+
317+
UpdateRecordTimeLabel();
318+
}
319+
320+
void OBSBasicStatusBar::UpdateRecordTimeLabel()
321+
{
322+
int seconds = totalRecordSeconds % 60;
323+
int totalMinutes = totalRecordSeconds / 60;
324+
int minutes = totalMinutes % 60;
325+
int hours = totalMinutes / 60;
326+
327+
QString text =
328+
QString::asprintf("%02d:%02d:%02d", hours, minutes, seconds);
329+
if (os_atomic_load_bool(&recording_paused)) {
330+
text += QStringLiteral(" (PAUSED)");
331+
}
332+
333+
statusWidget->ui->recordTime->setText(text);
325334
}
326335

327336
void OBSBasicStatusBar::UpdateDroppedFrames()
@@ -547,21 +556,21 @@ void OBSBasicStatusBar::RecordingStopped()
547556

548557
void OBSBasicStatusBar::RecordingPaused()
549558
{
550-
QString text = statusWidget->ui->recordTime->text() +
551-
QStringLiteral(" (PAUSED)");
552-
statusWidget->ui->recordTime->setText(text);
553-
554559
if (recordOutput) {
555560
statusWidget->ui->recordIcon->setPixmap(recordingPausePixmap);
556561
streamPauseIconToggle = true;
557562
}
563+
564+
UpdateRecordTimeLabel();
558565
}
559566

560567
void OBSBasicStatusBar::RecordingUnpaused()
561568
{
562569
if (recordOutput) {
563570
statusWidget->ui->recordIcon->setPixmap(recordingActivePixmap);
564571
}
572+
573+
UpdateRecordTimeLabel();
565574
}
566575

567576
static QPixmap GetPixmap(const QString &filename)

UI/window-basic-status-bar.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class OBSBasicStatusBar : public QStatusBar {
8484
void UpdateBandwidth();
8585
void UpdateStreamTime();
8686
void UpdateRecordTime();
87+
void UpdateRecordTimeLabel();
8788
void UpdateDroppedFrames();
8889

8990
static void OBSOutputReconnect(void *data, calldata_t *params);

0 commit comments

Comments
 (0)