mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-27 16:32:20 -07:00
Fixup from core commit
Took 6 minutes Took 5 seconds Took 5 minutes
This commit is contained in:
parent
ad2ff25f1c
commit
2c03ba853f
5 changed files with 26 additions and 23 deletions
|
|
@ -35,20 +35,20 @@ LatencyStatusWidget::LatencyStatusWidget(QWidget *parent) : QWidget(parent)
|
|||
hide();
|
||||
}
|
||||
|
||||
void LatencyStatusWidget::updateStats(int lastMs, int medianMs, int p95Ms, int maxMs, int sampleCount)
|
||||
void LatencyStatusWidget::updateStats(const LatencyTracker::Stats &stats)
|
||||
{
|
||||
if (sampleCount == 0) {
|
||||
if (stats.sampleCount == 0) {
|
||||
hide();
|
||||
return;
|
||||
}
|
||||
|
||||
const QString stats = statsText(lastMs, medianMs, p95Ms, maxMs, sampleCount);
|
||||
const QString statsStr = statsText(stats);
|
||||
|
||||
pingLabel->setText(tr("Ping: %1 ms").arg(lastMs));
|
||||
pingLabel->setToolTip(stats);
|
||||
pingLabel->setAccessibleDescription(stats);
|
||||
pingLabel->setText(tr("Ping: %1 ms").arg(stats.lastMs));
|
||||
pingLabel->setToolTip(statsStr);
|
||||
pingLabel->setAccessibleDescription(statsStr);
|
||||
if (popup && popup->isVisible() && detailLabel) {
|
||||
detailLabel->setText(stats);
|
||||
detailLabel->setText(statsStr);
|
||||
}
|
||||
show();
|
||||
}
|
||||
|
|
@ -106,9 +106,9 @@ void LatencyStatusWidget::togglePopup()
|
|||
popup->show();
|
||||
}
|
||||
|
||||
QString LatencyStatusWidget::statsText(int lastMs, int medianMs, int p95Ms, int maxMs, int sampleCount) const
|
||||
QString LatencyStatusWidget::statsText(const LatencyTracker::Stats &stats) const
|
||||
{
|
||||
return tr("Connection quality over the last %n sample(s):", "", sampleCount) + "\n" +
|
||||
tr("Last: %1 ms").arg(lastMs) + "\n" + tr("Median: %1 ms").arg(medianMs) + "\n" +
|
||||
tr("95th percentile: %1 ms").arg(p95Ms) + "\n" + tr("Maximum: %1 ms").arg(maxMs);
|
||||
return tr("Connection quality over the last %n sample(s):", "", stats.sampleCount) + "\n" +
|
||||
tr("Last: %1 ms").arg(stats.lastMs) + "\n" + tr("Median: %1 ms").arg(stats.medianMs) + "\n" +
|
||||
tr("95th percentile: %1 ms").arg(stats.p95Ms) + "\n" + tr("Maximum: %1 ms").arg(stats.maxMs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <QList>
|
||||
#include <QWidget>
|
||||
#include <libcockatrice/network/client/abstract/latency_tracker.h>
|
||||
|
||||
class QLabel;
|
||||
class LatencyGraphWidget;
|
||||
|
|
@ -29,7 +30,7 @@ public:
|
|||
explicit LatencyStatusWidget(QWidget *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void updateStats(int lastMs, int medianMs, int p95Ms, int maxMs, int sampleCount);
|
||||
void updateStats(const LatencyTracker::Stats &stats);
|
||||
void updateSamples(const QList<int> &samplesMs);
|
||||
|
||||
protected:
|
||||
|
|
@ -37,7 +38,7 @@ protected:
|
|||
|
||||
private:
|
||||
void togglePopup();
|
||||
QString statsText(int lastMs, int medianMs, int p95Ms, int maxMs, int sampleCount) const;
|
||||
QString statsText(const LatencyTracker::Stats &stats) const;
|
||||
|
||||
QLabel *pingLabel = nullptr;
|
||||
LatencyGraphWidget *latencyGraph = nullptr;
|
||||
|
|
|
|||
|
|
@ -884,21 +884,21 @@ void TabSupervisor::updatePingTime(int value, int max)
|
|||
setTabIcon(indexOf(tabServer), QIcon(PingPixmapGenerator::generatePixmap(15, value, max)));
|
||||
}
|
||||
|
||||
void TabSupervisor::updateLatencyTooltip(int lastMs, int medianMs, int p95Ms, int maxMs, int sampleCount)
|
||||
void TabSupervisor::updateLatencyTooltip(const LatencyTracker::Stats &stats)
|
||||
{
|
||||
if (!tabServer) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sampleCount == 0) {
|
||||
if (stats.sampleCount == 0) {
|
||||
setTabToolTip(indexOf(tabServer), QString());
|
||||
return;
|
||||
}
|
||||
|
||||
setTabToolTip(indexOf(tabServer), tr("Connection quality over the last %n sample(s):", "", sampleCount) + "\n" +
|
||||
tr("Last: %1 ms").arg(lastMs) + "\n" + tr("Median: %1 ms").arg(medianMs) +
|
||||
"\n" + tr("95th percentile: %1 ms").arg(p95Ms) + "\n" +
|
||||
tr("Maximum: %1 ms").arg(maxMs));
|
||||
setTabToolTip(indexOf(tabServer),
|
||||
tr("Connection quality over the last %n sample(s):", "", stats.sampleCount) + "\n" +
|
||||
tr("Last: %1 ms").arg(stats.lastMs) + "\n" + tr("Median: %1 ms").arg(stats.medianMs) + "\n" +
|
||||
tr("95th percentile: %1 ms").arg(stats.p95Ms) + "\n" + tr("Maximum: %1 ms").arg(stats.maxMs));
|
||||
}
|
||||
|
||||
void TabSupervisor::gameJoined(const Event_GameJoined &event)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include <QMap>
|
||||
#include <QProxyStyle>
|
||||
#include <QTabWidget>
|
||||
#include <libcockatrice/network/client/abstract/latency_tracker.h>
|
||||
|
||||
class TabCardArtRules;
|
||||
inline Q_LOGGING_CATEGORY(TabSupervisorLog, "tab_supervisor");
|
||||
|
|
@ -220,7 +221,7 @@ private slots:
|
|||
|
||||
void updateCurrent(int index);
|
||||
void updatePingTime(int value, int max);
|
||||
void updateLatencyTooltip(int lastMs, int medianMs, int p95Ms, int maxMs, int sampleCount);
|
||||
void updateLatencyTooltip(const LatencyTracker::Stats &stats);
|
||||
void gameJoined(const Event_GameJoined &event);
|
||||
void localGameJoined(const Event_GameJoined &event);
|
||||
void gameLeft(TabGame *tab);
|
||||
|
|
|
|||
|
|
@ -541,9 +541,10 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
statusBar()->addPermanentWidget(latencyStatus);
|
||||
|
||||
connect(connectionController, &ConnectionController::pingStatsUpdated, latencyStatus,
|
||||
&LatencyStatusWidget::updateStats);
|
||||
connect(connectionController, &ConnectionController::pingSamplesUpdated, latencyStatus,
|
||||
&LatencyStatusWidget::updateSamples);
|
||||
[this](const LatencyTracker::Stats &stats, const QList<int> &samplesMs) {
|
||||
latencyStatus->updateStats(stats);
|
||||
latencyStatus->updateSamples(samplesMs);
|
||||
});
|
||||
|
||||
connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
|
||||
&MainWindow::refreshShortcuts);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue