aboutsummaryrefslogtreecommitdiff
path: root/src/qt/guiutil.cpp
diff options
context:
space:
mode:
authorAaron Golliver <aaron.golliver@gmail.com>2017-10-14 16:06:21 -0700
committerAaron Golliver <aaron.golliver@gmail.com>2017-10-16 20:58:23 -0700
commit8e4aa35ffbcaa0e0a3eceaa500193b0f97d957ab (patch)
treeb2c98603e3a20d4dedf0c611d3a8589bc182f152 /src/qt/guiutil.cpp
parent470c730e3fa9d1120dda1de2d433304023c8aa78 (diff)
move human-readable byte formatting to guiutil
Diffstat (limited to 'src/qt/guiutil.cpp')
-rw-r--r--src/qt/guiutil.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index d520d7d4be..4bd63f4649 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());