mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-28 00:42:19 -07:00
Consolidate.
Took 6 minutes
This commit is contained in:
parent
ae4f83fa66
commit
ae01f87687
3 changed files with 11 additions and 18 deletions
|
|
@ -35,8 +35,14 @@ LatencyStatusWidget::LatencyStatusWidget(QWidget *parent) : QWidget(parent)
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LatencyStatusWidget::updateStats(const LatencyTracker::Stats &stats)
|
void LatencyStatusWidget::updateData(const LatencyTracker::Stats &stats, const QList<int> &samplesMs)
|
||||||
{
|
{
|
||||||
|
latestSamples = samplesMs;
|
||||||
|
latencyGraph->setSamples(samplesMs);
|
||||||
|
if (popup && popup->isVisible() && detailGraph) {
|
||||||
|
detailGraph->setSamples(samplesMs);
|
||||||
|
}
|
||||||
|
|
||||||
if (stats.sampleCount == 0) {
|
if (stats.sampleCount == 0) {
|
||||||
hide();
|
hide();
|
||||||
return;
|
return;
|
||||||
|
|
@ -53,15 +59,6 @@ void LatencyStatusWidget::updateStats(const LatencyTracker::Stats &stats)
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LatencyStatusWidget::updateSamples(const QList<int> &samplesMs)
|
|
||||||
{
|
|
||||||
latestSamples = samplesMs;
|
|
||||||
latencyGraph->setSamples(samplesMs);
|
|
||||||
if (popup && popup->isVisible() && detailGraph) {
|
|
||||||
detailGraph->setSamples(samplesMs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LatencyStatusWidget::eventFilter(QObject *watched, QEvent *event)
|
bool LatencyStatusWidget::eventFilter(QObject *watched, QEvent *event)
|
||||||
{
|
{
|
||||||
if ((watched == pingLabel || watched == latencyGraph) && event->type() == QEvent::MouseButtonPress) {
|
if ((watched == pingLabel || watched == latencyGraph) && event->type() == QEvent::MouseButtonPress) {
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ class LatencyGraphWidget;
|
||||||
* sparkline of the rolling sample window. Clicking anywhere in the area opens
|
* sparkline of the rolling sample window. Clicking anywhere in the area opens
|
||||||
* a popup with a larger graph and the numeric statistics. It closes on any
|
* a popup with a larger graph and the numeric statistics. It closes on any
|
||||||
* outside click. Stays hidden while disconnected or before any samples exist.
|
* outside click. Stays hidden while disconnected or before any samples exist.
|
||||||
* Owns all latency display state so MainWindow only needs to forward two
|
* Owns all latency display state so MainWindow only needs to forward one
|
||||||
* signals here.
|
* signal here.
|
||||||
*/
|
*/
|
||||||
class LatencyStatusWidget : public QWidget
|
class LatencyStatusWidget : public QWidget
|
||||||
{
|
{
|
||||||
|
|
@ -30,8 +30,7 @@ public:
|
||||||
explicit LatencyStatusWidget(QWidget *parent = nullptr);
|
explicit LatencyStatusWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateStats(const LatencyTracker::Stats &stats);
|
void updateData(const LatencyTracker::Stats &stats, const QList<int> &samplesMs);
|
||||||
void updateSamples(const QList<int> &samplesMs);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||||
|
|
|
||||||
|
|
@ -541,10 +541,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
statusBar()->addPermanentWidget(latencyStatus);
|
statusBar()->addPermanentWidget(latencyStatus);
|
||||||
|
|
||||||
connect(connectionController, &ConnectionController::pingStatsUpdated, latencyStatus,
|
connect(connectionController, &ConnectionController::pingStatsUpdated, latencyStatus,
|
||||||
[this](const LatencyTracker::Stats &stats, const QList<int> &samplesMs) {
|
&LatencyStatusWidget::updateData);
|
||||||
latencyStatus->updateStats(stats);
|
|
||||||
latencyStatus->updateSamples(samplesMs);
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
|
connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
|
||||||
&MainWindow::refreshShortcuts);
|
&MainWindow::refreshShortcuts);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue