diff options
| author | Aaron Golliver <[email protected]> | 2017-10-14 16:06:21 -0700 |
|---|---|---|
| committer | Aaron Golliver <[email protected]> | 2017-10-16 20:58:23 -0700 |
| commit | 8e4aa35ffbcaa0e0a3eceaa500193b0f97d957ab (patch) | |
| tree | b2c98603e3a20d4dedf0c611d3a8589bc182f152 /src/qt/guiutil.cpp | |
| parent | Merge #10898: Fix invalid checks (NULL checks after dereference, redundant ch... (diff) | |
| download | discoin-8e4aa35ffbcaa0e0a3eceaa500193b0f97d957ab.tar.xz discoin-8e4aa35ffbcaa0e0a3eceaa500193b0f97d957ab.zip | |
move human-readable byte formatting to guiutil
Diffstat (limited to 'src/qt/guiutil.cpp')
| -rw-r--r-- | src/qt/guiutil.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index d520d7d4b..4bd63f464 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -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()); |