mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-07-29 08:36:18 -04:00
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.
This commit is contained in:
@@ -304,15 +304,6 @@ void OBSBasicStatusBar::UpdateRecordTime()
|
||||
if (!paused) {
|
||||
totalRecordSeconds++;
|
||||
|
||||
int seconds = totalRecordSeconds % 60;
|
||||
int totalMinutes = totalRecordSeconds / 60;
|
||||
int minutes = totalMinutes % 60;
|
||||
int hours = totalMinutes / 60;
|
||||
|
||||
QString text = QString::asprintf("%02d:%02d:%02d", hours,
|
||||
minutes, seconds);
|
||||
|
||||
statusWidget->ui->recordTime->setText(text);
|
||||
if (recordOutput && !statusWidget->ui->recordTime->isEnabled())
|
||||
statusWidget->ui->recordTime->setDisabled(false);
|
||||
} else {
|
||||
@@ -322,6 +313,24 @@ void OBSBasicStatusBar::UpdateRecordTime()
|
||||
|
||||
streamPauseIconToggle = !streamPauseIconToggle;
|
||||
}
|
||||
|
||||
UpdateRecordTimeLabel();
|
||||
}
|
||||
|
||||
void OBSBasicStatusBar::UpdateRecordTimeLabel()
|
||||
{
|
||||
int seconds = totalRecordSeconds % 60;
|
||||
int totalMinutes = totalRecordSeconds / 60;
|
||||
int minutes = totalMinutes % 60;
|
||||
int hours = totalMinutes / 60;
|
||||
|
||||
QString text =
|
||||
QString::asprintf("%02d:%02d:%02d", hours, minutes, seconds);
|
||||
if (os_atomic_load_bool(&recording_paused)) {
|
||||
text += QStringLiteral(" (PAUSED)");
|
||||
}
|
||||
|
||||
statusWidget->ui->recordTime->setText(text);
|
||||
}
|
||||
|
||||
void OBSBasicStatusBar::UpdateDroppedFrames()
|
||||
@@ -547,14 +556,12 @@ void OBSBasicStatusBar::RecordingStopped()
|
||||
|
||||
void OBSBasicStatusBar::RecordingPaused()
|
||||
{
|
||||
QString text = statusWidget->ui->recordTime->text() +
|
||||
QStringLiteral(" (PAUSED)");
|
||||
statusWidget->ui->recordTime->setText(text);
|
||||
|
||||
if (recordOutput) {
|
||||
statusWidget->ui->recordIcon->setPixmap(recordingPausePixmap);
|
||||
streamPauseIconToggle = true;
|
||||
}
|
||||
|
||||
UpdateRecordTimeLabel();
|
||||
}
|
||||
|
||||
void OBSBasicStatusBar::RecordingUnpaused()
|
||||
@@ -562,6 +569,8 @@ void OBSBasicStatusBar::RecordingUnpaused()
|
||||
if (recordOutput) {
|
||||
statusWidget->ui->recordIcon->setPixmap(recordingActivePixmap);
|
||||
}
|
||||
|
||||
UpdateRecordTimeLabel();
|
||||
}
|
||||
|
||||
static QPixmap GetPixmap(const QString &filename)
|
||||
|
||||
Reference in New Issue
Block a user