mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-25 15:05:55 +01:00
move human-readable byte formatting to guiutil
This commit is contained in:
@@ -984,6 +984,18 @@ QString formatNiceTimeOffset(qint64 secs)
|
||||
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)
|
||||
{
|
||||
Q_EMIT clicked(event->pos());
|
||||
|
||||
Reference in New Issue
Block a user