mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 00:55:09 -07:00
* [Client] Show live connection latency in the status bar Add a permanent status-bar label fed by ConnectionController's pingStatsUpdated: shows the latest round-trip time, hides while disconnected or without samples, and carries a tooltip with Last/Median/95th percentile/Maximum over the rolling sample window (mirrored into the accessible description). The server tab gets the same stats as its tooltip. Took 2 minutes Took 2 minutes Took 1 minute Took 48 seconds Took 25 seconds Took 4 minutes * [Client] Graph connection latency history in the status bar Add LatencyGraphWidget, a size-agnostic bar sparkline over the rolling sample window: heights scale to the window's own range while colors map onto an absolute quality ramp, so a steady good ping stays green. Embed it in the new LatencyStatusWidget together with the textual ping readout and feed both through ConnectionController's forwarded signals; the whole area hides while disconnected or without samples. Took 9 minutes Took 14 seconds * [Client] Show latency details when clicking the ping display Clicking the status bar ping area opens a popup with a larger instance of the latency graph plus the numeric statistics, selectable and mirrored into the accessible name. Qt::Popup closes it on any outside click; contents refresh live while open. Took 33 seconds * Fixup from core commit Took 6 minutes Took 5 seconds Took 5 minutes * Lint. Took 12 minutes * Consolidate. Took 6 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
/**
|
|
* @file latency_graph_widget.h
|
|
* @ingroup Client
|
|
*/
|
|
|
|
#ifndef LATENCY_GRAPH_WIDGET_H
|
|
#define LATENCY_GRAPH_WIDGET_H
|
|
|
|
#include <QList>
|
|
#include <QWidget>
|
|
|
|
/**
|
|
* @brief Bar graph of recent network round-trip samples.
|
|
*
|
|
* Draws one bar per sample, oldest on the left. Bar height is relative to the
|
|
* window's own scale so the shape of the variance stays readable, while bar
|
|
* color maps each sample onto an absolute quality ramp (green at rest through
|
|
* red at ColorScaleMs) so a steady good ping never looks alarming. Size
|
|
* agnostic: the status bar embeds a small instance while the latency detail
|
|
* popup shows a large one.
|
|
*/
|
|
class LatencyGraphWidget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit LatencyGraphWidget(QWidget *parent = nullptr);
|
|
|
|
/// Sample in milliseconds that maps to a fully red bar.
|
|
static constexpr qint64 ColorScaleMs = 500;
|
|
|
|
void setSamples(const QList<int> &samplesMs);
|
|
|
|
protected:
|
|
void paintEvent(QPaintEvent *event) override;
|
|
|
|
private:
|
|
/// Floor of the vertical scale in milliseconds. Keeps small windows readable.
|
|
static constexpr qint64 MinScaleMs = 100;
|
|
|
|
QList<int> samples;
|
|
};
|
|
|
|
#endif
|