UI: Add save notifications to status bar

This shows notifications in the status bar with the following:
- When screenshot is saved
- When replay buffer is saved
- When recording is saved
- When recording is auto remuxed
master
Clayton Groeneveld 2021-02-04 06:01:35 -06:00 committed by Jim
parent 416a55cccb
commit 448c7f38d0
7 changed files with 67 additions and 7 deletions

View File

@ -535,6 +535,10 @@ Basic.StatusBar.Delay="Delay (%1 sec)"
Basic.StatusBar.DelayStartingIn="Delay (starting in %1 sec)"
Basic.StatusBar.DelayStoppingIn="Delay (stopping in %1 sec)"
Basic.StatusBar.DelayStartingStoppingIn="Delay (stopping in %1 sec, starting in %2 sec)"
Basic.StatusBar.RecordingSavedTo="Recording saved to '%1'"
Basic.StatusBar.ReplayBufferSavedTo="Replay buffer saved to '%1'"
Basic.StatusBar.ScreenshotSavedTo="Screenshot saved to '%1'"
Basic.StatusBar.AutoRemuxedTo="Recording auto remuxed to '%1'"
# filters window
Basic.Filters="Filters"

View File

@ -2018,12 +2018,11 @@ bool AdvancedOutput::ReplayBufferActive() const
/* ------------------------------------------------------------------------ */
bool BasicOutputHandler::SetupAutoRemux(const char *&ext)
void BasicOutputHandler::SetupAutoRemux(const char *&ext)
{
bool autoRemux = config_get_bool(main->Config(), "Video", "AutoRemux");
if (autoRemux && strcmp(ext, "mp4") == 0)
ext = "mkv";
return autoRemux;
}
std::string
@ -2031,9 +2030,11 @@ BasicOutputHandler::GetRecordingFilename(const char *path, const char *ext,
bool noSpace, bool overwrite,
const char *format, bool ffmpeg)
{
bool remux = !ffmpeg && SetupAutoRemux(ext);
if (!ffmpeg)
SetupAutoRemux(ext);
string dst = GetOutputFilename(path, ext, noSpace, overwrite, format);
lastRecordingPath = remux ? dst : "";
lastRecordingPath = dst;
return dst;
}

View File

@ -63,7 +63,7 @@ struct BasicOutputHandler {
}
protected:
bool SetupAutoRemux(const char *&ext);
void SetupAutoRemux(const char *&ext);
std::string GetRecordingFilename(const char *path, const char *ext,
bool noSpace, bool overwrite,
const char *format, bool ffmpeg);

View File

@ -37,8 +37,17 @@ ScreenshotObj::~ScreenshotObj()
obs_leave_graphics();
obs_remove_tick_callback(ScreenshotTick, this);
if (th.joinable())
if (th.joinable()) {
th.join();
if (cx && cy) {
OBSBasic *main = OBSBasic::Get();
main->ShowStatusBarMessage(
QTStr("Basic.StatusBar.ScreenshotSavedTo")
.arg(QT_UTF8(path.c_str())));
}
}
}
void ScreenshotObj::Screenshot()

View File

@ -6348,10 +6348,22 @@ void OBSBasic::StreamingStop(int code, QString last_error)
void OBSBasic::AutoRemux()
{
if (outputHandler->lastRecordingPath.empty())
bool autoRemux = config_get_bool(Config(), "Video", "AutoRemux");
if (!autoRemux)
return;
const char *recType = config_get_string(Config(), "AdvOut", "RecType");
bool ffmpegOutput = astrcmpi(recType, "FFmpeg") == 0;
if (ffmpegOutput)
return;
QString input = outputHandler->lastRecordingPath.c_str();
if (input.isEmpty())
return;
QFileInfo fi(input);
QString suffix = fi.suffix();
@ -6496,6 +6508,12 @@ void OBSBasic::RecordingStop(int code, QString last_error)
} else if (code != OBS_OUTPUT_SUCCESS && !isVisible()) {
SysTrayNotify(QTStr("Output.RecordError.Msg"),
QSystemTrayIcon::Warning);
} else if (code == OBS_OUTPUT_SUCCESS) {
if (outputHandler) {
std::string path = outputHandler->lastRecordingPath;
QString str = QTStr("Basic.StatusBar.RecordingSavedTo");
ShowStatusBarMessage(str.arg(QT_UTF8(path.c_str())));
}
}
if (api)
@ -6638,6 +6656,20 @@ void OBSBasic::ReplayBufferSave()
void OBSBasic::ReplayBufferSaved()
{
if (!outputHandler || !outputHandler->replayBuffer)
return;
if (!outputHandler->ReplayBufferActive())
return;
calldata_t cd = {0};
proc_handler_t *ph =
obs_output_get_proc_handler(outputHandler->replayBuffer);
proc_handler_call(ph, "get_last_replay", &cd);
QString path = QT_UTF8(calldata_string(&cd, "path"));
QString msg = QTStr("Basic.StatusBar.ReplayBufferSavedTo").arg(path);
ShowStatusBarMessage(msg);
calldata_free(&cd);
if (api)
api->on_event(OBS_FRONTEND_EVENT_REPLAY_BUFFER_SAVED);
}
@ -9142,3 +9174,9 @@ void OBSBasic::on_sourceInteractButton_clicked()
{
on_actionInteract_triggered();
}
void OBSBasic::ShowStatusBarMessage(const QString &message)
{
ui->statusbar->clearMessage();
ui->statusbar->showMessage(message, 10000);
}

View File

@ -857,6 +857,8 @@ public:
OBSWeakSource copyFilter = nullptr;
void ShowStatusBarMessage(const QString &message);
protected:
virtual void closeEvent(QCloseEvent *event) override;
virtual void changeEvent(QEvent *event) override;

View File

@ -33,6 +33,7 @@
#include <QTimer>
#include "qt-wrappers.hpp"
#include "window-basic-main.hpp"
#include <memory>
#include <cmath>
@ -927,6 +928,11 @@ void OBSRemux::remuxFinished(bool success)
if (autoRemux && autoRemuxFile != "") {
QTimer::singleShot(3000, this, SLOT(close()));
OBSBasic *main = OBSBasic::Get();
main->ShowStatusBarMessage(
QTStr("Basic.StatusBar.AutoRemuxedTo")
.arg(autoRemuxFile));
}
remuxNextEntry();