Browse Source

UI: Add stats reset hotkey

Clayton Groeneveld 6 years ago
parent
commit
c4169ba15a
4 changed files with 28 additions and 1 deletions
  1. 1 0
      UI/data/locale/en-US.ini
  2. 21 0
      UI/window-basic-main.cpp
  3. 3 0
      UI/window-basic-main.hpp
  4. 3 1
      UI/window-basic-stats.hpp

+ 1 - 0
UI/data/locale/en-US.ini

@@ -210,6 +210,7 @@ Basic.Stats.DroppedFrames="Dropped Frames (Network)"
 Basic.Stats.MegabytesSent="Total Data Output"
 Basic.Stats.MegabytesSent="Total Data Output"
 Basic.Stats.Bitrate="Bitrate"
 Basic.Stats.Bitrate="Bitrate"
 Basic.Stats.DiskFullIn="Disk full in (approx.)"
 Basic.Stats.DiskFullIn="Disk full in (approx.)"
+Basic.Stats.ResetStats="Reset Stats"
 
 
 ResetUIWarning.Title="Are you sure you want to reset the UI?"
 ResetUIWarning.Title="Are you sure you want to reset the UI?"
 ResetUIWarning.Text="Resetting the UI will hide additional docks. You will need to unhide these docks from the view menu if you want them to be visible.\n\nAre you sure you want to reset the UI?"
 ResetUIWarning.Text="Resetting the UI will hide additional docks. You will need to unhide these docks from the view menu if you want them to be visible.\n\nAre you sure you want to reset the UI?"

+ 21 - 0
UI/window-basic-main.cpp

@@ -2214,6 +2214,19 @@ void OBSBasic::CreateHotkeys()
 	transitionHotkey = obs_hotkey_register_frontend(
 	transitionHotkey = obs_hotkey_register_frontend(
 		"OBSBasic.Transition", Str("Transition"), transition, this);
 		"OBSBasic.Transition", Str("Transition"), transition, this);
 	LoadHotkey(transitionHotkey, "OBSBasic.Transition");
 	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()
 void OBSBasic::ClearHotkeys()
@@ -2226,6 +2239,7 @@ void OBSBasic::ClearHotkeys()
 	obs_hotkey_unregister(forceStreamingStopHotkey);
 	obs_hotkey_unregister(forceStreamingStopHotkey);
 	obs_hotkey_unregister(togglePreviewProgramHotkey);
 	obs_hotkey_unregister(togglePreviewProgramHotkey);
 	obs_hotkey_unregister(transitionHotkey);
 	obs_hotkey_unregister(transitionHotkey);
+	obs_hotkey_unregister(statsHotkey);
 }
 }
 
 
 OBSBasic::~OBSBasic()
 OBSBasic::~OBSBasic()
@@ -7622,3 +7636,10 @@ void OBSBasic::ScenesReordered(const QModelIndex &parent, int start, int end,
 
 
 	OBSProjector::UpdateMultiviewProjectors();
 	OBSProjector::UpdateMultiviewProjectors();
 }
 }
+
+void OBSBasic::ResetStatsHotkey()
+{
+	QList<OBSBasicStats *> list = findChildren<OBSBasicStats *>();
+
+	foreach(OBSBasicStats * s, list) s->Reset();
+}

+ 3 - 0
UI/window-basic-main.hpp

@@ -386,6 +386,7 @@ private:
 	volatile bool previewProgramMode = false;
 	volatile bool previewProgramMode = false;
 	obs_hotkey_id togglePreviewProgramHotkey = 0;
 	obs_hotkey_id togglePreviewProgramHotkey = 0;
 	obs_hotkey_id transitionHotkey = 0;
 	obs_hotkey_id transitionHotkey = 0;
+	obs_hotkey_id statsHotkey = 0;
 	int quickTransitionIdCounter = 1;
 	int quickTransitionIdCounter = 1;
 	bool overridingTransition = false;
 	bool overridingTransition = false;
 
 
@@ -563,6 +564,8 @@ private slots:
 	void ScenesReordered(const QModelIndex &parent, int start, int end,
 	void ScenesReordered(const QModelIndex &parent, int start, int end,
 			     const QModelIndex &destination, int row);
 			     const QModelIndex &destination, int row);
 
 
+	void ResetStatsHotkey();
+
 private:
 private:
 	/* OBS Callbacks */
 	/* OBS Callbacks */
 	static void SceneReordered(void *data, calldata_t *params);
 	static void SceneReordered(void *data, calldata_t *params);

+ 3 - 1
UI/window-basic-stats.hpp

@@ -56,7 +56,6 @@ class OBSBasicStats : public QWidget {
 
 
 	void AddOutputLabels(QString name);
 	void AddOutputLabels(QString name);
 	void Update();
 	void Update();
-	void Reset();
 
 
 	virtual void closeEvent(QCloseEvent *event) override;
 	virtual void closeEvent(QCloseEvent *event) override;
 
 
@@ -77,6 +76,9 @@ private:
 private slots:
 private slots:
 	void RecordingTimeLeft();
 	void RecordingTimeLeft();
 
 
+public slots:
+	void Reset();
+
 protected:
 protected:
 	virtual void showEvent(QShowEvent *event) override;
 	virtual void showEvent(QShowEvent *event) override;
 	virtual void hideEvent(QHideEvent *event) override;
 	virtual void hideEvent(QHideEvent *event) override;