UI: Add stats reset hotkey

This commit is contained in:
Clayton Groeneveld committed 2019-10-15 23:20:35 -05:00
1 parent 7d34034ee2
commit c4169ba15a
4 files changed
+28 -1

No files matched your search

+21
View File
@@ -2214,6 +2214,19 @@ void OBSBasic::CreateHotkeys()
transitionHotkey = obs_hotkey_register_frontend(
"OBSBasic.Transition", Str("Transition"), transition, this);
LoadHotkey(transitionHotkey, "OBSBasic.Transition");
auto resetStats = [](void *data, obs_hotkey_id, obs_hotkey_t *,
bool pressed) {
if (pressed)
QMetaObject::invokeMethod(static_cast<OBSBasic *>(data),
"ResetStatsHotkey",
Qt::QueuedConnection);
};
statsHotkey = obs_hotkey_register_frontend(
"OBSBasic.ResetStats", Str("Basic.Stats.ResetStats"),
resetStats, this);
LoadHotkey(statsHotkey, "OBSBasic.ResetStats");
}
void OBSBasic::ClearHotkeys()
@@ -2226,6 +2239,7 @@ void OBSBasic::ClearHotkeys()
obs_hotkey_unregister(forceStreamingStopHotkey);
obs_hotkey_unregister(togglePreviewProgramHotkey);
obs_hotkey_unregister(transitionHotkey);
obs_hotkey_unregister(statsHotkey);
}
OBSBasic::~OBSBasic()
@@ -7622,3 +7636,10 @@ void OBSBasic::ScenesReordered(const QModelIndex &parent, int start, int end,
OBSProjector::UpdateMultiviewProjectors();
}
void OBSBasic::ResetStatsHotkey()
{
QList<OBSBasicStats *> list = findChildren<OBSBasicStats *>();
foreach(OBSBasicStats * s, list) s->Reset();
}