mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-28 00:42:19 -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();
|
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();
|
hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString stats = statsText(lastMs, medianMs, p95Ms, maxMs, sampleCount);
|
const QString statsStr = statsText(stats);
|
||||||
|
|
||||||
pingLabel->setText(tr("Ping: %1 ms").arg(lastMs));
|
pingLabel->setText(tr("Ping: %1 ms").arg(stats.lastMs));
|
||||||
pingLabel->setToolTip(stats);
|
pingLabel->setToolTip(statsStr);
|
||||||
pingLabel->setAccessibleDescription(stats);
|
pingLabel->setAccessibleDescription(statsStr);
|
||||||
if (popup && popup->isVisible() && detailLabel) {
|
if (popup && popup->isVisible() && detailLabel) {
|
||||||
detailLabel->setText(stats);
|
detailLabel->setText(statsStr);
|
||||||
}
|
}
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
@ -106,9 +106,9 @@ void LatencyStatusWidget::togglePopup()
|
||||||
popup->show();
|
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" +
|
return tr("Connection quality over the last %n sample(s):", "", stats.sampleCount) + "\n" +
|
||||||
tr("Last: %1 ms").arg(lastMs) + "\n" + tr("Median: %1 ms").arg(medianMs) + "\n" +
|
tr("Last: %1 ms").arg(stats.lastMs) + "\n" + tr("Median: %1 ms").arg(stats.medianMs) + "\n" +
|
||||||
tr("95th percentile: %1 ms").arg(p95Ms) + "\n" + tr("Maximum: %1 ms").arg(maxMs);
|
tr("95th percentile: %1 ms").arg(stats.p95Ms) + "\n" + tr("Maximum: %1 ms").arg(stats.maxMs);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <libcockatrice/network/client/abstract/latency_tracker.h>
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class LatencyGraphWidget;
|
class LatencyGraphWidget;
|
||||||
|
|
@ -29,7 +30,7 @@ public:
|
||||||
explicit LatencyStatusWidget(QWidget *parent = nullptr);
|
explicit LatencyStatusWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
public slots:
|
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);
|
void updateSamples(const QList<int> &samplesMs);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -37,7 +38,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void togglePopup();
|
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;
|
QLabel *pingLabel = nullptr;
|
||||||
LatencyGraphWidget *latencyGraph = nullptr;
|
LatencyGraphWidget *latencyGraph = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -884,21 +884,21 @@ void TabSupervisor::updatePingTime(int value, int max)
|
||||||
setTabIcon(indexOf(tabServer), QIcon(PingPixmapGenerator::generatePixmap(15, value, 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) {
|
if (!tabServer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sampleCount == 0) {
|
if (stats.sampleCount == 0) {
|
||||||
setTabToolTip(indexOf(tabServer), QString());
|
setTabToolTip(indexOf(tabServer), QString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTabToolTip(indexOf(tabServer), tr("Connection quality over the last %n sample(s):", "", sampleCount) + "\n" +
|
setTabToolTip(indexOf(tabServer),
|
||||||
tr("Last: %1 ms").arg(lastMs) + "\n" + tr("Median: %1 ms").arg(medianMs) +
|
tr("Connection quality over the last %n sample(s):", "", stats.sampleCount) + "\n" +
|
||||||
"\n" + tr("95th percentile: %1 ms").arg(p95Ms) + "\n" +
|
tr("Last: %1 ms").arg(stats.lastMs) + "\n" + tr("Median: %1 ms").arg(stats.medianMs) + "\n" +
|
||||||
tr("Maximum: %1 ms").arg(maxMs));
|
tr("95th percentile: %1 ms").arg(stats.p95Ms) + "\n" + tr("Maximum: %1 ms").arg(stats.maxMs));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::gameJoined(const Event_GameJoined &event)
|
void TabSupervisor::gameJoined(const Event_GameJoined &event)
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QProxyStyle>
|
#include <QProxyStyle>
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
|
#include <libcockatrice/network/client/abstract/latency_tracker.h>
|
||||||
|
|
||||||
class TabCardArtRules;
|
class TabCardArtRules;
|
||||||
inline Q_LOGGING_CATEGORY(TabSupervisorLog, "tab_supervisor");
|
inline Q_LOGGING_CATEGORY(TabSupervisorLog, "tab_supervisor");
|
||||||
|
|
@ -220,7 +221,7 @@ private slots:
|
||||||
|
|
||||||
void updateCurrent(int index);
|
void updateCurrent(int index);
|
||||||
void updatePingTime(int value, int max);
|
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 gameJoined(const Event_GameJoined &event);
|
||||||
void localGameJoined(const Event_GameJoined &event);
|
void localGameJoined(const Event_GameJoined &event);
|
||||||
void gameLeft(TabGame *tab);
|
void gameLeft(TabGame *tab);
|
||||||
|
|
|
||||||
|
|
@ -541,9 +541,10 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
statusBar()->addPermanentWidget(latencyStatus);
|
statusBar()->addPermanentWidget(latencyStatus);
|
||||||
|
|
||||||
connect(connectionController, &ConnectionController::pingStatsUpdated, latencyStatus,
|
connect(connectionController, &ConnectionController::pingStatsUpdated, latencyStatus,
|
||||||
&LatencyStatusWidget::updateStats);
|
[this](const LatencyTracker::Stats &stats, const QList<int> &samplesMs) {
|
||||||
connect(connectionController, &ConnectionController::pingSamplesUpdated, latencyStatus,
|
latencyStatus->updateStats(stats);
|
||||||
&LatencyStatusWidget::updateSamples);
|
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