From d8e67d2f3ca64b2388057f98715ccdd84f3665cd Mon Sep 17 00:00:00 2001 From: Bennik2000 Date: Tue, 14 Apr 2020 20:16:33 +0200 Subject: [PATCH] UI: Add status icons for recording and streaming --- UI/forms/images/recording-active.svg | 37 +++++++++ UI/forms/images/recording-inactive.svg | 37 +++++++++ UI/forms/images/recording-pause-inactive.svg | 45 +++++++++++ UI/forms/images/recording-pause.svg | 45 +++++++++++ UI/forms/images/streaming-active.svg | 55 +++++++++++++ UI/forms/images/streaming-inactive.svg | 55 +++++++++++++ UI/forms/obs.qrc | 6 ++ UI/window-basic-main.cpp | 4 + UI/window-basic-status-bar.cpp | 82 ++++++++++++++++---- UI/window-basic-status-bar.hpp | 12 +++ 10 files changed, 364 insertions(+), 14 deletions(-) create mode 100644 UI/forms/images/recording-active.svg create mode 100644 UI/forms/images/recording-inactive.svg create mode 100644 UI/forms/images/recording-pause-inactive.svg create mode 100644 UI/forms/images/recording-pause.svg create mode 100644 UI/forms/images/streaming-active.svg create mode 100644 UI/forms/images/streaming-inactive.svg diff --git a/UI/forms/images/recording-active.svg b/UI/forms/images/recording-active.svg new file mode 100644 index 000000000..d039ecb0a --- /dev/null +++ b/UI/forms/images/recording-active.svg @@ -0,0 +1,37 @@ + + + + + + + image/svg+xml + + + + + + + + + diff --git a/UI/forms/images/recording-inactive.svg b/UI/forms/images/recording-inactive.svg new file mode 100644 index 000000000..3d833d88f --- /dev/null +++ b/UI/forms/images/recording-inactive.svg @@ -0,0 +1,37 @@ + + + + + + + image/svg+xml + + + + + + + + + diff --git a/UI/forms/images/recording-pause-inactive.svg b/UI/forms/images/recording-pause-inactive.svg new file mode 100644 index 000000000..6ee3dc795 --- /dev/null +++ b/UI/forms/images/recording-pause-inactive.svg @@ -0,0 +1,45 @@ + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/UI/forms/images/recording-pause.svg b/UI/forms/images/recording-pause.svg new file mode 100644 index 000000000..884b226b4 --- /dev/null +++ b/UI/forms/images/recording-pause.svg @@ -0,0 +1,45 @@ + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/UI/forms/images/streaming-active.svg b/UI/forms/images/streaming-active.svg new file mode 100644 index 000000000..b7c87bcc8 --- /dev/null +++ b/UI/forms/images/streaming-active.svg @@ -0,0 +1,55 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/UI/forms/images/streaming-inactive.svg b/UI/forms/images/streaming-inactive.svg new file mode 100644 index 000000000..5c2e27117 --- /dev/null +++ b/UI/forms/images/streaming-inactive.svg @@ -0,0 +1,55 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/UI/forms/obs.qrc b/UI/forms/obs.qrc index 1e618445f..040e9af58 100644 --- a/UI/forms/obs.qrc +++ b/UI/forms/obs.qrc @@ -34,6 +34,12 @@ images/sources/text.svg images/sources/window.svg images/sources/default.svg + images/recording-active.svg + images/recording-inactive.svg + images/recording-pause.svg + images/recording-pause-inactive.svg + images/streaming-active.svg + images/streaming-inactive.svg images/settings/output.svg diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 93282dbe3..d39757f6e 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -7712,6 +7712,8 @@ void OBSBasic::PauseRecording() pause->setChecked(true); pause->blockSignals(false); + ui->statusbar->RecordingPaused(); + if (trayIcon) trayIcon->setIcon(QIcon(":/res/images/obs_paused.png")); @@ -7739,6 +7741,8 @@ void OBSBasic::UnpauseRecording() pause->setChecked(false); pause->blockSignals(false); + ui->statusbar->RecordingUnpaused(); + if (trayIcon) trayIcon->setIcon( QIcon(":/res/images/tray_active.png")); diff --git a/UI/window-basic-status-bar.cpp b/UI/window-basic-status-bar.cpp index a4ef72f55..93cc4af28 100644 --- a/UI/window-basic-status-bar.cpp +++ b/UI/window-basic-status-bar.cpp @@ -11,18 +11,36 @@ OBSBasicStatusBar::OBSBasicStatusBar(QWidget *parent) : QStatusBar(parent), delayInfo(new QLabel), droppedFrames(new QLabel), + streamIcon(new QLabel), streamTime(new QLabel), + recordIcon(new QLabel), recordTime(new QLabel), cpuUsage(new QLabel), transparentPixmap(20, 20), greenPixmap(20, 20), grayPixmap(20, 20), - redPixmap(20, 20) + redPixmap(20, 20), + recordingActivePixmap(QIcon(":/res/images/recording-active.svg") + .pixmap(QSize(20, 20))), + recordingPausePixmap(QIcon(":/res/images/recording-pause.svg") + .pixmap(QSize(20, 20))), + recordingPauseInactivePixmap( + QIcon(":/res/images/recording-pause-inactive.svg") + .pixmap(QSize(20, 20))), + recordingInactivePixmap(QIcon(":/res/images/recording-inactive.svg") + .pixmap(QSize(20, 20))), + streamingActivePixmap(QIcon(":/res/images/streaming-active.svg") + .pixmap(QSize(20, 20))), + streamingInactivePixmap(QIcon(":/res/images/streaming-inactive.svg") + .pixmap(QSize(20, 20))) { streamTime->setText(QString("LIVE: 00:00:00")); recordTime->setText(QString("REC: 00:00:00")); cpuUsage->setText(QString("CPU: 0.0%, 0.00 fps")); + streamIcon->setPixmap(streamingInactivePixmap); + recordIcon->setPixmap(recordingInactivePixmap); + QWidget *brWidget = new QWidget(this); QHBoxLayout *brLayout = new QHBoxLayout(brWidget); brLayout->setContentsMargins(0, 0, 0, 0); @@ -39,8 +57,12 @@ OBSBasicStatusBar::OBSBasicStatusBar(QWidget *parent) delayInfo->setAlignment(Qt::AlignVCenter); droppedFrames->setAlignment(Qt::AlignRight); droppedFrames->setAlignment(Qt::AlignVCenter); + streamIcon->setAlignment(Qt::AlignRight); + streamIcon->setAlignment(Qt::AlignVCenter); streamTime->setAlignment(Qt::AlignRight); streamTime->setAlignment(Qt::AlignVCenter); + recordIcon->setAlignment(Qt::AlignRight); + recordIcon->setAlignment(Qt::AlignVCenter); recordTime->setAlignment(Qt::AlignRight); recordTime->setAlignment(Qt::AlignVCenter); cpuUsage->setAlignment(Qt::AlignRight); @@ -50,13 +72,15 @@ OBSBasicStatusBar::OBSBasicStatusBar(QWidget *parent) delayInfo->setIndent(20); droppedFrames->setIndent(20); - streamTime->setIndent(20); - recordTime->setIndent(20); + streamIcon->setIndent(20); + recordIcon->setIndent(20); cpuUsage->setIndent(20); kbps->setIndent(10); addPermanentWidget(droppedFrames); + addPermanentWidget(streamIcon); addPermanentWidget(streamTime); + addPermanentWidget(recordIcon); addPermanentWidget(recordTime); addPermanentWidget(cpuUsage); addPermanentWidget(delayInfo); @@ -93,6 +117,14 @@ void OBSBasicStatusBar::Activate() statusSquare->setPixmap(grayPixmap); } } + + if (streamOutput) { + streamIcon->setPixmap(streamingActivePixmap); + } + + if (recordOutput) { + recordIcon->setPixmap(recordingActivePixmap); + } } void OBSBasicStatusBar::Deactivate() @@ -103,11 +135,13 @@ void OBSBasicStatusBar::Deactivate() if (!streamOutput) { streamTime->setText(QString("LIVE: 00:00:00")); + streamIcon->setPixmap(streamingInactivePixmap); totalStreamSeconds = 0; } if (!recordOutput) { recordTime->setText(QString("REC: 00:00:00")); + recordIcon->setPixmap(recordingInactivePixmap); totalRecordSeconds = 0; } @@ -247,25 +281,26 @@ void OBSBasicStatusBar::UpdateRecordTime() { bool paused = os_atomic_load_bool(&recording_paused); - if (!paused) + if (!paused) { totalRecordSeconds++; - QString text; - - if (paused) { - text = QStringLiteral("REC: PAUSED"); - } else { int seconds = totalRecordSeconds % 60; int totalMinutes = totalRecordSeconds / 60; int minutes = totalMinutes % 60; int hours = totalMinutes / 60; - text = QString::asprintf("REC: %02d:%02d:%02d", hours, minutes, - seconds); - } + QString text = QString::asprintf("REC: %02d:%02d:%02d", hours, + minutes, seconds); - recordTime->setText(text); - recordTime->setMinimumWidth(recordTime->width()); + recordTime->setText(text); + recordTime->setMinimumWidth(recordTime->width()); + } else { + recordIcon->setPixmap(streamPauseIconToggle + ? recordingPauseInactivePixmap + : recordingPausePixmap); + + streamPauseIconToggle = !streamPauseIconToggle; + } } void OBSBasicStatusBar::UpdateDroppedFrames() @@ -483,3 +518,22 @@ void OBSBasicStatusBar::RecordingStopped() recordOutput = nullptr; Deactivate(); } + +void OBSBasicStatusBar::RecordingPaused() +{ + QString text = QStringLiteral("REC: PAUSED"); + recordTime->setText(text); + recordTime->setMinimumWidth(recordTime->width()); + + if (recordOutput) { + recordIcon->setPixmap(recordingPausePixmap); + streamPauseIconToggle = true; + } +} + +void OBSBasicStatusBar::RecordingUnpaused() +{ + if (recordOutput) { + recordIcon->setPixmap(recordingActivePixmap); + } +} diff --git a/UI/window-basic-status-bar.hpp b/UI/window-basic-status-bar.hpp index 972bf8779..65e3fd40d 100644 --- a/UI/window-basic-status-bar.hpp +++ b/UI/window-basic-status-bar.hpp @@ -14,8 +14,10 @@ class OBSBasicStatusBar : public QStatusBar { private: QLabel *delayInfo; QLabel *droppedFrames; + QLabel *streamIcon; QLabel *streamTime; QLabel *recordTime; + QLabel *recordIcon; QLabel *cpuUsage; QLabel *kbps; QLabel *statusSquare; @@ -24,6 +26,7 @@ private: obs_output_t *recordOutput = nullptr; bool active = false; bool overloadedNotify = true; + bool streamPauseIconToggle = false; int retries = 0; int totalStreamSeconds = 0; @@ -48,6 +51,13 @@ private: QPixmap grayPixmap; QPixmap redPixmap; + QPixmap recordingActivePixmap; + QPixmap recordingPausePixmap; + QPixmap recordingPauseInactivePixmap; + QPixmap recordingInactivePixmap; + QPixmap streamingActivePixmap; + QPixmap streamingInactivePixmap; + float lastCongestion = 0.0f; QPointer refreshTimer; @@ -81,6 +91,8 @@ public: void StreamStopped(); void RecordingStarted(obs_output_t *output); void RecordingStopped(); + void RecordingPaused(); + void RecordingUnpaused(); void ReconnectClear(); };