提交 51198058 编写于 作者: C Clayton Groeneveld 提交者: jp9000

UI: Don't update stats dock if hidden

When the stats dock is hidden, the QTimer is still updating it, causing
unnecessary CPU usage.
上级 6550c0df
...@@ -146,7 +146,10 @@ OBSBasicStats::OBSBasicStats(QWidget *parent, bool closeable) ...@@ -146,7 +146,10 @@ OBSBasicStats::OBSBasicStats(QWidget *parent, bool closeable)
QObject::connect(&timer, &QTimer::timeout, this, &OBSBasicStats::Update); QObject::connect(&timer, &QTimer::timeout, this, &OBSBasicStats::Update);
timer.setInterval(TIMER_INTERVAL); timer.setInterval(TIMER_INTERVAL);
if (isVisible())
timer.start(); timer.start();
Update(); Update();
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow()); OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
...@@ -505,3 +508,13 @@ void OBSBasicStats::OutputLabels::Reset(obs_output_t *output) ...@@ -505,3 +508,13 @@ void OBSBasicStats::OutputLabels::Reset(obs_output_t *output)
first_total = obs_output_get_total_frames(output); first_total = obs_output_get_total_frames(output);
first_dropped = obs_output_get_frames_dropped(output); first_dropped = obs_output_get_frames_dropped(output);
} }
void OBSBasicStats::showEvent(QShowEvent *)
{
timer.start(TIMER_INTERVAL);
}
void OBSBasicStats::hideEvent(QHideEvent *)
{
timer.stop();
}
...@@ -61,4 +61,8 @@ public: ...@@ -61,4 +61,8 @@ public:
static void InitializeValues(); static void InitializeValues();
private: private:
QPointer<QObject> shortcutFilter; QPointer<QObject> shortcutFilter;
protected:
virtual void showEvent(QShowEvent *event) override;
virtual void hideEvent(QHideEvent *event) override;
}; };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册