mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-08 04:22:55 +00:00
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.
120 lines
2.5 KiB
C++
120 lines
2.5 KiB
C++
#pragma once
|
|
|
|
#include <QStatusBar>
|
|
#include <QPointer>
|
|
#include <QTimer>
|
|
#include <obs.h>
|
|
#include <memory>
|
|
|
|
class Ui_StatusBarWidget;
|
|
|
|
class StatusBarWidget : public QWidget {
|
|
Q_OBJECT
|
|
|
|
friend class OBSBasicStatusBar;
|
|
|
|
private:
|
|
std::unique_ptr<Ui_StatusBarWidget> ui;
|
|
|
|
public:
|
|
StatusBarWidget(QWidget *parent = nullptr);
|
|
~StatusBarWidget();
|
|
};
|
|
|
|
class OBSBasicStatusBar : public QStatusBar {
|
|
Q_OBJECT
|
|
|
|
private:
|
|
StatusBarWidget *statusWidget = nullptr;
|
|
|
|
obs_output_t *streamOutput = nullptr;
|
|
std::vector<OBSSignal> streamSigs;
|
|
obs_output_t *recordOutput = nullptr;
|
|
bool active = false;
|
|
bool overloadedNotify = true;
|
|
bool streamPauseIconToggle = false;
|
|
bool disconnected = false;
|
|
bool firstCongestionUpdate = false;
|
|
|
|
std::vector<float> congestionArray;
|
|
|
|
int retries = 0;
|
|
int totalStreamSeconds = 0;
|
|
int totalRecordSeconds = 0;
|
|
|
|
int reconnectTimeout = 0;
|
|
|
|
int delaySecTotal = 0;
|
|
int delaySecStarting = 0;
|
|
int delaySecStopping = 0;
|
|
|
|
int startSkippedFrameCount = 0;
|
|
int startTotalFrameCount = 0;
|
|
int lastSkippedFrameCount = 0;
|
|
|
|
int seconds = 0;
|
|
uint64_t lastBytesSent = 0;
|
|
uint64_t lastBytesSentTime = 0;
|
|
|
|
QPixmap excellentPixmap;
|
|
QPixmap goodPixmap;
|
|
QPixmap mediocrePixmap;
|
|
QPixmap badPixmap;
|
|
QPixmap disconnectedPixmap;
|
|
QPixmap inactivePixmap;
|
|
|
|
QPixmap recordingActivePixmap;
|
|
QPixmap recordingPausePixmap;
|
|
QPixmap recordingPauseInactivePixmap;
|
|
QPixmap recordingInactivePixmap;
|
|
QPixmap streamingActivePixmap;
|
|
QPixmap streamingInactivePixmap;
|
|
|
|
float lastCongestion = 0.0f;
|
|
|
|
QPointer<QTimer> refreshTimer;
|
|
QPointer<QTimer> messageTimer;
|
|
|
|
obs_output_t *GetOutput();
|
|
|
|
void Activate();
|
|
void Deactivate();
|
|
|
|
void UpdateDelayMsg();
|
|
void UpdateBandwidth();
|
|
void UpdateStreamTime();
|
|
void UpdateRecordTime();
|
|
void UpdateRecordTimeLabel();
|
|
void UpdateDroppedFrames();
|
|
|
|
static void OBSOutputReconnect(void *data, calldata_t *params);
|
|
static void OBSOutputReconnectSuccess(void *data, calldata_t *params);
|
|
|
|
public slots:
|
|
void UpdateCPUUsage();
|
|
|
|
void clearMessage();
|
|
void showMessage(const QString &message, int timeout = 0);
|
|
|
|
private slots:
|
|
void Reconnect(int seconds);
|
|
void ReconnectSuccess();
|
|
void UpdateStatusBar();
|
|
void UpdateCurrentFPS();
|
|
void UpdateIcons();
|
|
|
|
public:
|
|
OBSBasicStatusBar(QWidget *parent);
|
|
|
|
void StreamDelayStarting(int sec);
|
|
void StreamDelayStopping(int sec);
|
|
void StreamStarted(obs_output_t *output);
|
|
void StreamStopped();
|
|
void RecordingStarted(obs_output_t *output);
|
|
void RecordingStopped();
|
|
void RecordingPaused();
|
|
void RecordingUnpaused();
|
|
|
|
void ReconnectClear();
|
|
};
|