mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
move human-readable byte formatting to guiutil
This commit is contained in:
parent
470c730e3f
commit
8e4aa35ffb
@ -984,6 +984,18 @@ QString formatNiceTimeOffset(qint64 secs)
|
|||||||
return timeBehindText;
|
return timeBehindText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString formatBytes(uint64_t bytes)
|
||||||
|
{
|
||||||
|
if(bytes < 1024)
|
||||||
|
return QString(QObject::tr("%1 B")).arg(bytes);
|
||||||
|
if(bytes < 1024 * 1024)
|
||||||
|
return QString(QObject::tr("%1 KB")).arg(bytes / 1024);
|
||||||
|
if(bytes < 1024 * 1024 * 1024)
|
||||||
|
return QString(QObject::tr("%1 MB")).arg(bytes / 1024 / 1024);
|
||||||
|
|
||||||
|
return QString(QObject::tr("%1 GB")).arg(bytes / 1024 / 1024 / 1024);
|
||||||
|
}
|
||||||
|
|
||||||
void ClickableLabel::mouseReleaseEvent(QMouseEvent *event)
|
void ClickableLabel::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
Q_EMIT clicked(event->pos());
|
Q_EMIT clicked(event->pos());
|
||||||
|
@ -199,6 +199,8 @@ namespace GUIUtil
|
|||||||
|
|
||||||
QString formatNiceTimeOffset(qint64 secs);
|
QString formatNiceTimeOffset(qint64 secs);
|
||||||
|
|
||||||
|
QString formatBytes(uint64_t bytes);
|
||||||
|
|
||||||
class ClickableLabel : public QLabel
|
class ClickableLabel : public QLabel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -935,18 +935,6 @@ void RPCConsole::on_sldGraphRange_valueChanged(int value)
|
|||||||
setTrafficGraphRange(mins);
|
setTrafficGraphRange(mins);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RPCConsole::FormatBytes(quint64 bytes)
|
|
||||||
{
|
|
||||||
if(bytes < 1024)
|
|
||||||
return QString(tr("%1 B")).arg(bytes);
|
|
||||||
if(bytes < 1024 * 1024)
|
|
||||||
return QString(tr("%1 KB")).arg(bytes / 1024);
|
|
||||||
if(bytes < 1024 * 1024 * 1024)
|
|
||||||
return QString(tr("%1 MB")).arg(bytes / 1024 / 1024);
|
|
||||||
|
|
||||||
return QString(tr("%1 GB")).arg(bytes / 1024 / 1024 / 1024);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RPCConsole::setTrafficGraphRange(int mins)
|
void RPCConsole::setTrafficGraphRange(int mins)
|
||||||
{
|
{
|
||||||
ui->trafficGraph->setGraphRangeMins(mins);
|
ui->trafficGraph->setGraphRangeMins(mins);
|
||||||
@ -955,8 +943,8 @@ void RPCConsole::setTrafficGraphRange(int mins)
|
|||||||
|
|
||||||
void RPCConsole::updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut)
|
void RPCConsole::updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut)
|
||||||
{
|
{
|
||||||
ui->lblBytesIn->setText(FormatBytes(totalBytesIn));
|
ui->lblBytesIn->setText(GUIUtil::formatBytes(totalBytesIn));
|
||||||
ui->lblBytesOut->setText(FormatBytes(totalBytesOut));
|
ui->lblBytesOut->setText(GUIUtil::formatBytes(totalBytesOut));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RPCConsole::peerSelected(const QItemSelection &selected, const QItemSelection &deselected)
|
void RPCConsole::peerSelected(const QItemSelection &selected, const QItemSelection &deselected)
|
||||||
@ -1050,8 +1038,8 @@ void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats)
|
|||||||
ui->peerServices->setText(GUIUtil::formatServicesStr(stats->nodeStats.nServices));
|
ui->peerServices->setText(GUIUtil::formatServicesStr(stats->nodeStats.nServices));
|
||||||
ui->peerLastSend->setText(stats->nodeStats.nLastSend ? GUIUtil::formatDurationStr(GetSystemTimeInSeconds() - stats->nodeStats.nLastSend) : tr("never"));
|
ui->peerLastSend->setText(stats->nodeStats.nLastSend ? GUIUtil::formatDurationStr(GetSystemTimeInSeconds() - stats->nodeStats.nLastSend) : tr("never"));
|
||||||
ui->peerLastRecv->setText(stats->nodeStats.nLastRecv ? GUIUtil::formatDurationStr(GetSystemTimeInSeconds() - stats->nodeStats.nLastRecv) : tr("never"));
|
ui->peerLastRecv->setText(stats->nodeStats.nLastRecv ? GUIUtil::formatDurationStr(GetSystemTimeInSeconds() - stats->nodeStats.nLastRecv) : tr("never"));
|
||||||
ui->peerBytesSent->setText(FormatBytes(stats->nodeStats.nSendBytes));
|
ui->peerBytesSent->setText(GUIUtil::formatBytes(stats->nodeStats.nSendBytes));
|
||||||
ui->peerBytesRecv->setText(FormatBytes(stats->nodeStats.nRecvBytes));
|
ui->peerBytesRecv->setText(GUIUtil::formatBytes(stats->nodeStats.nRecvBytes));
|
||||||
ui->peerConnTime->setText(GUIUtil::formatDurationStr(GetSystemTimeInSeconds() - stats->nodeStats.nTimeConnected));
|
ui->peerConnTime->setText(GUIUtil::formatDurationStr(GetSystemTimeInSeconds() - stats->nodeStats.nTimeConnected));
|
||||||
ui->peerPingTime->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingTime));
|
ui->peerPingTime->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingTime));
|
||||||
ui->peerPingWait->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingWait));
|
ui->peerPingWait->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingWait));
|
||||||
|
@ -123,7 +123,6 @@ Q_SIGNALS:
|
|||||||
void cmdRequest(const QString &command);
|
void cmdRequest(const QString &command);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QString FormatBytes(quint64 bytes);
|
|
||||||
void startExecutor();
|
void startExecutor();
|
||||||
void setTrafficGraphRange(int mins);
|
void setTrafficGraphRange(int mins);
|
||||||
/** show detailed information on ui about selected node */
|
/** show detailed information on ui about selected node */
|
||||||
|
Loading…
Reference in New Issue
Block a user