UI: Add save button next to replay buffer button

Allows the ability to save replays with a button rather than with the
keyboard if desired.

Closes obsproject/obs-studio#1954
master
jp9000 2019-12-12 17:07:26 -08:00
parent d3b6f7a71f
commit e2fa510436
12 changed files with 94 additions and 2 deletions

View File

@ -517,6 +517,7 @@ Basic.Main.Controls="Controls"
Basic.Main.Connecting="Connecting..."
Basic.Main.StartRecording="Start Recording"
Basic.Main.StartReplayBuffer="Start Replay Buffer"
Basic.Main.SaveReplay="Save Replay"
Basic.Main.StartStreaming="Start Streaming"
Basic.Main.StopRecording="Stop Recording"
Basic.Main.PauseRecording="Pause Recording"

View File

@ -1044,3 +1044,9 @@ SceneTree#scenes {
padding-right: 10px;
margin: 0px;
}
/* Save replay icon */
* [themeID="replayIconSmall"] {
qproperty-icon: url(./Dark/save.svg);
}

View File

@ -809,3 +809,9 @@ SceneTree {
*[gridMode="true"] SceneTree::item:checked {
background-color: rgb(122,121,122); /* light */
}
/* Save icon */
* [themeID="replayIconSmall"] {
qproperty-icon: url(./Dark/save.svg);
}

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8" fill="#d2d2d2">
<path d="M3 0v3h-2l3 3 3-3h-2v-3h-2zm-3 7v1h8v-1h-8z" />
</svg>

After

Width:  |  Height:  |  Size: 161 B

View File

@ -1372,3 +1372,9 @@ SceneTree#scenes {
qproperty-gridItemWidth: 150;
qproperty-gridItemHeight: 30;
}
/* Save icon */
* [themeID="replayIconSmall"] {
qproperty-icon: url(./Dark/save.svg);
}

View File

@ -240,3 +240,9 @@ SceneTree {
qproperty-gridItemWidth: 150;
qproperty-gridItemHeight: 24;
}
/* Save icon */
* [themeID="replayIconSmall"] {
qproperty-icon: url(:res/images/save.svg);
}

3
UI/forms/images/save.svg Normal file
View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
<path d="M3 0v3h-2l3 3 3-3h-2v-3h-2zm-3 7v1h8v-1h-8z" />
</svg>

After

Width:  |  Height:  |  Size: 146 B

View File

@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/res">
<file>images/save.svg</file>
<file>images/media-pause.svg</file>
<file>images/mute.svg</file>
<file>images/refresh.svg</file>

View File

@ -17,3 +17,20 @@ void RecordButton::resizeEvent(QResizeEvent *event)
event->accept();
}
void ReplayBufferButton::resizeEvent(QResizeEvent *event)
{
OBSBasic *main = OBSBasic::Get();
if (!main->replay)
return;
QSize replaySize = main->replay->size();
int height = main->ui->recordButton->size().height();
if (replaySize.height() != height || replaySize.width() != height) {
main->replay->setMinimumSize(height, height);
main->replay->setMaximumSize(height, height);
}
event->accept();
}

View File

@ -10,3 +10,16 @@ public:
virtual void resizeEvent(QResizeEvent *event) override;
};
class ReplayBufferButton : public QPushButton {
Q_OBJECT
public:
inline ReplayBufferButton(const QString &text,
QWidget *parent = nullptr)
: QPushButton(text, parent)
{
}
virtual void resizeEvent(QResizeEvent *event) override;
};

View File

@ -1501,18 +1501,22 @@ void OBSBasic::ResetOutputs()
: CreateSimpleOutputHandler(this));
delete replayBufferButton;
delete replayLayout;
if (outputHandler->replayBuffer) {
replayBufferButton = new QPushButton(
replayBufferButton = new ReplayBufferButton(
QTStr("Basic.Main.StartReplayBuffer"), this);
replayBufferButton->setCheckable(true);
connect(replayBufferButton.data(),
&QPushButton::clicked, this,
&OBSBasic::ReplayBufferClicked);
replayLayout = new QHBoxLayout(this);
replayLayout->addWidget(replayBufferButton);
replayBufferButton->setProperty("themeID",
"replayBufferButton");
ui->buttonsVLayout->insertWidget(2, replayBufferButton);
ui->buttonsVLayout->insertLayout(2, replayLayout);
}
if (sysTrayReplayBuffer)
@ -5664,6 +5668,7 @@ void OBSBasic::ReplayBufferStart()
api->on_event(OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTED);
OnActivate();
UpdateReplayBuffer();
blog(LOG_INFO, REPLAY_BUFFER_START);
}
@ -5725,6 +5730,7 @@ void OBSBasic::ReplayBufferStop(int code)
api->on_event(OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPED);
OnDeactivate();
UpdateReplayBuffer(false);
}
void OBSBasic::on_streamButton_clicked()
@ -7602,6 +7608,26 @@ void OBSBasic::UpdatePause(bool activate)
}
}
void OBSBasic::UpdateReplayBuffer(bool activate)
{
if (!activate || !outputHandler ||
!outputHandler->ReplayBufferActive()) {
replay.reset();
return;
}
replay.reset(new QPushButton());
replay->setAccessibleName(QTStr("Basic.Main.SaveReplay"));
replay->setToolTip(QTStr("Basic.Main.SaveReplay"));
replay->setCheckable(true);
replay->setChecked(false);
replay->setProperty("themeID",
QVariant(QStringLiteral("replayIconSmall")));
connect(replay.data(), &QAbstractButton::clicked, this,
&OBSBasic::ReplayBufferSave);
replayLayout->addWidget(replay.data());
}
#define MBYTE (1024ULL * 1024ULL)
#define MBYTES_LEFT_STOP_REC 50ULL
#define MAX_BYTES_LEFT (MBYTES_LEFT_STOP_REC * MBYTE)

View File

@ -157,6 +157,7 @@ class OBSBasic : public OBSMainWindow {
friend class AutoConfig;
friend class AutoConfigStreamPage;
friend class RecordButton;
friend class ReplayBufferButton;
friend class ExtraBrowsersModel;
friend class ExtraBrowsersDelegate;
friend struct OBSStudioAPI;
@ -241,7 +242,9 @@ private:
QPointer<QPushButton> transitionButton;
QPointer<QPushButton> replayBufferButton;
QPointer<QHBoxLayout> replayLayout;
QScopedPointer<QPushButton> pause;
QScopedPointer<QPushButton> replay;
QScopedPointer<QSystemTrayIcon> trayIcon;
QPointer<QAction> sysTrayStream;
@ -669,6 +672,7 @@ private:
void AutoRemux();
void UpdatePause(bool activate = true);
void UpdateReplayBuffer(bool activate = true);
bool LowDiskSpace();
void DiskSpaceMessage();