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();
|
||||
}
|
||||
|
||||
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) {
|
||||
hide();
|
||||
return;
|
||||
|
|
@ -53,15 +59,6 @@ void LatencyStatusWidget::updateStats(const LatencyTracker::Stats &stats)
|
|||
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)
|
||||
{
|
||||
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
|
||||
* 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.
|
||||
* Owns all latency display state so MainWindow only needs to forward two
|
||||
* signals here.
|
||||
* Owns all latency display state so MainWindow only needs to forward one
|
||||
* signal here.
|
||||
*/
|
||||
class LatencyStatusWidget : public QWidget
|
||||
{
|
||||
|
|
@ -30,8 +30,7 @@ public:
|
|||
explicit LatencyStatusWidget(QWidget *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void updateStats(const LatencyTracker::Stats &stats);
|
||||
void updateSamples(const QList<int> &samplesMs);
|
||||
void updateData(const LatencyTracker::Stats &stats, const QList<int> &samplesMs);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
|
|
|||
|
|
@ -541,10 +541,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
statusBar()->addPermanentWidget(latencyStatus);
|
||||
|
||||
connect(connectionController, &ConnectionController::pingStatsUpdated, latencyStatus,
|
||||
[this](const LatencyTracker::Stats &stats, const QList<int> &samplesMs) {
|
||||
latencyStatus->updateStats(stats);
|
||||
latencyStatus->updateSamples(samplesMs);
|
||||
});
|
||||
&LatencyStatusWidget::updateData);
|
||||
|
||||
connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
|
||||
&MainWindow::refreshShortcuts);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue