mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-19 20:32:15 +02:00
UI: Add Undo/Redo for volume change/mute via main fader
This commit is contained in:
parent
cec8061d83
commit
20bbc9794d
@ -1,3 +1,4 @@
|
||||
#include "window-basic-main.hpp"
|
||||
#include "volume-control.hpp"
|
||||
#include "qt-wrappers.hpp"
|
||||
#include "obs-app.hpp"
|
||||
@ -63,13 +64,46 @@ void VolControl::VolumeMuted(bool muted)
|
||||
|
||||
void VolControl::SetMuted(bool checked)
|
||||
{
|
||||
bool prev = obs_source_muted(source);
|
||||
obs_source_set_muted(source, checked);
|
||||
|
||||
auto undo_redo = [](const std::string &name, bool val) {
|
||||
obs_source_t *source = obs_get_source_by_name(name.c_str());
|
||||
obs_source_set_muted(source, val);
|
||||
obs_source_release(source);
|
||||
};
|
||||
|
||||
QString text =
|
||||
QTStr(checked ? "Undo.Volume.Mute" : "Undo.Volume.Unmute");
|
||||
|
||||
const char *name = obs_source_get_name(source);
|
||||
OBSBasic::Get()->undo_s.add_action(
|
||||
text.arg(name),
|
||||
std::bind(undo_redo, std::placeholders::_1, prev),
|
||||
std::bind(undo_redo, std::placeholders::_1, checked), name,
|
||||
name);
|
||||
}
|
||||
|
||||
void VolControl::SliderChanged(int vol)
|
||||
{
|
||||
float prev = obs_source_get_volume(source);
|
||||
|
||||
obs_fader_set_deflection(obs_fader, float(vol) / FADER_PRECISION);
|
||||
updateText();
|
||||
|
||||
auto undo_redo = [](const std::string &name, float val) {
|
||||
obs_source_t *source = obs_get_source_by_name(name.c_str());
|
||||
obs_source_set_volume(source, val);
|
||||
obs_source_release(source);
|
||||
};
|
||||
|
||||
float val = obs_source_get_volume(source);
|
||||
const char *name = obs_source_get_name(source);
|
||||
OBSBasic::Get()->undo_s.add_action(
|
||||
QTStr("Undo.Volume.Change").arg(name),
|
||||
std::bind(undo_redo, std::placeholders::_1, prev),
|
||||
std::bind(undo_redo, std::placeholders::_1, val), name, name,
|
||||
true);
|
||||
}
|
||||
|
||||
void VolControl::updateText()
|
||||
|
Loading…
Reference in New Issue
Block a user